:root {
  --bg: #0d0b14;
  --bg-panel: #171320;
  --bg-inset: #241d33;
  --border: #3a2f4a;
  --border-bright: #5a4a72;
  --text: #ece7f5;
  --muted: #9a8fb3;
  --amber: #ffb347;
  --amber-deep: #f2860f;
  --red: #ff5a5a;
  --blue: #6fa8ff;
  --green: #5bd66b;
  --pixel: "Press Start 2P", system-ui, sans-serif;
  --read: "VT323", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

html, body {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 16 16'%3E%3Cpolygon points='0,0 0,13 3,10 5,15 7,14 5,9 9,9' fill='%23ffffff' stroke='%23000000' stroke-width='1' shape-rendering='crispEdges'/%3E%3C/svg%3E") 1 1, auto;
}

a, button, label, select, input, .map-btn, .choice, .picker__arrow, [role="button"] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 16 16'%3E%3Cpolygon points='0,0 0,13 3,10 5,15 7,14 5,9 9,9' fill='%23ffb347' stroke='%23000000' stroke-width='1' shape-rendering='crispEdges'/%3E%3C/svg%3E") 1 1, pointer;
}

#game-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 12 12' shape-rendering='crispEdges'%3E%3Crect x='5' y='0' width='2' height='4' fill='%23ffb347'/%3E%3Crect x='5' y='8' width='2' height='4' fill='%23ffb347'/%3E%3Crect x='0' y='5' width='4' height='2' fill='%23ffb347'/%3E%3Crect x='8' y='5' width='4' height='2' fill='%23ffb347'/%3E%3Crect x='5' y='5' width='2' height='2' fill='%23ffffff'/%3E%3C/svg%3E") 12 12, crosshair;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1c1630 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--read);
  font-size: 20px;
  -webkit-font-smoothing: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 3px solid var(--border);
  background: linear-gradient(180deg, #150f22, #0d0b14);
}

.topbar__brand { display: flex; align-items: center; gap: 14px; }
.topbar__mark { font-size: 28px; color: var(--amber); text-shadow: 0 0 12px rgba(255, 179, 71, 0.5); }
.topbar__title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 18px;
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 #000;
}
.topbar__tag { margin: 6px 0 0; color: var(--muted); font-size: 18px; letter-spacing: 1px; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }

.icon-link { color: var(--muted); display: inline-flex; transition: color 0.15s, transform 0.15s; }
.icon-link:hover { color: var(--amber); transform: translateY(-2px); }

.btn {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 12px 16px;
  border: 3px solid var(--border-bright);
  background: var(--bg-inset);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
  box-shadow: 0 4px 0 #000;
}
.btn:hover { background: #2e2542; }
.btn:active { transform: translateY(4px); box-shadow: none; }
.btn--ghost { background: transparent; }
.btn--sm { font-size: 9px; padding: 9px 12px; }
.btn--primary {
  background: var(--amber);
  border-color: var(--amber-deep);
  color: #2a1400;
  box-shadow: 0 4px 0 var(--amber-deep);
}
.btn--primary:hover { background: #ffc266; }
.btn--primary:active { box-shadow: none; }

.game {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  padding: 14px 0;
  width: 100%;
  max-width: none;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 232px;
  flex-shrink: 0;
}
.hud--left { padding-left: 12px; }
.hud--right { padding-right: 12px; }
.hud .panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.hud .panel + .panel { margin-top: -3px; }

.stage {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  border: 4px solid var(--border-bright);
  box-shadow: 0 0 0 4px #000, 0 12px 30px rgba(0, 0, 0, 0.6);
  line-height: 0;
  background: #0d0b14;
}

#game-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

.stage-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  font-size: 12px;
  color: var(--text);
  background: rgba(13, 11, 20, 0.8);
  border: 2px solid var(--border-bright);
  cursor: pointer;
}
.stage-btn:hover { color: var(--amber); }

.panel {
  background: var(--bg-panel);
  border: 3px solid var(--border);
  padding: 14px 12px;
  text-align: center;
  box-shadow: inset 0 0 0 2px #0d0b14;
}
.panel__label {
  margin: 0 0 10px;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--amber);
}
.panel__value { margin: 10px 0 0; font-size: 32px; line-height: 1; }
.panel__value--sm { font-size: 24px; }

