:root {
  --neon: #ffda58;
  --go: #7de7bd;
  --bad: #ff645d;
  --ink: #101b23;
  --muted: #a0b0b3;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #141e2a; color: #fff4d9; font-family: "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", system-ui, sans-serif; }
button, input, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #8be5d9; outline-offset: 5px; }
#app canvas { display: block; }
.hidden { display: none; }
#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity .2s; }
.menu-open #hud { opacity: 0; }
.hud-mark { position: absolute; top: 22px; left: 24px; width: 48px; filter: drop-shadow(0 4px 12px #0007); }
#time, #money, #speed { font-variant-numeric: tabular-nums; text-shadow: 0 3px 5px #0009; font-weight: 900; }
#time { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-size: 54px; color: var(--neon); line-height: 1.25; min-width: 105px; text-align: center; background: linear-gradient(#101b23e8, #101b2380); border-top: 3px solid var(--neon); border-radius: 2px 2px 14px 14px; padding: 8px 20px 4px; }
#time::before { content: attr(data-label); display: block; font-size: 9px; letter-spacing: 3px; color: #d0d6cc; }
#time.low { color: var(--bad); border-color: var(--bad); }
#money { position: absolute; top: 20px; right: 26px; font-size: 38px; color: var(--go); }
#money::before { content: 'TODAY’S FARES'; display: block; text-align: right; font-size: 9px; font-weight: 700; letter-spacing: 2px; color: #e1dfcf; }
#combo { position: absolute; top: 88px; right: 26px; font-size: 22px; font-weight: 900; color: var(--neon); text-shadow: 2px 2px #132129; }
#fare { position: absolute; top: 125px; left: 50%; transform: translateX(-50%); background: #101b23dc; border-left: 4px solid var(--go); border-radius: 3px; padding: 8px 20px; text-align: center; max-width: 90vw; }
#fare-dest { font-size: 18px; font-weight: 800; }
#fare-time { font-size: 26px; font-weight: 900; color: var(--go); }
#street { position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%); font-size: 16px; font-weight: 700; letter-spacing: 2px; padding: 8px 18px; border-left: 3px solid var(--neon); background: #101b23d9; white-space: nowrap; }
#street:empty { display: none; }
#speed { position: absolute; bottom: 30px; right: 28px; font-size: 52px; }
#speed small { font-size: 13px; letter-spacing: 1px; color: #d1d9d5; }
#minimap { position: absolute; bottom: 28px; left: 24px; width: 180px; height: 180px; border-radius: 50%; border: 3px solid #b8c7bd70; box-shadow: 0 5px 30px #0005; }
.drive-hint { position: absolute; bottom: 18px; width: 100%; text-align: center; color: #f1e4c8; font-size: 10px; letter-spacing: 1px; text-shadow: 0 1px 3px #000; }
.drive-hint span { color: #b6c9ca; font-size: 9px; margin-right: 8px; }
#msg { position: absolute; top: 37%; left: 50%; transform: translate(-50%, -50%) scale(.6); font-size: 46px; font-weight: 900; text-align: center; white-space: nowrap; text-shadow: 0 0 16px currentColor, 3px 3px #111c26; opacity: 0; transition: opacity .2s, transform .2s; }
#msg small { font-size: 22px; }
#msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#overlay { position: fixed; inset: 0; display: grid; grid-template-rows: minmax(min-content, 1fr) auto; row-gap: 24px; align-items: center; padding: 94px clamp(32px, 6vw, 100px) 18px; overflow-y: auto; isolation: isolate; }
#overlay::before { content: ''; position: fixed; inset: 0; z-index: -2; background: #14242a url('assets/art/mongkok-manhua.png') 60% center / cover no-repeat; }
#overlay::after { content: ''; position: fixed; inset: 0; z-index: -1; background: linear-gradient(90deg, #0b171cf7 0%, #0b171ce6 25%, #0b171c7a 52%, #0b171c05 82%), linear-gradient(0deg, #0b171cec 0%, transparent 28%, transparent 80%, #0b171c80); }
#overlay.hidden { display: none; }
.menu-rail { position: absolute; left: clamp(32px, 6vw, 100px); right: clamp(32px, 6vw, 100px); top: 27px; display: flex; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid #f0dfb529; font-size: 9px; font-weight: 600; letter-spacing: 2px; color: #d8d9c7; }
.menu-rail i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--neon); margin: 0 9px 1px 0; box-shadow: 0 0 10px #ffda5855; }
.menu-content { width: min(500px, 100%); position: relative; }
.edition { display: flex; align-items: center; gap: 20px; font-size: 9px; font-weight: 700; letter-spacing: 2.5px; color: #c2ccc6; margin-bottom: 16px; }
.edition span:first-child { color: var(--neon); }
.edition span + span { border-left: 1px solid #8b9f9d70; padding-left: 20px; }
#overlay h1 { margin: 0 0 16px -10px; line-height: 0; }
.game-logo { width: min(100%, 485px); height: auto; filter: drop-shadow(0 7px 24px #0004); }
#overlay h2 { font-size: 12px; font-weight: 800; letter-spacing: 4px; margin: 10px 0 12px; }
#overlay p { font-size: 14px; line-height: 1.8; margin: 10px 0; }
#overlay-text { color: #b6c8c4; min-height: 26px; }
#panel-title { max-width: 420px; }
.modes { display: flex; gap: 10px; flex-wrap: wrap; margin: 25px 0 20px; }
.modes button { display: flex; flex: 1; gap: 14px; align-items: center; text-align: left; cursor: pointer; border: 1px solid #d6d6b840; border-radius: 3px; background: #14252bc7; color: #fff1d3; padding: 15px 17px; font: inherit; font-size: 16px; font-weight: 800; transition: background .15s, transform .15s; }
.modes button.primary { background: var(--neon); color: #18232a; border-color: var(--neon); box-shadow: 0 5px 24px #ffda5816; }
.modes button small { display: block; font-size: 8px; margin-top: 3px; letter-spacing: 1.4px; font-weight: 800; }
.mode-number { font-size: 11px; opacity: .5; align-self: flex-start; margin-top: 3px; }
.button-arrow { margin-left: auto; font-size: 23px; font-weight: 400; }
.modes button:hover:not(:disabled) { background: #2e4147; transform: translateY(-2px); }
.modes button.primary:hover:not(:disabled) { background: #ffe991; }
button:disabled { opacity: .4; cursor: wait; }
.scene-picker { display: flex; align-items: center; gap: 7px; border-top: 1px solid #f0dfb51f; padding-top: 17px; }
.scene-picker > span { font-size: 8px; letter-spacing: 1.6px; margin-right: auto; color: #95aaa8; }
.scene-picker button { cursor: pointer; color: #bbc8c0; border: 1px solid transparent; background: transparent; font: inherit; font-size: 11px; padding: 6px 8px; border-radius: 2px; }
.scene-picker button small { font-size: 8px; margin-left: 4px; opacity: .6; }
.scene-picker button[aria-pressed="true"] { border-color: #d6c58360; color: var(--neon); background: #fadd5f0a; }
.controls { margin: 17px 0 0; border-bottom: 1px solid #f0dfb51f; padding: 0 0 14px; }
.controls summary { font-size: 9px; letter-spacing: 1.8px; cursor: pointer; color: #b1c1ba; list-style: none; display: flex; justify-content: space-between; }
.controls summary::-webkit-details-marker { display: none; }
.controls summary span { font-size: 10px; letter-spacing: 1px; color: #738e8e; }
.keys { margin: 13px 0 0; border-collapse: collapse; font-size: 11px; color: #b7c9c4; width: 100%; }
.keys td { padding: 3px 0; text-align: left; }
.keys td:first-child { font-weight: 800; color: var(--neon); width: 115px; }
#overlay .start { color: #809995; font-size: 10px; letter-spacing: 1px; margin: 17px 0 0; }
#overlay #credits { position: static; color: #849998; font-size: 9px; line-height: 1.6; max-width: 820px; margin: 0; }
.scene-caption { position: absolute; right: 6vw; bottom: 86px; display: flex; align-items: center; gap: 12px; font-size: 11px; letter-spacing: 2px; text-shadow: 0 1px 5px #0009; }
.caption-line { width: 36px; height: 1px; background: var(--neon); }
.scene-caption small { display: block; font-size: 8px; letter-spacing: 1.5px; margin-top: 7px; color: #c0cfca; }
#panel-join { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; width: min(380px, 100%); }
#panel-join.hidden, #panel-title.hidden, #panel-lobby.hidden { display: none; }
#panel-join label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 700; color: #b5c7c1; }
#panel-join input { font: inherit; font-size: 18px; padding: 12px; border-radius: 3px; border: 1px solid #bac8bc50; background: #0c1b20e6; color: #fff2d3; width: 100%; }
#panel-join input::placeholder { font-size: 11px; color: #809993; }
#join-room { text-transform: uppercase; }
#join-error { color: var(--bad); min-height: 1.4em; }
#panel-lobby { width: min(500px, 100%); }
#panel-lobby .room { font-size: 16px; }
#panel-lobby .room b { font-size: 30px; letter-spacing: 6px; color: var(--neon); margin: 0 8px; }
#panel-lobby .room small { display: block; font-size: 11px; opacity: .7; }
.team-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.team-lists h3 { margin: 0 0 8px; font-size: 14px; }
.team-lists ul { list-style: none; margin: 0; padding: 0; min-height: 60px; }
.team-lists li { padding: 7px 10px; border-radius: 3px; background: #c3d9cb0a; margin-bottom: 5px; font-size: 13px; }
.team-lists li.me { outline: 1px solid var(--neon); }
.red { color: var(--bad); }
.green { color: var(--go); }
#lobby-status { font-size: 18px; font-weight: 800; color: var(--neon); }
#overlay p.hint { font-size: 11px; color: #a1b6af; }
#teams { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); font-size: 20px; font-weight: 900; text-shadow: 2px 2px #11232a; white-space: nowrap; }
#teams.hidden { display: none; }
#feed { position: absolute; top: 84px; left: 24px; margin: 0; padding: 0; list-style: none; font-size: 12px; font-weight: 700; max-width: 35vw; }
#feed li { background: #101b23cb; padding: 5px 10px; border-radius: 3px; margin-bottom: 5px; }
@media (min-width: 1100px) { #overlay .modes { flex-direction: column; } #panel-title .modes button { min-height: 70px; } #panel-title .modes button span:nth-child(2) { display: flex; align-items: center; gap: 14px; } #panel-title .modes button small { margin: 0; } }
@media (max-height: 820px) and (min-width: 700px) { #overlay { padding-top: 85px; } .game-logo { width: 365px; } #overlay h1 { margin-bottom: 8px; } .edition { margin-bottom: 5px; } #overlay h2 { margin-top: 5px; } .modes { margin: 16px 0; } #panel-title .modes button { min-height: 55px; padding-top: 10px; padding-bottom: 10px; } }
@media (max-width: 700px) {
  #overlay { padding: 100px 27px 18px; align-items: center; }
  #overlay::before { background-position: 68% center; }
  #overlay::after { background: linear-gradient(90deg, #0b171ce0, #0b171c88), linear-gradient(0deg, #0b171cf5, #0b171c2e 90%); }
  .menu-rail { left: 27px; right: 27px; font-size: 8px; letter-spacing: 1px; }
  .menu-rail span:last-child { display: none; }
  .menu-content { margin: auto 0; }
  .edition { font-size: 8px; gap: 15px; letter-spacing: 1.7px; }
  .edition span + span { padding-left: 15px; }
  #overlay h2 { font-size: 10px; letter-spacing: 2.6px; }
  #overlay p { font-size: 12px; }
  .game-logo { width: 100%; }
  .modes { flex-direction: column; margin-top: 22px; }
  .modes button { padding: 14px 16px; gap: 18px; }
  .modes button span:nth-child(2) { display: flex; align-items: center; gap: 14px; }
  .modes button small { margin-top: 0; }
  .scene-picker > span { font-size: 7px; }
  .scene-picker button { font-size: 10px; padding: 5px; }
  .scene-picker button small { font-size: 7px; margin-left: 2px; }
  #overlay #credits { font-size: 8px; }
  .scene-caption { display: none; }
  #time { font-size: 36px; top: 15px; min-width: 80px; padding: 8px 12px 4px; }
  #money { font-size: 28px; right: 16px; }
  #money::before { font-size: 7px; letter-spacing: 1px; }
  .hud-mark { left: 17px; width: 38px; }
  #combo { right: 16px; font-size: 16px; }
  #minimap { width: 120px; height: 120px; left: 16px; bottom: 20px; }
  #speed { right: 17px; bottom: 20px; font-size: 38px; }
  #street { bottom: 155px; font-size: 13px; }
  .drive-hint { display: none; }
  #msg { font-size: 30px; }
  #msg small { font-size: 15px; }
  #fare-dest { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

/* Arcade controls remain outside the HUD so they work on the title screen too. */
#app { position: fixed; inset: 0; width: 100%; height: 100%; }
#app canvas { width: 100%; height: 100%; }
#btn-fullscreen { position: fixed; right: 24px; bottom: 105px; z-index: 20; border: 1px solid #ffe17480; border-radius: 4px; background: #14232cdd; color: #ffdf65; padding: 9px 12px; font: 700 20px system-ui; cursor: pointer; }
#btn-fullscreen span { font-size: 9px; letter-spacing: 1px; vertical-align: 3px; }
.menu-open #btn-fullscreen { top: 19px; bottom: auto; }
.menu-open .menu-rail > span:last-child { margin-right: 330px; }
@media(max-width:1000px) { .menu-open .menu-rail > span:last-child { display: none; } }
#display-note { position: fixed; z-index: 30; left: 50%; bottom: 30px; transform: translate(-50%, 15px); width: min(540px, 90vw); padding: 14px 20px; color: #ffe8a3; background: #101c29f2; border: 1px solid #ffe17480; border-radius: 6px; font-size: 14px; line-height: 1.6; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#display-note.show { opacity: 1; transform: translate(-50%, 0); }
#navigation-caption { position: absolute; left: 24px; bottom: 10px; width: 210px; text-align: center; font-size: 11px; color: #fff4c4; font-weight: 900; letter-spacing: 1px; text-shadow: 1px 2px 2px #000; }
#minimap { width: 210px; height: 210px; bottom: 34px; border: 3px solid #ffe373; }
#reward-time, #reward-money { position: absolute; top: 115px; font-size: 23px; font-style: italic; font-weight: 900; color: #7dff69; -webkit-text-stroke: 1px #152b23; text-shadow: 2px 3px #10232e; opacity: 0; transform: translateY(10px) scale(.8); transition: opacity .15s, transform .2s; }
#reward-time { left: 30px; }
#reward-money { right: 28px; color: #ffe269; }
#reward-time.show, #reward-money.show { opacity: 1; transform: translateY(0) scale(1); }
#time.bonus, #money.bonus { filter: drop-shadow(0 0 15px #a0ff64); }
body[data-look="arcade"] { --go: #77ff63; }
body[data-look="arcade"] #time { left: 30px; top: 18px; transform: none; font-size: 78px; font-style: italic; border: none; padding: 0; background: none; line-height: 1; -webkit-text-stroke: 2px #202730; text-shadow: 3px 5px #a12e22, 0 0 2px #151b25; }
body[data-look="arcade"] #time::before { font-style: normal; -webkit-text-stroke: 0; color: #ffe567; font-size: 13px; letter-spacing: 2px; text-shadow: 2px 2px #0c1927; }
body[data-look="arcade"] .hud-mark { display: none; }
body[data-look="arcade"] #money { font-size: 52px; font-style: italic; -webkit-text-stroke: 1px #1c2927; text-shadow: 3px 4px #14232d; }
body[data-look="arcade"] #money::before { -webkit-text-stroke: 0; font-style: normal; font-size: 11px; }
body[data-look="arcade"] #msg { font-style: italic; -webkit-text-stroke: 1px #101923; }
@media(max-width:700px) {
  #btn-fullscreen { right: 16px; bottom: 90px; padding: 7px 9px; }
  .menu-open #btn-fullscreen { top: 19px; right: 20px; }
  .menu-open #btn-fullscreen span { display: none; }
  .scene-picker { gap: 3px; }
  .scene-picker > span { display: none; }
  .scene-picker button { flex: 1; }
  #minimap { width: 140px; height: 140px; bottom: 33px; }
  #navigation-caption { left: 13px; width: 146px; font-size: 8px; bottom: 12px; }
  body[data-look="arcade"] #time { font-size: 52px; left: 17px; top: 20px; }
  body[data-look="arcade"] #time::before { font-size: 9px; }
  body[data-look="arcade"] #money { font-size: 32px; }
  body[data-look="arcade"] #money::before { font-size: 8px; }
  #reward-time, #reward-money { top: 92px; font-size: 16px; }
  #reward-time { left: 18px; }
  #reward-money { right: 17px; }
}
:fullscreen, :fullscreen body { width: 100vw; height: 100vh; }

#btn-preview { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 0 15px; margin-top: -7px; border: 0; background: transparent; color: #dfc976; font: 700 11px system-ui; cursor: pointer; }
#btn-preview span { font-size: 8px; letter-spacing: 1px; color: #91b5a6; }
@media(max-width:900px) { .drive-hint { display: none; } }
/* Navigation sits above the road; the clock and takings occupy the two corners. */
#time { left: 24px; transform: none; }
.hud-mark { display: none; }
#fare { top: 168px; }
#panel-over.hidden { display: none; }
#overlay.is-results .game-logo { width: 280px; }
#overlay.is-results .edition, #overlay.is-results h2 { display: none; }
.results-kicker { color: #e5b96a; font-size: 10px; letter-spacing: 3px; margin: 25px 0 8px; }
#results-title { font: italic 900 clamp(38px,6vw,66px)/1 system-ui,sans-serif; letter-spacing: -2px; color: #ffe160; text-shadow: 4px 4px #a1352a; margin: 0 0 20px; }
#overlay #results-record { color: #9ee7af; font-size: 12px; }
.results-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 22px 0; border-top: 1px solid #e2cd6b50; border-bottom: 1px solid #e2cd6b50; margin-top: 20px; }
.results-scores span { display: block; font-size: 8px; letter-spacing: 1px; color: #a9bfb1; }
.results-scores strong { display: block; font-size: 42px; font-style: italic; color: #ffdd58; margin-top: 7px; }
.results-scores > div + div strong { color: #9ce1ae; }
#panel-over .modes { margin-top: 22px; }
@media(max-width:700px) { #fare { top: 165px; } #time { left: 16px; } #overlay.is-results .game-logo { width: 230px; } .results-scores { gap: 12px; } .results-scores strong { font-size: 34px; } }

/* ---------- touch controls (phones / tablets, only while driving) ---------- */
#touch-controls { position: fixed; inset: 0; z-index: 30; pointer-events: none; display: none; user-select: none; -webkit-user-select: none; }
#touch-controls.show { display: block; }
body.touch-driving { touch-action: none; overscroll-behavior: none; }
body.touch-driving .drive-hint { display: none; }

/* Left half: the joystick appears wherever the thumb lands. */
.stick-zone { position: absolute; left: 0; bottom: 0; width: 48%; height: 62%; pointer-events: auto; touch-action: none; }
.stick-base {
  position: absolute; left: 22%; top: 62%; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0 55%, rgba(255,255,255,.04) 56%);
  border: 2px solid rgba(255,255,255,.35); opacity: .45; transition: opacity .15s;
}
.stick-base.active { opacity: 1; }
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c8, #ffd23a 55%, #c99a00);
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}

/* Right side: pedals and buttons, sized for thumbs. */
.pedals {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(3, auto); grid-template-areas: "cam horn ." "drift brake gas";
  gap: 12px; align-items: end; pointer-events: auto;
}
.pad-btn {
  touch-action: none; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); color: #fff;
  font: 900 26px/1 "PingFang HK", "Noto Sans HK", system-ui, sans-serif; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; background: rgba(13,15,26,.55); backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
}
.pad-btn small { font-size: 10px; letter-spacing: .08em; opacity: .85; }
.pad-btn.down { transform: scale(.92); filter: brightness(1.4); }
.pad-btn.gas { grid-area: gas; width: 96px; height: 96px; background: rgba(57,255,106,.32); border-color: #39ff6a; }
.pad-btn.brake { grid-area: brake; width: 78px; height: 78px; background: rgba(255,77,77,.3); border-color: #ff4d4d; }
.pad-btn.drift { grid-area: drift; width: 70px; height: 70px; background: rgba(255,138,240,.28); border-color: #ff8af0; }
.pad-btn.small { width: 52px; height: 52px; font-size: 16px; }
.pad-btn[data-action="camera"] { grid-area: cam; }
.pad-btn[data-action="horn"] { grid-area: horn; }

@media (max-height: 420px) { /* phones held sideways */
  .pad-btn.gas { width: 80px; height: 80px; }
  .pad-btn.brake { width: 64px; height: 64px; }
  .pad-btn.drift { width: 58px; height: 58px; }
}
.lobby-actions button { font-size: 16px; }

/* While driving on a touch screen, keep the HUD clear of both thumbs. */
body.touch-driving #btn-audio, body.touch-driving #btn-fullscreen {
  top: auto; left: auto; right: max(12px, env(safe-area-inset-right)); padding: 6px 9px; min-height: 0;
}
body.touch-driving #btn-audio { bottom: auto; top: 96px; }
body.touch-driving #btn-fullscreen { bottom: auto; top: 140px; }
body.touch-driving #btn-audio .audio-button-text, body.touch-driving #btn-fullscreen span { display: none; }
body.touch-driving #speed { right: auto; left: 50%; bottom: 6px; transform: translateX(-50%); font-size: 30px; }
body.touch-driving #street { bottom: 46px; }
body.touch-driving #minimap { width: 112px; height: 112px; left: 12px; top: 96px; bottom: auto; }

/* ---------- install as an app (PWA) ---------- */
.install-btn {
  margin-top: 12px; padding: 9px 16px; border-radius: 999px; border: 1px solid #ffe17499; cursor: pointer;
  background: #14232ccc; color: #ffdf65; font: 800 15px "PingFang HK", "Noto Sans HK", system-ui, sans-serif;
}
.install-btn small { font-size: 10px; letter-spacing: .08em; opacity: .8; margin-left: 6px; }
.install-btn[hidden], .install-tip[hidden] { display: none; }
.install-tip { max-width: 420px; margin: 10px auto 0; font-size: 14px; line-height: 1.5; background: #101b23e6; border-left: 3px solid #ffdf65; padding: 10px 14px; text-align: left; }
.install-tip small { opacity: .75; }
/* Running as an installed full-screen app: the browser fullscreen button isn't needed. */
.installed-app #btn-fullscreen { display: none; }
@media (display-mode: fullscreen), (display-mode: standalone) { #btn-fullscreen { display: none; } }

/* ---------- phones: notch / Dynamic Island, and landscape only ---------- */
/* Keep the HUD inside the safe area so the notch or Dynamic Island never covers it. */
#hud {
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.stick-zone { left: env(safe-area-inset-left); }
body.touch-driving #minimap { left: calc(12px + env(safe-area-inset-left)); }

#rotate-hint {
  position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: #111c24; color: #ffdf65; text-align: center;
  font: 900 26px/1.3 "PingFang HK", "Noto Sans HK", system-ui, sans-serif;
}
#rotate-hint small { font-size: 13px; letter-spacing: .15em; color: #d1d9d5; }
.rotate-phone {
  width: 54px; height: 92px; border: 4px solid #ffdf65; border-radius: 12px; position: relative;
  animation: rotate-phone 1.8s ease-in-out infinite;
}
.rotate-phone::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 4px; margin-left: -7px; border-radius: 2px; background: #ffdf65; }
@keyframes rotate-phone { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
/* Touch screens in portrait: the game is landscape only. */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint { display: flex; }
}

/* Touch driving on a phone: keep the road ahead and the taxi clear of HUD boxes. */
body.touch-driving #fare {
  top: 4px; bottom: auto; left: 50%; transform: translateX(-50%); padding: 3px 12px; min-width: 0; max-width: 46vw;
  display: flex; align-items: baseline; gap: 10px; white-space: nowrap; background: #101b23cc;
}
body.touch-driving #fare-dest { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
body.touch-driving #fare-time { font-size: 18px; }
body.touch-driving #street { display: none; }
body.touch-driving #speed { left: 34%; bottom: 4px; transform: none; font-size: 24px; }
body.touch-driving #msg { font-size: 26px; top: 26%; }
body.touch-driving #msg small { font-size: 13px; }
.pedals { grid-template-areas: "cam horn eject" "drift brake gas"; }
.pad-btn.eject { grid-area: eject; background: rgba(255,176,32,.32); border-color: #ffb020; font-size: 15px; }
.pad-btn.eject[hidden] { display: none; }

/* ---------- tutorial coach, levels, credits line ---------- */
.modes-secondary { margin-top: -10px; }
.modes-secondary button { padding: 11px 15px; font-size: 14px; }
#panel-levels.hidden { display: none; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.level-card {
  text-align: left; cursor: pointer; border: 1px solid #d6d6b840; border-radius: 4px; background: #14252bc7; color: #fff1d3;
  padding: 12px 14px; font: inherit; display: flex; flex-direction: column; gap: 4px;
}
.level-card:hover:not(:disabled) { background: #2e4147; }
.level-card:disabled { opacity: .45; cursor: not-allowed; }
.level-card .lv-num { font-size: 10px; letter-spacing: 2px; color: #e5b96a; }
.level-card .lv-name { font-size: 17px; font-weight: 900; }
.level-card .lv-brief { font-size: 12px; color: #c9d4cd; }
.level-card .lv-stars { font-size: 15px; letter-spacing: 2px; color: #ffdd58; }
#coach {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(460px, 70vw);
  background: #101b23e6; border-left: 4px solid var(--neon); border-radius: 4px; padding: 10px 16px 12px; text-align: center;
  pointer-events: none; box-shadow: 0 6px 24px #0006;
}
#coach[hidden] { display: none; }
#coach.pop { animation: coach-pop .35s ease-out; }
@keyframes coach-pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.coach-label { font-size: 10px; letter-spacing: 2px; color: #e5b96a; }
.coach-text { font-size: 19px; font-weight: 900; margin-top: 3px; }
.coach-en { font-size: 11px; color: #c9d4cd; margin-top: 2px; }
.coach-hint { font-size: 13px; font-weight: 800; color: var(--neon); margin-top: 5px; }
.coach-hint:empty, .coach-skip:empty, .coach-en:empty { display: none; }
.coach-bar { height: 4px; background: #ffffff20; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.coach-bar i { display: block; height: 100%; width: 0; background: var(--neon); transition: width .3s; }
.coach-skip { font-size: 10px; color: #a9bfb1; margin-top: 6px; letter-spacing: 1px; }
body.touch-driving #coach { top: 30px; width: min(380px, 52vw); padding: 6px 12px 8px; }
body.touch-driving .coach-text { font-size: 15px; }
body.touch-driving .coach-en { display: none; }
#overlay .powered-by { position: static; font-size: 10px; letter-spacing: 1px; color: #c9d4cd; margin: 4px 0 0; }
#overlay .powered-by b { color: #ffdd58; }

/* Phones: stack the top-centre messages (destination, tutorial, passenger line) without overlap. */
#coach .coach-skip { pointer-events: auto; cursor: pointer; }
body.touch-driving #coach {
  top: 36px; width: auto; max-width: 56vw; padding: 4px 12px 5px; display: grid;
  grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; text-align: left;
}
body.touch-driving .coach-label, body.touch-driving .coach-en { display: none; }
body.touch-driving .coach-text { font-size: 14px; margin: 0; grid-column: 1; }
body.touch-driving .coach-hint { font-size: 11px; margin: 0; grid-column: 1; }
body.touch-driving .coach-skip { grid-column: 2; grid-row: 1 / span 2; margin: 0; font-size: 11px; padding: 6px 8px; border: 1px solid #ffffff40; border-radius: 4px; }
body.touch-driving .coach-skip:empty { display: none; }
body.touch-driving .coach-bar { grid-column: 1 / -1; margin-top: 4px; height: 3px; }
body.touch-driving #npc-street-subtitle {
  bottom: auto !important; top: 96px !important; font-size: 12px !important; padding: 4px 10px !important; max-width: 50vw !important;
}
body.touch-driving #msg { top: 42%; }
body.touch-driving #reward-time { top: 40px; left: calc(130px + env(safe-area-inset-left)); font-size: 18px; }
body.touch-driving #reward-money { top: 96px; font-size: 18px; }
body.touch-driving #msg { top: 54%; font-size: 22px; }
body.touch-driving #reward-time { left: auto; right: calc(64px + env(safe-area-inset-right)); top: 66px; }
body.touch-driving #reward-money { right: calc(64px + env(safe-area-inset-right)); top: 88px; }

/* ---------- results: leaderboard and sharing ---------- */
#results-social { margin-top: 14px; }
.board-form { display: flex; gap: 8px; }
.board-form[hidden] { display: none; }
.board-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 9px 12px; border-radius: 4px;
  border: 1px solid #d6d6b860; background: #0d171ccc; color: #fff1d3;
}
.board-form button, .share-row button {
  font: inherit; font-size: 13px; font-weight: 800; padding: 9px 13px; border-radius: 4px; cursor: pointer;
  border: 1px solid #ffdd5899; background: #14252bd9; color: #ffdd58;
}
.board-form button:disabled { opacity: .5; cursor: default; }
.board-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 190px; overflow-y: auto; font-size: 14px; }
.board-list:empty { display: none; }
.board-list li { display: flex; gap: 10px; padding: 4px 8px; border-bottom: 1px solid #ffffff12; }
.board-list li b { width: 2.2em; color: #e5b96a; }
.board-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li strong { color: #ffdd58; }
.board-list li.me { background: #ffdd5826; outline: 1px solid #ffdd5880; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.share-row span { font-size: 10px; letter-spacing: 1.5px; color: #a9bfb1; margin-right: 4px; }
