:root {
  color-scheme: dark;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  background: #090b0e;
  color: #f5faff;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  --viewport-height: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  height: var(--viewport-height);
  margin: 0;
  padding: var(--safe-top) env(safe-area-inset-right, 0px) var(--safe-bottom) env(safe-area-inset-left, 0px);
  overflow: hidden;
}
@supports (height: 100dvh) {
  body { --viewport-height: 100dvh; }
}
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible + span {
  outline: 2px solid #f8cc78;
  outline-offset: 4px;
}
.pause, .text-button { color: #d6e5ee; background: transparent; border: 1px solid #486073; border-radius: 5px; padding: 6px 13px; }
.pause:hover, .text-button:hover { background: #243949; }
.game {
  --ui-scale: 1;
  --edge: 18px;
  position: relative;
  isolation: isolate;
  container: game / inline-size;
  overflow: hidden;
  width: 100%;
  max-width: calc((var(--viewport-height) - var(--safe-top) - var(--safe-bottom)) * 16 / 9);
  aspect-ratio: 16 / 9;
  background: #b9d9e6;
  touch-action: manipulation;
}
.game:is([data-mode="riding"], [data-mode="crashing"]) {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
canvas { display: block; width: 100%; height: 100%; }
.interface {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--ui-width, 100%);
  height: var(--ui-height, 100%);
  transform: scale(var(--ui-scale));
  transform-origin: top left;
  pointer-events: none;
}
.hud { position: absolute; z-index: 2; top: var(--edge); left: var(--edge); right: var(--edge); display: flex; align-items: flex-start; justify-content: space-between; gap: 5px; pointer-events: none; }
.game:has(.overlay:not([hidden])) .hud :is(.hud-trail, .metrics) { display: none; }
.game:has(.overlay:not([hidden])) .hud-actions { margin-left: auto; }
.hud-actions { display: grid; justify-items: end; gap: 6px; }
.pause { pointer-events: auto; min-height: 36px; background: #132637eb; }
.music-toggle[aria-pressed="true"] { border-color: #91d1d3; color: #c2f3f1; }
.terrain, .metrics {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid #def3ff4d; border-radius: 6px; background: #132637eb;
}
.terrain { padding: 8px 11px; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.terrain-dot { width: 7px; height: 7px; border-radius: 50%; background: #9de2cd; }
.metrics { gap: 0; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.metrics div { padding: 0 11px; min-width: 67px; }
.metrics div + div { border-left: 1px solid #a7cad446; }
.metrics span { display: block; color: #b3ccd9; font-size: .6rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.metrics strong { font-size: 1.4rem; }
.metrics small { margin-left: .25em; color: #b3ccd9; font-size: .62rem; }
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 18px 5% 16px;
  background: linear-gradient(90deg, #102131f5, #102131d1 35%, #10213143 62%, transparent 85%);
}
.menu {
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: min(100%, 520px);
}
.menu > [role="tabpanel"] { min-height: 0; overflow: auto; }
#run-panel { display: flex; flex-direction: column; overflow: hidden; }
.run-content { min-height: 0; overflow: auto; padding: 4px; }
.run-options fieldset:last-child { margin-bottom: 0; }
.run-actions { display: flex; align-items: center; gap: 8px; padding: 6px 4px 4px; }
.run-actions .text-button { margin: 0; }
.run-help { margin-top: 10px; font-size: .8rem; }
.run-help summary { cursor: pointer; padding-block: 4px; }
.run-help .controls { margin-top: 5px; }
.eyebrow { color: #a4e8e7; font-weight: 850; font-size: .71rem; letter-spacing: .18em; margin: 0 0 12px; }
h1 { font-size: 4.8rem; line-height: .89; letter-spacing: -.075em; margin: 0; }
#description { color: #e0edf3; font-size: .95rem; line-height: 1.55; max-width: 44ch; margin: 18px 0; }
fieldset { padding: 0; border: 0; margin: 0 0 17px; min-inline-size: 0; }
legend { color: #c7dce6; font-weight: 650; font-size: .72rem; margin-bottom: 7px; padding: 0; }
fieldset label { display: inline-block; position: relative; margin-right: 3px; }
fieldset input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
fieldset span { display: block; border: 1px solid #93bcc47d; border-radius: 4px; padding: 6px 12px; font-size: .8rem; }
.menu-options { display: flex; flex-wrap: wrap; gap: 6px; }
.menu-options label { margin: 0; }
.menu-options span { white-space: nowrap; }
.character-trait { margin: 7px 0 0; color: #c7dce6; font-size: .75rem; }
fieldset input:checked + span { color: #132b35; background: #b8e8e9; border-color: #b8e8e9; font-weight: 750; }
.primary {
  display: flex; align-items: center; justify-content: space-between; gap: 32px; min-width: 156px;
  padding: 11px 14px; border: 0; border-radius: 5px; background: #ffdb91; color: #152536; font-weight: 850;
}
.primary:hover { background: #ffe8b9; }
.text-button { margin-top: 12px; font-size: .8rem; }
.message { position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%); padding: 7px 12px; border-radius: 4px; color: #fff5d9; background: #162a39ed; font-size: .86rem; font-weight: 750; text-align: center; pointer-events: none; }
.message:empty { display: none; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; color: #e3edf4; font-size: .75rem; }
.control { display: flex; align-items: center; gap: 6px; padding: 3px 7px; border-radius: 4px; background: #132637eb; }
.touch-help { display: none; margin: 0; max-width: 48ch; line-height: 1.5; }
kbd { font: inherit; min-width: 22px; display: inline-block; padding: 2px 5px; text-align: center; color: #e5eff5; background: #233545; border: 1px solid #456073; border-radius: 4px; }
.touch {
  position: absolute;
  inset: auto var(--edge) var(--edge);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.touch-steering, .touch-actions {
  display: grid;
  grid-auto-rows: var(--touch-key-size);
  gap: 6px;
}
.touch-steering { flex: 0 0 max(56px, var(--touch-key-size)); }
.touch-actions {
  flex: 0 1 258px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.touch button {
  padding: 0 4px;
  border: 1px solid #a9dcf291;
  border-radius: 9px;
  color: #f0fcff;
  background: #132637eb;
  font-size: .88rem;
  font-weight: 750;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-steering button { font-size: 1.35rem; }
.touch button[data-action="tuck"] { grid-column: span 2; }
.touch button.is-held, .touch button:active { color: #132637; background: #a4e8e7; }
@container game (width <= 600px) {
  .hud, .touch, .power-controls, .message { --edge: 10px; }
  .metrics div { min-width: 49px; padding: 0 5px; }
  .metrics strong { font-size: 1.1rem; }
  .terrain { padding: 7px 6px; gap: 4px; font-size: .66rem; }
  .overlay { padding: 10px 3% 8px; background: linear-gradient(90deg, #102131f2, #102131ac 79%, #10213170); }
  .menu { width: 100%; }
  .menu-tabs { padding-right: 122px; }
  .run-content { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 8px 12px; align-items: start; }
  .run-content > :is(.slalom-records, .run-help) { grid-column: 1 / -1; margin-top: 0; }
  .eyebrow { margin-bottom: 7px; }
  h1 { font-size: 3.25rem; }
  #description { margin: 8px 0 0; }
  .run-options fieldset { margin-bottom: 8px; }
  .run-options legend { margin-bottom: 4px; }
  .bests-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bests-panel > dl { grid-column: 1 / -1; }
}
@container game (width <= 420px) {
  .menu-options { gap: 4px; }
  .menu-options span { padding-inline: 8px; }
}
@media (pointer: coarse) {
  .controls .control { display: none; }
  #pause { min-height: calc(44px / var(--ui-scale)); }
  .run-actions button { min-height: calc(40px / var(--ui-scale)); }
}

.terrain:has(.green) .terrain-dot { background: #9de8a2; }
.terrain:has(.steep) .terrain-dot {
  position: relative;
  width: 17px;
  height: 9px;
  background: transparent;
}
.terrain:has(.steep) .terrain-dot::before,
.terrain:has(.steep) .terrain-dot::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 7px;
  height: 7px;
  background: #f8cc78;
  transform: rotate(45deg);
}
.terrain:has(.steep) .terrain-dot::after { left: 10px; }

.hud-trail { display: grid; justify-items: start; gap: 6px; }
.race-status, .pipe-status {
  max-width: min(16rem, 46cqw);
  padding: 6px 9px;
  border: 1px solid #a9dcf29c;
  border-radius: 6px;
  background: #132637f0;
  color: #e6f3fa;
  font-size: .72rem;
  line-height: 1.35;
}
.race-status strong { display: block; color: #ffdb91; }
.pipe-status { border-color: #ffc465aa; font-weight: 700; }

.conditions {
  padding: 4px 9px;
  border: 1px solid #def3ff4d;
  border-radius: 5px;
  background: #132637eb;
  color: #dcecf5;
  font-size: .68rem;
  font-weight: 650;
  white-space: nowrap;
}

.hud-wallet { display: flex; align-items: center; gap: 6px; }
.wallet, .power-status {
  padding: 6px 9px;
  border: 1px solid #def3ff4d;
  border-radius: 5px;
  background: #132637eb;
  color: #ffdb91;
  font-size: .73rem;
  font-weight: 750;
  white-space: nowrap;
}
.wax-option input:checked + span {
  color: #132b35;
  background: #ffdb91;
  border-color: #ffdb91;
  font-weight: 750;
}
.power-controls {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  bottom: var(--edge);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.power-controls button {
  pointer-events: auto;
  min-height: 36px;
  padding: 5px 8px;
  color: #edf8fc;
  background: #132637eb;
  border: 1px solid #a9dcf27f;
  border-radius: 5px;
  font-size: .73rem;
  font-weight: 700;
}
.power-controls button:hover { background: #25455b; }
.power-controls small { color: #ffdb91; font-size: .66rem; white-space: nowrap; }
@media (any-pointer: coarse) {
  .game {
    --touch-key-size: max(48px, calc(44px / var(--ui-scale)));
    --touch-top: calc(var(--edge) + 2 * var(--touch-key-size) + 6px);
  }
  .touch-help { display: block; }
  .power-controls {
    left: calc(var(--edge) + max(56px, var(--touch-key-size)) + 12px);
    right: calc(var(--edge) + 270px);
    justify-content: center;
  }
  .power-controls button { min-height: calc(44px / var(--ui-scale)); touch-action: manipulation; }
  .power-controls kbd { display: none; }
  .message { bottom: calc(var(--touch-top) + 10px); }
  @container game (width < 640px) {
    .touch, .power-controls {
      --lanes-width: var(--touch-key-size);
      --actions-width: calc(3 * var(--touch-key-size) + 8px);
    }
    .touch { gap: 4px; }
    .touch-steering, .touch-actions { gap: 4px; }
    .touch-steering { flex-basis: var(--lanes-width); }
    .touch-actions { flex-basis: var(--actions-width); }
    .power-controls {
      left: calc(var(--edge) + var(--lanes-width) + 4px);
      right: calc(var(--edge) + var(--actions-width) + 4px);
      gap: 4px;
    }
    .power-controls button { min-width: min(100%, 100px); }
    .message { bottom: calc(var(--edge) + 2 * var(--touch-key-size) + 8px); }
  }
}

.groomer-warning {
  max-width: min(13rem, 45cqw);
  padding: 6px 8px;
  border: 1px solid #ffd28b;
  border-radius: 5px;
  background: #654020f5;
  color: #fff0ce;
  font-size: .74rem;
  font-weight: 800;
}

.ice-turn {
  padding: 7px 10px;
  border: 1px solid #99dce5;
  border-radius: 5px;
  color: #e8faff;
  background: #244861f5;
  font-size: .78rem;
  font-weight: 800;
}
.ice-turn.now {
  background: #176c59;
  border-color: #a5f4d2;
  color: #f1fff6;
}

.ice-countdown {
  position: absolute;
  z-index: 2;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  width: 146px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #a0e4f0;
  border-radius: 50%;
  background: #17394ce8;
  color: #f2fcff;
  font-size: 7.5rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
@container game (width <= 600px) {
  .ice-countdown { width: 100px; font-size: 5rem; }
}

.terrain:has(.slalom) .terrain-dot { background: #ffb7a0; }
.slalom-status strong { color: #a4e8e7; }
#slalom-clock { margin-left: .4em; font-variant-numeric: tabular-nums; }
.slalom-records {
  margin-top: 18px;
  padding: 10px 12px;
  background: #132637eb;
  border: 1px solid #486073;
  border-radius: 5px;
}
.slalom-records h2 { margin: 0 0 6px; color: #a4e8e7; font-size: .8rem; }
.slalom-records ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 23px;
  padding-left: 1.1em;
  margin: 0;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}
.slalom-records li::marker { color: #a9c4d2; }

.menu-tabs {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 16px;
  border-bottom: 1px solid #7396a77a;
}
.menu-tabs button {
  padding: 7px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #c7dce6;
  font-size: .82rem;
  font-weight: 750;
  white-space: nowrap;
}
@container game (width <= 420px) {
  .menu-tabs button { padding-inline: 6px; font-size: .76rem; }
}
.menu-tabs button:hover { background: #243949; }
.menu-tabs button[aria-selected="true"] {
  color: #f0fcff;
  border-bottom-color: #a4e8e7;
}
.bests-panel {
  display: grid;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid #486073;
  border-radius: 5px;
  background: #132637f2;
}
.bests-panel h2 { margin: 0 0 3px; color: #a4e8e7; font-size: .78rem; }
.bests-list { margin: 0; font-size: .86rem; }
.bests-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}
.bests-list div + div { border-top: 1px solid #7396a736; }
.bests-list dd {
  margin: 0;
  color: #f6fdff;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.upgrades-panel {
  padding: 13px 15px;
  border: 1px solid #486073;
  border-radius: 5px;
  background: #132637f2;
}
.upgrade-toolbar, .upgrade-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.upgrade-toolbar label {
  display: grid;
  gap: 5px;
  color: #c7dce6;
  font-size: .73rem;
}
.upgrade-toolbar select, .upgrade-row button {
  padding: 6px 8px;
  border: 1px solid #587b91;
  border-radius: 4px;
  background: #233545;
  color: #f0fcff;
  font: inherit;
}
.upgrade-note, .upgrade-row p {
  margin: 6px 0 3px;
  color: #c7dce6;
  font-size: .75rem;
  line-height: 1.35;
}
.upgrade-row {
  padding: 10px 0;
  border-top: 1px solid #7396a736;
}
.upgrade-row h2 { margin: 0; font-size: .9rem; }
.upgrade-row strong { color: #a4e8e7; font-size: .72rem; }
.upgrade-row button { font-size: .75rem; font-weight: 750; white-space: nowrap; }
.upgrade-row button:hover:enabled { background: #345d70; }
.upgrade-row button:disabled { color: #a1b9c6; cursor: default; }
.upgrade-message { margin: 5px 0 0; color: #ffdb91; font-size: .75rem; }
.upgrade-message:empty { display: none; }

.customize-panel {
  padding: 14px;
  border: 1px solid #486073;
  border-radius: 5px;
  background: #132637f2;
}
.customize-header, .customize-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.customize-header h2 { margin: 0; color: #f0fcff; font-size: 1rem; }
.customize-parts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 13px 0 12px;
}
.customize-parts button, #customize-unlock {
  color: #e7f3fa;
  background: #233545;
  border: 1px solid #587b91;
  border-radius: 5px;
  font-size: .74rem;
  font-weight: 700;
}
.customize-parts button {
  min-height: 48px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 4px 1px;
}
.customize-parts button::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #dfebf5a6;
  background: var(--gear-swatch, linear-gradient(135deg, #bdc7cc 50%, #425c70 50%));
}
.customize-parts button[aria-pressed="true"] {
  background: #32556a;
  border-color: #a4e8e7;
}
.customize-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
  gap: 6px;
}
.palette-swatch {
  aspect-ratio: 1.15;
  min-height: 31px;
  border: 2px solid #0e2160aa;
  border-radius: 5px;
  background: var(--gear-swatch, repeating-linear-gradient(135deg, #b4c5ce 0 5px, #456179 5px 10px));
}
.palette-swatch[aria-pressed="true"] { outline: 2px solid #f6fafc; outline-offset: 1px; }
.palette-swatch:hover:enabled { filter: brightness(1.15); }
.customize-palette.locked .palette-swatch { opacity: .66; cursor: default; }
#customize-current { margin: 0; color: #e1eef5; font-size: .78rem; font-weight: 750; }
.customize-footer { min-height: 38px; margin-top: 10px; }
#customize-unlock { min-height: 34px; padding: 4px 8px; color: #122535; background: #ffdc91; }
#customize-unlock:disabled { background: #364d5b; color: #b0c6d3; cursor: default; }
.customize-note { margin: 3px 0 0; color: #c0d5e3; font-size: .71rem; }
