:root {
  --bg: #0e1116;
  --card: #171c24;
  --border: #2a3242;
  --text: #dbe2ec;
  --muted: #8794a6;
  --accent: #4da3ff;
  --green: #3ecf7a;
  --amber: #ffc857;
  --red: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}

header {
  padding: 20px 24px 8px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.home-link { color: var(--text); text-decoration: none; }
.home-link:hover { color: var(--accent); }
.tagline { color: var(--muted); font-size: 13px; flex: 1; }
.beta-tag {
  background: var(--amber);
  color: #06121f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: 1px;
}
#about-link { color: var(--accent); font-size: 13px; text-decoration: none; }
#about-link:hover { text-decoration: underline; }

#intro h2 { margin: 0 0 10px; font-size: 18px; }
#intro p, #intro li { color: var(--text); font-size: 14.5px; }
#intro ul { padding-left: 20px; margin: 10px 0 14px; }
#intro li { margin: 4px 0; }

#feedback-box summary { cursor: pointer; color: var(--muted); font-size: 14px; }
#feedback-box summary:hover { color: var(--text); }
.fb-hint { color: var(--muted); font-size: 13px; margin: 10px 0 8px; }
#fb-message { width: 100%; resize: vertical; background: #0b0e13; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit; }
.fb-row { display: flex; gap: 10px; margin-top: 8px; }
.fb-row input { flex: 1; }
#fb-status { color: var(--green); font-size: 13px; }
input[type='email'] {
  background: #0b0e13;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}

main { max-width: 720px; margin: 0 auto; padding: 12px 16px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.hidden { display: none !important; }

.step-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
#quota { float: right; text-transform: none; letter-spacing: 0.3px; }
#quota.low { color: var(--amber); }

/* Deliberate rows (scenario / aircraft+start / toggles) — one wrapping flex
   row broke at arbitrary points once the type select joined the party. */
#setup { display: flex; flex-direction: column; gap: 10px; }
.setup-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#scenario-select { flex: 1; min-width: 0; }
#setup label { color: var(--muted); font-size: 14px; }
/* Start reads as the row's action: fields left, button right. */
#start-btn { margin-left: auto; }
select, input[type='text'] {
  background: #0b0e13;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
button {
  background: var(--accent);
  color: #06121f;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: #22303f; color: var(--text); border: 1px solid var(--border); }
#complete button { margin-right: 8px; margin-top: 4px; }
.toggle { display: flex; align-items: center; gap: 6px; }

#mic-btn {
  width: 100%;
  padding: 22px;
  font-size: 16px;
  letter-spacing: 2px;
  background: #22303f;
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#mic-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
#mic-btn.setup {
  border-style: dashed;
  color: var(--accent);
}
/* Inattention nudge — the mic (or text box) glows only after a delay if the
   pilot hasn't keyed up on their turn, and stops the instant they do. It's an
   "are you still there?" prompt, not an immediate instruction. */
#mic-btn.your-turn:not(.active) { animation: turn-pulse 1.3s ease-in-out infinite; }
#text-input.your-turn { animation: turn-pulse 1.3s ease-in-out infinite; }
@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 87, 0.2); border-color: var(--amber); }
  50% { box-shadow: 0 0 20px 2px rgba(255, 200, 87, 0.7); border-color: var(--amber); }
}

/* Step checklist. Completed steps collapse to a checked one-liner, the current
   step is the only expanded one, upcoming steps sit below in muted text. This
   replaced a per-advance flash animation: on a 14-step scenario that fired 14
   times and read as repeated motion, where position in a list conveys the same
   "you moved" information with no animation at all. */
#stepper { list-style: none; margin: 0 0 2px; padding: 0; }
#stepper li { font-size: 14px; line-height: 1.45; }

#stepper .sp-done {
  color: var(--muted);
  padding: 3px 0 3px 22px;
  position: relative;
}
#stepper .sp-done::before {
  content: '✓';
  position: absolute;
  left: 2px;
  color: var(--green);
}

