/* Macau Simulator. Warm, clean casual-game UI, in the key of the world
 * the game draws: a cream paper, a soft teal sea and one warm accent. */
:root {
  --ink: #26304a;
  --ink-soft: #5a6278;
  --cream: #fff8ef;
  --panel: rgba(255, 249, 241, 0.90);
  --panel-edge: rgba(255, 255, 255, 0.7);
  --shadow: 0 10px 30px rgba(40, 24, 70, 0.28);
  --accent: #1f7fc4;
  --teal: #17a39c;
  --warm: #f29b4b;
  --good: #3cb371;
  --mid: #f0b443;
  --bad: #e2574c;
  --radius: 16px;
  --paper: #f4efe6;
  --amber: #f0a850;
  --void: #06070a;
  --ease: cubic-bezier(.22,.61,.24,1);
  --pad: max(26px, env(safe-area-inset-left));
  --font: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Hiragino Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--void); }
body { font-family: var(--font); color: var(--ink); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.label { font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); }
kbd { font-family: inherit; font-size: 11px; background: #fff; border-radius: 5px; padding: 1px 6px; box-shadow: 0 1px 0 rgba(0,0,0,.2); color: var(--ink); margin-right: 2px; }
.credits { font-size: 10.5px; color: var(--ink-soft); margin: 4px 0 0; }

/* ---------- full screen overlays ---------- */
.screen, .overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 20; pointer-events: none;
}
.screen { background: radial-gradient(120% 90% at 30% 20%, rgba(255, 170, 120, .18), rgba(30, 22, 60, .55) 60%, rgba(18, 14, 40, .75)); }
.overlay { background: radial-gradient(120% 90% at 30% 20%, rgba(255, 170, 120, .10), rgba(20, 15, 44, .42) 65%, rgba(14, 10, 34, .58)); }
.card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 22px; box-shadow: var(--shadow);
  padding: 22px 24px; width: 100%; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
}
.card h2 { margin: 2px 0 2px; font-size: 24px; font-weight: 800; }
.pt { margin: 0; color: var(--accent); font-weight: 700; font-size: 13px; }
.card .intro { font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; margin: 6px 0 12px; }
.small-card { max-width: 340px; text-align: center; }
.results-card { max-width: 520px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 13px; border: 0; border-radius: 12px; padding: 10px 15px; cursor: pointer;
  background: var(--panel); color: var(--ink); box-shadow: 0 2px 0 rgba(38,48,74,.12), 0 6px 14px rgba(20,14,44,.22);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .08s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .round:focus-visible, .mode:focus-visible, .chip:focus-visible { outline: 3px solid var(--warm); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #2f97da, #1f7fc4); color: #fff; }
.btn.ats { background: linear-gradient(180deg, #23b3ab, #118880); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.55); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.vertical { flex-direction: column; }

/* ============ the boot: the loading screen and the menu ============
 *
 * One still of the city - six of them in all - and the menu grows out of the
 * same corner the loading screen wrote in, so the picture never cuts.  The
 * stills are renders of the menu's own cameras (assets/menu/60_menu_*.jpg), which is
 * why the hand-over to the live 3D is a cross-fade and not a jump.
 */
#bg { position: absolute; inset: 0; overflow: hidden; z-index: 12; pointer-events: none; transition: opacity .9s ease; }
/* the hand-over: the stills go, the live 3D that was rendered behind them stays */
body.in-menu #bg { opacity: 0; }
/* the picture and its dress are the boot's and the menu's.  A running mode has
 * the whole screen: the scrims would sit on top of the game as a dark band
 * along the bottom, and the grade's vignette over the whole view. */
body.playing #bg,
body.playing .grade,
body.playing .scrim,
body.playing .scrim-menu,
body.playing .grain,
body.playing .flash { display: none; }
.shot { position: absolute; inset: 0; opacity: 0; transition: opacity 1.05s var(--ease); }
.shot.on { opacity: 1; }
.shot .img {
  position: absolute; inset: -7%;
  background-size: cover; background-position: 50% 48%; background-repeat: no-repeat;
  filter: saturate(.86) contrast(1.08) brightness(.92);
  animation: drift 26s ease-in-out infinite alternate;
  will-change: transform;
}
/* one endless push: it never restarts, so a change of still is a change of
 * photograph, not a change of speed */
@keyframes drift {
  from { transform: scale(1.03) translate3d(.6%, .4%, 0); }
  to   { transform: scale(1.10) translate3d(-1.1%, -.8%, 0); }
}
.grade {
  position: absolute; inset: 0; z-index: 13; pointer-events: none;
  background:
    radial-gradient(122% 86% at 50% 40%, rgba(0,0,0,0) 34%, rgba(6,7,10,.54) 100%),
    linear-gradient(202deg, rgba(255,196,130,.13) 0%, rgba(96,148,196,.10) 52%, rgba(8,10,18,.24) 100%);
}
/* the scrim of the loading screen: the picture dissolves into the black */
.scrim {
  position: absolute; inset: 0; z-index: 13; pointer-events: none;
  background: linear-gradient(to top, rgba(6,7,10,.95) 0%, rgba(6,7,10,.74) 11%, rgba(6,7,10,.20) 29%, rgba(6,7,10,0) 45%);
}
/* the scrim of the menu: the same, plus a left side for the column */
.scrim-menu {
  position: absolute; inset: 0; z-index: 13; pointer-events: none; opacity: 0;
  transition: opacity .9s ease;
  background:
    linear-gradient(90deg, rgba(6,7,10,.80) 0%, rgba(6,7,10,.46) 32%, rgba(6,7,10,0) 62%),
    linear-gradient(to top, rgba(6,7,10,.94) 0%, rgba(6,7,10,.60) 24%, rgba(6,7,10,0) 58%);
}
body.in-menu .scrim-menu { opacity: 1; }
/* the grain moves its own tile, never its box: an oversized element here is
 * what made the page 100 px wider than the window */
.grain {
  position: absolute; inset: 0; z-index: 14; pointer-events: none; opacity: .055; mix-blend-mode: overlay;
  background-repeat: repeat;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='.6'/></svg>");
  animation: grain 1.1s steps(1, end) infinite;
}
@keyframes grain {
  0%   { background-position: 0 0; }
  33%  { background-position: -37px 23px; }
  66%  { background-position: 19px -31px; }
  100% { background-position: 0 0; }
}
.flash { position: absolute; inset: 0; z-index: 14; pointer-events: none; background: #fff; opacity: 0; transition: opacity .4s ease; }
.flash.hit { opacity: .035; transition: opacity .05s linear; }

/* the stills keep their crossfade (a fade is not a camera move); the push, the
 * grain and the shutter go when the system asks for less motion */
body.motion-off .shot .img { animation: none; transform: scale(1.03); }
body.motion-off .grain { animation: none; }
body.motion-off .flash { display: none; }

/* ---------- the loading screen ---------- */
#loading { position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 1; transition: opacity .45s ease; }
body.in-menu #loading { opacity: 0; }
/* the same screen over the circuit that is being built: the type of the
   boot, over the scene of the race, with the bar on the real progress */
#loading.build { background: rgba(9, 11, 15, .78); }
.id {
  position: absolute; left: var(--pad);
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 20px));
}
.kicker {
  margin: 0 0 10px; font-size: 10px; font-weight: 600; letter-spacing: .4em;
  text-transform: uppercase; color: rgba(244,239,230,.5);
}
.id h1, .brand h1 {
  margin: 0; font-size: clamp(26px, 3.4vw, 38px); line-height: 1; font-weight: 900;
  letter-spacing: -.015em; color: #f6f1e7; text-shadow: 0 2px 30px rgba(0,0,0,.45);
}
.id h1 { margin-bottom: 14px; }
.stage { margin: 0 0 15px; font-size: 12.5px; line-height: 1.4; color: rgba(244,239,230,.66); }
.stage i { font-style: italic; letter-spacing: .015em; }
.stage .sep { margin: 0 .5em; opacity: .45; }
.row-bar { display: flex; align-items: center; gap: 12px; }
.prog {
  position: relative; width: min(264px, 58vw); height: 2px; border-radius: 1px;
  background: rgba(244,239,230,.18); overflow: hidden;
}
.prog i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 1px;
  background: var(--amber); box-shadow: 0 0 12px rgba(240,168,80,.55);
  transition: width .55s var(--ease);
}
/* the failure: the bar says so in the one colour the boot has for it */
#loading.failed .prog i { background: var(--bad); box-shadow: none; }
.pct { margin: 0; font-size: 10.5px; letter-spacing: .08em; font-variant-numeric: tabular-nums; color: rgba(244,239,230,.55); }
.tip {
  position: absolute; right: max(26px, env(safe-area-inset-right));
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 20px));
  max-width: min(320px, 42vw); margin: 0; text-align: right;
  font-size: 11px; line-height: 1.55; color: rgba(244,239,230,.5);
  transition: opacity .5s ease, transform .5s ease;
}
.tip.fade { opacity: 0; transform: translateY(4px); }

