:root {
  color-scheme: light;
  --night: #172e28;
  --dark: #203d34;
  --cream: #f9f0d7;
  --paper: #eff3e8;
  --ink: #20372d;
  --buff: #efd59f;
  --muted: #c3d5c5;
  --serif: Georgia, "Times New Roman", serif;
  --gutter: clamp(12px, 2.45vw, 42px);
  font: 16px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--night); color: var(--cream); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; min-width: 44px; min-height: 44px; }
a { color: inherit; text-underline-offset: 0.21em; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #fff4bf;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #273f36;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.masthead { padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right)); }
.masthead-inner {
  max-width: 1536px; margin: auto; height: clamp(60px, 9.4dvh, 79px);
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand:link { text-decoration: none; font: 700 1.65rem/1 var(--serif); letter-spacing: -0.035em; }
.brand img { display: block; width: clamp(34px, 4vw, 42px); height: auto; }
.brand h1 { font: 700 clamp(31px, 4vw, 44px)/1 var(--serif); letter-spacing: -0.055em; margin: -4px 0 0; }
.guide-link {
  display: grid; align-items: center; min-height: 44px; padding: 0 3px;
  color: #e0ead9; font-size: 0.93rem; font-weight: 650;
  text-decoration-color: #93af9e; text-decoration-thickness: 1px;
}
#game {
  position: relative; isolation: isolate; overflow: clip; overflow-anchor: none;
  margin: 0 auto; width: min(1536px, calc(100% - var(--gutter) * 2));
  height: clamp(400px, 84dvh, 1050px);
  border: 1px solid #759889; border-radius: 22px;
  background: #accace; touch-action: none; user-select: none; -webkit-user-select: none;
}
#game:focus { outline: none; }
canvas { display: block; width: 100%; height: 100%; }
#hud {
  position: absolute; inset: clamp(10px, 2.4vw, 24px) clamp(10px, 2.4vw, 24px) auto;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; z-index: 3;
}
.gauges {
  background: #1d392f; color: var(--cream);
  border: 1px solid #aec4ac; border-radius: 13px;
  padding: 9px 14px; display: flex; align-items: stretch; gap: 14px;
  box-shadow: 0 3px 0 #183a3255;
}
.meter { min-width: 78px; }
.meter-name { display: block; color: #d3e2cf; font-size: 0.82rem; font-weight: 650; }
.meter strong { display: block; white-space: nowrap; font-size: clamp(21px, 3.2vw, 30px); line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.05em; }
.meter strong small { font-size: 0.55em; font-weight: 650; color: #e4e6cc; letter-spacing: 0; }
.meter.best { min-width: 82px; padding-left: 13px; border-left: 1px solid #66877a; }
.meter.best strong { color: #f0d39d; font-size: clamp(20px, 2.8vw, 26px); }
.track { height: 4px; background: #506c5d; border-radius: 6px; margin-top: 6px; overflow: hidden; }
.track span { display: block; width: 100%; height: 100%; background: #f0d094; transform: scaleX(0); transform-origin: left center; }
#split {
  position: absolute; top: 100%; left: 0; margin: 8px 0 0; padding: 4px 8px;
  background: #1d392f; color: var(--cream); border: 1px solid #aec4ac; border-radius: 6px;
  font-size: 0.79rem; font-weight: 720; font-variant-numeric: tabular-nums;
}
.tools { pointer-events: auto; display: flex; gap: 8px; }
.tool {
  display: grid; place-items: center; border: 1px solid #b4c9b3;
  border-radius: 12px; width: 46px; height: 46px; background: #1d392f; color: var(--cream);
  box-shadow: 0 3px 0 #183a3255;
}
.tool:hover, .tool[aria-expanded="true"] { background: #34574b; }
.panel {
  position: absolute; z-index: 2; top: 20%; right: clamp(26px, 11%, 180px);
  width: min(37%, 406px); min-width: 320px;
  padding: clamp(23px, 3.15vw, 44px); border-radius: 18px;
  border: 1px solid #fffae7;
  background: #f3edda; color: var(--ink);
  box-shadow: 0 5px 0 #3452483d, 0 21px 48px #204a4124;
  animation: card-in 180ms ease-out both;
}
@keyframes card-in { from { opacity: 0.65; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
[data-mode="menu"] #overlay { animation: none; }
.panel-caption { color: #3e6555; font-weight: 780; font-size: 0.85rem; letter-spacing: 0.035em; }
.panel h2 { font: 700 clamp(37px, 4.25vw, 64px)/0.99 var(--serif); letter-spacing: -0.061em; margin: 0.2em 0; }
.panel p { max-width: 27ch; margin: 14px 0 23px; color: #344c40; font-size: 1rem; line-height: 1.43; }
#retry-tip { margin-top: -6px; font-weight: 700; }
[data-mode="paused"] .panel-actions { margin-top: 15px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.quick-sfx {
  border: 1px solid #86a797; background: #294b3f; color: var(--cream);
  border-radius: 9px; padding: 0 9px; font-size: 0.88rem; font-weight: 680;
}
.quick-sfx:hover { background: #34594c; }
.panel .primary {
  background: #a3314f; color: #fff5e3; border: 1px solid #8e2844;
  border-radius: 9px; padding: 0 19px; min-height: 49px; min-width: 118px;
  display: inline-flex; align-items: center; justify-content: center; gap: 11px;
  font-weight: 790; box-shadow: 0 3px 0 #731e37; transition: background 130ms, translate 130ms;
}
.panel .primary:hover { background: #8a2841; }
.panel .primary:active { translate: 0 2px; box-shadow: 0 1px 0 #731e37; }
.play-icon { display: inline-block; border-block: 6px solid transparent; border-left: 10px solid currentColor; }
[data-mode="over"] #overlay, [data-mode="won"] #overlay, [data-mode="paused"] #overlay {
  background: #1d392f; color: var(--cream); border-color: #a4baa1;
}
[data-mode="over"] #overlay p, [data-mode="won"] #overlay p, [data-mode="paused"] #overlay p { color: #dce8d6; }
[data-mode="over"] #caption, [data-mode="won"] #caption, [data-mode="paused"] #caption { color: #f0d39d; }
[data-mode="over"] #primary, [data-mode="won"] #primary, [data-mode="paused"] #primary { background: #f0d39d; color: #233a30; border-color: #dfc58e; box-shadow: 0 3px 0 #978659; }
[data-mode="over"] #primary:hover, [data-mode="won"] #primary:hover, [data-mode="paused"] #primary:hover { background: #ffe4ab; }
.settings-panel {
  color: var(--cream); background: #1d392f; border-color: #b4c9b3;
  max-height: calc(100% - 99px); overflow: auto; overscroll-behavior: contain;
  top: 14%; right: clamp(67px, 9%, 170px); padding: 21px;
  width: min(420px, calc(100% - 26px));
}
.settings-panel h2 { margin: 0 0 13px; font-size: clamp(26px, 3.8vw, 39px); }
.switches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.switches button {
  border: 1px solid #658777; background: #28473c; border-radius: 7px;
  padding: 4px 8px; text-align: left; font-size: 0.86rem; font-weight: 640;
  display: flex; align-items: center; justify-content: space-between; gap: 5px;
}
.switches button [aria-hidden=true] { flex: 0 0 25px; height: 15px; border-radius: 12px; background: #53766a; position: relative; }
.switches button [aria-hidden=true]::after {
  content: ""; width: 9px; height: 9px; position: absolute; inset: 3px auto auto 3px;
  background: #f7edd1; border-radius: 50%; transition: translate 130ms;
}
.switches button[aria-pressed="true"] [aria-hidden=true] { background: #eed29b; }
.switches button[aria-pressed="true"] [aria-hidden=true]::after { background: #283b31; translate: 10px 0; }
.switches button[aria-disabled="true"] { cursor: default; }
.settings-panel .done { margin-top: 11px; min-height: 44px; min-width: 82px; }
#pedals {
  z-index: 1;
  position: absolute; inset: auto clamp(12px, 2.5vw, 31px) max(clamp(13px, 2.45vw, 27px), env(safe-area-inset-bottom));
  display: grid; grid-template-columns: minmax(0, 198px) 1fr minmax(0, 198px);
  justify-items: stretch; align-items: end; gap: 9px; pointer-events: none;
}
.pedal {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px;
  padding: 0 13px; min-height: 69px; text-align: left; background: #223f34;
  border: 1px solid #8ba893; border-radius: 13px; color: var(--cream);
  box-shadow: 0 4px 0 #112b23; pointer-events: auto;
  transition: background 110ms, translate 100ms, box-shadow 100ms;
}
.pedal.gas { background: #e8cb94; color: #20372e; border-color: #f4dfb2; box-shadow: 0 4px 0 #785f39; }
.pedal:not(:disabled):hover { background: #315349; }
.pedal.gas:not(:disabled):hover { background: #f6dfa9; }
.pedal.down, .pedal.down:not(:disabled):hover { color: #222f24; background: #fff0c1; translate: 0 3px; box-shadow: 0 1px 0 #182e28; }
.pedal:disabled { cursor: default; opacity: 0.79; pointer-events: none; }
.pedal-face {
  width: 23px; height: 32px; border: 1px solid currentColor; border-radius: 5px;
  background: repeating-linear-gradient(0deg, transparent 0 5px, currentColor 5px 6px, transparent 6px 8px);
  background-size: 67% 71%; background-repeat: no-repeat; background-position: center; opacity: 0.8;
}
.gas .pedal-face { width: 19px; height: 35px; rotate: 8deg; }
.pedal-label { font-weight: 800; font-size: 1.05rem; line-height: 1.14; }
.pedal-label small { display: block; font-size: 0.75rem; font-weight: 650; margin-top: 3px; white-space: nowrap; }
.pedal kbd {
  font: 700 14px/1 system-ui, sans-serif; min-width: 24px; padding: 4px;
  text-align: center; border: 1px solid currentColor; border-radius: 5px;
}
.brake { grid-column: 1; grid-row: 1; }
.gas { grid-column: 3; grid-row: 1; }
.mirrored .brake { grid-column: 3; }
.mirrored .gas { grid-column: 1; }
.large-pedals #pedals { grid-template-columns: minmax(0, 237px) 1fr minmax(0, 237px); }
.large-pedals .pedal { min-height: 83px; }
.hint-wrap {
  position: absolute; z-index: 1; top: 25%; inset-inline: 14px;
  display: grid; justify-items: center; pointer-events: none;
}
#hint {
  margin: 0; padding: 8px 13px; width: max-content; max-width: 100%;
  background: #19382d; color: #fff1d2; border-radius: 8px; border: 1px solid #93ad94;
  font-size: 0.89rem; text-align: center; font-weight: 680;
}
#hint[data-warning="true"] {
  background: #f6db9d; color: #253329; border: 2px solid #553f23;
  box-shadow: 0 3px 0 #28382f45; font-weight: 790;
}
.guide, .legal {
  background: var(--paper); color: var(--ink); margin: clamp(30px, 6vw, 74px) auto 0;
  padding: clamp(34px, 7vw, 91px) max(var(--gutter), calc((100% - 1030px) / 2));
  scroll-margin-top: 12px;
}
.guide > h2, .legal h1 { margin: 0 0 15px; font: 700 clamp(34px, 5vw, 61px)/1.02 var(--serif); letter-spacing: -0.047em; }
.guide section h2, .legal h2 { font: 700 clamp(25px, 3vw, 35px)/1.09 var(--serif); margin: 0 0 0.65em; letter-spacing: -0.024em; }
.guide p, .legal p { max-width: 71ch; line-height: 1.65; margin: 0 0 1em; }
.guide .intro { font-size: clamp(17px, 2vw, 21px); max-width: 64ch; }
.guide-layout { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(23px, 6vw, 86px); margin-top: clamp(23px, 4vw, 56px); }
.guide li { margin-bottom: 0.7em; }
.guide ul { padding-left: 1.15em; margin-top: 0; }
.faq { border-top: 1px solid #bac9bb; margin-top: clamp(28px, 5vw, 56px); padding-top: 23px; }
.faq details { border-bottom: 1px solid #bac9bb; }
.faq summary { cursor: pointer; font-weight: 740; padding: 12px 4px; }
.faq p { padding-inline-start: 4px; }
.guide-note { margin-top: 21px !important; color: #435d50; font-size: 0.94rem; }
.language-nav {
  display: flex; flex-wrap: wrap; justify-content: center; column-gap: clamp(8px, 2vw, 24px);
  margin: 8px var(--gutter) 0; color: var(--muted); font-size: 0.88rem;
}
.language-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.language-nav a[aria-current="page"] { color: var(--cream); font-weight: 750; text-decoration: none; }
.legal { margin-top: 0; min-height: calc(100dvh - 163px); }
.legal h2 { margin-top: 1.1em; }
.footer > div {
  margin: auto; max-width: 1100px; min-height: 98px;
  display: flex; gap: 8px 25px; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 16px var(--gutter);
}
.footer nav { display: flex; gap: clamp(12px, 4vw, 35px); }
.footer a { display: inline-grid; align-items: center; min-height: 44px; font-weight: 650; }
.footer nav { flex-wrap: wrap; row-gap: 0; }
.switches button span:first-child { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.pedal-label { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.pedal-label small { white-space: normal; }
.masthead-inner { gap: 12px; }
.brand img { flex: 0 0 auto; }
.brand h1 { font-size: clamp(28px, 3.8vw, 44px); }
.guide-link { flex: 0 0 auto; }
#message { overflow-wrap: anywhere; hyphens: auto; }

@media (max-width: 670px) {
  :root { --gutter: 14px; }
  #game { width: calc(100% - 12px); height: min(88dvh, 820px); min-height: 475px; border-radius: 15px; }
  #hud { inset: 10px 10px auto; }
  .gauges { padding: 7px 10px; gap: 9px; }
  .meter { min-width: 67px; }
  .meter.best { min-width: 65px; padding-left: 9px; }
  .panel { left: 50%; right: auto; top: 16%; transform: translateX(-50%); width: min(340px, calc(100% - 38px)); min-width: 0; padding: 21px; }
  .panel h2 { font-size: clamp(35px, 8.8vw, 53px); }
  .panel p { margin: 10px 0 15px; }
  [data-mode="menu"] #overlay { padding: 13px 20px 16px; }
  [data-mode="menu"] #overlay h2 { margin: 0.12em 0; }
  [data-mode="menu"] #overlay p { margin: 5px 0 11px; }
  [data-mode="menu"] #overlay .primary { min-height: 46px; }
  .settings-panel { top: 13%; padding: 16px; }
  .settings-panel h2 { font-size: 29px; }
  #pedals, .large-pedals #pedals { grid-template-columns: minmax(0, 1fr) 13px minmax(0, 1fr); gap: 0; }
  .pedal { padding: 0 10px; gap: 9px; min-height: 65px; grid-template-columns: auto 1fr; }
  .pedal kbd { display: none; }
  .hint-wrap { top: 37%; }
  .guide-layout { grid-template-columns: 1fr; }
  .brand h1 { font-size: clamp(20px, 4.9vw, 30px); letter-spacing: -0.04em; }
}
@media (max-width: 400px) {
  .brand { gap: 9px; }
  .guide-link { font-size: 0.86rem; }
  .panel { width: calc(100% - 36px); }
}
@media (max-height: 575px) and (orientation: portrait) {
  #game { min-height: 400px; height: calc(100dvh - 65px); }
  .panel { top: 19%; padding: 14px 18px; }
  .panel h2 { font-size: 32px; }
  .panel p { margin: 7px 0 10px; }
  .settings-panel { top: 17%; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .masthead-inner { height: 47px; }
  .brand img { width: 30px; }
  .brand h1 { font-size: clamp(24px, 3.8vw, 31px); }
  #game {
    min-height: 243px; height: calc(100dvh - 55px); border-radius: 13px;
    width: calc(100% - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right) + 10px));
  }
  #hud { inset: 8px 9px auto; }
  .gauges { padding: 6px 10px; }
  .meter strong { font-size: 22px; }
  .panel {
    top: 18%; left: auto; right: 8%; transform: none;
    width: min(43%, 410px); min-width: 225px; padding: 13px 17px;
  }
  .panel h2 { font-size: clamp(28px, 4.1vw, 37px); }
  .panel p { margin: 6px 0 9px; font-size: 0.90rem; }
  .panel .primary { min-height: 44px; }
  .settings-panel { top: 8px; right: 65px; width: min(565px, 68%); max-height: calc(100% - 16px); }
  .settings-panel h2 { font-size: 24px; }
  .switches { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #pedals { bottom: 10px; }
  .pedal { min-height: 49px; }
  .large-pedals .pedal { min-height: 60px; }
  .hint-wrap { top: 29%; }
}
@media (max-height: 360px) and (orientation: landscape) {
  .panel { top: 16%; width: min(49%, 360px); right: 5%; }
  .settings-panel { top: 6px; right: 64px; width: min(565px, 68%); }
  .panel h2 { font-size: 28px; }
  .settings-panel h2 { font-size: 23px; }
  .quick-sfx { font-size: 0.81rem; }
}
@media (pointer: coarse) {
  .pedal kbd { display: none; }
  .pedal { grid-template-columns: auto 1fr; }
}
.reduced *, .reduced *::before, .reduced *::after { animation: none !important; transition-duration: 0s !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