#stepper .sp-todo { color: #5c6675; padding: 3px 0 3px 22px; }
#stepper .sp-muted { font-style: italic; }

#stepper .sp-current {
  margin: 10px 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--accent);
}
#stepper .sp-current .sp-head {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
/* The one bit of motion kept: the newly-opened step fades up once. Cheap, and it
   only ever plays on the step you're about to act on. */
#stepper .sp-current > #step-body { animation: step-open 0.28s ease-out both; }
@keyframes step-open {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #mic-btn.your-turn:not(.active), #text-input.your-turn { animation: none; box-shadow: 0 0 0 2px rgba(255, 200, 87, 0.75); border-color: var(--amber); }
  #stepper .sp-current > #step-body { animation: none; }
}

#hint-box { margin: 4px 0 10px; font-size: 14px; }
#hint-box summary { color: var(--muted); cursor: pointer; user-select: none; }
#hint-box p { color: var(--muted); margin: 6px 0 0 14px; }

.transcript { min-height: 22px; color: var(--muted); font-style: italic; margin-top: 10px; }
.mic-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 6px; }
.mic-hint kbd {
  background: #0b0e13;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}

#text-controls { display: flex; gap: 10px; }
#text-input { flex: 1; }

#comm-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.comm { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13.5px; }
.comm.you { color: var(--text); }
.comm.atc { color: var(--accent); }
.comm.silence { color: var(--muted); font-style: italic; }
/* Ear training: mask every transmission (ATC, TFC and YOU) until tapped. Blur
   (not display:none) keeps line lengths honest and makes "there's something
   here" obvious. The live interim transcript blurs too: still proves the mic
   is picking you up, without live captioning. */
body.ears #comm-log .maskable {
  cursor: pointer;
  /* No selection/callout during the press-and-hold peek (also while revealed,
     so a hold can't start a text selection mid-peek). */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Transition needs interpolable endpoints — blur(0), never an unset filter
   (blur(5px)→none leaves Chrome stuck at the start value). */
body.ears #comm-log .maskable .masked-text {
  filter: blur(0);
  transition: filter 0.25s ease;
}
body.ears #comm-log .maskable:not(.revealed) .masked-text,
body.ears #transcript {
  filter: blur(5px);
}
body.ears #comm-log .maskable::after {
  content: 'tap to peek';
  color: var(--muted);
  font-size: 10.5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
}
/* State-labeled toggle (password-eye research: unlabeled reveal toggles get
   misread) — revealed lines say what the next tap does. */
body.ears #comm-log .maskable.revealed::after { content: 'hide'; }
.comm.pending { color: var(--accent); animation: blink 1s ease-in-out infinite; letter-spacing: 3px; }
#debrief-pending { color: var(--muted); font-style: italic; }
/* Typing-indicator dots: staggered bounce in the accent color — the uniform
   opacity blink was too easy to miss. */
#debrief-pending .dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
#debrief-pending .dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
#debrief-pending .dots i:nth-child(2) { animation-delay: 0.15s; }
#debrief-pending .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

