/* LIGHT GUN — visual identity: tower cab at dusk. Amber flight strips, signal greens and reds. */
:root {
  --bg: #0a1120;
  --bg2: #0f1a2f;
  --panel: #13203a;
  --panel2: #1a2a48;
  --line: #263a60;
  --ink: #e9effc;
  --muted: #9aaacb;
  --amber: #ffb547;
  --amber-ink: #2a1a00;
  --strip: #f3e3b8;
  --strip-ink: #2b2311;
  --green: #3bf08c;
  --red: #ff5465;
  --white: #f7f9ff;
  --focus: #7cc4ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef3f9;
  --bg2: #e2eaf4;
  --panel: #ffffff;
  --panel2: #f3f6fb;
  --line: #c9d5e6;
  --ink: #0f1a2e;
  --muted: #4a5a77;
  --amber: #a85f00;
  --amber-ink: #ffffff;
  --strip: #f7ebc6;
  --strip-ink: #2b2311;
  --green: #0b8a47;
  --red: #c81f35;
  --white: #3d4a63;
  --focus: #0b63c4;
  --shadow: 0 10px 26px rgba(20, 40, 80, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--amber); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--amber); color: var(--amber-ink); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; top: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: .06em; }
.brand svg { width: 30px; height: 30px; }
.brand span small { display: block; font-size: .62rem; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.site-nav { margin-left: auto; display: flex; gap: .2rem; align-items: center; }
.site-nav a {
  color: var(--muted); text-decoration: none; padding: .45rem .7rem; border-radius: 9px; font-weight: 600; font-size: .93rem;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); background: var(--panel); }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.1rem; cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover { border-color: var(--amber); }
#navToggle { display: none; }
@media (max-width: 760px) {
  #navToggle { display: inline-grid; margin-left: auto; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--bg); border-bottom: 1px solid var(--line); padding: .5rem;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: .8rem 1rem; }
}

/* ---------- layout ---------- */
main { display: block; }
.wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 1rem; }
.section { padding: 2.5rem 0; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .6rem; }
h1 { font-size: clamp(2.1rem, 6vw, 4rem); font-weight: 900; letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 800; }
p { margin: 0 0 1rem; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
.eyebrow { font-family: var(--mono); font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--amber); font-weight: 700; margin-bottom: .5rem; display: block; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.2rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .7rem 1.15rem; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  min-height: 44px;
}
.btn:hover { border-color: var(--amber); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .45rem .75rem; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; padding: 3rem 0 2rem; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(800px 380px at 85% 10%, color-mix(in srgb, var(--amber) 22%, transparent), transparent 70%),
    radial-gradient(600px 400px at 0% 100%, color-mix(in srgb, var(--green) 10%, transparent), transparent 70%);
}
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 em { font-style: normal; color: var(--amber); }
.ticker {
  font-family: var(--mono); font-size: .82rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px;
  padding: .55rem .8rem; display: inline-flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap;
}
.dot-live { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); animation: blink 1.4s steps(2, start) infinite; }
.stat-row { display: flex; flex-wrap: wrap; gap: 1.4rem; margin: 1.2rem 0 1.4rem; }
.stat b { display: block; font-size: 1.7rem; font-family: var(--mono); color: var(--ink); }
.stat span { font-size: .82rem; color: var(--muted); }
.hero-tower { width: 100%; max-width: 420px; justify-self: center; }

