/* ═══════════════════════════════════════════════════════
   STICKMAN BATTLE COMMAND — Stylesheet
═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold: #f5c542;
  --gold2: #ffd700;
  --blue: #4fc3f7;
  --blue2: #0288d1;
  --mana: #7c4dff;
  --mana2: #b388ff;
  --red: #ef5350;
  --green: #66bb6a;
  --dark: #0a0a12;
  --dark2: #12121e;
  --dark3: #1a1a2e;
  --text: #e8e8ff;
  --shadow: rgba(0,0,0,0.85);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--dark);
  font-family: 'Segoe UI', 'Arial', sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
}

/* ── SCREENS ── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ── START SCREEN ── */
#screen-start {
  background: #0a0010;
}
#start-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
}
#start-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  pointer-events: none;
}
#title-block {
  text-align: center;
  pointer-events: none;
}
#title-top {
  font-size: clamp(28px, 6vw, 64px);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-shadow: 0 0 30px #ff8800, 0 0 60px #ff4400;
  line-height: 1;
}
#title-main {
  font-size: clamp(40px, 9vw, 96px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 0 20px #fff, 0 4px 0 #333, 0 8px 20px #000;
  line-height: 1.05;
}
#title-sub {
  font-size: clamp(12px, 2vw, 20px);
  letter-spacing: 0.5em;
  color: #aaa;
  text-transform: uppercase;
  margin-top: 4px;
}
#start-buttons {
  display: flex;
  gap: 20px;
  pointer-events: all;
  flex-wrap: wrap;
  justify-content: center;
}
#start-footer {
  pointer-events: all;
}

/* ── BUTTONS ── */
.btn-primary {
  background: linear-gradient(135deg, #c8860a, #f5c542);
  color: #1a0a00;
  font-size: clamp(14px, 2vw, 20px);
  font-weight: 900;
  letter-spacing: 0.15em;
  border: none;
  padding: 14px 36px;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: all 0.15s;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(245,197,66,0.4);
  min-width: 160px;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #f5c542, #ffe082);
  box-shadow: 0 6px 30px rgba(245,197,66,0.7);
  transform: translateY(-2px) scale(1.04);
}
.btn-primary:active { transform: translateY(1px) scale(0.98); }

.btn-back {
  background: transparent;
  color: #aaa;
  font-size: clamp(12px, 1.8vw, 16px);
  font-weight: 700;
  letter-spacing: 0.1em;
  border: 2px solid #444;
  padding: 10px 22px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}
.btn-back:hover { border-color: #888; color: #fff; }

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 22px;
  width: 48px; height: 48px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* ── MAP SCREEN ── */
#screen-map {
  background: linear-gradient(180deg, #0a0520 0%, #1a0a10 100%);
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
#map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
#map-header h2 {
  font-size: clamp(16px, 3vw, 26px);
  letter-spacing: 0.25em;
  color: var(--gold);
}
#map-coins {
  font-size: 18px;
  color: var(--gold);
  font-weight: 700;
}
#map-world {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#map-path-svg {
  position: absolute;
  inset: 0;
}
#map-nodes {
  position: absolute;
  inset: 0;
}
.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  cursor: pointer;
  border: 3px solid transparent;
  font-weight: 900;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(0,0,0,0.5);
}
.map-node.locked {
  background: #222;
  border-color: #444;
  color: #666;
  cursor: default;
}
.map-node.available {
  background: linear-gradient(135deg, #1a3a1a, #2a5a2a);
  border-color: var(--green);
  color: #fff;
  animation: nodePulse 2s ease-in-out infinite;
}
.map-node.completed {
  background: linear-gradient(135deg, #1a2a3a, #2a3a5a);
  border-color: var(--gold);
  color: var(--gold);
}
.map-node:hover.available, .map-node:hover.completed {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 0 20px rgba(255,200,0,0.6);
}
@keyframes nodePulse {
  0%,100% { box-shadow: 0 0 12px rgba(100,200,100,0.4); }
  50% { box-shadow: 0 0 25px rgba(100,255,100,0.8); }
}
.node-stars {
  font-size: 10px;
  letter-spacing: -2px;
  color: var(--gold);
}
.map-node.boss-node {
  background: linear-gradient(135deg, #3a0a0a, #6a1a1a);
  border-color: #ff4444;
}
.map-node.boss-node .node-stars { color: #ff6666; }

/* ── PRE-BATTLE SCREEN ── */
#screen-prebattle {
  background: linear-gradient(180deg, #0a0520 0%, #1a0530 100%);
}
#prebattle-content {
  max-width: 700px;
  width: 92%;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 28px;
}
#pb-title {
  font-size: clamp(22px, 5vw, 40px);
  color: var(--gold);
  letter-spacing: 0.2em;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(245,197,66,0.5);
}
#pb-body {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
#pb-left, #pb-right {
  flex: 1;
  min-width: 200px;
}
.pb-section {
  margin-bottom: 16px;
}
.pb-section h3 {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #888;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.pb-section p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
#pb-enemy-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.enemy-badge {
  background: rgba(200,50,50,0.3);
  border: 1px solid rgba(200,50,50,0.5);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: #ff8888;
}
#pb-rewards {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--gold);
}
#pb-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  gap: 16px;
}

