:root {
  color-scheme: light;
  --ink: #1d4251;
  --muted: #3f6170;
  --ice: #eaf4f6;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow: hidden; overscroll-behavior: none; }
body { margin: 0; color: var(--ink); background: #bcd7e4; font: 400 15px var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid #234d62; outline-offset: 4px; }

.game { position: relative; isolation: isolate; width: 100%; height: 100dvh; min-height: 290px; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.game canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.scene { pointer-events: none; }
.riders { cursor: crosshair; touch-action: none; }
.is-locked .riders { cursor: default; }
.trail-area { position: absolute; inset: clamp(215px, calc(12vh + 132px), 260px) clamp(35px, 8%, 160px) clamp(104px, 18vh, 160px); pointer-events: none; }

.top { position: absolute; inset: 0 0 auto; display: flex; justify-content: space-between; align-items: center; padding: 21px clamp(18px, 3vw, 44px); pointer-events: none; z-index: 1; }
.round { position: absolute; left: 50%; transform: translateX(-50%); color: var(--muted); font-weight: 700; font-size: 12px; white-space: nowrap; }
.wordmark { font: 400 27px/.95 var(--serif); }
.menu-button { pointer-events: auto; width: 42px; height: 42px; display: grid; place-content: center; gap: 4px; background: #edf6f86b; border: 1px solid #f8fcfead; border-radius: 50%; }
.menu-button span { width: 16px; height: 1.5px; border-radius: 3px; background: var(--ink); }
.menu-button:hover { background: #edf6f8; }

.intro { position: absolute; top: clamp(86px, 12vh, 128px); left: 12px; right: 12px; text-align: center; pointer-events: none; }
h1 { margin: 0; font: 400 clamp(43px, 6.85vw, 75px)/.95 var(--serif); letter-spacing: -.025em; text-wrap: balance; }
h1 em { font-weight: inherit; color: #315e71; }
.intro p { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.car-speed {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid #b87e6a;
  border-radius: 8px;
  background: #fff5e9;
  color: #773e32;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.actions { position: absolute; inset: auto 12px max(23px, calc(env(safe-area-inset-bottom) + 15px)); display: flex; justify-content: center; pointer-events: none; }
.lock, .result { pointer-events: auto; box-shadow: 0 6px 24px #2a607227; }
.lock { background: #214c60; border: 1px solid #d1e6ec59; color: #fff; padding: 12px 17px 12px 20px; border-radius: 100px; display: inline-flex; gap: 14px; align-items: center; font-weight: 600; min-height: 48px; }
.lock:hover { background: #173d50; }
.lock span { font-size: 19px; line-height: 1; }
.result { display: flex; align-items: center; gap: 10px; padding: 8px 9px 8px 18px; border: 1px solid #f8fdff; border-radius: 100px; background: #f0f7f8ed; }
.accuracy { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 13px; }
.accuracy strong { color: var(--ink); font: 400 37px/1 var(--serif); }
.points { padding: 3px 0 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.continue { min-height: 42px; border: 0; border-radius: 100px; padding: 0 14px; background: #214c60; color: white; white-space: nowrap; font-size: 13px; font-weight: 600; }
.continue:hover { background: #173d50; }
.replay, .close { display: grid; place-items: center; border-radius: 50%; border: 0; background: #dcecf1; width: 38px; height: 38px; font: 400 22px/1 var(--sans); }
.replay:hover, .close:hover { background: #cddfe8; }

.info { position: fixed; inset: 73px clamp(18px, 3vw, 44px) auto auto; margin: 0; width: min(305px, calc(100% - 36px)); max-height: calc(100dvh - 88px); overflow-y: auto; overscroll-behavior: contain; border-radius: 17px; padding: 17px 18px; border: 1px solid #f8fdff; background: #eef6f9; color: var(--ink); box-shadow: 0 12px 44px #21485a30; }
.info-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.info h2, .share-dialog h2 { font: 400 35px/1 var(--serif); margin: 0; }
.info p { margin: 10px 0 15px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.close { width: 30px; height: 30px; font-size: 20px; }
.next { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #cbdfe7; padding-top: 12px; color: var(--muted); font-size: 12px; }
.next time { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.info .rollover { font-size: 12px; margin: 4px 0 0; }

.share-dialog { width: min(360px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 17px 18px; border-radius: 17px; border: 1px solid #f8fdff; background: #eef6f9; color: var(--ink); box-shadow: 0 12px 44px #21485a30; }
.share-dialog::backdrop { background: #2352644a; }
.share-dialog textarea { display: block; width: 100%; margin: 12px 0; padding: 10px 12px; resize: vertical; border: 1px solid #cbdfe7; border-radius: 10px; background: #f7fbfc; color: var(--ink); font: 400 14px/1.45 var(--sans); }
.copy-status:not(:empty) { margin-top: 8px; color: var(--muted); font-size: 13px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.game:has(#guess-slider:focus-visible) { outline: 3px solid #376678; outline-offset: -4px; }

@media (max-width: 600px) {
  .top { padding-block: 15px; }
  .wordmark { font-size: 24px; }
  .round { font-size: 11px; }
  .result { gap: 7px; padding-left: 12px; }
  .accuracy { gap: 4px; font-size: 11px; }
  .accuracy strong { font-size: 33px; }
  .points { font-size: 11px; }
  .continue { font-size: 12px; padding-inline: 11px; }
  .menu-button { width: 38px; height: 38px; }
  .intro { top: 82px; }
  h1 { font-size: clamp(36px, 10.8vw, 62px); }
  .intro p { font-size: 13px; }
  .trail-area { inset: 188px 26px 112px; }
  .info { top: 62px; }
}

@media (max-height: 520px) {
  .top { padding-block: 9px; }
  .menu-button { width: 34px; height: 34px; }
  .intro { top: 43px; }
  h1 { font-size: clamp(34px, 6vw, 46px); }
  .intro p { margin-top: 4px; font-size: 12px; }
  .trail-area { top: 135px; bottom: 86px; }
  .actions { bottom: 10px; }
}

@media (max-width: 350px) {
  .wordmark { font-size: 20px; }
  .round { left: 54%; }
}

@media (prefers-reduced-motion: no-preference) {
  .lock, .result { animation: appear .23s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(4px); } }
}