/* ---------- signal lamps ---------- */
.lamp {
  --c: var(--green);
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 14px var(--c), inset 0 -3px 6px rgba(0,0,0,.25);
  flex: none;
}
.lamp.g { --c: #3bf08c; }
.lamp.r { --c: #ff5465; }
.lamp.w { --c: #f7f9ff; }
.lamp.flash { animation: blink 0.8s steps(2, start) infinite; }
.lamp.alt { animation: altrg 0.8s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .12; box-shadow: none; } }
@keyframes altrg { 0% { background: #ff5465; box-shadow: 0 0 14px #ff5465; } 50% { background: #3bf08c; box-shadow: 0 0 14px #3bf08c; } }
@media (prefers-reduced-motion: reduce) {
  .lamp.flash, .dot-live { animation: none; background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); box-shadow: 0 0 0 2px var(--c); }
  .lamp.alt { animation: none; background: linear-gradient(90deg, #ff5465 50%, #3bf08c 50%); }
  * { scroll-behavior: auto !important; }
}

/* ---------- level select ---------- */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.mode-switch button {
  appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; padding: .55rem .95rem; cursor: pointer; min-height: 42px;
}
.mode-switch button[aria-pressed="true"] { background: var(--amber); color: var(--amber-ink); }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; margin-top: 1rem; }
.level-card {
  appearance: none; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--strip); color: var(--strip-ink); border: 0; border-radius: 6px; padding: .8rem .9rem .8rem 1.1rem;
  position: relative; box-shadow: var(--shadow); transition: transform .12s ease;
  border-left: 8px solid #c9933a;
  min-height: 118px;
}
.level-card:hover { transform: translateY(-2px); }
.level-card .num { font-family: var(--mono); font-size: .75rem; font-weight: 700; opacity: .7; }
.level-card .nm { display: block; font-weight: 900; font-size: 1.05rem; margin: .1rem 0 .2rem; }
.level-card .ap { font-family: var(--mono); font-size: .78rem; opacity: .8; }
.level-card .stars { position: absolute; right: .7rem; top: .6rem; letter-spacing: .1em; font-size: .95rem; }
.level-card .best { font-family: var(--mono); font-size: .75rem; margin-top: .35rem; display: block; opacity: .8; }
.level-card.endless { border-left-color: #b73a3a; background: #1f2b44; color: #f3e3b8; }
[data-theme="light"] .level-card.endless { background: #2a3550; }

/* ---------- game ---------- */
.game-shell {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start;
}
@media (max-width: 960px) { .game-shell { grid-template-columns: 1fr; } }
.radar-wrap { position: relative; background: #08101e; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow); }
#tower { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; touch-action: manipulation; cursor: crosshair; }
.hud {
  display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; font-family: var(--mono); font-size: .82rem;
  padding: .55rem .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem;
}
.hud b { color: var(--ink); }
.hud .sep { opacity: .35; }
.strikes { display: inline-flex; gap: 4px; vertical-align: middle; }
.strikes i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--red); display: inline-block; }
.strikes i.on { background: var(--red); box-shadow: 0 0 8px var(--red); }
.rwy-status { padding: .1rem .5rem; border-radius: 6px; font-weight: 700; }
.rwy-status.clear { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.rwy-status.busy { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); }
.hint {
  font-size: .92rem; padding: .55rem .8rem; border-radius: 10px; margin-top: .6rem; min-height: 2.6em;
  background: color-mix(in srgb, var(--amber) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--line));
}
.log { font-family: var(--mono); font-size: .78rem; color: var(--muted); max-height: 7.2em; overflow: hidden; margin-top: .5rem; }
.log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log .bad { color: var(--red); }
.log .good { color: var(--green); }

.signals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin-top: .6rem; }
.sig {
  appearance: none; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .5rem; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center;
}
.sig:hover { border-color: var(--amber); }
.sig:disabled { opacity: .5; cursor: not-allowed; }
.sig .key { font-family: var(--mono); font-size: .68rem; color: var(--muted); }
.sig .nm { font-size: .72rem; font-weight: 700; line-height: 1.15; }
.sig .mean { font-size: .72rem; color: var(--amber); line-height: 1.15; min-height: 1.1em; }
.pro .sig .mean { display: none; }

.side h3 { font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-family: var(--mono); margin: 0 0 .4rem; }
.strips { display: flex; flex-direction: column; gap: 4px; max-height: 520px; overflow-y: auto; padding-right: 2px; }
@media (max-width: 960px) { .strips { max-height: 260px; } }
.strip {
  appearance: none; font: inherit; text-align: left; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 1fr auto; gap: 0 .5rem; align-items: center;
  background: var(--strip); color: var(--strip-ink); border: 0; border-left: 7px solid #5b8bd6; border-radius: 4px;
  padding: .35rem .55rem; font-family: var(--mono); font-size: .78rem;
}
.strip.ground { border-left-color: #6a9e55; }
.strip.dep { border-left-color: #b073d6; }
.strip.warn { border-left-color: #e88a1a; }
.strip.crit { border-left-color: #e0303f; animation: pulse 1s ease-in-out infinite; }
.strip.sel { outline: 3px solid var(--amber); outline-offset: 1px; }
.strip .cs { font-weight: 800; font-size: .86rem; }
.strip .st { grid-column: 1 / -1; font-size: .7rem; opacity: .8; }
.strip .fuel { font-weight: 700; }
.fuelbar { grid-column: 1 / -1; height: 4px; background: rgba(0,0,0,.15); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.fuelbar i { display: block; height: 100%; background: #3a8f4f; }
.strip.warn .fuelbar i { background: #e88a1a; }
.strip.crit .fuelbar i { background: #e0303f; }
@keyframes pulse { 50% { filter: brightness(.88); } }
@media (prefers-reduced-motion: reduce) { .strip.crit { animation: none; } }

.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(5, 10, 20, .78); backdrop-filter: blur(3px); z-index: 5;
}
.overlay.show { display: flex; }
@media (max-width: 700px) { .overlay { position: fixed; z-index: 50; align-items: flex-start; padding-top: 4rem; overflow-y: auto; } .overlay .card { max-height: none; } }
.overlay .card { max-width: 520px; width: 100%; max-height: 100%; overflow-y: auto; }
.brief-fact { font-size: .9rem; border-left: 4px solid var(--amber); padding: .3rem .7rem; color: var(--muted); margin: .8rem 0; }
.game-controls { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }

/* results */
.result-card {
  background: var(--strip); color: var(--strip-ink); border-radius: 8px; padding: 1.1rem 1.2rem; border-left: 10px solid #c9933a;
  font-family: var(--mono); position: relative;
}
.result-card .rank { font-family: var(--font); font-weight: 900; font-size: 1.6rem; line-height: 1.1; margin: .2rem 0 .5rem; }
.result-card .big { font-size: 2.2rem; font-weight: 800; }
.result-card dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin: .6rem 0 0; font-size: .85rem; }
.result-card dd { margin: 0; font-weight: 700; text-align: right; }
.result-stars { font-size: 1.6rem; letter-spacing: .15em; }
.shared-banner { border: 2px dashed var(--amber); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; background: var(--panel); }

/* ---------- academy / sprint ---------- */
.chart { width: 100%; border-collapse: collapse; font-size: .95rem; }
.chart th, .chart td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.chart th { font-family: var(--mono); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.chart td:first-child { white-space: nowrap; }
.chart .lamp { width: 16px; height: 16px; vertical-align: middle; margin-right: .4rem; }
.table-scroll { overflow-x: auto; }
.sprint-stage {
  position: relative; border-radius: var(--radius); overflow: hidden; min-height: 260px; border: 1px solid var(--line);
  background: linear-gradient(#0c1730, #1b2c50 60%, #2c3a2a 60%, #24331f);
  display: grid; place-items: center; padding: 1.5rem 1rem; text-align: center; color: #e9effc;
}
.sprint-stage.ground { background: linear-gradient(#11203f, #2a3c63 45%, #3a4a36 45%, #2c3b27); }
.sprint-stage .bigLamp { width: 86px; height: 86px; }
.sprint-stage .ctx { font-family: var(--mono); letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; background: rgba(0,0,0,.4); padding: .3rem .6rem; border-radius: 6px; }
.sprint-timer { font-family: var(--mono); font-size: 1.4rem; font-weight: 800; }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem; margin-top: 1rem; }
.answers .btn { justify-content: flex-start; text-align: left; min-height: 52px; }
.btn.right { border-color: var(--green); background: color-mix(in srgb, var(--green) 20%, var(--panel)); }
.btn.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 20%, var(--panel)); }

/* ---------- quiz ---------- */
.quiz-box { max-width: 720px; margin: 0 auto; }
.progress { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: .6rem 0 1rem; }
.progress i { display: block; height: 100%; background: var(--amber); transition: width .3s ease; }
.explain { margin-top: 1rem; padding: .8rem 1rem; border-radius: 10px; background: var(--panel2); border-left: 4px solid var(--amber); }

/* ---------- story ---------- */
.stops { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.stop-card { border-top: 6px solid var(--amber); }
.stop-card .year { font-family: var(--mono); font-size: 2.4rem; font-weight: 800; line-height: 1; }
.stop-card ul { padding-left: 1.1rem; margin: .6rem 0 0; }
.timeline { position: relative; margin: 1.5rem 0; padding-left: 1.6rem; border-left: 3px solid var(--line); }
.tl-item { position: relative; margin-bottom: 1.2rem; }
.tl-item::before { content: ""; position: absolute; left: -2.05rem; top: .3rem; width: 14px; height: 14px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.tl-item time { font-family: var(--mono); font-weight: 800; color: var(--amber); font-size: .9rem; }
.tl-item p { margin: .2rem 0 0; }
.compare { display: grid; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 90px; gap: .6rem; align-items: center; font-family: var(--mono); font-size: .85rem; }
.bar { height: 20px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--amber); width: 0; transition: width 1s ease; }
.quote { font-size: 1.15rem; font-style: italic; border-left: 4px solid var(--amber); padding-left: 1rem; margin: 1rem 0; }
.quote cite { display: block; font-style: normal; font-size: .85rem; color: var(--muted); margin-top: .3rem; }

/* ---------- signal page ---------- */
.signal-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; }
.signal-picker button[aria-pressed="true"] { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber) inset; }
.beam-stage {
  position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line);
  background: linear-gradient(#0b1630, #233a66);
}
.beam-stage svg { width: 100%; height: 100%; display: block; }
input[type="text"], select {
  font: inherit; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; width: 100%; min-height: 44px;
}
label { font-weight: 700; display: block; margin-bottom: .3rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 3rem; margin-top: 2rem; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 700; z-index: 99;
  transition: opacity .2s ease, transform .2s ease; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.kbd { font-family: var(--mono); font-size: .8em; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 5px; padding: 0 .35em; background: var(--panel2); }
.tag { display: inline-block; font-family: var(--mono); font-size: .72rem; padding: .1rem .45rem; border-radius: 5px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
