:root {
  --bg: #0b0e13;
  --panel: #12161d;
  --panel-2: #171c25;
  --line: #2a3140;
  --amber: #ffb347;
  --amber-dim: #6b5225;
  --green: #3ddc84;
  --green-dim: #1c4a30;
  --red: #ff5a5a;
  --red-dim: #5a1f1f;
  --ink: #dfe6ef;
  --ink-dim: #8592a6;
  --njt: #7b52c8;
  --lirr: #2f6fd6;
  --amtk: #b23b3b;
  --font: -apple-system, BlinkMacSystemFont, "SF Mono", "Segoe UI", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
/* The blanket rule above reaches the name field too, and iOS Safari has been
 * known to refuse to place a caret in an input it cannot select text in. */
input, textarea { user-select: text; -webkit-user-select: text; }

/* The UA stylesheet hides [hidden] with `display: none`, but any author rule
 * setting `display` outranks it — and several here do. That quietly defeated
 * the attribute: .big-btn's `display: block` left RESUME TRICK on screen for
 * players who had nothing to resume, however faithfully the script set
 * `hidden`. Restore the attribute's meaning once, for everything. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.screen {
  display: none;
  height: 100%;
  width: 100%;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ---------- Title screen ---------- */
#screen-title {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% -10%, #1a2230 0%, var(--bg) 60%);
  position: relative;
  /* The card is centred until it stops fitting — on a short screen, a phone
   * held sideways especially, "safe" drops the centring rather than cutting
   * the top off, and the sign-in card can be scrolled to. Browsers that do
   * not know "safe" ignore this line and keep the plain centring above. */
  overflow-y: auto;
  justify-content: safe center;
}
.title-card {
  text-align: center;
  padding: 24px 32px;
  max-width: 520px;
}
.board-plate {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--bg);
  background: var(--amber);
  padding: 3px 10px;
  border-radius: 3px;
  font-weight: 700;
  margin-bottom: 18px;
}
.title-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 4px;
  line-height: 1.3;
  font-weight: 700;
}
.title-card h1 span { color: var(--amber); }
.tagline { color: var(--ink-dim); letter-spacing: 2px; font-size: 13px; margin: 6px 0 26px; }

.dispatcher-name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-dim);
  margin-bottom: 18px;
}
.dispatcher-name-field input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--amber);
  font-family: var(--font);
  font-size: 18px;
  letter-spacing: 1px;
  padding: 10px 12px;
  border-radius: 6px;
  text-align: center;
  outline: none;
}
.dispatcher-name-field input:focus { border-color: var(--amber); }
/* Only appears when a leaderboard is configured — the name is published there,
 * and that is worth saying next to the box rather than only in the policy. */
.name-note {
  margin: -12px 0 16px;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.5px;
  color: #46516a;
}

.career-stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.career-stats .stat { font-size: 11px; color: var(--ink-dim); letter-spacing: 1px; }
.career-stats .stat b { display: block; font-size: 20px; color: var(--ink); font-weight: 700; }

.big-btn {
  display: block;
  width: 100%;
  background: var(--amber);
  color: #241a08;
  border: none;
  font-family: var(--font);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
}
.big-btn:active { transform: scale(0.98); }
.big-btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.title-buttons { display: flex; flex-direction: column; }

a.link-btn { display: inline-block; }
.link-btn {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 1px;
  text-decoration: underline;
  padding: 10px;
  cursor: pointer;
}

.title-footer {
  position: absolute;
  bottom: 14px;
  width: 100%;
  text-align: center;
  color: #3a4457;
  font-size: 11px;
  letter-spacing: 1px;
}
/* The dedication is the point of the footer; the legal links sit under it,
 * quieter still, present because they have to be reachable from the game. */
.title-footer .legal-links {
  margin-top: 6px;
  font-size: 10px;
  color: #2f3949;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
}
.title-footer .legal-links a {
  color: #3a4457;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 4px 2px;
}
.title-footer .legal-links a:hover,
.title-footer .legal-links a:focus-visible { color: var(--ink-dim); border-bottom-color: currentColor; }

