/* KCR 2.5D — screens, HUD, results */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--f-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, select, input { font: inherit; color: inherit; }
h1, h2, h3, h4, p, dl, dd, dt, ol, ul, table { margin: 0; }
ol, ul { padding: 0; list-style: none; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 999;
  background: var(--yellow); color: #161005; padding: 10px 16px;
  border-radius: var(--r-2); font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }

.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--cream-dim); font-weight: 400; }

#app { position: fixed; inset: 0; }

/* ── screens ─────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease), visibility 0s linear var(--t-med);
  overflow: hidden;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--t-med) var(--ease), visibility 0s;
}

/* ── title ───────────────────────────────────────────────────── */
#screen-title { background: #060b14; }
#attract { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.title-veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 8%, rgba(6, 11, 20, 0.1) 0%, rgba(6, 11, 20, 0.62) 52%, rgba(6, 11, 20, 0.94) 100%),
    linear-gradient(180deg, rgba(6, 11, 20, 0.35) 0%, rgba(6, 11, 20, 0.1) 30%, rgba(6, 11, 20, 0.88) 100%);
}
.title-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); text-align: center; padding: var(--s-5);
}
.title-kicker {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.34em; color: var(--yellow); text-transform: uppercase;
  opacity: 0.9;
}
.title-mark {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  line-height: 0.95;
}
.title-main {
  font-size: clamp(2.2rem, 8.1vw, 5.5rem);
  font-weight: 800; letter-spacing: 0.055em;
  line-height: 0.95;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0,0,0,0.3), 0 22px 70px rgba(0,0,0,0.7);
}
.title-en {
  font-family: var(--f-mono);
  font-size: clamp(0.62rem, 1.7vw, 0.86rem);
  letter-spacing: 0.30em; color: var(--yellow);
  text-transform: uppercase; padding-left: 0.30em;
}
.title-sub {
  font-size: var(--fs-14); letter-spacing: 0.26em;
  color: var(--cream-dim); margin-top: var(--s-2);
}
.title-actions {
  display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center;
  margin-top: var(--s-6);
}
.title-foot {
  position: absolute; bottom: var(--s-5); left: 0; right: 0;
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.2em; color: var(--cream-faint); text-transform: uppercase;
}

/* ── buttons ─────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--panel-2);
  position: relative;
  display: inline-flex; align-items: baseline; gap: 0.5em;
  padding: 13px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--btn-bg);
  color: var(--cream);
  font-size: var(--fs-14); font-weight: 700; letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(244,235,217,0.28); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
.btn .btn-en {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--cream-dim); font-weight: 500;
}
.btn-primary {
  background: linear-gradient(180deg, var(--yellow-hot), var(--yellow));
  color: #1a1204; border-color: transparent;
  box-shadow: var(--glow-yellow);
}
.btn-primary .btn-en { color: rgba(26, 18, 4, 0.6); }
.btn-primary:hover { background: linear-gradient(180deg, #ffdd6d, var(--yellow-hot)); }
.btn-ghost { background: rgba(255,255,255,0.04); }
.btn-danger { background: rgba(224, 59, 47, 0.14); border-color: rgba(224,59,47,0.4); color: #ffb0a8; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-2);
  background: rgba(255,255,255,0.03);
  color: var(--cream); font-size: var(--fs-18); cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(244,235,217,0.3); }
.icon-btn.tiny { width: 28px; height: 28px; font-size: var(--fs-16); }

/* ── bars & pages ────────────────────────────────────────────── */
.bar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: var(--s-4);
  height: 68px; padding: 0 var(--s-5);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14,22,38,0.98), rgba(14,22,38,0.9));
}
.bar h2 {
  font-size: var(--fs-18); font-weight: 700; letter-spacing: 0.08em;
  display: flex; align-items: baseline; gap: 0.6em;
}
.bar-en {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--cream-faint);
  font-weight: 500;
}
.bar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }

