:root {
  --navy: rgba(8, 18, 38, 0.74);
  --navy-solid: #0b1730;
  --navy-2: #12224a;
  --line: rgba(120, 170, 255, 0.28);
  --line-strong: rgba(80, 170, 255, 0.75);
  --text: #eef3ff;
  --muted: #9fb0d0;
  --blue: #2ea8ff;
  --blue-2: #1677ff;
  --green: #3ee07a;
  --red: #ff4d5e;
  --gold: #ffd23f;
  --radius: 12px;
  --mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --sans: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --tamil: 'Noto Sans Tamil', 'Nirmala UI', Latha, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050a16; color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

#stage { position: fixed; inset: 0; z-index: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
#tags { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }

/* speed lines overlay (CSS only) */
#speedlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,0.0) 0deg 4deg, rgba(255,255,255,0.10) 4deg 4.4deg);
  -webkit-mask-image: radial-gradient(ellipse at 50% 55%, transparent 38%, #000 80%);
          mask-image: radial-gradient(ellipse at 50% 55%, transparent 38%, #000 80%);
}

.screen { position: fixed; inset: 0; z-index: 2; display: none; }
.screen.active { display: flex; }

/* ---------------------------------------------------------------- shared */
.panel-glass { background: var(--navy); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.btn {
  border: 1px solid var(--line); background: rgba(20, 40, 80, 0.7); border-radius: 10px; padding: 10px 18px; cursor: pointer;
  font-weight: 600; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--line-strong); background: rgba(30, 60, 120, 0.85); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #34b4ff, #1677ff); border-color: #5cc3ff; color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #4dc0ff, #2a86ff); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.big { padding: 14px 34px; font-size: 1.1rem; }
.btn.danger { background: rgba(120, 20, 35, .6); border-color: rgba(255, 90, 110, .5); color: #ffd0d6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
kbd { background: #1d2c50; border: 1px solid #3b4f80; border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font-family: var(--mono); font-size: .85em; }

.logo { font-family: Orbitron, var(--sans); font-weight: 900; font-size: clamp(2.2rem, 5vw, 3.5rem); letter-spacing: 2px; line-height: 1; font-style: italic;
  background: linear-gradient(180deg, #fff 30%, #b9d6ff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 18px rgba(0,0,0,.6)); }
.logo span { background: linear-gradient(180deg, #5fd0ff, #1677ff); -webkit-background-clip: text; background-clip: text; }
.logo small { display: block; font-family: var(--sans); font-style: normal; font-size: .8rem; letter-spacing: 6px; font-weight: 700; color: #9fc7ff; -webkit-text-fill-color: #9fc7ff; margin-top: 8px; }
.logo.small { font-size: 2.2rem; }

/* ---------------------------------------------------------------- loading */
#screen-loading { align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #10224a 0%, #050a16 70%); }
.loader { text-align: center; }
.spinner { width: 46px; height: 46px; margin: 26px auto 14px; border-radius: 50%; border: 4px solid rgba(46,168,255,.2); border-top-color: var(--blue); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { color: var(--muted); }

/* ---------------------------------------------------------------- menu */
#screen-menu { background: linear-gradient(90deg, rgba(4,10,24,.88) 0%, rgba(4,10,24,.55) 38%, rgba(4,10,24,0) 62%); }
.menu { width: min(480px, 100%); height: 100%; padding: clamp(18px, 5vh, 48px) 16px 20px clamp(16px, 5vw, 64px); display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; margin: clamp(18px, 4vh, 38px) 0 18px; }
.mbtn {
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 18px; border-radius: 10px; cursor: pointer;
  background: var(--navy); border: 1px solid var(--line); font-weight: 600; font-size: 1.02rem; transition: transform .12s, border-color .12s, background .12s;
  backdrop-filter: blur(6px);
}
.mbtn span { width: 22px; text-align: center; opacity: .9; }
.mbtn em { margin-left: auto; font-style: normal; font-size: .78rem; color: #cfe6ff; opacity: .85; }
.mbtn:hover, .mbtn:focus-visible { transform: translateX(4px); border-color: var(--line-strong); background: rgba(20, 50, 110, .8); }
.mbtn.primary { background: linear-gradient(90deg, #1b8cff, #1255c9); border-color: #5cc3ff; font-size: 1.2rem; padding: 15px 18px; }
.mbtn-row { display: flex; gap: 8px; }
.mbtn.small { flex: 1; justify-content: center; font-size: .92rem; padding: 10px; }
.menu-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu-stats div { background: var(--navy); border: 1px solid var(--line); border-radius: 10px; padding: 10px 8px; text-align: center; }
.menu-stats b { display: block; font-size: 1.35rem; color: var(--blue); }
.menu-stats span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.menu-foot { color: var(--muted); font-size: .78rem; margin-top: 12px; }

/* ---------------------------------------------------------------- panels */
#screen-setup, #screen-levels, #screen-howto, #screen-settings { align-items: center; justify-content: center; background: rgba(3, 8, 20, .55); padding: 16px; }
.panel { width: min(640px, 100%); max-height: 100%; overflow-y: auto; background: rgba(9, 19, 40, .9); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.panel.wide { width: min(980px, 100%); }
.panel-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-head > :first-child { justify-self: start; }
.panel-head > :last-child { justify-self: end; }
.panel-head h2 { margin: 0; font-size: 1.35rem; }
h3 { margin: 18px 0 8px; font-size: 1rem; color: #cfe1ff; }

.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.setup-grid fieldset { border: 0; padding: 0; margin: 0; }
.setup-grid legend { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); }
.field input, .field select, .panel-head select {
  background: #0d1b38; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; color: var(--text); font-size: .95rem; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--blue); }
.field input[type=range] { padding: 0; accent-color: var(--blue); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: #0d1b38; font-weight: 600; font-size: .9rem; }
.seg input:checked + span { background: linear-gradient(180deg, #2a9cff, #1660d8); border-color: #6cc8ff; }
.seg input:focus-visible + span { outline: 2px solid var(--blue); }
.local-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.local-names input { background: #0d1b38; border: 2px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--text); }
.row { display: flex; gap: 8px; margin-top: 8px; }
.level-info { background: #0c1a36; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: .9rem; color: #cbd8f2; }
.level-info b { color: #fff; }
.actions { display: flex; justify-content: flex-end; }
[data-show] { display: none; }
[data-show].on { display: flex; }
.field[data-show].on { display: flex; }

.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.lvl {
  position: relative; text-align: left; background: linear-gradient(180deg, #13254d, #0d1a37); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: transform .12s, border-color .12s;
}
.lvl:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--line-strong); }
.lvl:disabled { opacity: .45; cursor: not-allowed; }
.lvl .num { font-family: Orbitron, var(--sans); font-size: 1.5rem; color: var(--blue); }
.lvl .nm { font-weight: 700; }
.lvl .meta { font-size: .76rem; color: var(--muted); }
.lvl .env { font-size: .74rem; color: #9fd0ff; }
.stars i { font-style: normal; color: #34436b; font-size: 1.05rem; }
.stars i.on { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, .45); }

/* garage */
#screen-garage { justify-content: flex-end; padding: 16px; background: linear-gradient(270deg, rgba(4,10,24,.85) 0%, rgba(4,10,24,0) 55%); }
.panel.side { width: min(400px, 100%); align-self: stretch; }
.garage-cars { display: grid; gap: 8px; }
.car-opt { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #0d1b38; cursor: pointer; text-align: left; }
.car-opt.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue) inset; }
.car-opt:disabled { opacity: .5; cursor: not-allowed; }
.car-opt b { display: block; }
.car-opt small { color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); cursor: pointer; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 3px var(--blue); }

.howto { line-height: 1.55; color: #d6e2fa; }
.howto ul { padding-left: 20px; }
.howto .g { color: var(--green); } .howto .b { color: var(--blue); } .howto .r { color: var(--red); }
.settings { display: grid; gap: 14px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 14px; }

/* ---------------------------------------------------------------- race HUD */
.hud-screen { pointer-events: none; }
.hud-screen > * { pointer-events: auto; }
.hud-tl { position: absolute; top: 14px; left: 14px; width: 220px; padding: 10px 10px 8px; }
.hud-pos span { display: block; font-size: .8rem; color: #cfe1ff; font-weight: 600; }
.hud-pos b { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.hud-pos b i { font-style: normal; }
.hud-pos b i + i { color: var(--muted); font-size: 1.5rem; }
.hud-board { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.hud-board li { display: grid; grid-template-columns: 16px 34px 1fr auto; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 7px; background: rgba(10, 24, 50, .75); font-size: .85rem; font-weight: 600; }
.hud-board li.me { background: linear-gradient(90deg, #1b8cff, #1460d6); }
.hud-board li.ghost { opacity: .7; }
.lb-pos { text-align: center; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-detail { font-size: .72rem; color: #cfe1ff; font-family: var(--mono); }
.mini-car { width: 34px; height: 14px; }

.hud-tc { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 16px; }
.hud-tc .flag { width: 30px; height: 30px; color: #fff; }
.hud-tc span { display: block; font-size: .75rem; color: #cfe1ff; }
.hud-tc b { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-tc b.warn { color: var(--red); }
.icon-btn { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: .8rem; }
.icon-btn:hover { border-color: var(--line-strong); }

.hud-tr { position: absolute; top: 14px; right: 14px; display: flex; padding: 8px 4px; }
.hud-tr div { padding: 0 16px; text-align: center; border-right: 1px solid var(--line); }
.hud-tr div:last-child { border-right: 0; }
.hud-tr span { display: block; font-size: .78rem; color: #cfe1ff; font-weight: 600; }
.hud-tr b { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.g { color: var(--green); } .r { color: var(--red); }

.hud-speedo { position: absolute; left: 18px; bottom: 18px; width: clamp(130px, 15vw, 190px); }
.hud-speedo svg { width: 100%; display: block; filter: drop-shadow(0 6px 18px rgba(0,0,0,.5)); }
.sp-bg { fill: rgba(6, 14, 30, .78); stroke: rgba(120,170,255,.35); stroke-width: 2; }
.sp-track { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 10; }
.sp-red { fill: none; stroke: rgba(255, 77, 94, .65); stroke-width: 10; }
.sp-val { fill: none; stroke: var(--blue); stroke-width: 10; filter: drop-shadow(0 0 6px rgba(46,168,255,.8)); transition: stroke-dasharray .08s linear; }
.tk { stroke: rgba(255,255,255,.5); stroke-width: 1.5; } .tk.major { stroke: #fff; stroke-width: 2.5; }
.tl { fill: #dfe9ff; font-size: 12px; text-anchor: middle; font-weight: 600; font-family: var(--sans); }
.sp-needle { stroke: #ff4d5e; stroke-width: 3.5; stroke-linecap: round; }
.sp-hub { fill: #e8eefb; }
.sp-num { fill: #fff; font-size: 34px; font-weight: 800; text-anchor: middle; font-family: var(--sans); font-style: italic; }
.sp-unit { fill: #cfe1ff; font-size: 12px; font-weight: 700; text-anchor: middle; letter-spacing: 1px; font-family: var(--sans); }
.sp-x { fill: rgba(207,225,255,.5); font-size: 9px; text-anchor: middle; font-family: var(--sans); }

.hud-progress { position: absolute; right: 18px; bottom: 18px; width: clamp(150px, 15vw, 200px); padding: 10px 14px 12px; }
.prog-head { display: flex; gap: 10px; align-items: center; }
.prog-head svg { width: 26px; height: 26px; color: #dfe9ff; }
.prog-head span { display: block; font-size: .78rem; color: #cfe1ff; }
.prog-head b { font-size: 1.5rem; font-weight: 800; }
.prog-bar { height: 8px; border-radius: 5px; background: rgba(255,255,255,.12); margin-top: 8px; overflow: hidden; }
.prog-bar div { height: 100%; width: 0; background: linear-gradient(90deg, #1677ff, #3fd0ff); border-radius: 5px; transition: width .2s; }
.hud-progress small { display: block; margin-top: 6px; color: var(--muted); font-size: .75rem; }

.typing { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(820px, calc(100vw - 2 * clamp(170px, 17vw, 230px) - 24px)); display: grid; gap: 8px; }
.typing-text { padding: 10px 18px 8px; }
.sentence {
  font-family: var(--mono); font-size: clamp(1.05rem, 1.7vw, 1.6rem); line-height: 1.55; max-height: calc(1.55em * 2); overflow: hidden;
  word-break: break-word; scroll-behavior: smooth; color: #f2f5fb;
}
.sentence:lang(ta), .sentence[lang=ta] { font-family: var(--tamil); }
.sentence .c { border-radius: 3px; }
.sentence .done { color: var(--green); }
.sentence .pending { color: #f2f5fb; }
.sentence .cw { text-decoration: underline; text-decoration-color: var(--blue); text-decoration-thickness: 3px; text-underline-offset: 7px; }
.sentence .cw.pending { color: #8fd0ff; }
.sentence .current { color: #fff; background: rgba(46, 168, 255, .45); box-shadow: 0 0 0 1px rgba(46,168,255,.7); }
.sentence .error { color: #fff; background: var(--red); }
.sentence .sp.error { background: var(--red); }
.typing-meta { display: block; color: var(--muted); font-size: .72rem; margin-top: 2px; text-align: right; }
.type-input {
  width: 100%; background: rgba(6, 14, 30, .82); border: 2px solid var(--blue); border-radius: 12px; padding: 10px 16px;
  font-family: var(--mono); font-size: clamp(1.05rem, 1.6vw, 1.5rem); color: #fff; outline: none; box-shadow: 0 0 18px rgba(46,168,255,.35);
}
.type-input.has-error { border-color: var(--red); box-shadow: 0 0 18px rgba(255,77,94,.45); }
.type-input:disabled { opacity: .6; }

.countdown { position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%); font-family: Orbitron, var(--sans); font-weight: 900; font-size: clamp(4rem, 14vw, 9rem); color: #fff; text-shadow: 0 6px 30px rgba(0,0,0,.6), 0 0 30px rgba(46,168,255,.6); opacity: 0; pointer-events: none; }
.countdown.show { animation: cd .9s ease-out forwards; }
.countdown.go { color: var(--green); }
@keyframes cd { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }
.hud-banner { position: absolute; top: 92px; left: 50%; transform: translateX(-50%) translateY(-10px); padding: 8px 18px; border-radius: 30px; background: rgba(22, 119, 255, .85); font-weight: 700; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; }
.hud-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.name-tag { position: absolute; left: 0; top: 0; display: flex; align-items: stretch; border-radius: 6px; overflow: hidden; font-size: .82rem; font-weight: 700; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.4); transform-origin: 50% 100%; }
.name-tag b { background: #0b1730; color: #fff; padding: 3px 7px; }
.name-tag span { background: var(--tag); color: #fff; padding: 3px 9px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 6, 16, .6); backdrop-filter: blur(4px); }
.modal-card { width: min(680px, 100%); max-height: 94vh; overflow-y: auto; background: linear-gradient(180deg, #13244b, #0b1630); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.modal-card h2 { margin: 0 0 4px; text-align: center; font-size: 1.6rem; }
.res-status { text-align: center; color: var(--muted); margin: 0 0 12px; }
.res-status.win { color: var(--gold); }
.res-stars { text-align: center; } .res-stars i { font-size: 2rem; }
.res-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.res-grid div { background: #0c1a36; border: 1px solid var(--line); border-radius: 10px; padding: 7px 4px; text-align: center; }
.res-grid b { display: block; font-size: 1.35rem; color: var(--blue); font-variant-numeric: tabular-nums; }
.res-grid span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.res-grid em { display: block; font-style: normal; font-size: .72rem; margin-top: 2px; }
.up { color: var(--green); } .down { color: var(--red); }
.res-msg { text-align: center; padding: 10px; border-radius: 10px; background: rgba(46, 168, 255, .12); margin: 0 0 12px; }
.res-msg.pass { background: rgba(62, 224, 122, .12); color: #c9f7da; }
.res-msg.fail { background: rgba(255, 77, 94, .12); color: #ffd3d8; }
.res-rank { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 5px; }
.res-rank li { display: grid; grid-template-columns: 26px 36px 1fr auto; gap: 8px; align-items: center; background: #0c1a36; border-radius: 8px; padding: 7px 10px; font-weight: 600; }
.res-rank li.me { outline: 1px solid var(--blue); }
.res-rank small { font-family: var(--mono); color: var(--muted); font-weight: 500; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 30; background: #13244b; border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .typing { width: calc(100vw - 24px); bottom: 10px; }
  .hud-speedo { bottom: auto; top: 120px; left: 10px; width: 110px; }
  .hud-progress { bottom: auto; top: 120px; right: 10px; width: 140px; padding: 8px 10px; }
  .hud-progress small { display: none; }
}
@media (max-width: 760px) {
  .hud-tl { top: 8px; left: 8px; width: auto; padding: 6px 10px; }
  .hud-board { display: none; }
  .hud-pos b { font-size: 1.4rem; }
  .hud-tc { top: 8px; padding: 6px 10px; gap: 8px; }
  .hud-tc .flag { display: none; }
  .hud-tc b { font-size: 1.2rem; }
  .hud-tr { top: auto; bottom: auto; top: 62px; right: 8px; padding: 4px 0; }
  .hud-tr div { padding: 0 9px; }
  .hud-tr b { font-size: 1.15rem; }
  .hud-speedo { top: 62px; width: 92px; left: 8px; }
  .hud-progress { display: none; }
  .setup-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .res-grid { grid-template-columns: repeat(2, 1fr); }
  #screen-menu { background: rgba(4,10,24,.72); }
  .menu { margin: 0 auto; }
  .sentence { font-size: 1rem; }
  .type-input { font-size: 1.05rem; padding: 8px 12px; }
}
@media (max-height: 560px) {
  .hud-board li:nth-child(n+4) { display: none; }
  .hud-speedo { width: 100px; }
  .sentence { max-height: 1.55em; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* on-screen keyboard open (phones/tablets): the race fits exactly in the visible area above it */
body.kb-open #stage, body.kb-open #tags, body.kb-open #screen-race { top: var(--vvt, 0px); height: var(--vvh, 100%); bottom: auto; }
body.kb-open .hud-speedo, body.kb-open .hud-progress, body.kb-open .hud-board, body.kb-open .hud-tc .flag, body.kb-open .typing-meta { display: none; }
body.kb-open .hud-tl { top: 6px; left: 6px; padding: 4px 8px; }
body.kb-open .hud-pos span { display: none; }
body.kb-open .hud-pos b { font-size: 1.1rem; }
body.kb-open .hud-tc { top: 6px; left: 64px; transform: none; padding: 4px 8px; gap: 6px; }
body.kb-open .hud-tc span { display: none; }
body.kb-open .hud-tc b { font-size: 1.05rem; }
body.kb-open .hud-tc .icon-btn { width: 28px; height: 28px; }
body.kb-open .hud-tr { top: 6px; right: 6px; padding: 2px 0; }
body.kb-open .hud-tr div { padding: 0 8px; }
body.kb-open .hud-tr span { font-size: .62rem; }
body.kb-open .hud-tr b { font-size: 1rem; }
body.kb-open .hud-banner { top: 46px; }
body.kb-open .typing { bottom: 6px; gap: 4px; width: calc(100vw - 12px); }
body.kb-open .typing-text { padding: 5px 10px 4px; }
body.kb-open .sentence { font-size: .95rem; max-height: calc(1.55em * 2); }
body.kb-open .type-input { padding: 6px 10px; font-size: 1rem; }
@media (max-width: 760px) { .hud-banner { top: 132px; font-size: .85rem; } }