/* ---------- Generic narrow panel screens ---------- */
.panel-narrow {
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 24px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}
.panel-narrow h2 {
  letter-spacing: 3px;
  font-size: 18px;
  text-align: center;
  color: var(--amber);
  margin-bottom: 20px;
}

.shift-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.shift-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.shift-card:active { border-color: var(--amber); }
.shift-card.locked { opacity: 0.45; cursor: default; }
.shift-card.current { border-color: var(--amber); }
.shift-card.current .best { color: var(--amber); }
.roster-note {
  color: #46516a;
  font-size: 11px;
  line-height: 1.6;
  margin: 4px 0 16px;
}
.help-territory-head { color: var(--amber) !important; }
.shift-card.locked:active { border-color: var(--line); }
.shift-card .best b.lock { color: var(--ink-dim); font-size: 16px; }
.shift-card .info { flex: 1; }
.shift-card .name { font-weight: 700; letter-spacing: 1px; margin-bottom: 4px; }
.shift-card .desc { color: var(--ink-dim); font-size: 12px; line-height: 1.5; }
.shift-card .best { text-align: right; font-size: 11px; color: var(--ink-dim); white-space: nowrap; }
.shift-card .best b { display: block; font-size: 18px; color: var(--green); }

.help-panel .help-body { color: var(--ink-dim); font-size: 13px; line-height: 1.6; }
.help-lede {
  background: var(--panel);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 0 0 4px;
}
.help-lede b { color: var(--amber); }
.help-panel h3 { color: var(--ink); margin: 18px 0 6px; font-size: 14px; letter-spacing: 1px; }
.help-panel h3:first-child { margin-top: 0; }
.lamp-sample { padding: 1px 8px; border-radius: 10px; font-weight: 700; font-size: 11px; }
.lamp-sample.free { background: var(--green-dim); color: var(--green); }
.lamp-sample.busy { background: var(--red-dim); color: var(--red); }
.foreign-sample { opacity: 0.42; filter: saturate(0.4); font-weight: 700; }

/* ---------- Game HUD ---------- */
#screen-game { background: var(--bg); }
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
  gap: 10px;
}
.hud-left { min-width: 140px; }
.hud-shift { font-size: 12px; letter-spacing: 2px; color: var(--ink-dim); }
.hud-clock { font-size: 20px; font-weight: 700; color: var(--amber); letter-spacing: 1px; }
.hud-mid { display: flex; gap: 22px; }
.hud-stat { text-align: center; }
.hud-stat span { display: block; font-size: 18px; font-weight: 700; }
.hud-stat label { font-size: 9px; color: var(--ink-dim); letter-spacing: 1px; }
.hud-right { display: flex; gap: 6px; align-items: center; }
.hud-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 11px;
  border-radius: 6px;
  cursor: pointer;
}
.hud-btn.active { background: var(--amber); color: #241a08; border-color: var(--amber); }
.hud-btn.muted { color: var(--ink-dim); }
.hud-btn:active { transform: scale(0.96); }
/* The way off the board. It was a bare ⏹ next to the pause glyph, which on a
 * tablet has no hover text and nothing to say what it does — so the only exit
 * from a trick was invisible. Lettered, and set apart from the transport
 * controls it used to hide among. */
.hud-btn.quit {
  border-color: #5a3a3a;
  color: var(--ink-dim);
  letter-spacing: 1px;
  margin-left: 6px;
}
.hud-btn.quit.arming { border-color: var(--red); color: var(--red); }

/* ---------- Incident alerts ---------- */
.alerts {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(255, 90, 90, 0.09);
  border-bottom: 1px solid var(--red-dim);
}
.alerts[hidden] { display: none; }
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--red);
}
.alert b { color: var(--ink); }
/* A train that can't hold at the signal outranks anything already broken. */
.alert.urgent { color: #ffd166; font-weight: 700; }
.alert.urgent .alert-dot { background: #ffd166; animation-duration: 0.45s; }
.alert-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  animation: blockFlash 0.8s infinite;
}

/* ---------- Board ---------- */
/* The board is a panorama across the full width, with the arriving lists as a
 * strip beneath it. They used to be fixed columns down either side, which cost
 * the diagram 360px of the only dimension it was short of. */
#board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 8px;
  overflow: hidden;
  min-height: 0;
}
#yard { flex: 1; min-height: 0; }