/* ── GAME SCREEN ── */
#screen-game {
  background: #000;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* ── HUD ── */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
  gap: 8px;
}

.castle-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #aaa;
  margin-bottom: 4px;
}
.hp-bar-wrap {
  width: clamp(120px, 20vw, 240px);
  height: 16px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #44cc44, #88ff88);
  transition: width 0.3s;
  width: 100%;
}
.hp-bar.enemy {
  background: linear-gradient(90deg, #cc4444, #ff8888);
  margin-left: auto;
  float: right;
}
.hp-bar-wrap span {
  position: absolute;
  right: 4px; top: 0; bottom: 0;
  display: flex; align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  pointer-events: none;
}
#castle-hp-right .hp-bar-wrap {
  direction: rtl;
}
#castle-hp-right .hp-bar-wrap span {
  right: auto; left: 4px;
}

#hud-center-top {
  text-align: center;
  flex: 1;
}
#level-info {
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-shadow: 0 0 10px rgba(245,197,66,0.5);
}
#wave-info, #kill-count {
  font-size: clamp(10px, 1.5vw, 14px);
  color: #aaa;
  letter-spacing: 0.1em;
}

/* ── BOTTOM HUD ── */
#hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px 8px 10px;
  background: linear-gradient(0deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.7) 60%, transparent 100%);
  gap: 8px;
  pointer-events: all;
  flex-wrap: wrap;
}

/* Abilities */
#abilities-bar {
  display: flex;
  gap: 6px;
}
.ability-slot {
  width: clamp(52px, 7vw, 72px);
  height: clamp(52px, 7vw, 72px);
  position: relative;
  cursor: pointer;
  background: rgba(20,20,40,0.8);
  border: 2px solid rgba(100,100,200,0.5);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ability-slot:hover { border-color: var(--blue); box-shadow: 0 0 12px rgba(79,195,247,0.4); }
.ability-slot.on-cooldown { border-color: rgba(60,60,80,0.5); }
.ability-slot.active-ability { border-color: #fff; box-shadow: 0 0 20px rgba(255,255,255,0.6); }
.ab-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ab-key {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 11px;
  font-weight: 900;
  color: var(--gold);
  z-index: 2;
  text-shadow: 1px 1px 2px #000;
}
.ab-label {
  position: absolute;
  bottom: 2px;
  font-size: 7px;
  letter-spacing: 0.05em;
  color: #bbb;
  z-index: 2;
  text-align: center;
  width: 100%;
  line-height: 1;
}
.ab-cooldown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 3;
  display: none;
  border-radius: 4px;
}

/* Mana */
#mana-section {
  flex: 1;
  max-width: 220px;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#mana-label {
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--mana2);
  font-weight: 700;
}
#mana-bar-wrap {
  width: 100%;
  height: 18px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(124,77,255,0.4);
  border-radius: 9px;
  position: relative;
  overflow: hidden;
}
#mana-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--mana), var(--mana2));
  border-radius: 9px;
  transition: width 0.2s;
  box-shadow: 0 0 10px rgba(124,77,255,0.6);
}
#mana-text {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
}

