/* CommanderX design system — DBZ-anime energy: bold outlines, hot gradients, speed lines */

:root {
  --bg: #14103a;
  --bg2: #2a1a5e;
  --ink: #0d0a24;
  --paper: #fff8ec;
  --hot: #ff9e00;
  --hot2: #ffd500;
  --ki: #7df9ff;
  --danger: #ff4d3a;
  --outline: 3px solid var(--ink);
  --font-display: 'Arial Black', 'Impact', system-ui, sans-serif;
  --font-body: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, var(--bg2), var(--bg) 70%);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
  overflow: hidden;
}
.screen.active { display: flex; }
.hidden { display: none !important; }

/* anime speed lines radiating from center */
.speedlines {
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 9deg,
    rgba(255, 213, 0, 0.05) 9deg 11deg
  );
  animation: spin 60s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.title {
  font-family: var(--font-display);
  font-size: clamp(44px, 9vw, 96px);
  letter-spacing: 2px;
  font-style: italic;
  background: linear-gradient(180deg, var(--hot2) 30%, var(--hot) 60%, #ff5e00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(3px 3px 0 var(--ink)) drop-shadow(-1px -1px 0 var(--ink))
          drop-shadow(1px -1px 0 var(--ink)) drop-shadow(-1px 1px 0 var(--ink));
  z-index: 1;
}
.title-x { color: transparent; background: linear-gradient(180deg, var(--ki), #29c8ff); -webkit-background-clip: text; background-clip: text; }
.title-small { font-size: clamp(34px, 6vw, 64px); }

.tagline { z-index: 1; opacity: 0.85; font-size: 15px; }
.hint { z-index: 1; opacity: 0.6; font-size: 13px; }

/* --- buttons --- */
.btn {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  letter-spacing: 1px;
  padding: 12px 26px;
  border: var(--outline);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
  z-index: 1;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: linear-gradient(180deg, var(--hot2), var(--hot)); }
.btn-secondary { background: var(--ki); }
.btn-warn { background: var(--danger); color: var(--paper); }
.btn-tool { font-size: 14px; padding: 9px 16px; }

.menu-buttons { display: flex; gap: 14px; z-index: 1; }

/* --- player setup cards --- */
#player-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  z-index: 1;
  max-width: 900px;
}
.player-card {
  background: rgba(13, 10, 36, 0.75);
  border: var(--outline);
  border-radius: 14px;
  border-top: 8px solid var(--card-color, var(--hot));
  padding: 14px;
  width: 195px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.45);
}
.player-card h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--card-color, var(--hot));
}
.player-card input, .player-card select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
.player-card .remove {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
}
.card-row { display: flex; gap: 7px; align-items: center; }
.card-row label { font-size: 11px; text-transform: uppercase; opacity: 0.7; width: 42px; }

/* --- battle screen --- */
#screen-battle { padding: 0; }
#battlefield { position: absolute; inset: 0; width: 100%; height: 100%; }

#battle-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
#hud-top {
  display: flex;
  gap: 16px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  text-shadow: 2px 2px 0 var(--ink);
}
#hud-timer { color: var(--hot2); }
#hud-timer.urgent {
  color: var(--danger);
  font-size: 24px;
  animation: timerflash 1s steps(2, start) infinite;
}
@keyframes timerflash { 50% { opacity: 0.35; } }

/* big red centered countdown for the last few seconds — docs/01-HOW-IT-WORKS.md#urgent-countdown */
#countdown-big {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(120px, 30vw, 320px);
  color: var(--danger);
  text-shadow: 5px 5px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink);
  pointer-events: none;
  z-index: 3;
  animation: countpulse 1s ease-out;
}
@keyframes countpulse {
  0% { transform: scale(2.2); opacity: 0; }
  25% { transform: scale(1); opacity: 0.95; }
  100% { transform: scale(0.85); opacity: 0.25; }
}
#hud-armies { display: flex; gap: 10px; }
.army-chip {
  font-size: 13px;
  font-weight: bold;
  padding: 5px 11px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  color: var(--ink);
  background: var(--chip-color, #999);
  box-shadow: 2px 2px 0 var(--ink);
}
.army-chip.dead { opacity: 0.35; text-decoration: line-through; }

/* --- plan overlay --- */
#plan-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  pointer-events: none;
}
#plan-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-display);
  font-style: italic;
  text-shadow: 2px 2px 0 var(--ink);
}
#btn-undo {
  pointer-events: auto;
  font-size: 12px;
  padding: 6px 12px;
  margin-top: 4px;
}
#plan-player { font-size: 22px; color: var(--plan-color, var(--hot2)); }
#plan-step-hint { font-size: 13px; font-family: var(--font-body); font-style: normal; opacity: 0.9; }
#plan-tools { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; pointer-events: auto; }

/* --- tool rows (muster + command overlays) --- */
.tool-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}
.tool-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  text-shadow: 2px 2px 0 var(--ink);
}