.player-name { margin: 0; font-size: 30px; line-height: 1; letter-spacing: 1px; text-transform: uppercase; text-align: center; }
.player-name[data-team="blue"], #winner-name[data-team="blue"] { color: var(--blue); text-shadow: 0 0 12px rgba(111, 168, 255, 0.4); }
.player-name[data-team="red"], #winner-name[data-team="red"] { color: var(--red); text-shadow: 0 0 12px rgba(255, 90, 90, 0.4); }
.panel__sub { margin: 6px 0 0; font-family: var(--pixel); font-size: 10px; letter-spacing: 1px; }
.panel__stats { margin: 8px 0 0; font-size: 16px; letter-spacing: 1px; color: var(--amber); }

.meter__fill--health { background: linear-gradient(90deg, var(--green), #f2c14e); }

.vital { display: grid; grid-template-columns: 26px 1fr 40px; align-items: center; gap: 8px; margin-top: 10px; }
.vital:first-of-type { margin-top: 4px; }
.vital__k { font-family: var(--pixel); font-size: 8px; color: var(--muted); }
.vital__v { font-size: 20px; text-align: right; }

.board--mini li { font-size: 17px; padding: 5px 2px; }

.score { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.score__row { display: flex; justify-content: space-between; font-size: 18px; letter-spacing: 1px; }
.score__row[data-team="blue"] { color: var(--blue); }
.score__row[data-team="red"] { color: var(--red); }
.mini { height: 8px; background: var(--bg-inset); border: 1px solid var(--border); margin-bottom: 4px; }
.mini__fill { height: 100%; width: 100%; }
.score__row[data-team="blue"] + .mini .mini__fill { background: var(--blue); }
.score__row[data-team="red"] + .mini .mini__fill { background: var(--red); }

.timer { margin-top: 12px; font-size: 30px; color: var(--muted); }
.timer #timer { color: var(--text); }
.timer #timer.is-low { color: var(--red); }
.timer__unit { font-size: 18px; }

.dial {
  width: 92px; height: 92px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--border); border-radius: 50%;
  background: radial-gradient(circle, #241d33 0%, #120e1c 100%);
}
#arrow { width: 64px; height: 64px; image-rendering: pixelated; transform-origin: center; transition: transform 0.1s linear; }

.meter { width: 100%; height: 18px; background: var(--bg-inset); border: 2px solid var(--border); overflow: hidden; }
.meter__fill { height: 100%; width: 55%; background: linear-gradient(90deg, var(--amber), var(--red)); transition: width 0.1s linear; }
.meter__fill--stamina { background: linear-gradient(90deg, #3fd6c4, #6fa8ff); }

.music-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px;
  font-family: var(--pixel); font-size: 11px;
  color: var(--text); background: var(--bg-inset);
  border: 2px solid var(--border-bright); cursor: pointer;
}
.music-btn.is-on { color: var(--amber); border-color: var(--amber-deep); }
.music-btn__icon { font-size: 12px; }

.controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 20px;
  padding: 14px; border-top: 3px solid var(--border);
  color: var(--muted); font-size: 18px; letter-spacing: 1px;
}
.ctrl { display: inline-flex; align-items: center; gap: 8px; }

kbd {
  display: inline-block; min-width: 26px; padding: 4px 6px;
  font-family: var(--pixel); font-size: 10px; text-align: center;
  color: var(--text); background: var(--bg-inset);
  border: 2px solid var(--border-bright); border-bottom-width: 4px; border-radius: 3px;
}
.kbd--wide { min-width: 64px; }

.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 4, 12, 0.82); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s;
  z-index: 50;
}
.modal.is-visible { opacity: 1; visibility: visible; }

.modal__card {
  width: 100%; max-width: 480px; padding: 28px;
  background: var(--bg-panel); border: 4px solid var(--border-bright);
  box-shadow: 0 0 0 4px #000, 0 18px 50px rgba(0, 0, 0, 0.6);
  position: relative; max-height: 90vh; overflow-y: auto;
}
.modal__card--center { text-align: center; max-width: 420px; }
.modal__card--wide { max-width: 960px; }

.modal__close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  background: transparent; border: none; color: var(--muted);
  font-size: 28px; line-height: 1; cursor: pointer;
}
.modal__close:hover { color: var(--amber); }