#script-panel {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.script-row { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.script-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.script-tag.say { background: var(--green); color: #06121f; }
.script-tag.expect { background: var(--accent); color: #06121f; }
.script-row span:last-child { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; }

#assessment { font-weight: 600; margin-bottom: 8px; }
#elements, #debrief-well, #debrief-work { list-style: none; padding: 0; margin: 0 0 8px; }
#elements li, #debrief-well li, #debrief-work li { padding: 3px 0; font-size: 14px; }
#elements li.ok, #debrief-well li { color: var(--green); }
#elements li.missing, #elements li.wrong { color: var(--red); }
#debrief-work li { color: var(--text); }
#elements li em { color: var(--muted); }

#debrief { margin-top: 14px; }
#debrief-overall { font-weight: 600; margin-bottom: 4px; }
#debrief-summary { margin: 0 0 8px; color: var(--muted); }
#tip { color: var(--amber); font-size: 14px; margin: 0; }

#diagram { margin: 12px 0 4px; }
#diagram svg { width: 100%; max-width: 440px; display: block; margin: 0 auto; }
#diagram .pave { fill: #232d3a; stroke: var(--border); stroke-width: 1; }
#diagram .rwy { fill: #39434f; }
#diagram .centerline { stroke: #8b96a5; stroke-width: 1.5; stroke-dasharray: 10 8; }
#diagram .holdline { stroke: var(--amber); stroke-width: 3; stroke-dasharray: 4 3; }
#diagram .lbl { fill: var(--muted); font-size: 13px; text-anchor: middle; font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; }
#diagram .lbl.small { font-size: 10px; }
#diagram .lbl.vert { writing-mode: vertical-rl; }
#diagram .lbl.tiny { font-size: 8px; }
#diagram .rwynum { fill: #c9d3de; font-weight: 700; }
#diagram .circuit { fill: none; stroke: #3d4a5c; stroke-width: 2; }
#diagram .leg { stroke: var(--accent); stroke-width: 2; opacity: 0.65; }
#diagram .arrow { fill: none; stroke: var(--accent); stroke-width: 1.5; }
#diagram .inbound-track { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.7; }
#diagram .pos-dot .core { fill: var(--amber); }
#diagram .pos-dot .pulse {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2;
  animation: pulse 1.6s ease-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes pulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

#error-banner {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 90%;
}

select { max-width: 100%; }

/* Touch devices: no keyboard, so no spacebar hint; block long-press callout on the PTT button */
@media (pointer: coarse) {
  .mic-hint { display: none; }
  #mic-btn { -webkit-touch-callout: none; }
}

@media (max-width: 640px) {
  header { flex-wrap: wrap; padding: 14px 16px 4px; row-gap: 2px; }
  .tagline { flex-basis: 100%; order: 3; }
  main { padding: 8px 10px 60px; }
  .card { padding: 14px; margin-bottom: 10px; }

  /* Stack the setup rows; full-width controls are easier to hit */
  .setup-row { flex-direction: column; align-items: stretch; }
  #setup select, #setup input[type='text'], #setup button { width: 100%; }
  #setup .toggle { justify-content: flex-start; }

  /* 16px inputs stop iOS Safari from zooming the page on focus */
  select, input[type='text'], input[type='email'], textarea { font-size: 16px; }

  #mic-btn { padding: 26px 12px; font-size: 15px; letter-spacing: 1px; }
  .fb-row { flex-direction: column; }
  #quota { float: none; display: block; margin-top: 2px; }
  #comm-log { max-height: 160px; }
}

/* ---------------------------------------------------------------- footer */
footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
  padding: 18px 8px 8px;
  color: var(--muted);
  font-size: 12.5px;
}
footer a { color: var(--muted); text-decoration: underline; }
footer a:hover { color: var(--text); }

/* ------------------------------------------------------------ legal pages */
.legal { max-width: 760px; }
.legal h2 { margin-bottom: 2px; }
.legal h3 { margin: 22px 0 6px; font-size: 15px; }
.legal p, .legal li { line-height: 1.6; }
.legal ul { margin: 6px 0 0 18px; }
.legal li { margin-bottom: 6px; }
.legal .muted { color: var(--muted); font-size: 13px; }
/* The safety disclaimer must not read like the rest of the boilerplate. */
.legal .callout {
  border: 1px solid var(--red);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 18px 0;
  background: rgba(255, 92, 92, 0.06);
}
.legal .callout h3 { margin-top: 4px; color: var(--red); }

/* Scenario citations under the briefing. Matches #feedback-box's summary treatment
   so it reads as the same kind of "open if you care" affordance. */
.sources { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.sources summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.sources ul { margin: 10px 0 0; padding-left: 18px; }
.sources li { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-bottom: 7px; }
.sources-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 10px 0 0; font-style: italic; }