.rep-chip {
  display: inline-flex; align-items: baseline; gap: 0.4em;
  padding: 7px 13px; border-radius: var(--r-pill);
  border: 1px solid rgba(242,183,20,0.35);
  background: rgba(242,183,20,0.08);
  font-size: var(--fs-12); letter-spacing: 0.08em; color: var(--yellow);
}
.rep-chip b { font-family: var(--f-mono); font-size: var(--fs-14); }

.page {
  position: absolute; inset: 68px 0 0 0;
  overflow-y: auto; overflow-x: hidden;
  padding: var(--s-5) var(--s-5) var(--s-8);
  max-width: 1180px; margin: 0 auto;
  scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent;
}
.page::-webkit-scrollbar { width: 8px; }
.page::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 4px; }

/* ── roster ──────────────────────────────────────────────────── */
.route-strip {
  position: relative; height: 58px; margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--line-soft);
}
.route-strip .rs-line {
  position: absolute; left: 2%; right: 2%; top: 22px; height: 3px;
  background: linear-gradient(90deg, var(--yellow), rgba(242,183,20,0.25));
  border-radius: 2px;
}
.route-strip .rs-stop {
  position: absolute; top: 13px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-size: var(--fs-11); color: var(--cream-dim); white-space: nowrap;
}
.route-strip .rs-stop i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-2); border: 3px solid var(--yellow);
  display: block;
}
.route-strip .rs-stop.locked { color: var(--cream-faint); }
.route-strip .rs-stop.locked i { border-color: var(--panel-3); }

.shift-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.shift-card {
  position: relative; text-align: left;
  padding: var(--s-5); border-radius: var(--r-3);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--panel) 0%, var(--ink-2) 100%);
  cursor: pointer; overflow: hidden;
  transition: transform var(--t-med) var(--ease), border-color var(--t-med), box-shadow var(--t-med);
  min-height: 172px;
  display: flex; flex-direction: column; gap: var(--s-2);
}
.shift-card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 100% 0%, rgba(242,183,20,0.10), transparent 60%);
  pointer-events: none;
}
.shift-card:hover:not(.is-locked) {
  transform: translateY(-3px); border-color: rgba(242,183,20,0.4);
  box-shadow: var(--sh-2), 0 0 0 1px rgba(242,183,20,0.1);
}
.shift-card.is-locked { opacity: 0.46; cursor: not-allowed; }
.shift-card.is-locked:hover { transform: none; box-shadow: none; border-color: var(--line); }
.shift-card .sc-num {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.24em; color: var(--yellow);
}
.shift-card h3 { font-size: var(--fs-22); font-weight: 700; letter-spacing: 0.04em; }
.shift-card .sc-sub { font-family: var(--f-mono); font-size: var(--fs-11); letter-spacing: 0.12em; color: var(--cream-faint); text-transform: uppercase; }
.shift-card .sc-desc { font-size: var(--fs-13); color: var(--cream-dim); line-height: 1.55; flex: 1; }
.shift-card .sc-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: var(--s-3); border-top: 1px solid var(--line-soft);
  font-size: var(--fs-12); color: var(--cream-dim);
}
.shift-card .sc-grade {
  font-family: var(--f-mono); font-weight: 700; font-size: var(--fs-18);
  color: var(--yellow);
}
.shift-card .sc-weather { display: flex; align-items: center; gap: 6px; }

