* { box-sizing: border-box }
:root {
  font: 16px/1.5 system-ui, sans-serif;
  color: #281c19;
  background: #a74732;
  --ink: #271a19;
  --cream: #ffebc5;
  --paper: #ffdfab;
  --signal: #ffc43f;
  --rim: #f6b26e;
}
body { margin: 0 }
[hidden] { display: none !important }
button, select { font: inherit }
button { cursor: pointer; min-width: 44px; min-height: 44px; border: 0; color: var(--ink); font-weight: 780; }
button:disabled { opacity: .46; cursor: default }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #fff4d8; outline-offset: 3px; box-shadow: 0 0 0 5px #33211e }
a { color: inherit; text-underline-offset: .22em; }
button:not(:disabled):active { translate: 0 2px }
svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
#game {
  position: relative; isolation: isolate; overflow: hidden; width: 100%; height: 94dvh;
  touch-action: none; user-select: none; -webkit-touch-callout: none;
  background: radial-gradient(circle at 75% 21%,#fff0c1 0 3.2%,transparent 3.35%),
    linear-gradient(#e9a47e,#edb78f 23%,#f2ca9e 46%,#b9593c 100%);
  --edge-x: max(clamp(16px,4.2vw,70px),env(safe-area-inset-left));
  --top: max(15px,env(safe-area-inset-top));
  --bottom: max(18px,env(safe-area-inset-bottom));
  --safe-right: max(16px,env(safe-area-inset-right));
}
#game:fullscreen, #game.fixed-full { width: 100%; height: 100dvh; }
#game.fixed-full { position: fixed; inset: 0; z-index: 20; }
body.full-lock { overflow: hidden }
#scene { width: 100%; height: 100%; display: block; position: absolute; inset: 0; }
#game.map-open, #game[data-mode=paused], #game[data-mode=won], #game[data-mode=over] { touch-action: pan-y; }
.game-tools { position: absolute; top: var(--top); right: var(--safe-right); display: flex; gap: 7px; z-index: 4; }
.tool { display: grid; place-items: center; padding: 0; min-width: 46px; min-height: 46px; color: var(--cream); background: #34231f; border: 1px solid #f9d6a86e; transform: skew(-5deg); }
.tool:hover { background: #5b3325 }
.tool svg { transform: skew(5deg) }
.signature {
  position: absolute; bottom: calc(var(--bottom) + 2.1%); left: var(--edge-x);
  color: #fff0cc; transform: rotate(-4deg); transform-origin: left bottom;
  filter: drop-shadow(4px 5px 0 #652a21); pointer-events: none;
}
.wordmark { margin: 0; font: oblique 900 clamp(58px,9vw,142px)/.86 'Arial Black','Segoe UI Black',system-ui,sans-serif; letter-spacing: -.09em; padding-right: .11em; }
.wordmark span { color: #ffbd34 }
.edition {
  display: inline-block; margin: .58em 0 0 .24em; font-weight: 850; font-size: clamp(14px,1.3vw,20px); letter-spacing: .19em; text-transform: uppercase;
}
#game:not([data-mode=menu]) .signature, #game.map-open .signature { visibility: hidden }
.launch { position: absolute; left: var(--edge-x); top: 43%; display: grid; gap: 12px; }
.route-name {
  display: grid; justify-self: start; gap: 1px; background: var(--cream); padding: 10px 24px 12px;
  border-left: 6px solid #df672e; box-shadow: 5px 6px #552b22b3; transform: skew(-7deg); }
.route-name span { transform: skew(7deg) }
#chapter-name { font-size: 15px; font-weight: 760; }
#course-name { font-size: clamp(27px,3vw,46px); font-weight: 900; line-height: 1; letter-spacing: -.055em; }
.button-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap }
.primary, .secondary { position: relative; padding: .58rem 1rem; text-wrap: nowrap; border: 1px solid transparent; }
.primary { color: #251911; background: var(--signal); box-shadow: 0 4px #9a4f24 }
.primary:not(:disabled):hover { background: #ffdc72 }
.secondary { color: var(--cream); background: #3b2621; }
.secondary:not(:disabled):hover { background: #603928 }
.launch button { min-height: 53px; min-width: 93px; transform: skew(-6deg); }
.launch .primary { min-width: 136px; font-size: 21px; }
.play-mark { display: inline-block; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 10px solid #311f14; margin-right: .53em; vertical-align: .04em; }
#menu-pb { color: var(--cream); background: #38241e; justify-self: start; padding: 3px 9px; font-weight: 700; }
#hud { position: absolute; top: var(--top); left: var(--edge-x); color: var(--cream); pointer-events: none; }
.race-clock { display: grid; width: max-content; padding: 7px 17px 9px; border-left: 5px solid var(--signal); background: #332420; transform: skew(-5deg); }
#clock, #result-time { font-variant-numeric: tabular-nums; font-family: ui-monospace,Consolas,monospace; font-weight: 850; }
#clock { font-size: clamp(24px,3vw,39px); line-height: 1.17; }
#gates { color: #f2bf87; font-size: 14px; font-weight: 720; }
.speed { margin-top: 4px; background: #332420; padding: 4px 8px; width: max-content; min-width: 86px; display: flex; gap: 4px; align-items: baseline; flex-wrap: wrap; }
.speed span { font-size: 14px }
#grip { display: block; align-self: center; width: 36px; height: 11px; accent-color: var(--signal) }
#grip::-webkit-meter-bar { background: #211916; border: 1px solid #d59d69; border-radius: 0 }
#grip::-webkit-meter-optimum-value { background: #ffbf5b }
#grip::-moz-meter-bar { background: #ffbf5b }
#race-goal {
  display: grid; width: max-content; max-width: calc(100vw - 2*var(--edge-x)); gap: 1px; margin-top: 7px; color: var(--cream); background: #332420;
  border-left: 4px solid #78e5be; padding: 6px 11px 8px; line-height: 1.3; pointer-events: none;
}
#race-goal strong { font-size: 19px; }
#race-goal span { font-size: 14px; }
#cue { position: absolute; inset: auto 0 calc(var(--bottom) + 71px); display: grid; justify-content: center; padding: 0 12px; pointer-events: none; }
#message { background: #2b211f; color: var(--cream); padding: 5px 13px; font-size: 15px; border-left: 4px solid var(--signal); font-weight: 760; text-align: center; min-height: 33px; }
#game[data-mode=tutorial] #cue { bottom: var(--bottom); }
#cue.brake-warning #message { background: #5b291e; border-color: #ffd064; }
#wheel { position: absolute; bottom: var(--bottom); inset-inline: var(--edge-x) var(--safe-right); display: grid; grid-template-columns: repeat(2,62px) 1fr 66px 72px; gap: 6px; pointer-events: none; }
#wheel button {
  pointer-events: auto; min-height: 60px; padding: 0 3px; color: var(--cream); background: #32221f; border: 1px solid #ffd69a9e;
  box-shadow: 0 3px #211714a8; font-size: 15px; }
#wheel button.pressed { background: var(--cream); color: var(--ink); box-shadow: 0 1px #211714a8; translate: 0 2px; }
#wheel [data-drive=left], #wheel [data-drive=right] { font-size: 26px; }
#wheel [data-drive=brake] { grid-column: 4; }
#wheel [data-drive=gas] { background: var(--signal); color: var(--ink); border-color: #f5ce70; }
#wheel [data-drive=gas].pressed { background: #fff0b0; }
#game[data-auto-gas=true] #wheel { grid-template-columns: repeat(3,minmax(52px,66px)); justify-content: center; }
#game[data-auto-gas=true] #wheel [data-drive=brake] { grid-column: 3; }
#game[data-auto-gas=true] #wheel [data-drive=gas] { display: none; }
.overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 13px; background: #36201b43; overflow: hidden; }
.panel {
  width: min(100%,490px); max-height: 100%; overflow: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: clamp(16px,3.8vw,32px); background: var(--paper); color: var(--ink);
  box-shadow: 7px 8px 0 #321a1b9c; border-top: 8px solid #9a412b; clip-path: polygon(0 0,100% 0,100% calc(100% - 13px),calc(100% - 13px) 100%,0 100%);
}
.panel h2 { font-size: clamp(35px,5vw,63px); margin: 0 0 .28em; line-height: .96; letter-spacing: -.065em; font-weight: 900; }
.eyebrow { font-size: 15px; font-weight: 830; color: #642b20; margin: 0 0 .43em; }
.settings { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 17px; }
.settings button, .extra button, #replay-bar button { padding: .38rem .48rem; background: #f5ba7a; }
.settings button[aria-pressed=true] { box-shadow: inset 0 -4px #8e442e; }
.settings button[aria-pressed=false] { background: #fce1b8; color: #643b30; }
.result { width: min(390px, 42%); padding: clamp(12px,2vw,24px); }
.result h2 { font-size: clamp(28px,4.1vw,48px); }
.result .button-row { gap: 5px; }
.result .button-row button { padding-inline: .62rem; }
#result-time { font-size: clamp(32px,5vw,56px); line-height: 1.04; letter-spacing: -.065em; margin-bottom: .18em; }
#result-detail { font-weight: 720; margin-bottom: .5rem; }
#result-comparison { color: #642b20; margin: -.25rem 0 .6rem; font-size: 14px; font-weight: 720; }
.result .extra { margin-top: .45rem; }
#game[data-mode=won] .result { border-top: 10px solid transparent; border-image: repeating-linear-gradient(135deg,#402821 0 15px,#ffe0af 15px 30px) 10; }
#game:is([data-mode=won],[data-mode=over]):not(.map-open) .overlay {
  justify-items: start; padding-left: var(--edge-x); background: transparent;
}
#game[data-mode=won][data-reduced-motion=false]:not(.map-open) .result {
  opacity: var(--result-reveal,1);
  transform: translateY(calc(8px * (1 - var(--result-reveal,1))));
}
.atlas { width: min(100%,640px); display: grid; grid-template-rows: auto auto minmax(0,1fr) auto auto; overflow: hidden; }
.atlas-heading { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.atlas-heading h2 { margin-bottom: 0; }
.atlas-heading h2 { font-size: clamp(31px,5vw,55px); }
#chapter-tabs { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; margin: 8px 0; }
#chapter-tabs button { background: #f4bc82; padding: 0; min-width: 0; }
#chapter-tabs button[aria-pressed=true], #track-list button[aria-pressed=true] { color: var(--cream); background: #4a2d24; }
#track-list { display: grid; gap: 4px; overflow: auto; overscroll-behavior: contain; scroll-padding: 4px; padding: 4px; margin: -4px; }
#track-list button { display: flex; align-items: center; justify-content: space-between; text-align: left; background: #f7c693; padding: 3px 9px; gap: 4px; }
.track-medal { font-size: 14px; white-space: nowrap; }
#track-info { padding: 6px 0; font-size: 15px; min-height: 36px; font-weight: 640; }
.sector { display: flex; align-items: center; gap: 5px; font-weight: 720; }
.sector select { min-width: 46px; min-height: 44px; background: #ffe8c1; color: #36261d; border: 1px solid #835341; border-radius: 0; padding: 0 2px; }
#replay-bar { position: absolute; bottom: var(--bottom); inset-inline: var(--edge-x); max-width: 650px; margin-inline: auto; background: var(--paper); padding: 9px 12px; border-top: 5px solid #9a412b; z-index: 2; }
#replay-bar > div { display: flex; justify-content: space-between; gap: 3px; align-items: center; }
#replay-bar input { width: 100%; min-height: 32px; accent-color: #81422d; }
.replay-sectors button { flex: 1; }
.fallback { position: absolute; bottom: 3%; right: 3%; color: var(--cream); background: var(--ink); padding: .7rem; }
.editorial, .language, footer { width: min(calc(100% - 2*clamp(20px,7vw,100px)),1120px); margin: 0 auto; }
.editorial { padding-top: clamp(36px,7vw,104px); color: #fff0d6; }
.editorial h1 { margin: 0 0 .55em; font-size: clamp(33px,5.4vw,70px); line-height: 1.05; letter-spacing: -.055em; }
.editorial section { display: grid; grid-template-columns: minmax(160px,.8fr) minmax(0,1.45fr); gap: clamp(20px,5vw,80px); border-top: 1px solid #f9c5978c; padding: 1.5rem 0 1.8rem; }
.editorial h2 { font-size: clamp(25px,3.6vw,47px); letter-spacing: -.05em; line-height: 1.05; margin: 0; color: #fff0ce; }
.editorial p:first-child { margin-top: 0; }
.editorial p:last-child { margin-bottom: 0; }
.editorial strong { color: #ffebbd; }
.editorial ul { padding-inline-start: 1.35rem; }
.editorial li + li { margin-top: .35rem; }
.language { display: flex; flex-wrap: wrap; column-gap: 1rem; padding: .65rem 0 0; color: var(--cream); font-weight: 700; }
.language a { padding-block: .3rem; }
.language a[aria-current=page] { text-decoration-thickness: .16em; }
.language p { flex-basis: 100%; margin: .25rem 0 0; font-size: .875rem; font-weight: 400; }
footer { display: flex; flex-wrap: wrap; gap: .55rem clamp(15px,5vw,48px); border-top: 1px solid #f9c5978c; padding: 1.15rem 0 2.1rem; color: var(--cream); }
html:not([lang=en]) .panel { overflow-wrap: anywhere; }
html:not([lang=en]) .panel button, html:not([lang=en]) #replay-bar button { min-width: 0; text-wrap: wrap; }
html:not([lang=en]) .settings { grid-template-columns: repeat(3,minmax(0,1fr)); }
html:not([lang=en]) .launch { max-width: calc(100% - var(--edge-x) - var(--safe-right)); }
@media (max-width:480px) {
  html:not([lang=en]) #game.map-open .overlay { padding-top: calc(var(--top) + 52px); }
  html:not([lang=en]) #pause-panel > .button-row {
    display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: stretch;
  }
  html:not([lang=en]) .atlas-heading button { flex: 0 0 auto; white-space: nowrap; padding-inline: .62rem; }
  html:not([lang=en]) #pause-panel > .button-row button,
  html:not([lang=en]) .settings button,
  html:not([lang=en]) .atlas-actions button { padding-inline: .33rem; }
  html:not([lang=en]) .settings { grid-template-columns: repeat(2,minmax(0,1fr)); }
  html:not([lang=en]) .atlas-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  html:not([lang=en]) .atlas-actions .sector { justify-content: center; }
  html:not([lang=en]) #wheel button { font-size: 13px; }
  html:not([lang=en]) #wheel :is([data-drive=left], [data-drive=right]) { font-size: 26px; }
}
.document { max-width: 740px; margin: 0 auto; padding: 38px clamp(20px,5vw,45px); color: var(--cream); }
.document h1 { font-size: clamp(36px,8vw,64px); letter-spacing: -.06em; line-height: 1; }
.document h2 { font-size: 23px; margin-bottom: 0; }
.document p { margin-top: .65rem; }
@media (max-aspect-ratio: 9/10) {
  #game { height: 94dvh; }
  .launch { top: 25%; }
  .signature { bottom: calc(var(--bottom) + 3%); }
  .wordmark { font-size: clamp(55px,14vw,100px); }
  #wheel { grid-template-columns: repeat(2,54px) 1fr 57px 59px; }
  #wheel button { min-height: 64px; }
  #cue, #game[data-mode=tutorial] #cue { bottom: calc(var(--bottom) + 73px); }
  #game:is([data-mode=won],[data-mode=over]):not(.map-open) .overlay { place-items: start center; padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
  .result { width: min(100%, 430px); padding-right: 17px; }
  .result > .eyebrow { padding-right: 58px; }
  .editorial section { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width:340px) {
  #hud { top: calc(var(--top) + 52px); }
  #wheel { grid-template-columns: repeat(2,44px) 1fr 50px 50px; gap: 4px; inset-inline: 8px; }
  .launch .primary { min-width: 103px; }
  .launch .secondary { min-width: 73px; }
  .wordmark { font-size: clamp(43px,13vw,60px); }
  .settings { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (pointer:fine) and (min-width:800px) {
  #wheel { opacity: .87; }
}
@media (max-height:560px) and (min-aspect-ratio: 1/1) {
  #game { --bottom: 10px; --top: 9px; }
  .wordmark { font-size: clamp(43px,8.5vw,75px); }
  .signature { bottom: var(--bottom); }
  .launch { top: 29%; gap: 8px; }
  .route-name { padding-block: 4px 7px; }
  .launch button { min-height: 44px; }
  #wheel button { min-height: 50px; }
  .panel { padding: 14px; }
  .settings { margin-top: 9px; }
  .atlas { width: min(100%,720px); }
  #track-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .result { padding: 13px; }
}
@media (max-height:560px) and (min-aspect-ratio: 1/1) and (max-width:690px) {
  #track-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (min-aspect-ratio: 9/10) and (max-width:710px) {
  #game:is([data-mode=won],[data-mode=over]):not(.map-open) .overlay { padding-left: 12px; }
  .result { width: min(300px, 48%); }
}
