:root {
  color-scheme: dark;
  --ink: #e8f1f5;
  --muted: #8da1ae;
  --dim: #5d7482;
  --panel: rgba(14, 27, 39, 0.92);
  --panel-raised: #122332;
  --line: rgba(130, 164, 183, 0.2);
  --mint: #64e0c2;
  --blue: #75baff;
  --amber: #ffd27a;
  --danger: #ff647b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 12% 0%, rgba(35, 89, 96, 0.24), transparent 34rem),
    radial-gradient(ellipse at 92% 14%, rgba(35, 69, 113, 0.2), transparent 30rem),
    #07111a;
  font-family: "Segoe UI", Arial, sans-serif;
}

button { font: inherit; }

.app-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.app-header,
.brand-lockup,
.panel-heading,
.map-toolbar,
.map-footer,
.action-row,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header { gap: 20px; }
.brand-lockup { justify-content: flex-start; gap: 15px; }
.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(100, 224, 194, 0.55);
  border-radius: 15px;
  color: var(--mint);
  background: linear-gradient(145deg, rgba(100, 224, 194, 0.16), rgba(24, 46, 60, 0.8));
  box-shadow: inset 0 0 18px rgba(100, 224, 194, 0.08), 0 0 28px rgba(100, 224, 194, 0.08);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.eyebrow,
.hud-label {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 { margin: 2px 0 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: 0.12em; }
h1 span { color: var(--mint); }
.intro { margin: 16px 0 22px; color: #a9bbc5; font-size: 14px; }
.header-chip, .ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #b9cbd4;
  background: rgba(14, 27, 39, 0.72);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.live-dot, .toolbar-dot, .ai-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px var(--mint);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.85fr);
  align-items: start;
  gap: 18px;
}
.game-column, .sidebar { min-width: 0; }
.sidebar { display: grid; gap: 14px; }

.hud { display: grid; grid-template-columns: 0.9fr 0.9fr 1.6fr; gap: 10px; margin-bottom: 12px; }
.hud-card, .panel, .map-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.hud-card { min-height: 77px; padding: 13px 15px; }
.hud-card strong { display: block; margin-top: 8px; font-size: 19px; line-height: 1.15; }
.timer-card strong { color: var(--amber); font-variant-numeric: tabular-nums; }
.round-card strong { color: var(--blue); }
.objective-card strong { font-size: 15px; }