.daily-panel { margin-top: var(--s-5); display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.daily-panel .dp-main { flex: 1 1 320px; }
.daily-panel h3 { font-size: var(--fs-18); margin-bottom: 4px; }
.daily-panel p { font-size: var(--fs-13); color: var(--cream-dim); }
.daily-panel .dp-streak {
  font-family: var(--f-mono); font-size: var(--fs-28); color: var(--yellow);
  display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.daily-panel .dp-streak small { font-size: var(--fs-11); letter-spacing: 0.14em; color: var(--cream-faint); margin-top: 6px; }

.career-note {
  margin-top: var(--s-5); font-size: var(--fs-12); color: var(--cream-faint);
  line-height: 1.7; max-width: 70ch;
}

/* ── panels ──────────────────────────────────────────────────── */
.panel {
  padding: var(--s-5); border-radius: var(--r-3);
  border: 1px solid var(--line);
  background: rgba(22, 34, 58, 0.55);
}
.panel-h {
  display: flex; align-items: baseline; gap: 0.6em;
  font-size: var(--fs-13); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--yellow); margin-bottom: var(--s-4);
}
.panel-h span {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.16em; color: var(--cream-faint);
}

/* ── briefing ────────────────────────────────────────────────── */
.brief-page { max-width: 980px; }
.brief-head { display: flex; gap: var(--s-5); align-items: flex-start; margin-bottom: var(--s-5); }
.brief-head > div:first-child { flex: 1; }
.eyebrow {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.28em; color: var(--yellow); text-transform: uppercase;
  margin-bottom: var(--s-2);
}
.brief-title { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: 0.04em; }
.brief-desc { margin-top: var(--s-3); font-size: var(--fs-14); line-height: 1.75; color: var(--cream-dim); max-width: 60ch; }
.brief-weather {
  flex: 0 0 auto; width: 132px; padding: var(--s-4);
  border-radius: var(--r-3); border: 1px solid var(--line);
  background: var(--panel); text-align: center;
}
.brief-weather .bw-icon { font-size: 2rem; line-height: 1; margin-bottom: 8px; }
.brief-weather .bw-name { font-size: var(--fs-12); color: var(--cream-dim); }
.brief-weather .bw-temp { font-family: var(--f-mono); font-size: var(--fs-18); margin-top: 4px; }

.brief-cols { display: grid; gap: var(--s-4); grid-template-columns: 1fr 1fr; margin-bottom: var(--s-4); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px var(--s-4); font-size: var(--fs-13); }
.kv dt { color: var(--cream-faint); }
.kv dd { text-align: right; font-family: var(--f-mono); }

.brief-stops { display: flex; flex-direction: column; gap: 0; }
.brief-stops li {
  display: grid; grid-template-columns: 22px 1fr auto;
  align-items: center; gap: var(--s-3);
  padding: 9px 0; border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-13);
}
.brief-stops li:last-child { border-bottom: 0; }
.brief-stops .bs-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--yellow); justify-self: center;
}
.brief-stops li.origin .bs-dot { background: var(--yellow); }
.brief-stops .bs-time { font-family: var(--f-mono); color: var(--cream-dim); font-size: var(--fs-12); }

.brief-obj { margin-bottom: var(--s-5); }
.obj-list { display: grid; gap: 10px; font-size: var(--fs-13); color: var(--cream-dim); }
.obj-list li { display: flex; gap: 10px; line-height: 1.5; }
.obj-list li::before { content: "→"; color: var(--yellow); flex: 0 0 auto; }

.brief-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }

/* ── game canvas ─────────────────────────────────────────────── */
#screen-game { background: #05080f; }
.canvas-wrap { position: absolute; inset: 0; }
#world { display: block; width: 100%; height: 100%; }

/* ── HUD ─────────────────────────────────────────────────────── */
.hud {
  position: absolute; inset: 0; pointer-events: none;
  font-size: var(--fs-13);
  --hud-bg: rgba(10, 17, 30, 0.72);
  --hud-line: rgba(244, 235, 217, 0.14);
}
.hud-top {
  position: absolute; top: var(--s-4); left: var(--s-4); right: var(--s-4);
  display: flex; align-items: stretch; gap: var(--s-3);
}
.hud-next, .hud-limit, .hud-time {
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--hud-line); border-radius: var(--r-2);
  padding: 9px 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.hud-next { flex: 1; min-width: 0; }