.modal__eyebrow { margin: 0 0 10px; font-family: var(--pixel); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--amber); }
.modal__title { margin: 0 0 16px; font-family: var(--pixel); font-size: 18px; line-height: 1.5; text-shadow: 3px 3px 0 #000; }
.modal__lead { margin: 0 0 22px; font-size: 21px; line-height: 1.35; color: var(--muted); }
.modal__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.rules { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; }
.rule { display: flex; align-items: center; gap: 14px; font-size: 21px; }
.rule__keys { display: inline-flex; gap: 6px; min-width: 92px; }

#select-screen .modal__title { text-align: center; }
#select-screen #start-btn { display: block; margin: 4px auto 0; }
.select-grid { display: grid; grid-template-columns: 1fr 0.7fr 1fr; gap: 20px; margin-bottom: 22px; align-items: start; }
.select-col__head { margin: 0 0 12px; font-family: var(--pixel); font-size: 11px; letter-spacing: 1px; color: var(--muted); text-align: center; }

.picker { --accent: var(--amber); text-align: center; }
.picker__name {
  width: 100%; margin-bottom: 12px; padding: 8px 10px; text-align: center;
  font-family: var(--pixel); font-size: 11px; color: var(--text);
  background: var(--bg-inset); border: 2px solid var(--accent); outline: none;
}
.picker__name:focus { box-shadow: 0 0 0 2px var(--accent); }

.picker__stage { display: flex; align-items: center; justify-content: center; gap: 10px; }
.picker__arrow {
  width: 40px; height: 56px; flex-shrink: 0;
  font-family: var(--pixel); font-size: 18px; color: var(--accent);
  background: var(--bg-inset); border: 2px solid var(--border); cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
}
.picker__arrow:hover { border-color: var(--accent); }
.picker__arrow:active { transform: scale(0.94); }
.picker__frame {
  width: 150px; height: 150px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--accent);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, #120e1c), #0d0b14);
}
.picker__model { width: 150px; height: 150px; image-rendering: pixelated; }

.picker__char { margin: 14px 0 6px; font-family: var(--pixel); font-size: 16px; }
.picker__blurb { margin: 0 0 14px; font-size: 17px; line-height: 1.15; color: var(--muted); min-height: 40px; }
.picker__stats { display: flex; flex-direction: column; gap: 5px; text-align: left; }

.board-col { padding-top: 44px; text-align: center; }
.board-col .board { display: inline-block; min-width: 200px; text-align: left; margin-bottom: 16px; }

.stat { display: grid; grid-template-columns: 44px 1fr 30px; align-items: center; gap: 6px; font-size: 13px; }
.stat__k { font-family: var(--pixel); font-size: 8px; color: var(--muted); }
.stat__bar { height: 7px; background: #0d0b14; border: 1px solid var(--border); }
.stat__bar i { display: block; height: 100%; background: var(--accent); }
.stat__v { text-align: right; color: var(--text); font-size: 15px; }

.board { list-style: none; margin: 0 0 14px; padding: 0; }
.board li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 4px; font-size: 20px; border-bottom: 1px solid var(--border); }
.board li:last-child { border-bottom: none; }
.board li span:last-child { color: var(--amber); }
.board__empty { color: var(--muted); justify-content: center !important; }
.board--center { max-width: 280px; margin: 0 auto 20px; text-align: left; }

/* ---------- Unlocks / progression ---------- */
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover { background: var(--amber); }

.picker__frame { position: relative; }
.picker__lock {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: rgba(8, 6, 14, 0.82); color: var(--muted);
  font-family: var(--pixel); font-size: 10px; letter-spacing: 1px;
}
.picker__lock[hidden] { display: none; }
.picker__lock-icon { font-size: 26px; }
.picker.is-locked .picker__char { color: var(--muted) !important; }

.progress-line { margin: 4px 0 14px; font-size: 16px; color: var(--amber); text-align: center; }

.maps { margin: 0 0 18px; text-align: center; }
.maps__label { margin: 0 0 10px; font-family: var(--pixel); font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.map-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.map-btn {
  --swatch: #6ba43c; --sky: #7a2436;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
  background: var(--bg-inset); border: 2px solid var(--border); color: var(--text); font-size: 16px;
}
.map-btn:hover { border-color: var(--border-bright); }
.map-btn.is-selected { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.map-btn.is-locked { opacity: 0.5; cursor: not-allowed; }
.map-btn__swatch { width: 16px; height: 16px; border: 1px solid #000; background: linear-gradient(180deg, var(--sky), var(--swatch)); }
.map-btn__lock { font-size: 13px; color: var(--muted); }

.go-unlocks { margin: 0 0 16px; }
.go-unlocks__title { margin: 0 0 8px; font-family: var(--pixel); font-size: 11px; color: var(--amber); }
.unlock-chip { display: inline-block; margin: 3px; padding: 6px 10px; font-size: 15px; background: var(--bg-inset); border: 2px solid var(--amber-deep); color: var(--amber); }

@media (max-width: 1040px) {
  .game { flex-direction: column; }
  .hud { flex-direction: row; width: 100%; max-width: 1040px; }
  .hud .panel { flex: 1; }
  .stage { order: -1; width: 100%; }
}
@media (max-width: 820px) {
  .select-grid { grid-template-columns: 1fr; }
  .hud { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .topbar__title { font-size: 14px; }
}
