:root {
  color-scheme: dark;
  --night: #10251f;
  --paper: #fff5d8;
  --fern: #bdd9b4;
  --lime: #def771;
  --rule: #5a725e;
  --type: "Archivo Narrow", "Arial Narrow", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
  --body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-family: var(--body);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 86% 5%, #25463a 0, transparent 53%), var(--night);
  color: var(--paper);
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #fff9db; outline-offset: 3px; }
.masthead, main { width: min(1196px, calc(100% - 72px)); margin-inline: auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; padding: 28px 0 24px; }
.brand { display: inline-flex; gap: 12px; align-items: center; font: italic 900 26px/.95 var(--type); letter-spacing: -1.6px; white-space: nowrap; }
.brand b { color: var(--lime); }
.brand-mark { width: 37px; height: 23px; transform: skew(-18deg); background: repeating-linear-gradient(130deg,var(--lime) 0 6px,transparent 6.5px 10px); clip-path: polygon(18% 0,100% 0,82% 100%,0 100%); }
.help-button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 0 8px 12px; border: 0; background: none; font-size: 13px; font-weight: 650; color: #e2edda; }
.question { display: grid; place-items: center; border: 1.5px solid #c0cdbb; border-radius: 50%; width: 18px; height: 18px; font: 800 12px/1 var(--body); }
.help-button:hover { color: var(--lime); }
.frame { background: #10251f; border: 1px solid #6c846f; border-radius: 7px; overflow: hidden; box-shadow: 0 16px 55px #041e1838; }
.timing { min-height: 64px; display: flex; align-items: center; gap: 0; border-bottom: 1px solid #586e5d; background: #182f28; }
.timing > div { padding: 0 clamp(16px,2.4vw,36px); border-right: 1px solid #3c5446; }
.lap-stat { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; color: #c2d0ba; }
.lap-stat strong { font: italic 900 29px/1 var(--type); letter-spacing: -.06em; color: var(--lime); }
.total { color: #adc0ac; font: italic 700 16px/1 var(--type); }
.timing-item { display: flex; gap: 11px; align-items: baseline; }
.timing-item strong { font: 700 19px/1 var(--type); letter-spacing: .01em; font-variant-numeric: tabular-nums; min-width: 4.1em; }
.pause-button { position: relative; display: grid; place-items: center; margin: 0 16px 0 auto; border: 1px solid var(--rule); border-radius: 4px; background: #213c31; width: 36px; height: 34px; }
.pause-button i { width: 10px; height: 12px; border-inline: 3px solid var(--paper); }
.pause-button:disabled { opacity: .35; cursor: default; }
.pause-button:not(:disabled):hover { background: #32533f; }
.scene { isolation: isolate; position: relative; height: clamp(400px, min(49vw, 69vh), 590px); overflow: hidden; background: #779e86; }
canvas { width: 100%; height: 100%; display: block; }
.scene-shade { position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(90deg, #102723ea 0%, #142d276e 31%, transparent 57%); transition: opacity .25s ease; }
.frame:not([data-mode="ready"]) .scene-shade { opacity: 0; }
.cover { position: absolute; z-index: 2; top: clamp(30px,5.1vw,83px); left: clamp(23px,5.1vw,79px); max-width: 39%; }
.track-name { display: flex; gap: 8px; align-items: center; color: #fff2c7; font: 750 11px/1.3 var(--body); letter-spacing: .10em; text-transform: uppercase; }
.track-name i { display: block; width: 22px; height: 8px; background: repeating-linear-gradient(120deg,var(--lime) 0 4px,transparent 4.5px 7px); }
h1 { margin: 18px 0 13px; font: italic 1000 clamp(57px,7vw,100px)/.79 var(--type); letter-spacing: -.076em; transform-origin: left center; text-shadow: 1px 3px #18352d33; }
h1 em { font: inherit; color: var(--lime); }
.cover p { margin: 18px 0 20px; max-width: 230px; color: #fffbe8; font: 550 clamp(13px,1.3vw,16px)/1.4 var(--body); text-shadow: 0 1px 6px #19332c; }
.action { display: inline-flex; align-items: center; justify-content: center; padding: 12px 23px; min-width: 123px; min-height: 44px; border: 0; border-radius: 3px; background: var(--lime); color: #153122; font-size: 15px; font-weight: 800; box-shadow: 0 3px 0 #738d41; }
.action:hover { background: #edff94; }
.action:active { transform: translateY(2px); box-shadow: none; }
.speed { position: absolute; right: 20px; bottom: 17px; z-index: 2; pointer-events: none; padding: 6px 12px 7px; min-width: 101px; background: #142a23e3; border: 1px solid #b5c3a36b; border-radius: 3px; }
.speed div { display: flex; justify-content: flex-end; align-items: baseline; gap: 5px; }
.speed strong { font: italic 900 29px/1 var(--type); font-variant-numeric: tabular-nums; letter-spacing: -.06em; }
.speed span { font-size: 10px; color: #d3ddc7; }
.rev-bar { display: block; width: 100%; height: 3px; margin-top: 4px; background: linear-gradient(to right, var(--lime) 0% var(--speed,0%),#627463 var(--speed,0%) 100%); }
.race-progress { height: 5px; overflow: hidden; background: #446657; }
.race-progress i { display: block; width: 100%; height: 100%; transform: scaleX(var(--progress,0)); transform-origin: left; background: var(--lime); }
.overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; text-align: center; background: #0c211d5c; }
.result-card { max-width: min(340px,88%); border: 1px solid #a9bd91; padding: 28px 34px 32px; border-radius: 4px; background: #19372ef7; box-shadow: 0 8px 32px #071a1547; }
.result-card .track-name { justify-content: center; }
.result-card h2, .help-content h2 { margin: 14px 0 8px; font: italic 900 43px/.96 var(--type); letter-spacing: -.045em; }
.result-card p { color: #e3e9cf; font-size: 14px; line-height: 1.5; margin: 12px 0 18px; }
.toast { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); top: 16%; padding: 7px 14px; background: #183728de; border: 1px solid var(--lime); color: var(--lime); font: italic 850 18px/1 var(--type); white-space: nowrap; pointer-events: none; border-radius: 2px; }
.below { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 21px 2px 30px; }
.route-info, .keys, .keys > div { display: flex; align-items: center; }
.route-info { gap: 12px; }
.route-info strong, .route-info span { display: block; }
.route-info strong { font-size: 14px; font-weight: 700; }
.route-info span { margin-top: 2px; color: #b7c8b3; font-size: 12px; }
.route-info b { margin-inline: 4px; }
.finish-flag { width: 25px; height: 20px; border-left: 2px solid #d6e5c7; transform: skew(-10deg); }
.finish-flag::before { content: ''; display: block; width: 23px; height: 13px; background: conic-gradient(#d3e2be 25%,#254234 0 50%,#d3e2be 0 75%,#254234 0) 0 0/8px 8px; }
.keys { gap: 20px; }
.keys > div { gap: 3px; }
.keys span { color: #c6d4c0; font-size: 12px; margin-left: 4px; }
kbd { border: 1px solid #65816b; border-bottom-width: 2px; border-radius: 3px; color: #e7efd7; font: 650 12px/1 var(--body); padding: 4px 6px; }
.touch { display: none; gap: 6px; }
.touch button { border: 1px solid #78947a; background: #284739; border-radius: 4px; min-height: 46px; min-width: 48px; color: var(--paper); font-size: 22px; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch .brake { font-size: 13px; font-weight: 720; padding-inline: 12px; }
.touch button.held { background: var(--lime); color: #183727; }
dialog { padding: 0; width: min(410px,90%); border: 1px solid #90ab82; border-radius: 6px; background: #19352b; color: var(--paper); }
dialog::backdrop { background: #0b211cb8; }
.help-content { position: relative; padding: 27px; }
.help-content h2 { font-size: 34px; margin-top: 0; }
.help-content p,.help-content li { color: #d8e2ce; font-size: 14px; line-height: 1.5; }
.help-content ul { list-style: none; margin: 20px 0 0; padding: 0; }
.help-content li { border-top: 1px solid #4f6856; padding: 9px 0; }
.help-content li b { display: block; color: var(--lime); }
.close { display: grid; place-items: center; position: absolute; right: 12px; top: 12px; width: 32px; height: 32px; border: 1px solid #72896f; border-radius: 3px; background: none; font-size: 23px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (pointer:coarse), (max-width:760px) { .keys { display: none; } .touch { display: flex; } }
@media (max-width:760px) {
  .masthead, main { width: calc(100% - 28px); }
  .masthead { padding: 17px 0; }
  .brand { font-size: 23px; gap: 7px; }
  .brand-mark { width: 28px; height: 18px; }
  .scene { height: clamp(395px, 61svh, 530px); }
  .cover { left: 22px; top: 25px; max-width: 58%; }
  h1 { font-size: clamp(51px,10vw,76px); }
  .cover p { max-width: 180px; font-size: 13px; margin-block: 12px 15px; }
  .scene-shade { background: linear-gradient(130deg,#142c24d1 0%,#142c2436 39%,transparent 62%); }
  .timing { min-height: 54px; }
  .timing > div { padding-inline: 13px; }
  .timing-item { gap: 3px; flex-direction: column; }
  .timing-item strong { font-size: 15px; min-width: 3.8em; }
  .speed { right: 10px; bottom: 10px; min-width: 75px; padding: 5px 9px; }
  .speed strong { font-size: 23px; }
  .below { gap: 6px; padding: 13px 0 20px; }
  .route-info { gap: 7px; }
  .route-info strong { font-size: 12px; }
}
@media (max-width:470px) {
  .timing > div { padding-inline: 9px; }
  .lap-stat { gap: 4px; }
  .lap-stat strong { font-size: 23px; }
  .total { font-size: 12px; }
  .pause-button { margin-right: 8px; width: 30px; height: 31px; }
  .track-name { font-size: 9px; }
  .cover { top: 20px; left: 16px; }
  .action { min-height: 40px; padding: 9px 14px; }
  .route-info { flex: 1; }
  .finish-flag { display: none; }
  .touch { gap: 4px; }
  .touch button { min-width: 44px; }
}
@media (max-width:355px) { .masthead,main { width: calc(100% - 16px); } .lap-stat .label { font-size: 8px; } .route-info { max-width: 98px; } .help-button { font-size: 12px; } }
@media (max-height:520px) and (orientation:landscape) {
  .masthead { padding: 7px 0; }
  .brand { font-size: 19px; }
  .scene { height: max(215px,calc(100svh - 155px)); }
  .timing { min-height: 40px; }
  .cover { top: 12px; left: 24px; }
  h1 { margin-block: 9px; font-size: 46px; }
  .cover p { margin-block: 7px; }
  .below { padding-block: 7px; }
}
@media (prefers-reduced-motion:reduce) { .scene-shade { transition: none; } }
