:root {
  --bg: #0a0c0b;
  --forest: #10231c;
  --phosphor: #a5ff78;
  --phosphor-dim: #6cb853;
  --amber: #ffb454;
  --amber-dim: #c4842e;
  --warn: #ff4d4d;
  --paper: #d7ead0;
  --mute: #8aa392;
  --inset: #07110d;
  --display: "Courier New", Courier, ui-monospace, monospace;
  --ui: system-ui, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--paper);
  font-family: var(--ui);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(165, 255, 120, 0.08), transparent 50%),
    radial-gradient(80% 50% at 100% 100%, rgba(255, 180, 84, 0.06), transparent 46%),
    var(--bg);
}

body.reduce-motion .scanlines,
body.reduce-motion .static-layer {
  animation: none !important;
  opacity: 0.04;
}

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--phosphor);
  color: #041208;
  font-weight: 700;
}
.skip:focus { top: 12px; }

.static-layer,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.static-layer { opacity: 0.04; mix-blend-mode: screen; }
.scanlines {
  opacity: 0.07;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.35) 0 1px,
    transparent 1px 3px
  );
}

.app { min-height: 100dvh; position: relative; z-index: 1; }

.screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}

.panel {
  width: min(720px, 100%);
  background: linear-gradient(180deg, rgba(16, 35, 28, 0.92), rgba(10, 12, 11, 0.94));
  border: 1px solid rgba(165, 255, 120, 0.18);
  border-radius: 22px;
  padding: 28px 24px 26px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);
}

.panel-narrow { width: min(560px, 100%); }

.brand {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--amber);
}

.back { margin: 8px 0 0; }
.back a,
.text-link {
  color: var(--mute);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.back a:hover,
.text-link:hover { color: var(--phosphor); }

.kicker {
  margin: 22px 0 8px;
  font-family: var(--display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--phosphor-dim);
}
.kicker.warn { color: var(--warn); }
.kicker.ok { color: var(--phosphor); }

h1, h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phosphor);
  text-shadow: 0 0 18px rgba(165, 255, 120, 0.25);
}

h1 { font-size: clamp(1.8rem, 6vw, 3rem); line-height: 1.05; }
h2 { font-size: clamp(1.3rem, 4vw, 2rem); }

.tagline {
  margin: 10px 0 0;
  color: var(--amber);
  font-size: 1.05rem;
}

.intro {
  margin: 16px 0 0;
  color: var(--paper);
  line-height: 1.55;
  font-size: 0.98rem;
}

.section-label {
  margin: 28px 0 10px;
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

.control-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--mute);
  line-height: 1.5;
}
.control-list li + li { margin-top: 0.4rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.04em;
}

.sr-num {
  font-family: var(--display);
  font-size: 0.75rem;
  color: var(--mute);
  margin-right: 4px;
}

.btn-primary {
  background: var(--phosphor);
  color: #07140c;
  box-shadow: 0 0 24px rgba(165, 255, 120, 0.2);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: rgba(165, 255, 120, 0.28);
}
.btn-ghost:hover { border-color: var(--phosphor); color: var(--phosphor); }
.btn-ghost[aria-pressed="true"] {
  background: rgba(165, 255, 120, 0.12);
  border-color: var(--phosphor);
  color: var(--phosphor);
}

.btn-small { min-height: 42px; padding: 0 14px; font-size: 0.92rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

#btnTuneIn {
  margin-top: 22px;
  width: 100%;
}
#btnContinue { margin-top: 10px; width: 100%; }

.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
.settings .btn { margin-top: 0; }

.voice-label {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  color: var(--mute);
  font-size: 0.88rem;
}
.voice-label select {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(165, 255, 120, 0.25);
  background: var(--inset);
  color: var(--paper);
  font: inherit;
  padding: 0 10px;
}

.chapter-grid {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.chapter-card {
  text-align: left;
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(165, 255, 120, 0.2);
  background: rgba(7, 17, 13, 0.7);
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.chapter-card:hover:not(:disabled) { border-color: var(--phosphor); }
.chapter-card:disabled { opacity: 0.5; cursor: not-allowed; }
.chapter-card .ch-kicker {
  margin: 0;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}
.chapter-card h2 {
  margin: 6px 0 4px;
  font-size: 1.15rem;
  text-shadow: none;
}
.chapter-card p { margin: 0; color: var(--mute); font-size: 0.92rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.actions .btn { margin-top: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 0;
}
.stats div {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(165, 255, 120, 0.16);
  border-radius: 12px;
  background: rgba(7, 17, 13, 0.55);
}
.stats dt {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}
.stats dd {
  margin: 6px 0 0;
  font-size: 1.35rem;
  color: var(--phosphor);
  font-family: var(--display);
}

.topics {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--mute);
  line-height: 1.55;
}

/* Play layout */
.screen-play {
  display: block;
  padding: calc(12px + var(--safe-top)) 12px calc(16px + var(--safe-bottom));
}

.play-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto 12px;
}
.play-chapter, .play-progress {
  margin: 0;
  font-family: var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--mute);
}
.play-progress { margin-left: auto; }

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.8fr);
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