/* Unit Buttons */
#units-bar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60vw;
}
.unit-btn {
  width: clamp(50px, 7vw, 68px);
  height: clamp(64px, 9vw, 84px);
  position: relative;
  cursor: pointer;
  background: rgba(10,20,30,0.85);
  border: 2px solid rgba(80,140,200,0.5);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  transition: all 0.15s;
  padding-top: 4px;
}
.unit-btn:hover { border-color: #4fc3f7; box-shadow: 0 0 12px rgba(79,195,247,0.4); transform: translateY(-2px); }
.unit-btn:active { transform: translateY(1px); }
.unit-btn.locked { border-color: #333; opacity: 0.4; cursor: not-allowed; }
.unit-btn.no-mana { border-color: #444; opacity: 0.5; }
.unit-btn canvas { width: 100%; flex: 1; }
.unit-btn .unit-name {
  font-size: 8px;
  letter-spacing: 0.05em;
  color: #ccc;
  line-height: 1.2;
}
.unit-btn .unit-cost {
  font-size: 11px;
  font-weight: 700;
  color: var(--mana2);
  display: flex; align-items: center; gap: 2px;
}
.unit-btn .unit-cost::before {
  content: '◆';
  font-size: 8px;
  color: var(--mana);
}
.unit-btn .spawn-cd-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  transform-origin: left;
  transition: transform 0.1s linear;
}
.unit-btn .unit-hotkey {
  position: absolute;
  top: 2px; left: 4px;
  font-size: 9px;
  color: var(--gold);
  font-weight: 900;
}

/* Pause button */
#pause-btn-wrap {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: all;
}
#btn-pause {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}
#btn-pause:hover { opacity: 1; }

/* Incoming banner */
#incoming-banner {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  background: rgba(200,0,0,0.85);
  border: 2px solid #ff4444;
  border-radius: 6px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  font-size: clamp(14px, 2.5vw, 20px);
  letter-spacing: 0.2em;
  color: #fff;
  z-index: 20;
  pointer-events: none;
  animation: blink 0.6s step-end infinite;
}
#incoming-banner.hidden { display: none; }
@keyframes blink {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#incoming-preview { display: flex; gap: 6px; }
.incoming-unit-icon { font-size: 16px; }

/* ── RESULT SCREEN ── */
#screen-result {
  background: radial-gradient(ellipse at center, #1a1020 0%, #050508 100%);
}
#result-content {
  text-align: center;
  padding: 32px;
  max-width: 500px;
  width: 92%;
}
#result-title {
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-bottom: 16px;
  animation: resultPop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
#result-title.win { color: var(--gold); text-shadow: 0 0 40px rgba(245,197,66,0.8); }
#result-title.lose { color: var(--red); text-shadow: 0 0 40px rgba(239,83,80,0.8); }
@keyframes resultPop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
#result-stars { font-size: 40px; margin-bottom: 16px; letter-spacing: 4px; }
#result-stats {
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 15px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: #aaa; }
.stat-row span:last-child { font-weight: 700; color: #fff; }
#result-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── PAUSE SCREEN ── */
#screen-pause {
  background: rgba(0,0,0,0.88);
}
#pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 220px;
}
#pause-content h2 {
  font-size: 36px;
  letter-spacing: 0.3em;
  color: var(--gold);
  margin-bottom: 8px;
}

/* ── MISC ── */
.hidden { display: none !important; }

/* ── FLASH OVERLAY ── */
#screen-game::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(255,255,255,0);
  transition: background 0.1s;
  z-index: 100;
}
#screen-game.flash::after {
  background: rgba(255,200,100,0.25);
  transition: none;
}

/* ── TOOLTIP ── */
.tooltip {
  position: absolute;
  background: rgba(0,0,0,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #fff;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  top: -40px; left: 50%;
  transform: translateX(-50%);
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  #hud-bottom { padding: 6px 4px 8px; gap: 4px; }
  #units-bar { max-width: 55vw; }
  #abilities-bar { gap: 4px; }
}
@media (max-width: 400px) {
  #hud-top { font-size: 10px; }
  .hp-bar-wrap { width: 100px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
