:root {
  --ink: #143d48;
  --paper: #fff4d7;
  --rim: 3px solid var(--ink);
  font: 700 16px/1.4 "Barlow", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0; height: 100%; overscroll-behavior: none }
body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: #124553;
  background-image: repeating-radial-gradient(ellipse at 0 115%, transparent 0 36px, #6ebda226 37px 39px, transparent 40px 61px),
    linear-gradient(140deg, #337575, #164955 52%, #143741);
}
main {
  --gutter: clamp(12px, 2.4dvh, 22px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: min(100vw, 56.25dvh);
  height: 100dvh;
  background: #3fb7bb;
  container-type: inline-size;
}
@media (orientation: portrait) and (max-width: 620px) { main { width: 100vw } }
@media (min-width: 621px) and (min-height: 500px) {
  main { height: min(94dvh, 940px); width: min(52.875dvh, 529px); border-radius: 26px; box-shadow: 0 0 0 5px #103b46, 0 0 0 7px #629a93, 0 22px 52px #092e3dd4 }
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab }
canvas:active { cursor: grabbing }
button { touch-action: manipulation; font: inherit; cursor: pointer; color: var(--ink) }
button:focus-visible { outline: 3px solid white; outline-offset: 3px }
#hud, #mute { position: absolute; top: max(var(--gutter), env(safe-area-inset-top)) }
#hud { left: var(--gutter); right: calc(var(--gutter) + 53px); display: flex; gap: 7px; pointer-events: none }
.race, .counter, #mute { border: var(--rim); background: var(--paper); box-shadow: 0 3px var(--ink); border-radius: 14px }
.race { flex: 1; padding: 4px 12px 6px; min-width: 0; }
#stage { font-size: clamp(12px, 3.5cqw, 16px); font-weight: 900 }
.bar { height: 4px; border-radius: 4px; background: #d7d8bc; overflow: hidden }
#fill { display: block; width: 0; height: 100%; background: #e9753c }
.counter { padding: 0 10px; display: flex; align-items: center; gap: 7px; font-size: 20px; font-variant-numeric: tabular-nums }
.counter i { width: 15px; height: 9px; background: #ffad44; border: 1px solid #ad582c; box-shadow: 0 3px #c77431; transform: skewY(-10deg) }
#mute { z-index: 2; right: var(--gutter); width: 44px; height: 44px; font: 900 24px/1 system-ui }
#mute[aria-pressed=true] span { opacity: .55; text-decoration: line-through }
#routeHUD { position: absolute; top: calc(max(var(--gutter), env(safe-area-inset-top)) + 54px); left: var(--gutter); display: grid; justify-items: start; gap: 4px; pointer-events: none }
#routeHUD span, #tip.active { display: inline-block; border-radius: 8px; padding: 4px 9px; color: white; background: #164653f2; font-size: 13px }
#bridgeInfo.short { background: #93471e }
#boostInfo { background: #674997 !important }
#wallInfo { background: #82413e !important }
#tip { position: absolute; bottom: max(4dvh, env(safe-area-inset-bottom)); width: max-content; max-width: 92%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none }
#panel { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, #11729240, transparent 40%, transparent 73%, #13515baf) }
.masthead { position: absolute; left: 7%; top: max(6%, calc(env(safe-area-inset-top) + 10px)); transform: rotate(-6deg) skewX(-5deg); transform-origin: left center }
#eyebrow { margin: 0 0 6px; color: #153e48; letter-spacing: .17em; font: italic 1000 clamp(15px, 5cqw, 26px)/1.1 "Barlow", system-ui, sans-serif; letter-spacing: .13em }
h1 { margin: 0; font: italic 1000 clamp(36px, 16cqw, 84px)/.99 "PingFang SC",system-ui,sans-serif; letter-spacing: -.075em; color: var(--paper); paint-order: stroke fill; -webkit-text-stroke: .09em var(--ink); text-shadow: .045em .075em var(--ink) }
h1 span { display: block }
h1 span + span { margin-left: .68em; color: #ffbc53 }
.menu { position: absolute; bottom: max(3.5%, calc(env(safe-area-inset-bottom) + 10px)); left: 6%; right: 6%; padding: 13px 16px 17px; border: var(--rim); border-radius: 20px; background: var(--paper); box-shadow: 0 5px var(--ink); text-align: center; pointer-events: auto }
#desc { margin: 0 0 10px; font-size: clamp(13px,3.5cqw,16px); line-height: 1.45 }
#go { width: 100%; min-height: 46px; position: relative; border: var(--rim); border-radius: 12px; background: #ffae47; box-shadow: 0 3px var(--ink); font-size: 20px; font-weight: 900 }
#go::after { content: ''; position: absolute; top: 50%; right: 18px; transform: translateY(-50%); border-left: 9px solid var(--ink); border-block: 6px solid transparent }
#go:active { transform: translateY(2px); box-shadow: 0 1px var(--ink) }
main:not([data-screen=play]) :is(#hud,#routeHUD) { visibility: hidden }
main[data-screen=end] .masthead { top: 21%; right: 5%; }
main[data-screen=end] h1 { font-size: clamp(24px, 11cqw, 58px) }
#live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
