:root {
  --ink: #07141c;
  --panel: #0a202a;
  --copper: #d8823d;
  --copper-light: #f0ad68;
  --cyan: #45dce8;
  --cream: #f4ead8;
  --muted: #9bb0b5;
  --danger: #f16055;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 0%, rgba(69, 220, 232, .1), transparent 28rem),
    repeating-linear-gradient(90deg, transparent 0 59px, rgba(255,255,255,.018) 60px),
    var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  letter-spacing: .035em;
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell { width: min(100% - 28px, 920px); margin: 0 auto; padding-bottom: 64px; }
.brand-bar { display: flex; align-items: center; justify-content: space-between; padding: 22px 0; border-bottom: 1px solid rgba(216,130,61,.35); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; font-size: .88rem; letter-spacing: .12em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: var(--ink); background: var(--copper); font-weight: 900; clip-path: polygon(50% 0,100% 100%,0 100%); padding-top: 8px; }
.brand b { color: var(--copper-light); }
.header-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: flex-end; }
.variant-switch { display: flex; padding: 3px; border: 1px solid #36505a; background: #061219; }
.variant-switch a { padding: 7px 10px; color: var(--muted); text-decoration: none; font-size: .6rem; font-weight: 800; letter-spacing: .12em; }
.variant-switch a:hover { color: var(--cream); }
.variant-switch a[aria-current="page"] { color: var(--ink); background: var(--cyan); }
.icon-button, .text-button { color: var(--muted); background: none; border: 0; letter-spacing: .12em; font-size: .68rem; }
.icon-button:hover, .text-button:hover { color: var(--cream); }

.hero-copy { text-align: center; padding: 42px 12px 28px; }
.eyebrow { margin: 0 0 10px; color: var(--copper-light); font-size: .72rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.hero-copy h1 { margin: 0; font-size: clamp(2.25rem, 8vw, 5.15rem); line-height: .85; letter-spacing: -.025em; text-shadow: 0 0 36px rgba(69,220,232,.15); }
.hero-copy h1 span { display: block; color: var(--cyan); font-size: .52em; letter-spacing: .22em; margin-bottom: 12px; }
.hero-copy > p:last-child { color: var(--muted); margin: 18px 0 0; font-family: Arial, sans-serif; font-size: .9rem; }

.game-card { overflow: hidden; width: min(100%, 650px); margin: 0 auto; background: rgba(6,24,32,.92); border: 1px solid rgba(216,130,61,.7); box-shadow: 0 24px 70px #000a, inset 0 0 30px rgba(216,130,61,.06); }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 14px 18px; border-bottom: 1px solid rgba(216,130,61,.35); }
.hud > div { display: flex; flex-direction: column; }
.hud-label { color: var(--muted); font-size: .58rem; letter-spacing: .18em; }
.hud strong { margin-top: 3px; font-size: 1rem; letter-spacing: .09em; }
.hud > div:last-child strong { color: var(--cyan); }

.canvas-wrap { position: relative; width: 100%; aspect-ratio: 19 / 21; background: #030c12; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3,12,18,.73); backdrop-filter: blur(3px); }
.overlay.inactive { pointer-events: none; opacity: 0; }
.panel { width: min(100%, 440px); padding: clamp(22px, 5vw, 38px); text-align: center; background: rgba(7,20,28,.96); border: 1px solid var(--copper); box-shadow: 0 0 0 5px rgba(216,130,61,.08), 0 20px 50px #000b; }
.panel.hidden { display: none; }
.panel h2 { margin: 6px 0 15px; font-size: clamp(1.55rem, 5vw, 2.45rem); line-height: .95; }
.panel > p:not(.eyebrow) { color: #bdc9ca; font: .85rem/1.5 Arial, sans-serif; }
.probe-icon { position: relative; width: 68px; height: 68px; margin: 0 auto 20px; border-radius: 50% 50% 44% 44%; background: var(--cyan); box-shadow: 0 0 30px rgba(69,220,232,.5); }
.probe-icon::before { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: #08202a; border: 5px solid #eafcff; }
.probe-icon span { position: absolute; left: 25px; bottom: -12px; width: 18px; height: 18px; background: var(--copper); transform: rotate(45deg); }
.primary-button { min-width: 190px; margin-top: 12px; padding: 13px 22px; color: #061219; background: var(--copper-light); border: 0; font-weight: 900; letter-spacing: .12em; box-shadow: 4px 4px 0 #7b3e1b; }
.primary-button:hover, .primary-button:focus-visible { background: var(--cyan); box-shadow: 4px 4px 0 #18747c; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.controls-hint { margin: 16px 0 0 !important; font-size: .7rem !important; }

.lead-panel { max-height: 96%; overflow: auto; }
.lead-panel form { text-align: left; }
.lead-panel label { display: grid; gap: 5px; margin: 10px 0; color: var(--muted); font: .67rem Arial, sans-serif; text-transform: uppercase; letter-spacing: .1em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lead-panel input:not([type="checkbox"]) { width: 100%; min-width: 0; padding: 10px; color: var(--cream); background: #0c2933; border: 1px solid #38515a; outline: none; }
.lead-panel input:focus { border-color: var(--cyan); }
.lead-panel .consent { display: flex; grid-template-columns: auto 1fr; align-items: flex-start; text-transform: none; letter-spacing: 0; line-height: 1.35; }
.consent input { margin-top: 2px; accent-color: var(--cyan); }
.consent a { color: var(--cyan); }
.form-error { min-height: 16px; margin: 4px 0; color: #ff8279; font: .72rem Arial, sans-serif; }
.lead-panel .text-button { display: block; margin: 15px auto 0; }
.leaderboard-panel ol { margin: 20px 0; padding: 0; list-style-position: inside; }
.leaderboard-panel li { display: grid; grid-template-columns: 32px 1fr auto; padding: 9px 4px; border-bottom: 1px solid #ffffff14; text-align: left; }
.leaderboard-panel li span:last-child { color: var(--cyan); }

.steering-status { margin: 0; padding: 12px; color: var(--cyan); text-align: center; font: .75rem/1.5 Arial, sans-serif; }
.score-board { padding: 20px; border: 1px solid var(--copper); background: var(--panel); }
.score-table-wrap { overflow-x: auto; }
.score-board table { width: 100%; border-collapse: collapse; font: .85rem/1.5 Arial, sans-serif; }
.score-board caption { text-align: left; padding-bottom: 12px; color: var(--muted); }
.score-board th, .score-board td { padding: 12px 8px; text-align: left; border-bottom: 1px solid #36505a; }
.score-board td:nth-child(2) { overflow-wrap: anywhere; max-width: 200px; }
.score-board th { color: var(--cyan); }
#board-status, #game-board-status { font: .85rem/1.5 Arial, sans-serif; }
.mobile-controls { display: none; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; padding: 8px 8px 16px; }
.joystick-control { text-align: center; }
.joystick { position: relative; width: 136px; height: 136px; margin: auto; border: 2px solid #426470; border-radius: 50%; background: radial-gradient(circle, #143e49, #081a23); box-shadow: inset 0 0 18px #0008; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.joystick:focus-visible { outline: 3px solid var(--cyan); outline-offset: 4px; }
.joystick.active { border-color: var(--cyan); cursor: grabbing; }
.joystick-axis { position: absolute; background: #426470; pointer-events: none; }
.joystick-axis-vertical { width: 2px; top: 12px; bottom: 12px; left: calc(50% - 1px); }
.joystick-axis-horizontal { height: 2px; left: 12px; right: 12px; top: calc(50% - 1px); }
.joystick-thumb { position: absolute; width: 52px; height: 52px; left: calc(50% - 26px); top: calc(50% - 26px); border: 2px solid #aafaff; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #91f4fa, #2097a5); box-shadow: 0 4px 10px #0009; pointer-events: none; }
.joystick-control p { color: var(--muted); font: .65rem/1.5 Arial, sans-serif; margin: 10px 0 0; }
.touch-controls { display: none; grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(2, 42px); justify-content: center; gap: 5px; padding: 12px; }
.touch-controls button { color: var(--cyan); background: #0e2a34; border: 1px solid #31515a; border-radius: 4px; }
.touch-controls button[data-direction="up"] { grid-column: 2; }
.touch-controls button[data-direction="left"] { grid-column: 1; grid-row: 2; }
.touch-controls button[data-direction="down"] { grid-column: 2; grid-row: 2; }
.touch-controls button[data-direction="right"] { grid-column: 3; grid-row: 2; }
.game-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 24px; padding: 14px; color: var(--muted); border-top: 1px solid rgba(216,130,61,.25); font: .68rem Arial, sans-serif; }
.game-footer b { color: var(--cream); }
.legend-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; vertical-align: 1px; background: var(--cream); }
.legend-dot.kit { width: 11px; height: 11px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.legend-dot.germ { width: 11px; height: 11px; background: var(--danger); }

.mission { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: end; margin: 70px auto 0; padding: 40px 0; border-top: 1px solid rgba(216,130,61,.3); }
.mission h2 { margin: 0; font-size: clamp(1.7rem, 5vw, 3.2rem); line-height: .95; }
.mission > p { margin: 0; color: var(--muted); font: .95rem/1.65 Arial, sans-serif; }

@media (max-width: 650px) {
  .shell { width: min(100% - 16px, 920px); }
  .brand-bar { padding: 14px 4px; }
  .header-actions { gap: 8px; }
  .variant-switch a { padding: 6px; font-size: .52rem; }
  .hero-copy { padding-top: 30px; }
  .hud { padding: 10px; }
  .hud strong { font-size: .78rem; }
  .touch-controls { display: grid; }
  .mission { grid-template-columns: 1fr; gap: 20px; margin-top: 42px; }
  .game-footer { display: none; }
  .panel { padding: 20px; }
}

@media (max-width: 650px), (any-pointer: coarse) {
  .mobile-controls { display: flex; }
  .mobile-controls .touch-controls { display: grid; padding: 0; }
}

@media (max-width: 430px) {
  .brand-bar { align-items: flex-start; }
  .header-actions { flex-direction: column-reverse; align-items: flex-end; }
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .lead-panel { padding: 16px; }
  .lead-panel h2 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