.radio { position: relative; }
.antenna {
  width: 8px;
  height: 28px;
  margin: 0 auto 4px;
  background: linear-gradient(#9aa7a0, #3a4540);
  border-radius: 4px;
  box-shadow: 0 -10px 0 2px #6d7872;
}

.radio-body {
  background:
    linear-gradient(180deg, #1b3328 0%, #10231c 42%, #0c1813 100%);
  border: 2px solid #2c4a3c;
  border-radius: 28px;
  padding: 16px;
  box-shadow:
    inset 0 1px 0 rgba(165, 255, 120, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.35);
}

.radio-chrome {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--phosphor);
  box-shadow: 0 0 10px var(--phosphor);
}
.led.is-warn {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}

.chrome-readout {
  margin: 0;
  font-family: var(--display);
  color: var(--amber);
  letter-spacing: 0.08em;
  font-size: 0.86rem;
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}
.signal-bars span {
  width: 4px;
  background: var(--phosphor-dim);
  border-radius: 1px;
  opacity: 0.28;
}
.signal-bars span.on { opacity: 1; background: var(--phosphor); }

.battery {
  display: flex;
  gap: 4px;
}
.battery span {
  width: 10px;
  height: 14px;
  border: 1px solid var(--amber-dim);
  border-radius: 2px;
}
.battery span.on { background: var(--amber); border-color: var(--amber); }

.crt {
  position: relative;
  min-height: 168px;
  padding: 16px;
  border-radius: 8px;
  background: #050a07;
  color: var(--phosphor);
  font-family: var(--display);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8), 0 0 0 2px #14261c;
  overflow: hidden;
}
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(165, 255, 120, 0.06), transparent 30%, rgba(0, 0, 0, 0.15));
}

.crt-meta, .crt-speaker, .crt-message, .crt-warn { position: relative; z-index: 1; }
.crt-meta {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--phosphor-dim);
  text-transform: uppercase;
}
.crt-speaker {
  margin: 8px 0 0;
  color: var(--amber);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.crt-message {
  margin: 12px 0 0;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  line-height: 1.45;
  overflow-wrap: break-word;
}
.blank {
  display: inline-block;
  min-width: 4.5ch;
  border-bottom: 2px solid var(--amber);
  color: var(--amber);
  text-align: center;
  margin: 0 2px;
  white-space: nowrap;
}
.crt-warn {
  margin: 12px 0 0;
  color: var(--warn);
  letter-spacing: 0.16em;
  font-size: 0.78rem;
}

.radio.is-decoded .crt { box-shadow: inset 0 0 40px rgba(165, 255, 120, 0.12), 0 0 0 2px #1d3d2b; }

.meter-wrap { margin: 14px 0 12px; }
.meter-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--display);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 6px;
}
.meter {
  height: 10px;
  border-radius: 999px;
  background: #07110d;
  border: 1px solid rgba(165, 255, 120, 0.2);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--phosphor), var(--amber) 70%, var(--warn));
}

.opt-grid {
  display: grid;
  gap: 10px;
}
.opt-grid[data-count="3"] { grid-template-columns: 1fr; }
.opt-grid[data-count="4"] { grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .opt-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .opt-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
}

.opt {
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(165, 255, 120, 0.28);
  background: rgba(5, 10, 7, 0.7);
  color: var(--paper);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  overflow-wrap: anywhere;
}
.opt[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255, 180, 84, 0.08);
}
.opt.is-correct {
  border-color: var(--phosphor);
  color: var(--phosphor);
}
.opt.is-wrong {
  border-color: var(--warn);
  color: var(--warn);
}

.order-ui { display: grid; gap: 10px; }
.order-built, .order-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 54px;
  padding: 8px;
  border-radius: 12px;
  border: 1px dashed rgba(165, 255, 120, 0.28);
}
.order-built { border-style: solid; background: rgba(5, 10, 7, 0.55); }
.tile {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 180, 84, 0.45);
  background: #13241c;
  color: var(--amber);
  font: inherit;
  cursor: pointer;
}
.tile:hover { border-color: var(--phosphor); color: var(--phosphor); }

.feedback, .hint-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  line-height: 1.45;
  font-size: 0.95rem;
}
.feedback.is-ok {
  background: rgba(165, 255, 120, 0.1);
  border: 1px solid rgba(165, 255, 120, 0.35);
  color: var(--phosphor);
}
.feedback.is-bad {
  background: rgba(255, 77, 77, 0.08);
  border: 1px solid rgba(255, 77, 77, 0.35);
  color: #ffb3b3;
}
.hint-box {
  background: rgba(255, 180, 84, 0.08);
  border: 1px solid rgba(255, 180, 84, 0.3);
  color: var(--amber);
}

.radio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.radio-controls .btn { margin-top: 0; }

.speech-fallback {
  margin: 10px 0 0;
  color: var(--mute);
  font-size: 0.85rem;
}

.log {
  background: rgba(16, 35, 28, 0.7);
  border: 1px solid rgba(165, 255, 120, 0.16);
  border-radius: 18px;
  padding: 8px 12px 12px;
  max-height: calc(100dvh - 120px);
  overflow: auto;
}
.log summary {
  cursor: pointer;
  font-family: var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--amber);
  padding: 8px 0;
}
.log ol {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--mute);
  font-size: 0.9rem;
  line-height: 1.45;
}
.log li + li { margin-top: 8px; }
.log strong { color: var(--paper); font-weight: 650; }

@media (max-width: 860px) {
  .play-grid { grid-template-columns: 1fr; }
  .log { max-height: none; }
}

@media (max-width: 640px) {
  .panel { padding: 22px 16px; }
  .radio-chrome {
    grid-template-columns: auto 1fr;
  }
  .signal-bars, .battery { justify-self: end; }
  .chrome-readout { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .scanlines { animation: none; opacity: 0.05; }
}

:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}