/* type buy buttons: name + live affordable count */
.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 96px;
}
.type-btn .count {
  font-size: 12px;
  font-family: var(--font-body);
  font-style: normal;
  opacity: 0.75;
}
.type-btn:disabled { opacity: 0.35; }
/* the muster type you're placing right now */
.type-btn.active {
  background: linear-gradient(180deg, var(--hot2), var(--hot));
  box-shadow: 4px 4px 0 var(--ink), 0 0 14px rgba(255, 213, 0, 0.85);
  transform: translateY(-2px);
}
/* SELECT-BY-TYPE buttons read as the default command tool (ki-blue) */
.select-type-btn { background: var(--ki); min-width: 84px; }

/* subtle-but-clear tutorial glow on the next expected action */
.glow {
  animation: glowpulse 1.4s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 rgba(125, 249, 255, 0); }
  50% { box-shadow: 4px 4px 0 var(--ink), 0 0 18px rgba(125, 249, 255, 0.9); }
}

/* type filter chips for lasso selection */
.filter-chip {
  font-size: 13px;
  font-weight: bold;
  padding: 6px 13px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(255, 248, 236, 0.35);
  color: var(--paper);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.filter-chip.on {
  background: var(--ki);
  color: var(--ink);
}

/* --- gold bar + coin feedback --- */
#gold-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--hot2);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}
#gold-coin { color: var(--hot); font-size: 18px; }
#gold-amount.spending { animation: goldpop 0.15s ease-out; }
/* pending spend shown beside the bank, never subtracted from it — docs/01-HOW-IT-WORKS.md#finishing-commits-pending-work */
#gold-pending { font-size: 0.72em; opacity: 0.75; margin-left: 6px; letter-spacing: 0.02em; }
@keyframes goldpop {
  0% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
#coin-burst { position: absolute; left: 100%; top: 0; width: 0; }
.coin-fly {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 13px;
  color: var(--hot2);
  text-shadow: 1px 1px 0 var(--ink);
  animation: coinfly 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes coinfly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(26px, -34px) scale(0.5); opacity: 0; }
}

/* --- battle splash ("FIGHT!") --- */
#splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(60px, 14vw, 150px);
  letter-spacing: 4px;
  color: var(--hot2);
  text-shadow: 4px 4px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
  pointer-events: none;
  animation: smash 0.9s ease-out forwards;
}
@keyframes smash {
  0% { transform: scale(3); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  80% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}

/* --- results --- */
#results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
  min-width: min(430px, 90vw);
}
.result-row {
  display: flex;
  align-items: center;
  gap: 13px;
  background: rgba(13, 10, 36, 0.75);
  border: var(--outline);
  border-left: 10px solid var(--row-color, #999);
  border-radius: 11px;
  padding: 11px 15px;
  font-size: 16px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
}
.result-row .place { font-family: var(--font-display); font-style: italic; font-size: 21px; width: 34px; }
.result-row .rname { flex: 1; font-weight: bold; }
.result-row .rcount { opacity: 0.8; }
.result-row.winner { border-color: var(--hot2); background: rgba(255, 158, 0, 0.18); }

/* --- tactics controls (session 10) — docs/01-HOW-IT-WORKS.md#tactics-controls --- */
.tab-btn { min-width: 110px; opacity: 0.7; }
.tab-btn.active {
  opacity: 1;
  background: linear-gradient(180deg, var(--hot2), var(--hot));
  box-shadow: 4px 4px 0 var(--ink), 0 0 10px rgba(255, 213, 0, 0.6);
}
.tab-btn:disabled { opacity: 0.35; }
.dev-btn { background: #6b4a2a; }
.stance-chip.on { background: var(--hot2); color: var(--ink); }
.ability-btn { background: #5a2a6b; min-width: 96px; }
.ability-btn.queued {
  background: linear-gradient(180deg, #ffd500, #ff8a00);
  color: var(--ink);
}
.ability-btn.confirm { background: #c0262d; animation: glowpulse 0.8s ease-in-out infinite; }
.ability-btn:disabled { opacity: 0.35; }
.group-note {
  font-size: 13px;
  font-weight: bold;
  color: #ffb0b0;
  text-shadow: 1px 1px 0 var(--ink);
}

/* --- pause menu: the way out of a battle (session 12) --- */
.hud-menu {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 44px);
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  z-index: 6;
  font-size: 13px;
  padding: 6px 12px;
  pointer-events: auto;
}
#pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 10, 36, 0.72);
}
#pause-overlay.hidden { display: none; }
.pause-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-width: min(320px, 86vw);
  padding: 24px;
  background: var(--bg2);
  border: var(--outline);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink);
  text-align: center;
}
.pause-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 34px;
  color: var(--hot2);
  text-shadow: 3px 3px 0 var(--ink);
}
.quit-confirm { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.quit-confirm.hidden { display: none; }
.quit-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pause-hint { margin: 0; font-size: 12px; opacity: 0.7; }
