:root {
  --bus: #f4c20d;
  --ink: #1b1d21;
  --bg: #f6f7f9;
  --card: #fff;
  --muted: #5a616b;
  --primary: #1c6ef2;
  --ok: #2a9d4a;
  --no: #c23b3b;
  --line: #e2e5ea;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 10; }
#app { max-width: 880px; margin: 0 auto; padding: 16px; }

.hero { background: var(--bus); border-radius: 14px; padding: 22px; margin-bottom: 18px; }
.hero h1 { margin: 0 0 6px; font-size: 1.6rem; }
.tagline { margin: 0; color: #3a3000; }

h2 { font-size: 1.2rem; margin: 22px 0 10px; }
.muted { color: var(--muted); font-size: .9rem; margin: 4px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.sim-card { border-color: var(--no); }

.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-block; text-decoration: none; cursor: pointer;
  background: #eef1f5; color: var(--ink); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 14px; font-size: .95rem; font: inherit;
}
.btn:hover { background: #e4e8ee; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:focus-visible { outline: 3px solid #ffb800; outline-offset: 2px; }

.badge { font-size: .72rem; padding: 2px 7px; border-radius: 20px; vertical-align: middle; }
.badge.ok { background: #e0f3e6; color: var(--ok); }
.badge.no { background: #fbe3e3; color: var(--no); }

.briefing {
  background: #fff8e1; border-left: 4px solid var(--bus);
  padding: 10px 14px; border-radius: 8px; margin: 10px 0 16px; font-size: .95rem;
}
.voicebar { margin: 0 0 10px; }
.voice-btn, .voice-toggle { margin-top: 6px; }

/* Touch polish: kill the 300ms tap delay / double-tap zoom on interactive surfaces. */
.btn, .choice, button, canvas { touch-action: manipulation; }
canvas { max-width: 100%; height: auto; }

/* ---- Drive Mode (game) ---- */
.game-wrap { position: relative; }
.game-hud { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.game-obj { font-size: .95rem; flex: 1; min-width: 200px; }
.game-menu { white-space: nowrap; }
.game-canvas { display: block; width: 100%; background: #7bb45a; border-radius: 10px; touch-action: none; }
.game-pad { position: absolute; bottom: 16px; left: 16px; display: grid;
  grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 6px; }
.padbtn { font-size: 1.3rem; background: rgba(255,255,255,.85); border: 1px solid #1b1d21;
  border-radius: 12px; user-select: none; touch-action: none; padding: 0; }
.pad-u { grid-column: 2; grid-row: 1; }
.pad-l { grid-column: 1; grid-row: 2; }
.pad-d { grid-column: 2; grid-row: 2; }
.pad-r { grid-column: 3; grid-row: 2; }
.game-banner { position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  background: rgba(27,29,33,.92); color: #fff; padding: 9px 16px; border-radius: 8px; font-weight: 600;
  max-width: 90%; text-align: center; }
.game-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 16px; }
.game-overlay-panel { background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; max-width: 700px; width: 100%; margin-top: 16px; }
.game-overlay-panel h2 { margin-top: 4px; }

.qcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; }
.q { font-weight: 600; margin: 0 0 8px; }
.ans { color: var(--ok); margin: 4px 0; }
.explain { margin: 6px 0; }
.cite { font-size: .8rem; color: var(--muted); font-style: italic; margin: 4px 0 0; }

.choices { display: grid; gap: 8px; margin: 8px 0; }
.choice { text-align: left; width: 100%; }
.choice.correct { background: #e0f3e6; border-color: var(--ok); }
.choice.wrong { background: #fbe3e3; border-color: var(--no); }
.next { margin-top: 12px; background: var(--primary); color: #fff; border-color: var(--primary); }

.runner-head { font-weight: 600; margin-bottom: 8px; }
.exam-banner { background: #e8f0fe; border-radius: 8px; padding: 10px; margin-bottom: 10px; font-size: .9rem; }
.exam-banner.warn { background: #fff3cd; }
.pass { color: var(--ok); font-weight: 700; }
.fail { color: var(--no); font-weight: 700; }

canvas#dz { width: 100%; max-width: 520px; height: auto; background: #3b3f45; border-radius: 12px; display: block; }
.hud { font-weight: 600; min-height: 1.5em; }
.a11y { margin-top: 10px; color: var(--muted); }

.back-note { color: var(--muted); font-size: .85rem; margin-top: 20px; }

canvas#sim-canvas { width: 100%; max-width: 560px; height: auto; border-radius: 12px; display: block; background: #2c2f34; }
.seq-list { list-style: decimal; padding-left: 20px; margin: 10px 0; }
.seq-list li { margin: 6px 0; }
.seq-btn { width: 100%; text-align: left; }
.checklist { margin: 10px 0; }
.check-ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.check-ul li.done .btn { background: #e0f3e6; border-color: var(--ok); }
.check-ul .btn { width: 100%; text-align: left; }

.pathway { padding-left: 22px; }
.path-step { margin: 0 0 14px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.path-step h3 { margin: 0 0 4px; font-size: 1.02rem; }
.path-step p { margin: 4px 0; }

.table-19a { width: 100%; border-collapse: collapse; margin: 10px 0; background: var(--card); font-size: .92rem; }
.table-19a th, .table-19a td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.table-19a th { background: #eef1f5; }
.notes-19a { color: var(--muted); font-size: .9rem; }
.verify-flag { background: #fff3cd; border-left: 4px solid #f4c20d; padding: 10px 14px; border-radius: 8px; font-size: .9rem; }

.cheatsheet h2 { margin-top: 4px; }
.cheat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cheat-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cheat-card h3 { margin: 0 0 6px; font-size: 1rem; color: #8a5a00; }
.cheat-card ul { margin: 0; padding-left: 18px; }
.cheat-card li { margin: 3px 0; font-size: .9rem; }

@media print {
  .noprint, .disclaimer, .briefing, footer { display: none !important; }
  body, #app { background: #fff; color: #000; max-width: none; }
  .cheat-card { border: 1px solid #999; break-inside: avoid; }
  .cheat-grid { grid-template-columns: 1fr 1fr; }
}

.disclaimer {
  max-width: 880px; margin: 30px auto 50px; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  font-size: .82rem; color: var(--muted);
}
.disclaimer a { color: var(--primary); }