/* ---------- the menu: the same corner, grown upward ---------- */
.menu { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.menu button, .menu input, .menu a { pointer-events: auto; }
#title {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 24px max(26px, env(safe-area-inset-right))
           max(24px, calc(env(safe-area-inset-bottom) + 16px)) var(--pad);
  opacity: 0; visibility: hidden;
  transition: opacity .8s ease, visibility 0s linear .8s;
}
body.in-menu #title { opacity: 1; visibility: visible; transition: opacity .8s ease .2s, visibility 0s; }
.menu-col { width: min(520px, 100%); }

/* the modes: rules and type, no cards */
.modes { display: flex; flex-direction: column; border-bottom: 1px solid rgba(244,239,230,.14); }
.mode {
  position: relative; display: flex; align-items: flex-start; gap: 14px; width: 100%;
  background: none; border: 0; border-top: 1px solid rgba(244,239,230,.14);
  padding: 12px 0 13px; text-align: left; cursor: pointer; font: inherit; color: inherit;
  transition: transform .16s var(--ease);
}
.mode:hover, .mode:focus-visible { transform: translateX(3px); }
.mode .n { flex: none; width: 22px; padding-top: 3px; font-size: 10.5px; letter-spacing: .1em; color: rgba(244,239,230,.38); }
.mode .tx { flex: 1; min-width: 0; }
.mode .tx b {
  display: block; font-size: 21px; font-weight: 800; letter-spacing: -.01em;
  color: rgba(246,241,231,.8); transition: color .16s;
}
.mode:hover .tx b, .mode:focus-visible .tx b { color: #fff; }
.mode .tx small { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.35; color: rgba(244,239,230,.46); }
.mode .tag {
  display: inline-block; margin-left: 8px; vertical-align: 3px; padding: 1px 5px;
  font-size: 9px; font-weight: 700; letter-spacing: .12em; color: var(--amber);
  border: 1px solid rgba(240,168,80,.55); border-radius: 2px;
}
.mode kbd { background: rgba(244,239,230,.12); color: rgba(246,241,231,.75); box-shadow: none; }

/* the scenes: the still behind the menu, and the only thing that changes it */
.scenes { margin-top: 20px; }
.slabel { margin: 0 0 9px; font-size: 9px; letter-spacing: .34em; text-transform: uppercase; color: rgba(244,239,230,.36); }
.chips { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.chip {
  position: relative; background: none; border: 0; border-bottom: 1px solid transparent;
  padding: 0 0 5px; cursor: pointer; text-align: left; font: inherit; color: inherit;
  transition: color .2s, border-color .2s;
}
.chip b { display: block; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: rgba(244,239,230,.44); transition: color .2s; }
.chip small { display: block; margin-top: 1px; font-size: 8.5px; letter-spacing: .02em; color: rgba(244,239,230,.26); }
.chip:hover b { color: rgba(246,241,231,.9); }
/* the line of the twenty seconds the scene has: a dim track, a bright fill */
.chip.on { border-bottom-color: rgba(240,168,80,.28); }
.chip.on b { color: #f6f1e7; }
.chip .prog {
  position: absolute; left: 0; bottom: -1px; width: 0; height: 1.5px;
  background: var(--amber); transition: width .2s linear;
}

/* the brand keeps the corner the loading screen left it in */
.brand { margin-top: 24px; }
.brand .kicker { margin-bottom: 9px; }

/* the foot: the two options, the credits, the author - and the author is the
 * last thing on the screen, which is where a signature belongs */
.foot { margin-top: 18px; width: 100%; }
.credits { max-width: 520px; margin: 0 0 10px auto; text-align: right; font-size: 9.5px; line-height: 1.55; color: rgba(244,239,230,.3); }
.credits .short { display: none; }
.foot .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.opts { display: flex; gap: 16px; }
.opt {
  background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit;
  font-size: 10.5px; letter-spacing: .1em; color: rgba(244,239,230,.5);
  border-bottom: 1px solid transparent; transition: color .18s, border-color .18s;
}
.opt:hover, .opt:focus-visible { color: rgba(246,241,231,.9); border-bottom-color: rgba(244,239,230,.4); }
.author {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 11px; letter-spacing: .02em; color: rgba(244,239,230,.42);
  transition: color .18s;
}
.author:hover, .author:focus-visible { color: rgba(246,241,231,.85); }
.author .li {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 2px; font-size: 9px; font-weight: 800; letter-spacing: 0;
  border: 1px solid rgba(244,239,230,.35); color: rgba(244,239,230,.5);
}
.mode:focus-visible, .chip:focus-visible, .opt:focus-visible, .author:focus-visible {
  outline: 3px solid var(--warm); outline-offset: 2px;
}

/* ---------- the phone ---------- */
@media (max-width: 700px) {
  :root { --pad: max(20px, env(safe-area-inset-left)); }
  .id { bottom: max(22px, calc(env(safe-area-inset-bottom) + 16px)); }
  .id h1, .brand h1 { font-size: 27px; }
  .kicker { font-size: 9px; letter-spacing: .34em; margin-bottom: 9px; }
  .stage { font-size: 11.5px; margin-bottom: 13px; }
  .prog { width: min(240px, 56vw); }
  .tip {
    right: auto; left: var(--pad);
    bottom: max(150px, calc(env(safe-area-inset-bottom) + 142px));
    max-width: 78vw; text-align: left; font-size: 10.5px;
  }

  #title { padding: 20px max(20px, env(safe-area-inset-right)) max(20px, calc(env(safe-area-inset-bottom) + 14px)) var(--pad); }
  .menu-col { width: 100%; }
  .mode { padding: 10px 0 11px; gap: 10px; }
  .mode .n { width: 18px; font-size: 9.5px; }
  .mode .tx b { font-size: 18px; }
  .mode .tx small { font-size: 10.5px; }
  .scenes { margin-top: 16px; }
  /* six places will not fit across a phone: one line, and the thumb scrolls it */
  .chips { flex-wrap: nowrap; overflow-x: auto; gap: 0 18px; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .chip small { display: none; }
  .brand { margin-top: 20px; }
  .foot { margin-top: 14px; }
  .credits { font-size: 8.5px; margin-bottom: 8px; max-width: none; }
  .credits .full { display: none; }
  .credits .short { display: inline; }
  .foot .row { gap: 10px; }
  .opts { gap: 12px; }
  .opt { font-size: 10px; }
  .author { font-size: 10.5px; }
}

/* a phone on its side, or a short window */
@media (max-height: 520px) {
  .mode { padding: 7px 0 8px; }
  .mode .tx b { font-size: 17px; }
  .mode .tx small { display: none; }
  .scenes { margin-top: 12px; }
  .brand { margin-top: 14px; }
  .brand h1, .id h1 { font-size: 24px; }
  .brand .kicker { margin-bottom: 6px; }
  .foot { margin-top: 10px; }
  .credits { display: none; }
  .tip { display: none; }
}

/* ---------- the cards of the two route pickers ---------- */
.lrt-card { max-width: 560px; }
.routes { display: grid; gap: 8px; margin: 10px 0 16px; }
.route { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 13px; background: rgba(255,255,255,.65); border: 1.5px solid transparent; cursor: pointer; }
.route:has(input:checked) { border-color: var(--teal); background: #fff; }
.route input { margin-top: 4px; accent-color: var(--teal); }
.route b { display: block; font-size: 15px; }
.route small { color: var(--ink-soft); font-size: 12px; }

.bus-card { max-width: 640px; display: flex; flex-direction: column; max-height: min(86vh, 760px); }
.bus-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bus-count { font-size: 13px; font-weight: 800; color: var(--teal); white-space: nowrap; }
#road-search {
  width: 100%; padding: 10px 13px; border-radius: 12px; border: 1px solid rgba(0,0,0,.14);
  background: rgba(255,255,255,.8); color: var(--ink); font: inherit; font-size: 14px; margin: 10px 0;
}
#road-search:focus { outline: 2px solid var(--accent); }
.bus-list { list-style: none; margin: 0; padding: 0 4px 0 0; overflow-y: auto; flex: 1; min-height: 120px; }
.bus-list li { border-bottom: 1px solid rgba(38,48,74,.06); }
.bus-list li:last-child { border-bottom: 0; }
.bus-group {
  position: sticky; top: 0; background: var(--cream); font-size: 12px; font-weight: 800; color: var(--ink-soft);
  letter-spacing: .05em; padding: 7px 4px 5px; z-index: 1;
}
.bus-item {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; border: 0;
  background: rgba(255,255,255,.66); border-radius: 12px; padding: 9px 13px; margin-bottom: 6px; color: var(--ink);
  transition: background .15s, transform .08s;
}
.bus-item:hover { background: #fff; transform: translateX(2px); }
.bus-item b { font-size: 15px; font-weight: 800; margin-right: 8px; }
.bus-item small { font-size: 11.5px; color: var(--ink-soft); }
.bus-empty { font-size: 13px; color: var(--ink-soft); padding: 14px 4px; }
.bus-card .actions { margin-top: 12px; }
.bus-card .credits { font-size: 10px; color: var(--ink-soft); margin: 10px 0 0; }

/* ---------- the HUDs of the three modes ---------- */
.hud, #hud, #road-hud, #god-hud, #gp-hud { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
.hud button, #hud button, #road-hud button, #god-hud button, #gp-hud button { pointer-events: auto; }
.panel {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.hud-tl { position: absolute; left: max(16px, env(safe-area-inset-left)); top: max(16px, env(safe-area-inset-top)); padding: 12px 16px; min-width: 220px; max-width: min(340px, 60vw); }
.hud-trip { position: absolute; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(560px, 42vw); padding: 8px 14px; }
.hud-tr { position: absolute; right: max(16px, env(safe-area-inset-right)); top: max(16px, env(safe-area-inset-top)); padding: 11px 15px; min-width: 230px; max-width: min(340px, 60vw); }
.hud-br { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.hud-br .btnrow { display: flex; gap: 8px; align-items: flex-end; }
.dest-zh { font-size: 28px; font-weight: 800; line-height: 1.12; margin-top: 2px; }
.dest-pt { font-size: 13px; color: var(--accent); font-weight: 700; }
.hud-tl .row { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; margin-top: 7px; font-size: 13px; }
.hud-tl .row b { font-size: 15px; font-variant-numeric: tabular-nums; }
.hud-tr .dest-zh { font-size: 20px; }
.hud-tr .row { display: flex; justify-content: space-between; gap: 14px; margin-top: 6px; font-size: 12.5px; }
.hud-tr .row b { font-variant-numeric: tabular-nums; }
/* ---- the duel (spec 4.9.3)
   The place is the one number of the panel that is a RESULT and not an
   instrument reading, so it is set heavier than the rows around it, and the
   lead is the one place the accent is allowed: white for second, because
   behind is not news. */
.hud-tr .gp-posrow { margin-top: 2px; }
.hud-tr .gp-posrow b { font-size: 13px; font-weight: 800; letter-spacing: .01em; }
.hud-tr .gp-posrow b.lead { color: var(--accent); }
.trip-ends { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; }
#trip-bar { width: 100%; height: 30px; display: block; }

.ats-badge {
  position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(23,163,156,.94), rgba(17,136,128,.94));
  color: #fff; font-weight: 800; font-size: 15px; padding: 8px 20px; border-radius: 12px;
  box-shadow: var(--shadow); letter-spacing: .06em; white-space: nowrap;
}
.ats-take {
  font-size: 12px !important; padding: 9px 14px !important; border-radius: 12px !important;
  background: rgba(255, 249, 241, 0.9) !important; color: var(--ink) !important;
  box-shadow: var(--shadow) !important; white-space: nowrap;
}

.speedo { padding: 10px 16px; width: min(300px, 46vw); }
.speed-row { display: flex; align-items: baseline; gap: 6px; }
.speed-row b { font-size: 36px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.speed-row span { color: var(--ink-soft); font-weight: 700; font-size: 13px; }
.speed-row .notch { margin-left: auto; font-weight: 800; font-size: 14px; padding: 2px 10px; border-radius: 8px; background: var(--teal); color: #fff; min-width: 52px; text-align: center; }
.speed-bar { position: relative; height: 10px; border-radius: 6px; background: rgba(38,48,74,.12); margin-top: 8px; }
#road-speed-fill, #gp-speed-fill { height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--teal), var(--accent)); }
/* over the posted limit: the bar turns red, the way a driver sees it */
#road-speed-fill.over { background: linear-gradient(90deg, var(--mid), var(--bad)); }

/* ---------- the instrument of the race (docs/gp-feel-spec.md 4.6) ----------
   The panel in the bottom right corner: the slip arc on the left, the speed
   and the gear on the right, and the rev counter under them.  The drawing is
   the one in mockups/gp-hud.html, which is drawn with this very stylesheet.

   The arc is a half circle with the needle at the top when the car is
   straight.  It points to the LEFT when the rear lets go (甩尾) and to the
   RIGHT when the front does (推頭) - the two ends are named, so the reading
   does not depend on knowing which way is which. */
#gp-speedo { padding: 9px 14px 10px; width: min(310px, 46vw); }

.gp-cluster { display: flex; align-items: flex-end; gap: 12px; }

.gp-slip { flex: none; width: 122px; }
.gp-slip svg { display: block; width: 100%; height: auto; overflow: visible; }
.gp-slip .arc-track { fill: none; stroke: rgba(38,48,74,.15); stroke-width: 5; stroke-linecap: round; }
.gp-slip .arc-tick { stroke: rgba(38,48,74,.3); stroke-width: 1.5; stroke-linecap: round; }
.gp-slip .arc-limit { fill: none; stroke: rgba(226,87,76,.45); stroke-width: 2; stroke-linecap: round; }
.gp-slip .needle { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.gp-slip .hub { fill: var(--ink); }
.gp-slip .ring { fill: none; stroke: var(--teal); stroke-width: 2; opacity: 0; }
.gp-slip.assist .ring { opacity: 1; }
.gp-slip.over .needle { stroke: var(--bad); }
.gp-slip.over .hub { fill: var(--bad); }
.gp-slip .ends { font-size: 9px; font-weight: 800; letter-spacing: .02em; fill: var(--ink-soft); }

/* the speed and the gear */
.gp-readout { flex: 1; min-width: 0; padding-bottom: 2px; }
.gp-readout .speed-row b { font-size: 38px; }

/* the rev counter: the bar is the revs against the redline, and the red
   zone is the last fifteen per cent of it */
.gp-rpm { position: relative; margin-top: 7px; }
.rpm-bar { position: relative; height: 10px; border-radius: 6px; background: rgba(38,48,74,.12); }
.rpm-red { position: absolute; right: 0; top: 0; bottom: 0; width: 15%; border-radius: 0 6px 6px 0; background: rgba(226,87,76,.20); }
.rpm-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: linear-gradient(90deg, var(--teal), var(--accent)); }
.rpm-fill.hot { background: linear-gradient(90deg, var(--warm), var(--bad)); }
.rpm-shift { position: absolute; right: 1px; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: rgba(38,48,74,.16); }
.rpm-shift.on { background: var(--bad); box-shadow: 0 0 10px rgba(226,87,76,.95); }
.rpm-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px;
  font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.rpm-row b { color: var(--ink); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.round {
  font: inherit; font-weight: 800; font-size: 12px; min-width: 46px; height: 46px; border-radius: 23px; border: 0; cursor: pointer;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; padding: 0 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.round svg { width: 20px; height: 20px; }
.round.on { background: var(--accent); color: #fff; }

/* ---------- the map in the corner ---------- */
#mm-wrap { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 18; width: 196px; pointer-events: none; }
#mm-frame { position: relative; width: 196px; height: 196px; border-radius: 18px; overflow: hidden; border: 3px solid rgba(255, 249, 241, .92); box-shadow: var(--shadow); background: #7fb8d4; pointer-events: auto; cursor: grab; touch-action: none; }
#mm-frame:active { cursor: grabbing; }
#minimap { width: 100%; height: 100%; display: block; }
#mm-n { position: absolute; left: 8px; top: 7px; font-size: 11px; font-weight: 800; color: #fff; background: rgba(22,18,44,.55); border-radius: 7px; padding: 1px 7px; letter-spacing: .05em; }
#mm-zoom { position: absolute; right: 8px; bottom: 7px; font-size: 10px; font-weight: 700; color: #fff; background: rgba(22,18,44,.55); border-radius: 7px; padding: 1px 7px; }
/* the button that puts the map back where the camera left it.  It is only
 * there when the map has been moved or zoomed by the hand. */
#mm-reset { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(22,18,44,.55); color: #fff; font-size: 13px; line-height: 22px; text-align: center; cursor: pointer; display: none; }
#mm-reset.on { display: block; }
#mm-reset:hover { background: rgba(22,18,44,.75); }
#street { margin-bottom: 8px; padding: 8px 13px 9px; border-radius: 14px; text-align: left; }
#street b { display: block; font-size: 16.5px; font-weight: 800; line-height: 1.2; }
#street small { display: block; font-size: 10.5px; color: var(--accent); font-weight: 700; margin-top: 2px; line-height: 1.3; }

/* ---------- the god view ----------
 *
 * The free view has nothing in the corner of the screen: the city is the
 * whole picture, and the only thing on it is the column in the other
 * corner - the keys of the camera, and the time of the day. */
#god-side {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
#god-side .btnrow { display: flex; gap: 8px; align-items: flex-end; }
.god-keys {
  width: 236px; max-width: 42vw; padding: 11px 14px 12px;
}
.gk-head {
  font-size: 11.5px; font-weight: 800; color: var(--accent); letter-spacing: .1em;
  margin-bottom: 8px;
}
.gk-row { display: flex; align-items: center; gap: 9px; margin-top: 5px; font-size: 13px; font-weight: 700; }
.gk-row kbd {
  flex: none; min-width: 54px; text-align: center; padding: 3px 7px; border-radius: 8px;
  background: rgba(38,48,74,.07); border: 1px solid rgba(38,48,74,.13);
  font: inherit; font-size: 11.5px; font-weight: 800; color: var(--ink); letter-spacing: .02em;
}
.gk-row i { font-style: normal; font-weight: 700; font-size: 11px; color: var(--ink-soft); }

/* ---------- the Grand Prix ----------
 *
 * The race has three things the other modes do not: a lap timer, five start
 * lights, and the picker of the car.  Everything else on the screen is the
 * HUD the bus and the light rail already use - the panel in the corner, the
 * speedometer and its buttons.
 */
.gp-time {
  font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums;
  line-height: 1.05; margin-top: 2px;
}

/* the five lamps over the grid.  They hang over the middle of the road,
 * which is where a driver looks - a tenth of the way up the screen - and
 * they go out together, which is the start. */
#gp-lights {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  display: flex; gap: 12px; align-items: center; padding: 13px 20px;
  border-radius: 14px; background: rgba(14,16,20,.90); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.12);
}
.gp-lamp {
  width: 28px; height: 28px; border-radius: 50%; background: #3b2b28;
  border: 2px solid rgba(255,255,255,.22);
  transition: background .06s linear, box-shadow .06s linear;
}
.gp-lamp.on {
  background: #e2574c;
  box-shadow: 0 0 16px rgba(226,87,76,.95), inset 0 -3px 6px rgba(0,0,0,.4);
}
#gp-lights .note {
  margin-left: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  color: rgba(246,241,231,.55);
}

/* the picker of the car.
 *
 * The picture of the car is the one thing on this card a player looks at, so
 * it gets as much of the card as the card has.  It used to be a 150 x 64
 * thumbnail beside the text (110 x 58 on a phone): the photograph was all
 * there - the file and the box had the same proportions, so `cover` cropped
 * nothing - but the car in it was the size of a postage stamp, and a car you
 * cannot see is a car you cannot choose.
 *
 * Two columns, the car on the left and everything the driver sets up on the
 * right, so that a big picture does not push the start button off a 720 px
 * screen.  A phone has no room for two columns and stacks them. */
.gp-card { max-width: 820px; max-height: min(94vh, 920px); overflow-y: auto; }
.gp-grid {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
}
.gp-route { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.gp-head { display: flex; align-items: center; gap: 8px; }
.gp-head input { flex: none; margin: 0; accent-color: var(--teal); }
.gp-head b { font-size: 15px; }
.gp-head i { font-style: normal; color: var(--ink-soft); font-weight: 600; font-size: 12px; }
.gp-route .gp-shot { display: block; width: 100%; }
.gp-shot img,
.gp-shot svg {
  width: 100%; height: auto; display: block; border-radius: 12px;
  aspect-ratio: 1200 / 512; object-fit: cover; object-position: 50% 42%;
  background: #e8edf1; border: 1px solid rgba(38,48,74,.08);
}
.gp-route > small { color: var(--ink-soft); font-size: 11.5px; line-height: 1.45; }
.gp-side { display: flex; flex-direction: column; min-width: 0; }

/* the controls, said where the car is chosen instead of over the road */
.gp-help {
  padding: 11px 14px 12px;
  border-radius: 14px; background: rgba(38,48,74,.045);
  border: 1px solid rgba(38,48,74,.09);
}
.gp-help .gk-head { color: var(--teal); margin-bottom: 6px; }
.gp-help .gk-row { margin-top: 4px; font-size: 12.5px; }
.gp-help .gk-row kbd {
  background: #fff; border: 1px solid rgba(38,48,74,.16);
  box-shadow: 0 1px 0 rgba(38,48,74,.10); min-width: 62px;
}
.gp-help-touch { display: none; }
/* a device with no keyboard is told about the stick, not about the keys */
@media (pointer: coarse) {
  .gp-help-keys { display: none; }
  .gp-help-touch { display: block; }
}
.gp-help-note {
  margin: 10px 2px 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-soft);
}
.gp-help-note b { color: var(--ink); font-weight: 800; }
.gp-help-note i {
  display: block; margin-top: 3px; font-style: normal;
  font-weight: 600; font-size: 10.5px; opacity: .82;
}
/* the driver's own music: a file he picks, and the volume he wants it at.
 * Nothing here is remembered between visits - a page opened from file://
 * has no database to remember it in (js/audio/bgm.js says why) - so the
 * file pick is a session thing and the slider is the only part that is
 * saved. */
.gp-bgm { margin: 12px 0 0; }
.gp-bgm-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gp-bgm-pick { position: relative; display: inline-block; }
.gp-bgm-pick input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}
.gp-bgm-pick span {
  display: inline-block; padding: 6px 12px; border-radius: 10px;
  border: 1.5px solid rgba(38,48,74,.14); background: rgba(255,255,255,.66);
  font-size: 12.5px; font-weight: 700; color: var(--ink);
}
.gp-bgm-pick input:focus-visible + span { outline: 3px solid var(--warm); outline-offset: 2px; }
/* the track that ships with the game.  The same chip as the file pick, and it
 * is lit when it is the one playing - the same teal the laps use for the one
 * that is selected. */
.gp-bgm-chip {
  flex: none; padding: 6px 12px; border-radius: 10px;
  border: 1.5px solid rgba(38,48,74,.14); background: rgba(255,255,255,.66);
  font-size: 12.5px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.gp-bgm-chip.on { background: var(--teal); color: #fff; border-color: transparent; }
.gp-bgm-chip:focus-visible { outline: 3px solid var(--warm); outline-offset: 2px; }
.gp-bgm-x {
  flex: none; width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 1.5px solid rgba(38,48,74,.14); background: rgba(255,255,255,.66);
  color: var(--ink-soft); font-size: 15px; line-height: 1; cursor: pointer;
}
.gp-bgm-name {
  flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.4; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gp-bgm-name.on { color: var(--ink); font-weight: 700; }
.gp-bgm-name.bad { color: var(--warm-ink, #a4442c); font-weight: 700; }
/* the name and the slider on one line: a second row for the name would put
 * the card of a 390 x 844 phone 70 px past its own height */
.gp-bgm-vol {
  display: flex; align-items: center; gap: 10px; margin-top: 6px;
  font-size: 11px; letter-spacing: .04em; color: var(--ink-soft);
}
.gp-bgm-vol input { flex: none; width: 104px; min-width: 0; margin: 0; accent-color: var(--teal); }

.gp-laps { display: flex; align-items: center; gap: 12px; margin: 14px 0 2px; }
.gp-laps .seg {
  display: flex; border: 1.5px solid rgba(38,48,74,.14); border-radius: 12px;
  overflow: hidden; background: rgba(255,255,255,.6);
}
.gp-laps .seg label { position: relative; }
.gp-laps .seg input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.gp-laps .seg span { display: block; padding: 8px 15px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.gp-laps .seg input:checked + span { background: var(--teal); color: #fff; }
.gp-laps .seg input:focus-visible + span { outline: 3px solid var(--warm); outline-offset: -3px; }
.gp-card .credits { font-size: 10px; color: var(--ink-soft); margin: 10px 0 0; }
/* the start button is the one thing on this card that must not be hunted
 * for.  A phone, a short window, and the card is taller than the screen -
 * so the buttons stay at the bottom edge of the card while the rest of it
 * scrolls under them, on a fade of the card's own colour.  When the card
 * fits, sticky does nothing and this is just the gap it always was. */
#gp-menu .actions {
  position: sticky; bottom: 0; z-index: 2;
  margin-top: 12px; padding: 10px 0 2px;
  background: linear-gradient(180deg,
    rgba(255,249,241,0) 0%, rgba(255,249,241,.94) 32%, rgba(255,249,241,.98) 100%);
}

/* no room for two columns: the car on top, the set-up under it.  The
 * paragraph that goes is the one about the view - the line above it already
 * says how long the lap is and how many corners it has. */
@media (max-width: 780px) {
  .gp-card { max-width: 560px; padding: 18px 18px 14px; }
  .gp-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .gp-card .intro { display: none; }
  .gp-help-touch { padding: 10px 12px 11px; }
  .gp-help-touch .gk-row { margin-top: 3px; font-size: 12px; }
  .gp-help-note { margin-top: 8px; }
  .gp-laps { margin-top: 10px; }
}

/* the times of the race */
.gp-table { margin: 12px 0 4px; border-top: 1px solid rgba(38,48,74,.10); }
.gp-row {
  display: flex; justify-content: space-between; align-items: baseline; padding: 7px 2px;
  border-bottom: 1px solid rgba(38,48,74,.07); font-size: 13.5px;
}
.gp-row .n { color: var(--ink-soft); font-weight: 700; font-size: 12px; }
.gp-row b { font-variant-numeric: tabular-nums; }
.gp-row.best { color: var(--teal); font-weight: 800; }
.gp-row.best .n { color: var(--teal); }
/* the rival's row is the other car of the duel: under the total, and quiet */
.gp-row.rival { margin-top: 6px; border-top: 1px solid rgba(255,255,255,.10); padding-top: 6px; }
.gp-row.rival .n { font-weight: 600; }
/* the three sectors of the lap, under the lap's time */
.gp-sectors {
  display: flex; gap: 12px; padding: 1px 2px 7px;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* the car is against the barrier: the screen says so for as long as it is */
#gp-hud.hit { box-shadow: inset 0 0 130px rgba(226,87,76,.55); }

/* ---------- the messages of the game ---------- */
#subtitle { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); text-align: center; max-width: 86vw; pointer-events: none; transition: opacity .4s; z-index: 19; }
#subtitle.off { opacity: 0; }
#sub-zh, #sub-pt { display: inline-block; padding: 3px 12px; margin: 2px 0; border-radius: 8px; background: rgba(22, 18, 44, .62); color: #fff; }
#sub-zh { font-size: 19px; font-weight: 700; }
#sub-pt { font-size: 14px; font-weight: 700; color: #ffe2b8; display: block; width: fit-content; margin: 2px auto 0; }
#sub-zh:empty, #sub-pt:empty { display: none; }

#banner { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); text-align: center; padding: 14px 22px; border-radius: 18px; background: rgba(226, 87, 76, .92); color: #fff; box-shadow: var(--shadow); animation: pop .35s ease-out; max-width: min(620px, 90vw); z-index: 19; }
#banner.good { background: rgba(23, 163, 156, .94); }
#banner-zh { font-size: 21px; font-weight: 800; }
#banner-pt { font-size: 13px; opacity: .92; margin-top: 2px; }
@keyframes pop { from { transform: translate(-50%, -40%) scale(.85); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

#toasts { position: absolute; left: 50%; top: 210px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 19; }
.toast { background: #fff; color: var(--ink); border-radius: 12px; padding: 6px 14px; font-weight: 800; box-shadow: var(--shadow); animation: rise 2.6s ease-out forwards; white-space: nowrap; }
.toast small { display: block; font-weight: 600; color: var(--ink-soft); font-size: 11px; text-align: center; }
@keyframes rise { 0% { opacity: 0; transform: translateY(14px) scale(.9); } 12% { opacity: 1; transform: translateY(0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

/* ---------- the caption of the tour camera ---------- */
.tour-caption {
  position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  background: rgba(22, 18, 44, 0.78); color: #fff; padding: 12px 16px; border-radius: 14px;
  max-width: min(340px, 70vw); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow); transition: opacity 0.45s; pointer-events: none; z-index: 19;
}
.tour-caption.hidden { display: none; }
.tc-zh { font-size: 20px; font-weight: 800; line-height: 1.2; }
.tc-pt { font-size: 13px; font-weight: 600; color: #ffd28a; margin-top: 2px; }
.tc-en { font-size: 12px; color: rgba(255,255,255,0.8); margin-top: 1px; }
.tc-fact { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 4px; font-style: italic; }

#fade { position: absolute; inset: 0; background: #120e26; opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 30; }
#fade.on { opacity: 1; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .hud-trip { display: none; }
  #mm-wrap { width: 148px; }
  #mm-frame { width: 148px; height: 148px; border-radius: 14px; }
  #street b { font-size: 14px; }
  .hud-tl { min-width: 0; max-width: calc(100vw - 190px); padding: 9px 12px; }
  .dest-zh { font-size: 20px; }
  .hud-tr { display: none; }
  .speedo { width: 190px; }
  .speed-row b { font-size: 28px; }
  .ats-badge { bottom: 60px; font-size: 13px; padding: 5px 14px; }
}
@media (max-width: 820px) {
  .subtitle { bottom: 118px; max-width: 66vw; }
  #sub-zh { font-size: 17px; }
  .card { padding: 16px 18px; max-height: 96vh; overflow: auto; }
  #banner { top: 52%; }
}

/* ---------- the hands of a phone ----------
 *
 * The touch layer is hidden on a desk: there the keyboard is the driver.
 * It appears on a phone (a narrow screen, or a finger) and it is the only
 * thing the thumbs touch. */
#touch { display: none; }
.touch-stick {
  position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom));
  width: 132px; height: 132px; pointer-events: auto; touch-action: none;
  display: none;
}
.touch-stick.on { display: block; }
.touch-stick::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(22,18,44,.10), rgba(22,18,44,.34));
  border: 1.5px solid rgba(255,249,241,.34);
  box-shadow: 0 10px 30px rgba(12,8,32,.34), inset 0 0 22px rgba(0,0,0,.18);
}
.touch-stick::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: rgba(255,249,241,.5);
}
#touch-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: rgba(255,249,241,.93); box-shadow: 0 8px 20px rgba(12,8,32,.42);
  transition: transform .08s linear;
}
#touch-knob::after {
  content: ""; position: absolute; inset: 21px; border-radius: 50%; background: rgba(38,48,74,.28);
}
.touch-cluster {
  position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; width: 158px; pointer-events: auto;
}
.touch-cluster.three { width: 158px; }
.touch-cluster.col {
  flex-direction: column; flex-wrap: nowrap; justify-content: flex-end; width: auto;
  /* clear of the map, which stands in the corner under it: the map is 126 px
   * of frame plus the street name above it, so the column starts above all
   * of that, not just above the frame */
  bottom: 205px;
}
.touch-btn {
  width: 47px; height: 47px; border-radius: 24px; border: 0; cursor: pointer; padding: 0;
  background: rgba(255,249,241,.90); color: #26304a; box-shadow: 0 10px 26px rgba(12,8,32,.38);
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  font: inherit; font-weight: 800; font-size: 13px; pointer-events: auto;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .08s, background .12s;
}
.touch-btn svg { width: 21px; height: 21px; flex: none; }
.touch-btn.held { background: var(--warm); color: #fff; transform: scale(.95); }
#touch-back {
  position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top));
  width: 44px; height: 44px; border-radius: 22px; display: none;
}
#touch-back.on { display: flex; }
#touch-back svg { width: 19px; height: 19px; }

/* ---------- the phone ---------- */
@media (max-width: 900px), (pointer: coarse) {
  #touch { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 25; }

  /* the map follows the mode: in the free view it is in the corner, the
   * way GTA keeps it, and the numbers of the camera are not wanted there */
  #mm-wrap { width: 126px; }
  #mm-frame { width: 126px; height: 126px; border-radius: 12px; border-width: 2px; }
  #mm-n { left: 6px; top: 5px; font-size: 10px; }
  #mm-zoom { right: 6px; bottom: 5px; font-size: 9px; }
  /* the button that puts the map back is a finger-sized one here */
  #mm-reset { right: 5px; top: 5px; width: 28px; height: 28px; line-height: 28px; font-size: 15px; }
  #street { margin: 0 0 6px; padding: 5px 9px 6px; border-radius: 11px; }
  #street b { font-size: 13px; }
  #street small { font-size: 9px; margin-top: 1px; }
  body[data-state="god"] #mm-wrap {
    left: auto; right: max(10px, env(safe-area-inset-right));
    top: auto; bottom: max(10px, env(safe-area-inset-bottom));
  }
  body:not([data-state="god"]) #mm-wrap {
    left: auto; right: max(10px, env(safe-area-inset-right));
    top: max(10px, env(safe-area-inset-top)); bottom: auto;
  }
  /* on a phone the keys are the thumbs and the sun is the button on the
     screen: the column of the desk has no business here */
  #god-side { display: none; }
  #hud .btnrow, #road-hud .btnrow, #god-hud .btnrow { display: none; }
  .btn.ghost { font-size: 12.5px; padding: 8px 13px; }

  /* the panels of the game */
  .hud-tl { max-width: calc(100vw - 156px); }
  .ats-badge {
    left: max(12px, env(safe-area-inset-left)); right: auto; transform: none;
    bottom: max(14px, env(safe-area-inset-bottom)); font-size: 12px; padding: 5px 12px;
  }
  #road-hud .hud-br { left: max(12px, env(safe-area-inset-left)); right: auto; align-items: flex-start; }
  #road-hud .speedo { width: 150px; }
  #subtitle { bottom: 128px; }

  /* the race on a phone: the corner ahead is at the top left, the clock
   * hangs under it, and the map keeps the corner it always has */
  #gp-next { max-width: calc(100vw - 156px); }
  #gp-timer {
    display: block; left: max(12px, env(safe-area-inset-left)); right: auto;
    top: 140px; min-width: 0; max-width: calc(100vw - 156px); padding: 9px 12px;
  }
  #gp-timer .gp-time { font-size: 23px; }
  #gp-timer .row { font-size: 12px; margin-top: 5px; }
  #gp-hud .hud-br {
    left: max(12px, env(safe-area-inset-left)); right: auto;
    align-items: flex-start; bottom: 170px;
  }
  #gp-hud .speedo { width: 176px; padding: 8px 11px 9px; }
  /* on a phone the arc goes OVER the speed instead of beside it: the panel
     is 176 px wide, and an arc beside the number is too small to read */
  .gp-cluster { flex-direction: column; align-items: stretch; gap: 3px; }
  .gp-slip { width: 118px; align-self: center; }
  .gp-readout { padding-bottom: 0; }
  .gp-readout .speed-row b { font-size: 28px; }
  .gp-readout .speed-row span { font-size: 11px; }
  .gp-readout .speed-row .notch { min-width: 30px; font-size: 12px; padding: 1px 7px; }
  .rpm-row { font-size: 9.5px; }
  .rpm-row b { font-size: 11px; }
  #gp-hud .btnrow { display: none; }
  #gp-lights { top: 44%; gap: 9px; padding: 10px 14px; }
  .gp-lamp { width: 22px; height: 22px; }
  #touch.gp #touch-buttons { width: 156px; }
  #touch.gp .touch-btn { width: 74px; height: 74px; border-radius: 22px; font-size: 15px; }
}

/* ---------- the phone on its side ---------- */
@media (orientation: landscape) and (max-width: 900px), (orientation: landscape) and (pointer: coarse) {
  .touch-stick { width: 112px; height: 112px; }
  #touch-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  .touch-cluster.three { width: 150px; }
  .touch-btn { width: 44px; height: 44px; border-radius: 22px; font-size: 12px; }
  /* on its side there is no room for the column between the way back and the
   * map: it stands to the left of the map instead, where the wide screen
   * has room for it */
  .touch-cluster.col {
    bottom: max(14px, env(safe-area-inset-bottom));
    right: calc(max(12px, env(safe-area-inset-right)) + 134px);
  }
  #subtitle { bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, #banner { animation: none; }
  .mode, .btn, .chip { transition: none; }
}