.hud-next b { font-size: var(--fs-16); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-label {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.2em;
  color: var(--cream-faint); text-transform: uppercase;
}
.hud-dist { font-size: var(--fs-13); color: var(--yellow); }
.hud-limit { align-items: center; justify-content: center; min-width: 84px; }
.hud-limit b { font-size: var(--fs-28); color: var(--cream); line-height: 1; }
.hud-time { align-items: flex-end; min-width: 116px; }
.hud-time b { font-size: var(--fs-18); line-height: 1.1; }
.hud-delta { font-size: var(--fs-11); color: var(--cream-dim); }
.hud-delta.late { color: #ff8a7a; }
.hud-delta.early { color: var(--green-hot); }

.hud-signal {
  position: absolute; top: 108px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--hud-bg); border: 1px solid var(--hud-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.sig-lamp {
  width: 13px; height: 13px; border-radius: 50%;
  background: #26303f; border: 1px solid rgba(255,255,255,0.09);
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.sig-lamp.red.on { background: var(--red); box-shadow: 0 0 14px rgba(224,59,47,0.8); }
.sig-lamp.amber.on { background: var(--yellow); box-shadow: 0 0 14px rgba(242,183,20,0.8); }
.sig-lamp.green.on { background: var(--green); box-shadow: 0 0 14px rgba(47,163,107,0.8); }
.sig-text { font-family: var(--f-mono); font-size: var(--fs-11); letter-spacing: 0.12em; color: var(--cream-dim); margin-left: 4px; }

.hud-ghost {
  position: absolute; top: 150px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: rgba(242,183,20,0.10); border: 1px solid rgba(242,183,20,0.3);
  font-family: var(--f-mono); font-size: var(--fs-11); color: var(--yellow);
}
.ghost-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 10px var(--yellow); }

.hud-bottom {
  position: absolute; left: var(--s-4); right: var(--s-4); bottom: 37.5%;
  display: flex; align-items: flex-end; gap: var(--s-3);
}
.lever-readout, .hud-doors {
  background: var(--hud-bg); border: 1px solid var(--hud-line); border-radius: var(--r-2);
  padding: 9px 14px; display: flex; flex-direction: column; gap: 3px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lever-readout b { font-size: var(--fs-22); color: var(--yellow); line-height: 1; }
.hud-doors b { font-size: var(--fs-16); line-height: 1.2; }
.hud-doors.open b { color: var(--green-hot); }
.hud-prompts { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.prompt-key {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: rgba(242,183,20,0.13); border: 1px solid rgba(242,183,20,0.36);
  color: var(--yellow); font-size: var(--fs-12); letter-spacing: 0.04em;
  animation: pulse-soft 1.8s infinite;
}
.prompt-key kbd {
  font-family: var(--f-mono); font-size: 10px; padding: 2px 6px;
  background: rgba(0,0,0,0.3); border-radius: 3px; border: 1px solid rgba(242,183,20,0.3);
}
@keyframes pulse-soft { 0%,100% { opacity: .82 } 50% { opacity: 1 } }

.hud-msg {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  font-size: clamp(1.2rem, 3vw, 2rem); font-weight: 800; letter-spacing: 0.06em;
  text-align: center; text-shadow: 0 3px 22px rgba(0,0,0,0.8);
  opacity: 0; transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  white-space: nowrap;
}
.hud-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
.hud-msg.good { color: var(--green-hot); }
.hud-msg.warn { color: var(--yellow-hot); }
.hud-msg.bad { color: #ff6a5c; }

.hud-stop {
  position: absolute; left: 50%; bottom: 44%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--r-2);
  background: var(--hud-bg); border: 1px solid var(--hud-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.stop-bar {
  position: relative; width: 220px; height: 22px;
  background: linear-gradient(90deg, rgba(224,59,47,0.22), rgba(47,163,107,0.18) 42%, rgba(47,163,107,0.22) 58%, rgba(224,59,47,0.22));
  border-radius: 4px; border: 1px solid var(--hud-line);
}
.stop-bar::before {
  content: ""; position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px;
  background: var(--cream); transform: translateX(-50%); opacity: 0.7;
}
.stop-bar em {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 10px;
  transform: translate(-50%, -50%); border: 1px solid var(--green-hot);
  border-radius: 2px; opacity: 0.55;
}
.stop-bar i {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  background: var(--yellow); box-shadow: 0 0 10px var(--yellow);
  transform: translateX(-50%); left: 50%;
}
#stop-meters { font-size: var(--fs-12); color: var(--yellow); }

/* ── modal ───────────────────────────────────────────────────── */
.modal {
  position: absolute; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(5, 8, 15, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(440px, 92vw); padding: var(--s-6);
  border-radius: var(--r-4); border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--sh-3);
}
.modal-card h3 { font-size: var(--fs-28); margin-bottom: var(--s-5); letter-spacing: 0.06em; }
.modal-actions { display: flex; flex-direction: column; gap: var(--s-2); }
.modal-keys {
  margin-top: var(--s-4); font-size: var(--fs-11); line-height: 1.8;
  color: var(--cream-faint); text-align: center;
}

.help-card {
  position: absolute; right: var(--s-4); bottom: 110px; z-index: 30;
  width: 300px; padding: var(--s-4);
  border-radius: var(--r-3); border: 1px solid var(--line);
  background: rgba(14,22,38,0.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: var(--sh-2);
}
.help-card[hidden] { display: none; }
.help-card h4 { font-size: var(--fs-13); letter-spacing: 0.12em; color: var(--yellow); margin-bottom: var(--s-3); }
.keys { display: grid; grid-template-columns: 72px 1fr; gap: 9px var(--s-3); font-size: var(--fs-12); }
.keys dt { font-family: var(--f-mono); color: var(--cream); }
.keys dd { color: var(--cream-dim); }

/* ── results ─────────────────────────────────────────────────── */
.results-page { max-width: 760px; }
.results-title { font-size: clamp(1.6rem, 3.4vw, 2.3rem); font-weight: 800; letter-spacing: 0.04em; }
.grade-wrap {
  display: flex; align-items: center; gap: var(--s-5);
  margin: var(--s-4) 0 var(--s-5);
  padding: var(--s-5); border-radius: var(--r-3);
  border: 1px solid rgba(242,183,20,0.26);
  background: radial-gradient(90% 130% at 10% 0%, rgba(242,183,20,0.14), transparent 60%), var(--panel);
}
.grade {
  font-family: var(--f-mono); font-size: clamp(4rem, 12vw, 6.5rem); font-weight: 800;
  line-height: 0.8; color: var(--yellow);
  text-shadow: 0 0 40px rgba(242,183,20,0.45);
}
.grade-meta { display: flex; flex-direction: column; gap: 8px; }
.grade-meta .mono { font-size: var(--fs-18); }
.rep-line { font-size: var(--fs-13); color: var(--cream-dim); }

.stop-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.stop-table th {
  text-align: left; font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--cream-faint);
  padding: 0 8px 10px; border-bottom: 1px solid var(--line);
  font-weight: 500;
}
.stop-table td { padding: 11px 8px; border-bottom: 1px solid var(--line-soft); }
.stop-table tr:last-child td { border-bottom: 0; }
.stop-table .num { font-family: var(--f-mono); text-align: right; }
.stop-table .g { font-family: var(--f-mono); font-weight: 700; }
.stop-table .g.S { color: var(--yellow); }
.stop-table .g.A { color: var(--green-hot); }
.stop-table .g.B { color: var(--blue); }
.stop-table .g.C { color: var(--cream-dim); }
.stop-table .g.D { color: #ff8a7a; }

.penalty-panel { margin-top: var(--s-4); }
.penalty-list { display: grid; gap: 8px; font-size: var(--fs-13); }
.penalty-list li { display: flex; justify-content: space-between; gap: var(--s-4); color: var(--cream-dim); }
.penalty-list .neg { font-family: var(--f-mono); color: #ff8a7a; }
.penalty-list .pos { font-family: var(--f-mono); color: var(--green-hot); }

.results-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-5); }

/* ── settings ────────────────────────────────────────────────── */
.settings-page { max-width: 620px; display: flex; flex-direction: column; gap: var(--s-4); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-14);
}
.row:last-child { border-bottom: 0; }
.row select, .row input[type="range"] { max-width: 220px; }
select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-1); padding: 7px 10px; font-size: var(--fs-13);
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--yellow); }
input[type="range"] { accent-color: var(--yellow); width: 180px; }
.settings-foot { text-align: center; font-family: var(--f-mono); font-size: var(--fs-11); color: var(--cream-faint); letter-spacing: 0.12em; padding: var(--s-5) 0; }

/* ── toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 200; left: 50%; bottom: 38%;
  transform: translate(-50%, 18px);
  padding: 11px 20px; border-radius: var(--r-pill);
  background: rgba(14,22,38,0.96); border: 1px solid var(--line);
  font-size: var(--fs-13); color: var(--cream);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-med) var(--ease);
  box-shadow: var(--sh-2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── responsive ──────────────────────────────────────────────── */
@media (max-width: 760px) {
  .bar { height: 58px; padding: 0 var(--s-4); }
  .page { inset: 58px 0 0 0; padding: var(--s-4) var(--s-4) var(--s-7); }
  .brief-cols { grid-template-columns: 1fr; }
  .brief-head { flex-direction: column; }
  .brief-weather { width: 100%; display: flex; align-items: center; gap: var(--s-3); text-align: left; }
  .brief-weather .bw-icon { margin: 0; }
  .hud-top { top: var(--s-2); left: var(--s-2); right: var(--s-2); gap: var(--s-2); }
  .hud-next b { font-size: var(--fs-14); }
  .hud-limit { min-width: 66px; }
  .hud-limit b { font-size: var(--fs-22); }
  .hud-time { min-width: 92px; }
  .hud-time b { font-size: var(--fs-14); }
  .hud-signal { top: 96px; }
  .hud-ghost { top: 134px; }
  .hud-bottom { left: var(--s-2); right: var(--s-2); bottom: var(--s-2); }
  .hud-stop { bottom: 44%; }
  .stop-bar { width: 168px; }
  .help-card { right: var(--s-2); bottom: 96px; width: calc(100vw - 24px); }
  .title-actions { flex-direction: column; width: 100%; max-width: 320px; }
  .title-actions .btn { width: 100%; justify-content: center; }
  .shift-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── mobile: rotate gate ─────────────────────────────────────── */
.rotate-overlay {
  position: fixed; inset: 0; z-index: 600;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px;
  background:
    radial-gradient(80% 60% at 50% 38%, #14213a 0%, #070c14 72%);
  color: var(--cream);
}
body.is-mobile.is-portrait .rotate-overlay { display: flex; }

.rotate-phone {
  width: 54px; height: 92px;
  border: 3px solid var(--yellow); border-radius: 12px;
  position: relative; margin-bottom: 12px;
  animation: rotate-hint 2.8s var(--ease) infinite;
}
.rotate-phone i {
  position: absolute; left: 50%; bottom: 7px;
  width: 18px; height: 3px; border-radius: 2px;
  background: var(--yellow); transform: translateX(-50%);
}
.rotate-overlay h2 { font-size: clamp(1.4rem, 7vw, 2rem); letter-spacing: 0.1em; font-weight: 800; }
.rotate-overlay p {
  font-family: var(--f-mono); font-size: var(--fs-11);
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--cream-faint);
}
@keyframes rotate-hint {
  0%, 20%  { transform: rotate(0deg); }
  62%, 100% { transform: rotate(90deg); }
}

/* ── mobile: touch controls ──────────────────────────────────── */
.touch-controls {
  display: none;
  position: absolute; inset: 0; z-index: 35;
  pointer-events: none;
}
body.is-mobile #screen-game.is-active .touch-controls { display: block; }

.tc-lever {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  pointer-events: auto;
}
.tc-actions {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 10px;
  pointer-events: auto;
}

.tc-btn, .tc-round, .tc-readout {
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tc-btn {
  width: 66px; height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 14px;
  border: 1.5px solid rgba(242, 183, 20, 0.55);
  background: rgba(10, 17, 30, 0.80);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--yellow);
  font-size: 17px; font-weight: 700; line-height: 1;
  transition: background var(--t-fast), transform var(--t-fast);
}
.tc-btn small {
  font-family: var(--f-mono); font-size: 8px; font-weight: 500;
  letter-spacing: 0.14em; color: var(--cream-dim);
}
.tc-btn:active { background: rgba(242, 183, 20, 0.24); transform: scale(0.96); }
.tc-brk { border-color: rgba(224, 59, 47, 0.55); color: #FF9C8C; }
.tc-brk:active { background: rgba(224, 59, 47, 0.24); }

.tc-readout {
  width: 66px; padding: 3px 0; text-align: center;
  font-family: var(--f-mono); font-size: 15px; font-weight: 700;
  color: var(--yellow);
  border: 1px solid var(--line); border-radius: 6px;
  background: rgba(10, 17, 30, 0.72);
}

.tc-round {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line);
  background: rgba(10, 17, 30, 0.80);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--cream);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.tc-round:active { background: rgba(255, 255, 255, 0.14); transform: scale(0.95); }
.tc-aws { color: var(--yellow); border-color: rgba(242, 183, 20, 0.4); }
.tc-door {
  width: 76px; height: 76px;
  font-size: 15px;
  color: var(--yellow);
  border-color: rgba(242, 183, 20, 0.6);
}
.tc-door.ready { animation: tc-pulse 1.3s infinite; }
.tc-door.open { background: rgba(47, 163, 107, 0.28); border-color: var(--green-hot); color: #B9F5D6; }
@keyframes tc-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(242, 183, 20, 0.18); }
  50%      { box-shadow: 0 0 22px rgba(242, 183, 20, 0.62); }
}

/* keep the canvas from scrolling / pinch-zooming the page */
#world { touch-action: none; }
body.is-mobile { overscroll-behavior: none; }

/* ── mobile landscape / short viewport ───────────────────────── */
@media (max-height: 560px) and (orientation: landscape) {
  .bar { height: 48px; padding: 0 12px; }
  .bar h2 { font-size: 15px; }
  .bar-en { display: none; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .page { inset: 48px 0 0 0; padding: 12px 14px 32px; }

  .hud-top {
    top: max(6px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 6px;
  }
  .hud-next, .hud-limit, .hud-time { padding: 5px 10px; gap: 1px; }
  .hud-label { font-size: 8px; letter-spacing: 0.14em; }
  .hud-next b { font-size: 13px; }
  .hud-dist { font-size: 11px; }
  .hud-limit { min-width: 56px; }
  .hud-limit b { font-size: 20px; }
  .hud-time { min-width: 84px; }
  .hud-time b { font-size: 13px; }
  .hud-delta { font-size: 9px; }

  .hud-signal { top: 60px; padding: 5px 10px; gap: 5px; }
  .sig-lamp { width: 10px; height: 10px; }
  .sig-text { font-size: 9px; }
  .hud-ghost { top: 92px; padding: 4px 9px; font-size: 9px; }

  .hud-bottom { display: none; }
  .help-card { display: none !important; }
  .hud-msg { top: 30%; font-size: 1.1rem; }
  .hud-stop { bottom: 40%; padding: 6px 10px; gap: 4px; }
  .stop-bar { width: 150px; height: 18px; }
  #stop-meters { font-size: 10px; }

  .title-kicker { display: none; }
  .title-main { font-size: clamp(1.9rem, 11vh, 3.4rem); letter-spacing: 0.04em; }
  .title-en { font-size: 9px; letter-spacing: 0.24em; }
  .title-sub { font-size: 11px; margin-top: 4px; }
  .title-actions { margin-top: 14px; }
  .title-foot { display: none; }
  .title-inner { gap: 4px; }

  .brief-head { flex-direction: row; gap: 14px; }
  .brief-title { font-size: 1.55rem; }
  .brief-desc { font-size: 12px; line-height: 1.5; }
  .brief-cols { grid-template-columns: 1fr 1fr; gap: 10px; }
  .panel { padding: 12px; }
  .brief-weather { width: 104px; }
  .brief-weather .bw-icon { font-size: 1.4rem; }

  .shift-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
  .shift-card { min-height: 132px; padding: 12px; }
  .shift-card h3 { font-size: 17px; }
  .shift-card .sc-desc { font-size: 11px; }
  .route-strip { height: 46px; margin-bottom: 12px; }

  .grade-wrap { padding: 14px; gap: 18px; }
  .grade { font-size: 3.4rem; }
  .results-page { max-width: 660px; }
  .settings-page { max-width: 560px; }
  .modal-card { padding: 18px; }
  .modal-card h3 { font-size: 20px; margin-bottom: 12px; }
}

/* mobile: keyboard hints are irrelevant */
body.is-mobile .modal-keys { display: none; }

/* mobile: central pause button (no keyboard on a phone) */
.tc-pause {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  top: max(62px, calc(env(safe-area-inset-top) + 56px));
  left: auto; bottom: auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: rgba(10, 17, 30, 0.78);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--cream-dim);
  font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.06em;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: background var(--t-fast), transform var(--t-fast);
}
.tc-pause:active { background: rgba(255, 255, 255, 0.14); transform: scale(0.95); }

/* mobile: keep primary actions reachable without scrolling */
@media (max-height: 560px) and (orientation: landscape) {
  .brief-actions,
  .results-actions {
    position: sticky;
    bottom: 0;
    z-index: 6;
    margin-top: 10px;
    padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(11, 18, 32, 0) 0%, rgba(11, 18, 32, 0.94) 38%);
  }
}

/* the redesigned desk shows these itself */
.lever-readout, .hud-doors { display: none; }

/* mobile: reverser toggle beside the controller readout */
.tc-rev {
  position: absolute;
  left: 80px; top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: rgba(10, 17, 30, 0.80);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--cream-dim);
  font-family: var(--f-mono); font-size: 15px; font-weight: 700;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; user-select: none; -webkit-user-select: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.tc-rev:active { background: rgba(255, 255, 255, 0.14); }
.tc-rev.on {
  color: var(--yellow);
  border-color: rgba(242, 183, 20, 0.75);
  background: rgba(242, 183, 20, 0.16);
  box-shadow: 0 0 14px rgba(242, 183, 20, 0.35);
}

.tc-door.far {
  border-color: rgba(224, 59, 47, 0.7);
  color: #FFB39E;
}

.credits-text {
  font-size: var(--fs-12);
  line-height: 1.65;
  color: var(--cream-dim);
  margin: 0 0 6px;
}
.credits-text a { color: var(--yellow); }

/* right-side forward / reverse switch */
.hud-rev {
  position: absolute;
  right: var(--s-4);
  top: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 13px;
  border-radius: var(--r-2);
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  color: var(--cream);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.hud-rev b {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--green-hot);
}
.hud-rev.rev {
  border-color: rgba(242, 183, 20, 0.55);
  background: rgba(242, 183, 20, 0.12);
}
.hud-rev.rev b { color: var(--yellow); }
.hud-rev:active { transform: scale(0.97); }

@media (max-height: 560px) and (orientation: landscape) {
  .hud-rev {
    top: 112px;
    right: max(8px, env(safe-area-inset-right));
    padding: 5px 9px;
  }
  .hud-rev b { font-size: 13px; }
}
