  /* Wayfinding: HTTP codes are directions. Gateways, redirects, not found.
     Sign yellow for the thing you must read, class colors that carry meaning. */
  :root {
    --bg: #E8EBEE;        /* terminal concourse grey */
    --surface: #FFFFFF;
    --ink: #000000;
    --ink-2: #39404A;
    --muted: #5E6672;
    --line: #CDD2D8;
    --sign: #FFC72C;      /* wayfinding yellow */
    --board: #23262B;     /* split-flap board graphite */
    --c1: #6B7280;        /* 1xx info: grey */
    --c2: #1A7A43;        /* 2xx success: exit green (darkened for 4.5:1 with white) */
    --c3: #1D5FD1;        /* 3xx redirect: route blue */
    --c4: #FFC72C;        /* 4xx client: caution yellow */
    --c5: #D7263D;        /* 5xx server: stop red */
    --r-sign: 6px;
    --r-panel: 14px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    background: var(--bg); color: var(--ink);
    font-family: "Overpass", "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    min-height: 100vh; line-height: 1.5;
  }
  a { color: inherit; }
  button { font-family: inherit; cursor: pointer; color: inherit; }
  :focus-visible { outline: 3px solid var(--c3); outline-offset: 2px; }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

  /* ---------- top bar ---------- */
  .bar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .bar-in { max-width: 1120px; margin: 0 auto; padding: 0 20px; display: flex; align-items: stretch; gap: 28px; min-height: 64px; flex-wrap: wrap; }
  .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 900; font-size: 21px; letter-spacing: -.4px; }
  .tabs { display: flex; gap: 4px; }
  .tabs a { display: flex; align-items: center; padding: 0 14px; text-decoration: none; font-weight: 700; color: var(--ink-2); border-bottom: 4px solid transparent; border-top: 4px solid transparent; }
  .tabs a:hover { color: var(--ink); }
  .tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
  .bar-stats { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--muted); }
  .bar-stats b { color: var(--ink); font-weight: 800; }

  /* mobile menu: a departures-board panel under the bar */
  .menu-btn { display: none; margin-left: auto; align-self: center; width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 8px; background: var(--surface); flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
  .menu-btn span { display: block; width: 20px; height: 3px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }
  .menu-btn[aria-expanded="true"] { background: var(--sign); }
  .menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .mmenu { background: var(--board); color: #E9E6DA; padding: 8px 20px 20px; border-bottom: 6px solid var(--sign); }
  .mmenu[hidden] { display: none; }
  .mmenu nav a { display: flex; align-items: center; gap: 16px; padding: 16px 4px 13px; text-decoration: none; font-weight: 800; font-size: 22px; border-bottom: 1px solid #30343A; }
  .mmenu nav a .mm-code { background: #2E3238; color: #8C9099; border-radius: 4px; padding: 4px 8px 1px; font-size: 16px; font-weight: 800; box-shadow: inset 0 -1px 0 #1A1C20, inset 0 1px 0 #3B4047; }
  .mmenu nav a.active .mm-code { background: var(--sign); color: var(--ink); box-shadow: none; }
  .mmenu nav a.active { color: #fff; }
  .mmenu nav a:not(.active) { color: #C9CCD2; }
  .mm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
  .mm-stats div { background: #2E3238; border-radius: 8px; padding: 12px 14px 8px; }
  .mm-stats small { display: block; color: #8C9099; font-weight: 700; font-size: 13px; }
  .mm-stats b { color: var(--sign); font-size: 28px; font-weight: 900; }
  @media (prefers-reduced-motion: no-preference) {
    .mmenu:not([hidden]) { animation: drop .18s ease-out; }
    .mmenu.closing { animation: lift .18s ease-in forwards; }
  }
  @keyframes drop { from { transform: translateY(-8px); opacity: 0; } }
  @keyframes lift { to { transform: translateY(-8px); opacity: 0; } }
  @media (max-width: 900px) {
    .bar-in > .tabs, .bar-stats { display: none; }
    .menu-btn { display: inline-flex; }
    .bar-in { min-height: 64px; }
  }
  @media (min-width: 901px) { .mmenu { display: none !important; } }

  .page { max-width: 1120px; margin: 0 auto; padding: 36px 20px 64px; }
  .narrow { max-width: 760px; }
  h1 { font-weight: 900; letter-spacing: -1px; line-height: 1.05; }
  h2 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 40px 0 14px; }
  .lede { color: var(--ink-2); font-size: 18px; max-width: 60ch; }
  .muted { color: var(--muted); }

  /* class chips: color carries the class */
  .chip { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; padding: 3px 8px 1px; border-radius: 4px; font-weight: 800; font-size: 15px; color: #fff; }
  .k1 { background: var(--c1); } .k2 { background: var(--c2); } .k3 { background: var(--c3); }
  .k4 { background: var(--c4); color: var(--ink); } .k5 { background: var(--c5); }
  .tag-chip { display: inline-flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px 4px 4px; margin: 6px 6px 0 0; text-decoration: none; font-weight: 600; font-size: 14px; }
  .tag-chip .chip { min-width: 40px; font-size: 13px; }

  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-weight: 800; font-size: 16px; padding: 11px 22px 9px; border-radius: var(--r-sign); text-decoration: none; }
  .btn:hover { background: var(--ink-2); border-color: var(--ink-2); }
  .btn.quiet { background: transparent; color: var(--ink); }
  .btn.quiet:hover { background: var(--surface); }
  .btn.stop { background: var(--c5); border-color: var(--c5); }

  /* ---------- home ---------- */
  .home { display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: stretch; padding-top: clamp(40px, 7vh, 80px); }
  .home > section:first-child { display: flex; flex-direction: column; }
  .home h1 { font-size: clamp(44px, 6vw, 76px); margin-bottom: 18px; }
  .home .lede { margin-bottom: 28px; }
  .board { background: var(--board); border-radius: var(--r-panel); padding: 18px 18px 14px; margin-top: auto; color: #E9E6DA; overflow-x: auto; }
  .board-head, .board-row { display: grid; grid-template-columns: 70px 1fr 150px; gap: 14px; align-items: center; }
  .board-head { color: #8C9099; font-size: 13px; font-weight: 700; padding: 0 2px 10px; border-bottom: 1px solid #3A3E45; }
  .board-row { padding: 9px 2px; border-bottom: 1px solid #30343A; }
  .board-row:last-child { border-bottom: none; }
  .flap { display: inline-flex; gap: 4px 8px; flex-wrap: wrap; }
  .flap .w { display: inline-flex; gap: 2px; white-space: nowrap; }
  .flap span { display: inline-block; min-width: .72em; text-align: center; background: #2E3238; border-radius: 3px; padding: 2px 1px 0; font-weight: 800; text-transform: uppercase; box-shadow: inset 0 -1px 0 #1A1C20, inset 0 1px 0 #3B4047; }
  .flap.code span { color: var(--sign); font-size: 20px; }
  .flap.msg span { font-size: 15px; min-width: .68em; }
  .where { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: #C9CCD2; white-space: nowrap; }
  .where i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

  .start { background: var(--surface); border-radius: var(--r-panel); padding: 26px; border: 1px solid var(--line); display: flex; flex-direction: column; }
  .start h2 { margin: 0 0 4px; }
  .levels { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-radius: 8px; padding: 4px; margin: 14px 0 22px; }
  .levels button { border: none; background: transparent; padding: 14px 6px 11px; border-radius: 6px; font-weight: 800; font-size: 16px; color: var(--ink-2); }
  .levels button small { display: block; font-weight: 600; font-size: 12px; color: var(--muted); }
  .levels button.on { background: var(--sign); color: var(--ink); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
  .levels button.on small { color: var(--ink-2); }
  .mode { width: 100%; text-align: left; display: grid; grid-template-columns: 74px 1fr; gap: 16px; align-items: center; background: var(--surface); border: 2px solid var(--ink); border-radius: 10px; padding: 22px 18px; margin-bottom: 14px; }
  .mode:hover { background: #FFF8DF; }
  .mode .plate { background: var(--sign); border-radius: var(--r-sign); font-weight: 900; font-size: 26px; text-align: center; padding: 12px 0 8px; }
  .mode b { font-size: 19px; font-weight: 800; display: block; color: var(--ink); }
  .mode .desc { color: var(--muted); font-size: 15px; }
  .start-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; min-height: 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; }
  .start-foot a { font-weight: 700; }

  /* ---------- play ---------- */
  .play-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
  .play-top .what { font-weight: 800; font-size: 18px; letter-spacing: 0; line-height: 1.4; }
  .play-top .what a { font-weight: 600; font-size: 15px; color: var(--muted); margin-left: 10px; }
  .scoreline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
  .lights { display: flex; gap: 8px; }
  .light { width: 18px; height: 18px; border-radius: 50%; background: var(--c2); border: 2px solid var(--ink); transition: background .2s; }
  .light.out { background: var(--line); }
  .score-side { display: flex; align-items: center; gap: 14px; }
  .pause { width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 8px; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
  .pause span { width: 4px; height: 14px; background: var(--ink); border-radius: 1px; }
  .pause:hover:not(:disabled) { background: var(--sign); }
  .pause:disabled { opacity: .35; cursor: default; }
  .arena.is-paused .block { filter: blur(6px); }
  .modal.pausebox { position: relative; border-top-color: var(--sign); max-width: 420px; }
  .pause-actions { display: flex; flex-direction: column; gap: 10px; }
  .modal-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--line); background: var(--surface); font-size: 20px; line-height: 1; }
  .modal-x:hover { border-color: var(--ink); }
  .small { font-size: 13px; margin: 12px 0 0 !important; text-align: center; }
  .score { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink-2); }
  .score b { background: var(--board); color: var(--sign); font-size: 22px; font-weight: 900; padding: 4px 10px 1px; border-radius: 4px; min-width: 56px; text-align: center; }
  .arena {
    position: relative; height: 62vh; min-height: 420px; border-radius: var(--r-panel); overflow: hidden;
    background:
      repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(0,0,0,.06) calc(25% - 1px) 25%),
      linear-gradient(#F4F6F8, #DCE0E5);
    border: 1px solid var(--line);
  }
  .arena::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: repeating-linear-gradient(135deg, var(--ink) 0 12px, var(--sign) 12px 24px); }
  .block { position: absolute; background: var(--sign); color: var(--ink); font-weight: 800; font-size: 21px; padding: 10px 16px 7px; border-radius: var(--r-sign); white-space: nowrap; will-change: transform; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
  .block.num { font-size: 28px; font-weight: 900; padding: 8px 18px 4px; }
  .block.hit { animation: hit .28s forwards; }
  .block.miss { background: var(--c5); color: #fff; }
  @keyframes hit { 60% { transform: var(--pos) scale(1.12); } to { transform: var(--pos) scale(.6); opacity: 0; } }
  .block.hit.k2c { background: var(--c2); color: #fff; } .block.hit.k3c { background: var(--c3); color: #fff; }
  .block.hit.k5c { background: var(--c5); color: #fff; } .block.hit.k1c { background: var(--c1); color: #fff; }
  .block.hit.k4c { background: var(--ink); color: var(--sign); }

  .overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(232,235,238,.82); padding: 20px; z-index: 2; }
  .overlay-card { background: var(--surface); border-radius: var(--r-panel); border: 1px solid var(--line); padding: 26px 28px; max-width: 420px; text-align: center; }
  .overlay-card h2 { margin: 0 0 8px; font-size: 26px; }
  .overlay-card p { color: var(--ink-2); margin-bottom: 18px; }
  .count { font-size: 120px; font-weight: 900; line-height: 1; }
  .answer-row { display: flex; justify-content: center; margin-top: 18px; }
  #answer { width: 180px; height: 58px; background: var(--surface); border: 3px solid var(--ink); border-radius: 8px; font: 800 26px "Overpass", sans-serif; text-align: center; outline: none; padding-top: 4px; }
  #answer.wide { width: 380px; max-width: 100%; font-size: 21px; }
  #answer:focus { box-shadow: 0 0 0 4px var(--sign); }
  #answer.off { border-color: var(--c5); }
  #answer.wrong { border-color: var(--c5); animation: shake .25s; }
  @keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
  .hint { text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }

  /* ---------- phones and tablets: the play view fills the visible screen ---------- */
  body.touch-play { overflow: hidden; }
  body.touch-play .bar, body.touch-play .foot { display: none; }
  body.touch-play #view { position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh); }
  body.touch-play .page.play { height: 100%; display: flex; flex-direction: column; padding-top: 20px; padding-bottom: 16px; }
  body.touch-play .play-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.touch-play .arena { flex: 1 1 auto; height: auto; min-height: 120px; }
  body.touch-play .answer-row { margin-top: 12px; }
  #view.tight .play-top, #view.tight .hint { display: none; }
  #view.tight .page.play { padding-top: 10px; padding-bottom: 8px; }
  /* tablets: one row under the arena, like a keyboard's number row */
  .keypad { display: grid; grid-template-columns: repeat(11, 1fr); gap: 8px; width: 100%; max-width: 760px; margin: 12px auto 0; }
  .keypad button { height: 60px; border: 2px solid var(--ink); border-radius: 8px; background: var(--surface); font-size: 26px; font-weight: 800; padding-top: 4px; display: flex; align-items: center; justify-content: center; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  .keypad button.down, .keypad button:active { background: var(--sign); }
  .keypad [data-key="back"] { padding-top: 0; }

  /* ---------- results ---------- */
  .result { max-width: 720px; margin: 0 auto; }
  .result h1 { font-size: 48px; margin-bottom: 4px; }
  .result-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; margin: 24px 0; }
  .stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
  .stat small { color: var(--muted); font-weight: 700; font-size: 14px; }
  .stat b { display: block; font-size: 34px; font-weight: 900; line-height: 1.1; margin-top: 4px; }
  .stat .new { display: inline-block; background: var(--sign); font-size: 12px; font-weight: 800; padding: 2px 6px 0; border-radius: 3px; margin-left: 6px; vertical-align: middle; }
  .stat.big { background: var(--board); border-color: var(--board); color: #fff; grid-row: span 2; }
  .stat.big small { color: #A6AAB2; }
  .stat.big b { color: var(--sign); font-size: 72px; }
  .result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }

  /* ---------- codes directory ---------- */
  .dir-tools { display: flex; gap: 12px; margin: 22px 0 8px; flex-wrap: wrap; }
  .search { flex: 1; min-width: 220px; background: var(--surface); border: 2px solid var(--ink); border-radius: 8px; padding: 12px 14px 9px; font: 600 16px "Overpass", sans-serif; outline: none; }
  .search:focus { box-shadow: 0 0 0 4px var(--sign); }
  .dir { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
  .dir-group { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; border: 1px solid var(--line); }
  .dir-band { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 9px; color: #fff; }
  .dir-band b { font-size: 20px; font-weight: 900; }
  .dir-band span { font-weight: 700; font-size: 15px; }
  .dir-band.k4 { color: var(--ink); }
  .band-btn { background: rgba(0,0,0,.25); border: 1.5px solid currentColor; color: inherit; border-radius: 6px; padding: 4px 10px 2px; font-weight: 800; font-size: 13px; }
  .band-btn:hover { background: rgba(0,0,0,.4); }
  .dir-band.k4 .band-btn { background: rgba(0,0,0,.06); }
  .dir-row { display: grid; grid-template-columns: 50px 1fr auto; gap: 12px; align-items: center; padding: 9px 16px 7px; text-decoration: none; border-top: 1px solid var(--line); }
  .dir-row:hover { background: #F6F7F9; }
  .dir-row b { font-weight: 900; font-size: 17px; }
  .dir-row em { font-style: normal; font-size: 12px; color: var(--muted); }

  /* ---------- code detail ---------- */
  .back { font-weight: 700; text-decoration: none; color: var(--muted); }
  .back:hover { color: var(--ink); }
  .plate-big { display: inline-flex; align-items: baseline; gap: 18px; padding: 18px 26px 12px; border-radius: 10px; margin: 22px 0 18px; color: #fff; }
  .plate-big b { font-size: 64px; font-weight: 900; line-height: 1; }
  .plate-big span { font-size: 30px; font-weight: 800; line-height: 1.1; }
  .plate-big.k4 { color: var(--ink); }
  .class-line { font-weight: 700; color: var(--ink-2); }
  .def { font-size: 22px; line-height: 1.5; margin: 6px 0 22px; max-width: 58ch; }
  .note { background: var(--surface); border-radius: 10px; padding: 16px 18px; border-left: 6px solid var(--sign); margin-bottom: 22px; max-width: 70ch; }
  .note b { display: block; margin-bottom: 4px; font-weight: 800; }
  .ref { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; color: var(--ink-2); }
  .ref code { font-family: "Overpass", sans-serif; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px 1px; color: var(--ink); }
  .pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); }
  .pager a { text-decoration: none; font-weight: 700; display: inline-flex; gap: 8px; align-items: center; }

  /* ---------- learn ---------- */
  .ladder { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; border: 1px solid var(--line); }
  .rung { display: grid; grid-template-columns: 74px 190px 1fr; gap: 16px; align-items: center; padding: 14px 18px 12px; border-top: 1px solid var(--line); }
  .rung:first-child { border-top: none; }
  .rung .chip { font-size: 18px; padding: 6px 8px 3px; }
  .rung strong { font-weight: 800; font-size: 17px; }
  .rung p { color: var(--ink-2); }
  .pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .pair { background: var(--surface); border-radius: 10px; padding: 16px; border: 1px solid var(--line); }
  .pair h3 { font-size: 19px; font-weight: 900; margin-bottom: 6px; }
  .pair p { color: var(--ink-2); font-size: 15px; }

  .deck-tools { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
  .seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
  .seg button { border: none; background: transparent; padding: 7px 12px 5px; border-radius: 6px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
  .seg button.on { background: var(--ink); color: #fff; }
  .seg.wrap { flex-wrap: wrap; }
  .seg .cnt { font-weight: 600; color: var(--muted); margin-left: 2px; }
  .seg button.on .cnt { color: #C9CCD2; }
  .newhere { color: var(--ink-2); margin: 14px 0 22px; }
  .linkish { background: none; border: none; padding: 0; font: inherit; font-weight: 700; text-decoration: underline; color: var(--ink); }
  #basics { scroll-margin-top: 90px; }
  #basics:focus { outline: none; }
  .progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
  .progress i { display: block; height: 100%; width: 0; background: var(--c2); transition: width .3s; }

  .flipcard { perspective: 1400px; height: 300px; cursor: pointer; max-width: 640px; margin: 0 auto; }
  .flipcard .inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
  .flipcard.flipped .inner { transform: rotateY(180deg); }
  .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 24px -14px rgba(0,0,0,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px; gap: 10px; }
  .face.back { transform: rotateY(180deg); }
  .face .prompt { font-size: 40px; font-weight: 900; letter-spacing: -.6px; line-height: 1.1; }
  .face .tap { color: var(--muted); font-size: 14px; position: absolute; bottom: 16px; }
  .face .ans { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
  .face .ans .chip { font-size: 30px; padding: 8px 12px 4px; }
  .face .ans span:last-child { font-size: 26px; font-weight: 800; color: var(--ink); }
  .face p { color: var(--ink-2); max-width: 48ch; }
  .flipcard.leave-l .inner { animation: leaveL .22s forwards; }
  .flipcard.leave-r .inner { animation: leaveR .22s forwards; }
  .flipcard.enter .inner { animation: enter .22s; }
  @keyframes leaveL { from { transform: rotateY(180deg); } to { transform: rotateY(180deg) translateX(60px); opacity: 0; } }
  @keyframes leaveR { from { transform: rotateY(180deg); } to { transform: rotateY(180deg) translateX(-60px); opacity: 0; } }
  @keyframes enter { from { transform: translateY(14px); opacity: 0; } }
  .card-actions { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
  .card-actions .btn { min-width: 150px; }
  .kbd { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
  .kbd kbd { font-family: inherit; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px 0; }

  /* ---------- history ---------- */
  .tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .log { background: var(--surface); border-radius: var(--r-panel); border: 1px solid var(--line); overflow: hidden; }
  .log-row { display: grid; grid-template-columns: 1.3fr 1.3fr .6fr .6fr .7fr; gap: 12px; padding: 13px 18px 10px; border-top: 1px solid var(--line); align-items: center; }
  .log-row:first-child { border-top: none; }
  .log-row.head { background: var(--bg); color: var(--muted); font-size: 14px; font-weight: 700; }
  .log-row .pb { background: var(--sign); font-size: 12px; font-weight: 800; padding: 2px 6px 0; border-radius: 3px; margin-left: 6px; }
  .log-miss { grid-column: 1 / -1; margin-top: -6px; }
  .hpager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-weight: 700; color: var(--ink-2); }
  .hpager .btn { padding: 8px 16px 6px; font-size: 15px; }
  .hpager .btn:disabled { opacity: .35; cursor: default; background: transparent; }
  #roundsTitle { scroll-margin-top: 90px; }
  #roundsTitle:focus { outline: none; }

  /* ---------- about ---------- */
  .about h1 { font-size: 48px; margin-bottom: 18px; }
  .about p { font-size: 18px; color: var(--ink-2); margin-bottom: 16px; max-width: 64ch; }
  .about .opener { font-size: 22px; color: var(--ink); line-height: 1.5; }
  .about h2 { font-size: 20px; margin: 32px 0 8px; }
  .about a { font-weight: 700; }
  .about .pairline { display: inline-flex; gap: 6px; align-items: center; }

  /* ---------- footer ---------- */
  body { display: flex; flex-direction: column; }
  main { flex: 1; }
  .foot { border-top: 1px solid var(--line); background: var(--surface); }
  .foot-in { max-width: 1120px; margin: 0 auto; padding: 18px 20px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px 24px; flex-wrap: wrap; }
  .foot-links { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
  .foot-links a { text-decoration: none; font-weight: 700; color: var(--ink-2); }
  .foot-links a:hover { color: var(--ink); text-decoration: underline; }
  .foot-brand { color: var(--ink); font-weight: 900; }
  .foot-note { color: var(--muted); font-size: 14px; }

  /* ---------- modal ---------- */
  .backdrop { position: fixed; inset: 0; background: rgba(35,38,43,.55); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
  .modal { background: var(--surface); border-radius: var(--r-panel); padding: 24px; width: 100%; max-width: 400px; border-top: 8px solid var(--c5); }
  .modal h3 { font-size: 22px; font-weight: 900; margin-bottom: 6px; }
  .modal p { color: var(--ink-2); margin-bottom: 20px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
  @keyframes fade { from { opacity: 0; } }

  @media (max-width: 900px) {
    .home { grid-template-columns: 1fr !important; }
    /* on narrow screens: headline, then the start card, then the board */
    .home { gap: 0; padding-top: 32px; }
    .home > section:first-child { display: contents; }
    .home h1 { order: 1; } .home .lede { order: 2; } .home .start { order: 3; } .home .board { order: 4; margin-top: 28px; }
    .tiles, .result-grid { grid-template-columns: 1fr 1fr; }
    .stat.big { grid-column: 1 / -1; grid-row: auto; }
  }
  @media (max-width: 600px) {
    .page { padding: 24px 16px 48px; }
    .bar-in { padding: 0 16px; }
    .mmenu { padding: 4px 16px 16px; }
    .home h1 { font-size: 40px; }
    .lede { font-size: 16px; }
    .start { padding: 18px; }
    .mode { padding: 16px 14px; grid-template-columns: 64px 1fr; }
    .flap.code span { font-size: 17px; }
    .flap.msg span { font-size: 12px; }
    .arena { height: 48vh; min-height: 320px; }
    /* phones: a 3 by 4 dial pad */
    .keypad { grid-template-columns: repeat(3, 1fr); }
    .keypad button { height: 48px; font-size: 24px; }
    .keypad [data-key="0"] { grid-column: 2; }
    .block { font-size: 17px; padding: 8px 12px 5px; }
    .block.num { font-size: 22px; }
    .result h1, .page h1[style] { font-size: 36px !important; }
    .result-grid, .tiles { grid-template-columns: 1fr 1fr; }
    .plate-big b { font-size: 44px; } .plate-big span { font-size: 22px; }
    .def { font-size: 18px; }
    .flipcard { height: 340px; }
    .card-actions .btn { min-width: 0; flex: 1; }
    .dir { grid-template-columns: 1fr; }
    .board-head, .board-row { grid-template-columns: 60px 1fr; }
    .board-head span:last-child, .where { display: none; }
    .rung { grid-template-columns: 64px 1fr; }
    .rung p { grid-column: 2; }
    .log-row { grid-template-columns: 1fr 1fr .6fr; }
    .log-row .hide-sm { display: none; }
    .face .prompt { font-size: 30px; }
  }

  /* ---------- 404 page (404.html) ---------- */
  .lost { max-width: 760px; margin: 0 auto; padding: 40px 20px 72px; text-align: center; }
  .lost h1 { font-size: clamp(36px, 6vw, 56px); margin: 28px 0 12px; }
  .lost .lede { margin: 0 auto; }
  .lost-floor { position: relative; height: 210px; border-radius: var(--r-panel); overflow: hidden; border: 1px solid var(--line); background: linear-gradient(#F4F6F8, #DCE0E5); }
  .lost-floor::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: repeating-linear-gradient(135deg, var(--ink) 0 12px, var(--sign) 12px 24px); }
  .lost-sign { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%) rotate(-4deg); display: inline-flex; align-items: baseline; gap: 14px; background: var(--sign); border-radius: var(--r-sign); padding: 14px 24px 9px; box-shadow: 0 2px 0 rgba(0,0,0,.35); white-space: nowrap; }
  .lost-sign b { font-size: 44px; font-weight: 900; line-height: 1; }
  .lost-sign span { font-size: 26px; font-weight: 800; }
  @media (prefers-reduced-motion: no-preference) {
    .lost-sign { animation: land .9s cubic-bezier(.5, 0, .75, 0) both, settle .35s ease-out .9s both; }
  }
  @keyframes land { from { bottom: 230px; transform: translateX(-50%) rotate(0deg); } to { bottom: 12px; transform: translateX(-50%) rotate(0deg); } }
  @keyframes settle { from { transform: translateX(-50%) rotate(0deg); } 60% { transform: translateX(-50%) rotate(-6deg); } to { transform: translateX(-50%) rotate(-4deg); } }
  .lost-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
  @media (max-width: 600px) {
    .lost-floor { height: 170px; }
    .lost-sign b { font-size: 34px; } .lost-sign span { font-size: 20px; }
  }