.portals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
  height: 104px;
}
.portal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  min-width: 0;
}
.portal-head {
  flex-shrink: 0;
  width: 132px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}
.portal-east .portal-head { order: 2; border-right: none; border-left: 1px solid var(--line); padding: 0 0 0 10px; }
.portal-east .queue { order: 1; }
.portal-title {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-dim);
  line-height: 1.5;
}
.portal-title small { color: #4d586c; }

.queue-label { font-size: 9px; letter-spacing: 1px; color: #46516a; margin-top: 6px; }

/* Chips run along the strip now, oldest first, and scroll sideways when a rush
 * stacks them up. */
.queue {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
}
.queue .chips, .queue .ghosts { display: flex; flex-direction: row; gap: 6px; }
.queue .ghosts:empty { display: none; }
.train-chip { flex: 0 0 138px; }

.train-chip {
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.train-chip .mark {
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.train-chip .due {
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--ink-dim);
  flex-shrink: 0;
}
.train-chip .line, .berth-chip .line {
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.train-chip .line { margin-top: 1px; }
.train-chip .dest {
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--amber);
  margin: 1px 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.train-chip.nonrev { opacity: 0.82; border-style: dashed; }
.train-chip.nonrev .mark { color: var(--ink-dim); }

/* Another desk's train: visible, because it is competing for your throats,
   but plainly not yours to touch. */
.train-chip.foreign {
  opacity: 0.42;
  cursor: default;
  filter: saturate(0.4);
}
.train-chip.foreign .due { color: var(--ink-dim); }
.train-chip.special, .berth-chip.special { box-shadow: 0 0 0 1px var(--amber) inset; }
.train-chip.special .mark::before, .berth-chip.special .mark::before { content: "★ "; color: var(--amber); }
/* An extra: not on the timetable, and much too long for the plant. */
.train-chip.extra {
  box-shadow: 0 0 0 2px #ffd166 inset;
  background: linear-gradient(180deg, rgba(255,209,102,0.16), rgba(255,209,102,0.05));
  opacity: 1;
}
.train-chip.extra { border-style: solid; }
.train-chip.extra .mark { color: var(--ink); }
.train-chip.extra .mark::before { content: "◆ "; color: #ffd166; }
.train-chip.extra .due { color: #241a08; background: #ffd166; padding: 1px 5px; border-radius: 2px; font-weight: 700; }
.train-chip .patience-bar {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}
.train-chip .patience-fill { height: 100%; background: var(--green); transition: width 0.2s linear, background 0.2s; }
.train-chip.late { animation: pulseLate 1s infinite; }
@keyframes pulseLate { 0%,100% { border-color: var(--red); } 50% { border-color: transparent; } }
.train-chip.selectable-src { cursor: pointer; }
.train-chip.selected { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }
/* Already on its way out; nothing to tap. */
.train-chip.ghost { opacity: 0.55; cursor: default; }

.type-NJT { background: rgba(123,82,200,0.22); border-left: 4px solid var(--njt); }
.type-LIRR { background: rgba(47,111,214,0.22); border-left: 4px solid var(--lirr); }
.type-AMTK { background: rgba(178,59,59,0.22); border-left: 4px solid var(--amtk); }

/* ---------- Yard: NX-panel schematic ---------- */
#yard {
  min-height: 0;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.schematic { width: 100%; height: 100%; display: block; }

.lead-line { stroke: #2a3140; stroke-width: 2; fill: none; transition: stroke 0.15s, stroke-width 0.15s; }
.lead-line.active { stroke: var(--amber); stroke-width: 2.5; }

.tick { stroke: #a53d3d; stroke-width: 1.5; opacity: 0.5; pointer-events: none; }

.lead-line.blocked { stroke: var(--red); stroke-width: 2.5; stroke-dasharray: 7 5; animation: blockFlash 1.1s infinite; }
@keyframes blockFlash { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.track-line { stroke: #3a4457; stroke-width: 3; fill: none; transition: stroke 0.2s; }
.track-line.blocked { stroke: var(--red); stroke-dasharray: 8 6; }
.track-line.type-DEAD { stroke: var(--red); animation: blockFlash 1.1s infinite; }
.track-tag-label {
  fill: #46516a; font-family: var(--font); font-size: 16px;
  letter-spacing: 1px; pointer-events: none;
}
.track-line.type-NJT { stroke: var(--njt); }
.track-line.type-LIRR { stroke: var(--lirr); }
.track-line.type-AMTK { stroke: var(--amtk); }
.track-line.selectable { stroke: var(--amber); animation: railPulse 1.1s infinite; }
@keyframes railPulse { 0%,100% { stroke-width: 3; opacity: 1; } 50% { stroke-width: 6; opacity: 0.6; } }
/* A track the selected train could use, whose throat is busy right now: yours,
 * but not yet. Still answers a tap, with the reason. */
.track-line.held { stroke: var(--amber-dim); stroke-dasharray: 10 8; }

.track-hit { cursor: default; }
.track-hit.selectable { cursor: pointer; }
.track-hit.held { cursor: not-allowed; }

.track-num-label { fill: var(--ink-dim); font-family: var(--font); font-size: 31px; font-weight: 700; pointer-events: none; }

.lamp-dot { fill: var(--green); stroke: #06210f; stroke-width: 2; transition: fill 0.15s; pointer-events: none; }
.lamp-dot.busy { fill: var(--red); }
.lamp-dot.blocked { fill: var(--red); animation: blockFlash 0.8s infinite; }
.lamp-dot.flash { animation: lampFlash 0.35s ease-in-out 2; }
@keyframes lampFlash { 0%,100% { opacity: 1; } 50% { opacity: 0.15; } }
.lamp-label { fill: var(--ink-dim); font-family: var(--font); font-size: 23px; font-weight: 700; letter-spacing: 1px; pointer-events: none; }
.lamp-sublabel { fill: #4d586c; font-family: var(--font); font-size: 17px; letter-spacing: 0.5px; pointer-events: none; }

/* Track-circuit occupancy: the red block the real overview board paints
   under a train as it rolls over each circuit. */
.occ {
  stroke: #e03131;
  stroke-width: 13;
  stroke-linecap: butt;
  pointer-events: none;
  opacity: 0.95;
}
.occ.dead { stroke: #ff8080; animation: blockFlash 0.7s infinite; }
.occ.extra { stroke: #ffd166; stroke-width: 15; }
.occ.foreign { stroke: #6d7688; }
/* Out on the corridor and not yet yours to route: present, clearly coming, and
 * visibly not part of the work in front of you. */
.occ.approaching { opacity: 0.5; }
.tag.approaching { opacity: 0.6; }
/* The train in hand, picked out on the panel as well as in the list. */
.occ.selected { stroke: #ffffff; }
.tag.selected .tag-rect { stroke: #ffffff; stroke-width: 3; }

/* The approach: same drawing language as the plant, a shade quieter, so the
 * eye still lands on the tracks you actually work. */
.approach-line {
  stroke: #38445a;
  stroke-width: 4;
  stroke-linecap: round;
}
.approach-label {
  fill: #46516a;
  font-family: var(--font);
  font-size: 23px;
  letter-spacing: 2px;
}
/* Control points out on the corridor: a stile across the tracks and its name,
 * the way the real board letters the railroad beyond the plant it works. */
.approach-cp { stroke: #2f3a4d; stroke-width: 3; }
.approach-cp-label {
  fill: #55617a;
  font-family: var(--font);
  font-size: 20px;
  letter-spacing: 1.5px;
}

.tag { pointer-events: none; }
.tag-rect { fill: #f4d35e; stroke: #241a08; stroke-width: 1.5; }
.tag-text { fill: #241a08; font-family: var(--font); font-weight: 700; }
.tag.special .tag-rect { stroke: var(--amber); stroke-width: 3; }
.tag.extra .tag-rect { fill: #ffd166; stroke: #b23b3b; stroke-width: 3; }
.tag.foreign .tag-rect { fill: #8b94a5; stroke: #3a4457; }
.tag.foreign .tag-text { fill: #1b2028; }

#toast {
  position: absolute;
  bottom: 84px;   /* clears the radio log along the bottom */
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* A stopped board looks exactly like a slow one without this. */
.paused-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-2);
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  pointer-events: none;
  z-index: 5;
}
#screen-game.tutorial #toast { bottom: 160px; }

/* ---------- Radio log ---------- */
.radio {
  flex-shrink: 0;
  padding: 5px 16px 6px;
  background: #0d1117;
  border-top: 1px solid var(--line);
  min-height: 52px;
}
.radio[hidden] { display: none; }
.radio-line {
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.radio-line.age-1 { opacity: 0.55; }
.radio-line.age-2 { opacity: 0.3; }
.radio-line.age-0 { color: var(--ink); }
.radio-line.warn.age-0 { color: var(--amber); }
.radio-line.bad.age-0 { color: var(--red); }
.radio-line.good.age-0 { color: var(--green); }
.radio-time {
  display: inline-block;
  min-width: 46px;
  color: #46516a;
  letter-spacing: 0.5px;
}
#screen-game.tutorial .radio { display: none; }

/* ---------- Tutorial coach bar ---------- */
.coach {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  border-top: 2px solid var(--amber);
  padding: 12px 20px;
}
.coach[hidden] { display: none; }
.coach-body { flex: 1; min-width: 0; }
.coach-step { font-size: 9px; letter-spacing: 2px; color: var(--amber); margin-bottom: 3px; }
.coach-title { font-size: 13px; font-weight: 700; letter-spacing: 2px; margin-bottom: 5px; }
.coach-text { font-size: 12px; line-height: 1.6; color: var(--ink-dim); }
.coach-text b { color: var(--ink); }
.coach-text .ok { color: var(--green); font-weight: 700; }
.coach-text .bad { color: var(--red); font-weight: 700; }

.coach-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
  min-width: 132px;
}
.coach-btn {
  background: var(--amber);
  color: #241a08;
  border: none;
  font-family: var(--font);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 11px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.coach-btn:active { transform: scale(0.97); }
.coach-btn.ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  font-size: 10px;
  padding: 7px 14px;
}
.coach-wait {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--amber);
  padding: 11px 0;
  animation: coachWait 1.2s infinite;
}
@keyframes coachWait { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* during training the board is the lesson — hide scoring and clock controls */
#hud.tutorial .hud-mid,
#hud.tutorial .speed-btn,
#hud.tutorial #btnPause { display: none; }

/* ---------- Summary ---------- */
.summary-panel { text-align: center; }
.grade {
  font-size: 64px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  margin: 10px 0 4px;
}
.grade-title { letter-spacing: 2px; color: var(--ink-dim); font-size: 12px; margin-bottom: 26px; }
.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 26px;
  text-align: left;
}
.summary-stats .row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.summary-stats .row label { display: block; font-size: 10px; color: var(--ink-dim); letter-spacing: 1px; }
.summary-stats .row b { font-size: 18px; }

/* small screens */
@media (max-width: 760px) {
  /* Two arriving strips side by side stop being readable on a phone. */
  .portals { grid-template-columns: 1fr; height: 176px; }
  .portal-head { width: 104px; }
  .hud-mid { gap: 12px; }
  .title-card h1 { font-size: 24px; }
}

/* Short screens: the sign-in card is a tight fit already, so give back more
 * room than the footer's second line takes. */
@media (max-height: 780px) {
  .title-card { padding-top: 10px; padding-bottom: 10px; }
  .tagline { margin-bottom: 18px; }
  .career-stats { margin-bottom: 14px; }
  .title-footer .legal-links { margin-top: 3px; }
}

.queue-more {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--ink-dim);
  align-self: center;
  white-space: nowrap;
  padding: 0 8px;
  flex-shrink: 0;
}

/* ---------- Difficulty picker ---------- */
.diff-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.diff-btn {
  flex: 1 1 30%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--font);
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
}
.diff-btn b { display: block; font-size: 12px; letter-spacing: 1px; }
.diff-btn span { display: block; font-size: 9px; color: var(--ink-dim); margin-top: 3px; }
.diff-btn.active { border-color: var(--amber); background: rgba(255,179,71,0.1); }
.diff-btn.active b { color: var(--amber); }
.diff-desc {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-dim);
}

/* ---------- Score floaters & streak ---------- */
.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  bottom: 130px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  animation: floatUp 1.1s ease-out forwards;
}
.floater.ok { color: var(--amber); }
.floater.late { color: var(--red); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(6px) scale(0.9); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-42px) scale(1); }
}
.hud-streak {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green);
  min-height: 12px;
}

/* ---------- Summary extras ---------- */
.sum-daily, .sum-commend, .sum-report { text-align: left; margin-bottom: 22px; }
.sum-daily h3, .sum-commend h3, .sum-report h3, .record-block h3 {
  font-size: 12px; letter-spacing: 2px; color: var(--amber);
  margin: 0 0 10px; text-align: center;
}
.sum-daily { text-align: center; }
.daily-spark { font-size: 20px; letter-spacing: 2px; margin-bottom: 8px; }
.daily-note { font-size: 11px; color: var(--ink-dim); margin: 0 0 12px; }
.report-rows > div, .board-row {
  display: flex; align-items: baseline; gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 7px 2px; font-size: 12px;
}
.report-rows > div span, .board-row span { flex: 1; color: var(--ink-dim); }
.report-rows > div b, .board-row b { color: var(--ink); }
.board-row em { font-style: normal; color: var(--amber); min-width: 56px; text-align: right; }
.commend {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 6px; padding: 9px 12px; margin-bottom: 8px;
}
.commend b { display: block; font-size: 12px; letter-spacing: 1px; }
.commend span { font-size: 11px; color: var(--ink-dim); line-height: 1.5; }
.commend:not(.earned) { opacity: 0.45; border-left-color: var(--line); }
.commend-strip { font-size: 11px; color: var(--amber); margin-bottom: 8px; min-height: 14px; }
.record-block { margin-bottom: 26px; text-align: left; }
.board-zone { margin-top: 16px; }
.board-zone h4 { font-size: 11px; letter-spacing: 2px; color: var(--ink-dim); margin: 0 0 8px; }
.board-loading { font-size: 11px; color: var(--ink-dim); padding: 8px 0; }

@media (prefers-reduced-motion: reduce) {
  .floater { animation-duration: 0.01ms; }
}

/* ---------- Title fly-through ---------- */
.title-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}
/* Keeps the middle of the screen quiet so the sign-in card stays legible. */
.title-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 34% 46% at 50% 50%, rgba(11,14,19,0.9) 0%, rgba(11,14,19,0.66) 55%, rgba(11,14,19,0) 100%),
    linear-gradient(to bottom, rgba(11,14,19,0.3) 0%, rgba(11,14,19,0) 30%, rgba(11,14,19,0) 76%, rgba(11,14,19,0.5) 100%);
}
#screen-title .title-card,
#screen-title .title-footer { position: relative; z-index: 2; }