.map-panel { overflow: hidden; padding: 10px; }
.map-toolbar, .map-footer { min-height: 30px; padding: 0 4px 9px; color: #9bb0bc; font-size: 9px; font-weight: 750; letter-spacing: 0.11em; }
.map-toolbar { justify-content: flex-start; gap: 9px; }
.toolbar-dot { width: 6px; height: 6px; }
.toolbar-divider { color: #526b79; }
.map-legend { display: flex; align-items: center; gap: 7px; margin-left: auto; color: #78909d; font-size: 8px; }
.legend-player, .legend-guard { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.legend-guard { margin-left: 5px; background: var(--danger); }
canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(125, 160, 179, 0.3);
  border-radius: 8px;
  background: #101b27;
}
.map-footer { min-height: auto; padding: 9px 4px 0; color: #647e8c; font-size: 8px; }

.action-row { justify-content: flex-start; gap: 10px; margin-top: 12px; }
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button-secondary { border-color: rgba(117, 186, 255, 0.35); color: #c5e1f5; background: rgba(23, 47, 74, 0.65); }
.button-secondary:hover:not(:disabled) { border-color: var(--blue); background: rgba(23, 47, 74, 0.95); }
.button-primary { color: #062019; background: var(--mint); }
.button-primary:hover { background: #8bf1d7; }
.button kbd, kbd { padding: 2px 6px; border: 1px solid rgba(190, 214, 226, 0.24); border-radius: 4px; color: #b3c8d2; background: rgba(0, 0, 0, 0.2); font: 700 10px "Segoe UI", sans-serif; }
#next-round[hidden] { display: none; }
.status-banner {
  min-height: 42px;
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(100, 224, 194, 0.18);
  border-radius: 9px;
  color: #b6ebdc;
  background: rgba(24, 61, 57, 0.35);
  font-size: 12px;
}

.panel { padding: 17px; }
.panel-heading { align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 17px; letter-spacing: 0.01em; }
.ai-badge { padding: 7px 9px; border-color: rgba(100, 224, 194, 0.18); color: var(--mint); background: rgba(30, 83, 71, 0.18); font-size: 8px; }
.ai-badge-dot { width: 5px; height: 5px; }
.prediction-card, .decision-card, .metric-card {
  border: 1px solid rgba(130, 164, 183, 0.14);
  border-radius: 10px;
  background: rgba(5, 14, 22, 0.44);
}
.prediction-card { padding: 14px; border-color: rgba(100, 224, 194, 0.24); background: linear-gradient(135deg, rgba(24, 65, 62, 0.44), rgba(7, 18, 27, 0.6)); }
.prediction-card strong { display: block; margin: 9px 0 4px; color: var(--mint); font-size: 22px; letter-spacing: 0.02em; }
.prediction-confidence { color: #93aab6; font-size: 11px; }
.ai-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.metric-card { min-width: 0; padding: 11px; }
.metric-card strong { display: block; overflow-wrap: anywhere; margin-top: 7px; color: #d6e2e8; font-size: 11px; line-height: 1.45; }
.decision-card { margin-top: 8px; padding: 13px; }
.decision-card strong { display: block; margin-top: 7px; color: var(--amber); font-size: 13px; line-height: 1.4; }
.decision-card p, .outcome-row p, .explanation p { margin: 6px 0 0; color: #93a8b4; font-size: 11px; line-height: 1.55; }
.outcome-row { padding: 14px 2px 2px; }
.outcome-row p { color: #c8d8df; }
.explanation { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.explanation summary { color: #a9c0cb; cursor: pointer; font-size: 11px; font-weight: 700; }
.explanation summary:hover { color: var(--mint); }
.intel-icon { color: var(--amber); font-size: 23px; }
.mission-list { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; }
.mission-list li { display: grid; grid-template-columns: 26px 1fr; align-items: start; gap: 9px; color: #b7c8d0; font-size: 11px; line-height: 1.45; }
.mission-number { color: var(--mint); font-size: 10px; font-weight: 800; }
.decoy-note { margin: 13px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: #738b98; font-size: 10px; line-height: 1.5; }
.app-footer { justify-content: center; gap: 20px; margin-top: 18px; color: #566d7b; font-size: 8px; font-weight: 750; letter-spacing: 0.14em; }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr); align-items: start; }
}
@media (max-width: 620px) {
  .app-shell { width: min(100% - 24px, 520px); padding-top: 16px; }
  .header-chip { font-size: 0; padding: 10px; }
  .header-chip .live-dot { width: 8px; height: 8px; }
  .intro { font-size: 12px; line-height: 1.5; }
  .hud { grid-template-columns: 0.9fr 0.9fr; }
  .objective-card { grid-column: 1 / -1; }
  .sidebar { grid-template-columns: 1fr; }
  .map-toolbar { font-size: 8px; }
  .map-footer { font-size: 7px; }
  .action-row { flex-wrap: wrap; }
  .app-footer { flex-wrap: wrap; gap: 8px 14px; font-size: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
#game-screen[hidden], #player-2-slot[hidden] { display: none; }

.selection-screen {
  margin-top: 26px;
  padding: clamp(18px, 3vw, 32px);
  border: 1px solid rgba(100, 224, 194, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(130deg, rgba(21, 45, 57, 0.93), rgba(9, 20, 30, 0.96) 55%),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px rgba(221, 250, 255, 0.04);
  animation: panel-in 380ms ease both;
}
.selection-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:22px; }
.selection-heading h2 { margin:7px 0 6px; font-size:clamp(23px,4vw,34px); letter-spacing:.01em; }
.selection-heading p:not(.eyebrow) { max-width:650px; margin:0; color:#9eb3be; font-size:13px; line-height:1.6; }
.selection-stamp { padding:8px 10px; border:1px solid rgba(117,186,255,.25); border-radius:7px; color:#80bfff; font-size:9px; font-weight:800; letter-spacing:.15em; white-space:nowrap; }
.setup-controls { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:13px; }
.setup-field { display:grid; gap:7px; color:var(--muted); font-size:9px; font-weight:800; letter-spacing:.14em; }
.setup-field select { width:100%; min-height:42px; padding:0 12px; border:1px solid rgba(130,164,183,.25); border-radius:8px; color:#dbe8ee; background:#0b1823; font:600 12px "Segoe UI",Arial,sans-serif; letter-spacing:normal; }
.setup-field select:focus-visible { outline:2px solid var(--mint); outline-offset:2px; }
.character-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.character-card { min-width:0; padding:14px; border:1px solid rgba(130,164,183,.18); border-radius:12px; background:rgba(5,14,22,.5); }
.character-card-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.player-chip,.control-chip { display:inline-flex; align-items:center; min-height:23px; padding:0 8px; border:1px solid rgba(100,224,194,.24); border-radius:999px; color:var(--mint); background:rgba(100,224,194,.07); font-size:8px; font-weight:800; letter-spacing:.12em; }
.player-two { color:var(--blue); border-color:rgba(117,186,255,.28); background:rgba(117,186,255,.07); }
.control-chip { border-color:rgba(130,164,183,.2); color:#91a8b4; background:transparent; letter-spacing:.08em; }
.character-preview { display:block; width:100%; height:112px; margin:10px 0; border:1px solid rgba(130,164,183,.14); border-radius:8px; background:#0b1620; image-rendering:pixelated; }
.character-choice select { min-height:38px; }
.selection-footer { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-top:16px; padding-top:15px; border-top:1px solid var(--line); }
.selection-footer p { max-width:640px; margin:0; color:#7f96a3; font-size:10px; line-height:1.6; }
#start-game { min-width:150px; flex-shrink:0; }

canvas#game { image-rendering:pixelated; }
.button:disabled { border-color:rgba(130,164,183,.15); color:#788b96; background:#14212b; }
.accuracy-row { padding-top:10px; border-top:1px solid rgba(130,164,183,.12); }

@keyframes panel-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@media (max-width:620px) {
  .selection-heading { flex-direction:column; }
  .setup-controls, .character-grid { grid-template-columns:1fr; }
  .selection-footer { align-items:stretch; flex-direction:column; }
  #start-game { width:100%; }
  .character-card { padding:12px; }
}
.scoreboard { display:flex; justify-content:flex-start; gap:10px; margin-top:10px; }
.score-entry { display:inline-flex; align-items:center; gap:9px; min-height:36px; padding:5px 10px; border:1px solid rgba(130,164,183,.18); border-radius:8px; background:rgba(5,14,22,.5); color:#9bb0bc; font-size:9px; font-weight:750; letter-spacing:.1em; }
.score-entry strong { color:#ffe58a; font-size:16px; font-variant-numeric:tabular-nums; }
.score-entry .player-chip { min-height:20px; }
@media (max-width:620px) { .scoreboard { flex-wrap:wrap; } }
#player-2-score-row[hidden] { display:none; }


/* Compact setup and undistorted sprite previews. */
.app-shell { width: min(1120px, calc(100% - 32px)); padding-top: 18px; }
.brand-mark { width: 42px; height: 42px; border-radius: 11px; box-shadow: none; }
.selection-screen { margin-top: 16px; padding: 20px; border-radius: 14px; box-shadow: none; }
.selection-heading { margin-bottom: 14px; }
.selection-heading h2 { margin-top: 4px; font-size: clamp(22px, 3vw, 28px); }
.selection-heading p:not(.eyebrow) { font-size: 12px; line-height: 1.45; }
.selection-stamp { display: none; }
.setup-controls { gap: 10px; margin-bottom: 10px; }
.setup-field select { min-height: 38px; }
.character-grid { gap: 10px; }
.character-card { padding: 10px; border-radius: 10px; box-shadow: none; }
.character-preview { width: 112px; height: 112px; max-width: 100%; margin: 8px auto; }
.character-choice select { min-height: 36px; }
.selection-footer { margin-top: 12px; padding-top: 12px; }
#start-game { min-width: 132px; }
.status-banner { min-height: 0; padding: 9px 11px; font-size: 11px; line-height: 1.4; }
@media (max-width: 620px) {
  .app-shell { width: min(100% - 20px, 520px); padding-top: 12px; }
  .selection-screen { padding: 14px; }
  .character-preview { width: 96px; height: 96px; }
}
