:root,
#game-root {
  color-scheme: dark;
  --app-sat: 0px;
  --app-sab: 0px;
  --app-sal: 0px;
  --app-sar: 0px;
  --sat: max(env(safe-area-inset-top, 0px), var(--app-sat));
  --sab: max(env(safe-area-inset-bottom, 0px), var(--app-sab));
  --sal: max(env(safe-area-inset-left, 0px), var(--app-sal));
  --sar: max(env(safe-area-inset-right, 0px), var(--app-sar));
  --hud-sat: var(--sat);
  --hud-sab: var(--sab);
  --hud-sal: var(--sal);
  --hud-sar: var(--sar);
  --sc-cream: #f4e8cc;
  --sc-orange: #e8793a;
  --sc-cyan: #5be5d5;
  --sc-indigo: #111a4c;
  --sc-coral: #ff647c;
  --sc-charcoal: #182033;
  --sc-menu-bg: radial-gradient(circle at 50% 10%, #31428d 0, #111a4c 44%, #050719 100%);
  --sc-menu-stars:
    radial-gradient(circle, rgba(255,255,255,.85) 1px, transparent 1.5px),
    radial-gradient(circle, rgba(201,212,255,.7) 1px, transparent 1.5px);
}

* { box-sizing: border-box; }
html, body, #game-root {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}
html, body {
  background: #000;
}
body {
  display: block;
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, sans-serif;
}

#game-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
  background: #000;
}

#game-stage {
  position: relative;
  width: 100cqw;
  height: 100cqh;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 10%, #31428d 0, #111a4c 44%, #050719 100%);
  flex: 0 0 auto;
  container: game-stage / size;
  touch-action: none;
}

#game-stage canvas[data-engine^="three.js"] {
  display: block;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  outline: none;
  background: #050719;
  object-fit: fill;
  pointer-events: none;
}
#game-stage canvas:not([data-engine^="three.js"]):not(#landing-vehicle-canvas) {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  outline: none;
  background: transparent !important;
  pointer-events: none;
}

#starbound-menu-root {
  position: absolute;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

#starbound-menu-root > * {
  pointer-events: auto;
}

.cosmic-result {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 16px) calc(var(--sab) + 12px) calc(var(--sal) + 16px);
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(4, 7, 26, .82);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease;
  container-type: size;
  touch-action: auto;
  pointer-events: none;
}
.cosmic-result.is-visible { opacity: 1; visibility: visible; pointer-events: auto; }
html.result-active #hud-top-actions,
html.result-active #gameplay-hud,
html.result-active #laneControls,
html.result-active #lane-tap-guide,
html.result-active #mobile-jump-btn { display: none !important; }
.cosmic-result__card {
  width: min(100%, 480px);
  max-height: 100%;
  margin: auto;
  padding: clamp(18px, 4.5cqh, 36px) clamp(18px, 6cqw, 48px);
  border: 1px solid rgba(91,229,213,.4);
  border-radius: clamp(18px, 4cqw, 28px);
  background: linear-gradient(150deg, rgba(33,48,119,.97), rgba(8,13,43,.98));
  color: var(--sc-cream);
  text-align: center;
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 28px 90px rgba(0,0,0,.5);
  overflow: auto;
}
.cosmic-result__eyebrow {
  margin: 0;
  color: var(--sc-cyan);
  font-size: clamp(9px, 2.4cqh, 12px);
  font-weight: 900;
  letter-spacing: .2em;
}
.cosmic-result h1 {
  margin: clamp(6px, 1.6cqh, 12px) 0 clamp(8px, 1.8cqh, 14px);
  color: white;
  font-size: clamp(28px, 8cqh, 64px);
  line-height: .92;
  letter-spacing: -.04em;
}
.cosmic-result__reason {
  margin: 0 0 clamp(12px, 2.4cqh, 18px);
  color: var(--sc-cream);
  font-size: clamp(13px, 2.8cqh, 16px);
  line-height: 1.35;
  opacity: .92;
}
.hit-callout {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 80;
  width: min(86%, 420px);
  padding: 14px 16px 16px;
  border: 2px solid #ff8b98;
  border-radius: 18px;
  background: rgba(12, 8, 24, .88);
  color: var(--sc-cream);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.hit-callout.hidden { display: none !important; }
.hit-callout strong {
  display: block;
  color: #ff8b98;
  font-size: clamp(18px, 4.2cqh, 28px);
  letter-spacing: .08em;
}
.hit-callout span {
  display: block;
  margin-top: 6px;
  font-size: clamp(13px, 2.6cqh, 16px);
  line-height: 1.3;
}
html.is-crashing #game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, transparent 40%, rgba(255, 70, 90, .28) 100%);
}
.cosmic-result__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 1.6cqh, 12px);
  margin-bottom: clamp(12px, 2.4cqh, 18px);
}
.cosmic-result__stats div {
  padding: clamp(8px, 1.8cqh, 14px);
  border-radius: 16px;
  background: rgba(4,7,26,.5);
}
.cosmic-result__stats span {
  display: block;
  color: var(--sc-cyan);
  font-size: clamp(8px, 2cqh, 10px);
  font-weight: 900;
  letter-spacing: .15em;
}
.cosmic-result__stats strong {
  display: block;
  min-width: 5ch;
  margin: 5px auto 0;
  color: white;
  font-size: clamp(22px, 5cqh, 32px);
  font-variant-numeric: tabular-nums;
  transform-origin: center;
}
.cosmic-result__stats strong.is-settled { animation: cosmic-number-settle .28s cubic-bezier(.2,.8,.2,1); }
@keyframes cosmic-number-settle {
  0% { transform: scale(.92); color: var(--sc-cyan); text-shadow: 0 0 18px rgba(91,229,213,.8); }
  65% { transform: scale(1.08); }
  100% { transform: scale(1); color: white; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cosmic-result__stats strong.is-settled { animation: none; }
}
.cosmic-result__actions { display: grid; gap: 10px; }
#cosmic-play-again, #cosmic-hangar-btn {
  width: 100%; min-height: clamp(44px, 8cqh, 58px); border: 0; border-radius: 17px;
  font: 950 clamp(13px, 3.2cqh, 17px)/1 Inter, system-ui, sans-serif; letter-spacing: .08em; cursor: pointer;
  touch-action: manipulation;
}
#cosmic-play-again {
  background: linear-gradient(135deg, var(--sc-orange), #ffac62); color: #17152c;
}
#cosmic-hangar-btn {
  background: transparent; color: var(--sc-cream);
  border: 1px solid rgba(91,229,213,.45);
}

@container (max-height: 520px) {
  .cosmic-result__card {
    width: min(100%, 720px);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(160px, .9fr);
    grid-template-areas:
      "eyebrow eyebrow"
      "title stats"
      "actions actions";
    align-items: center;
    column-gap: 18px;
    row-gap: 8px;
    text-align: left;
    padding: 16px 20px;
    border-radius: 20px;
  }
  .cosmic-result__eyebrow { grid-area: eyebrow; }
  .cosmic-result h1 {
    grid-area: title;
    margin: 0;
    font-size: clamp(26px, 10cqh, 44px);
  }
  .cosmic-result__stats {
    grid-area: stats;
    margin: 0;
    gap: 8px;
  }
  .cosmic-result__stats strong { font-size: clamp(20px, 7cqh, 28px); margin-top: 2px; }
  .cosmic-result__actions {
    grid-area: actions;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
  }
  #cosmic-play-again, #cosmic-hangar-btn {
    min-height: 44px;
    border-radius: 14px;
  }
}

@container (max-width: 380px) {
  .cosmic-result__card { padding: 18px 16px; border-radius: 20px; }
  .cosmic-result h1 { font-size: clamp(26px, 9cqw, 40px); }
  .cosmic-result__actions { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .cosmic-result {
    padding: calc(var(--sat) + 8px) calc(var(--sar) + 16px) calc(var(--sab) + 8px) calc(var(--sal) + 16px);
  }
}

html.modal-open .menu-screen { pointer-events: none; }

.menu-screen {
  position: absolute; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  padding: calc(var(--hud-sat) + 16px) calc(var(--hud-sar) + 16px) calc(var(--hud-sab) + 16px) calc(var(--hud-sal) + 16px);
  background: #050719;
  color: var(--sc-cream);
}
.menu-screen.hidden, #menu-chrome.hidden, #hud-top-actions.hidden, #gameplay-hud.hidden, .modal-overlay.hidden, .hidden { display: none !important; }

#gameplay-hud {
  position: absolute;
  inset: 0;
  z-index: 210;
  pointer-events: none;
}
.game-countdown {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  visibility: hidden;
  opacity: 0;
  background: rgba(5, 7, 25, .14);
  transition: opacity .12s ease;
}
.game-countdown.is-visible {
  visibility: visible;
  opacity: 1;
}
.game-countdown span {
  color: #fff;
  font: 950 clamp(76px, 24cqw, 132px)/1 Inter, ui-rounded, system-ui, sans-serif;
  text-shadow: 0 0 10px #5be5d5, 0 8px 28px rgba(0, 0, 0, .65);
  font-variant-numeric: tabular-nums;
}
html.countdown-active .hud-stats-block,
html.countdown-active .hud-energy-block,
html.countdown-active #hud-top-actions {
  opacity: .2;
}
.hud-stats-block {
  position: absolute;
  top: calc(var(--hud-sat) + 12px);
  left: calc(var(--hud-sal) + 12px);
  display: grid;
  gap: 8px;
  min-width: min(148px, 42cqw);
  padding: clamp(8px, 2.6cqw, 10px) clamp(10px, 3.2cqw, 12px);
  border-radius: 14px;
  background: rgba(8, 13, 43, .72);
  border: 1px solid rgba(91, 229, 213, .28);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.hud-stat-row {
  display: grid;
  gap: 2px;
}
.hud-stat-label {
  color: rgba(244, 232, 204, .72);
  font-size: clamp(8px, 2.6cqw, 10px);
  font-weight: 800;
  letter-spacing: .16em;
}
.hud-stat-value {
  color: #fff;
  font-size: clamp(16px, 5.8cqw, 22px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud-energy-block {
  position: absolute;
  left: 50%;
  bottom: max(108px, calc(var(--hud-sab) + 88px));
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 5px;
}
.hud-energy-cells {
  display: flex;
  gap: 7px;
  align-items: center;
}
.hud-energy-cell {
  width: clamp(22px, 8cqw, 30px);
  height: clamp(22px, 8cqw, 30px);
  border-radius: 50%;
  border: 2px solid rgba(91, 229, 213, .42);
  background: rgba(8, 13, 43, .55);
  box-shadow: inset 0 0 12px rgba(91, 229, 213, .08);
}
.hud-energy-cell.is-filled {
  border-color: var(--sc-cyan);
  background: radial-gradient(circle at 50% 38%, rgba(91, 229, 213, .42), rgba(8, 13, 43, .2) 68%);
  box-shadow: 0 0 18px rgba(91, 229, 213, .35), inset 0 0 10px rgba(91, 229, 213, .22);
}
.hud-energy-cell.is-low {
  border-color: #ff647c;
  box-shadow: 0 0 14px rgba(255, 100, 124, .35);
}
.hud-energy-label {
  color: rgba(244, 232, 204, .82);
  font-size: clamp(8px, 2.6cqw, 10px);
  font-weight: 800;
  letter-spacing: .18em;
}
#laneControls {
  position: absolute;
  left: 50%;
  bottom: max(22px, var(--hud-sab));
  z-index: 380;
  display: none;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 7cqw, 28px);
  transform: translateX(-50%);
  pointer-events: auto;
}
body[data-game-phase="running"] #laneControls:not([hidden]) { display: flex; }

#lane-tap-guide {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  pointer-events: none !important;
}
#lane-tap-guide:not([hidden]) { display: flex; flex-direction: column; }
.lane-tap-split {
  flex: 1;
  display: flex;
  min-height: 0;
}
.lane-tap-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.lane-tap-left {
  background: linear-gradient(90deg, rgba(5, 7, 25, 0.42), rgba(5, 7, 25, 0.08));
  border-right: 2px dashed rgba(244, 232, 204, 0.45);
}
.lane-tap-right {
  background: linear-gradient(270deg, rgba(5, 7, 25, 0.42), rgba(5, 7, 25, 0.08));
}
.lane-tap-arrow, .lane-control-btn {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sc-cyan);
  background: rgba(8, 13, 43, 0.88);
  border: 2px solid rgba(91, 229, 213, 0.7);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .08);
}
.lane-control-btn {
  width: clamp(48px, 15cqw, 72px);
  height: clamp(48px, 15cqw, 72px);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  color: var(--sc-cream);
}
.lane-control-btn.is-pressed {
  border-color: var(--sc-cyan);
  background: rgba(91, 229, 213, .3);
  transform: scale(.94);
}
.lane-tap-arrow svg, .lane-control-btn svg { width: 28px; height: 28px; display: block; }
.lane-tap-label {
  color: var(--sc-cyan);
  font: 800 15px/1 Inter, ui-rounded, system-ui, sans-serif;
  letter-spacing: 0.12em;
}
.lane-tap-hint {
  color: var(--sc-cream);
  font: 700 13px/1 Inter, ui-rounded, system-ui, sans-serif;
}
.lane-tap-jump {
  position: absolute;
  left: 50%;
  bottom: max(168px, calc(var(--hud-sab) + 148px));
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.lane-tap-jump .lane-tap-arrow {
  color: #ffac62;
  border-color: rgba(232, 121, 58, .75);
}
.lane-tap-jump .lane-tap-label { color: #ffac62; }

#mobile-jump-btn {
  position: absolute;
  right: max(18px, var(--hud-sar));
  bottom: max(22px, var(--hud-sab));
  z-index: 380;
  display: none;
  pointer-events: auto;
  border-color: rgba(232, 121, 58, .75);
  color: #ffac62;
}
body[data-game-phase="running"] #mobile-jump-btn:not([hidden]) { display: inline-flex; }

#landing-screen {
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-top: calc(var(--hud-sat) + 64px);
  padding-right: max(12px, var(--hud-sar));
  padding-bottom: max(18px, calc(var(--hud-sab) + 12px));
  padding-left: max(12px, var(--hud-sal));
  background-color: #050719;
  background-image:
    radial-gradient(circle at 50% 16%, rgba(49, 66, 141, .9) 0, rgba(17, 26, 76, .72) 42%, transparent 72%),
    radial-gradient(circle, rgba(244, 232, 204, .5) 1px, transparent 1.5px),
    linear-gradient(180deg, #111a4c 0%, #080d2b 58%, #050719 100%);
  background-position: center, 0 0, center;
  background-size: 100% 100%, 96px 96px, 100% 100%;
  background-repeat: no-repeat;
  text-align: center;
}
#landing-screen .landing-hero {
  display: none;
}
.landing-carousel-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 420px);
  min-height: 0;
  margin: 0 auto 4px;
  flex: 1 1 auto;
}
.landing-pad-wrap {
  position: relative;
  width: min(78cqw, 300px);
  height: min(46cqw, 240px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: transparent;
}
#game-stage .landing-vehicle-canvas {
  position: relative;
  inset: auto;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent !important;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.5)) saturate(1.06) contrast(1.03);
}
.landing-vehicle-canvas.is-hidden { display: none; }
.landing-vehicle-canvas.is-loading { opacity: 0; }
.landing-vehicle-fallback {
  position: relative;
  z-index: 2;
  width: min(82vw, 300px);
  height: auto;
  max-height: min(44vw, 190px);
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.5)) saturate(1.06) contrast(1.03);
  animation: hangar-float 2.8s ease-in-out infinite;
}
.landing-arrow {
  position: absolute;
  top: 42%;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(91,229,213,.35);
  border-radius: 14px;
  background: rgba(8,13,43,.86);
  color: var(--sc-cyan);
  font: 800 18px/1 Inter, sans-serif;
  cursor: pointer;
}
.landing-arrow-left { left: 0; }
.landing-arrow-right { right: 0; }
.landing-arrow:hover { border-color: rgba(91,229,213,.65); color: #8ef5ea; }
.landing-ride-name {
  margin: 0;
  color: #fff;
  font-size: clamp(18px, 4.8vw, 24px);
  font-weight: 900;
  letter-spacing: .12em;
}
.landing-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 2px 0 8px;
}
.landing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(91,229,213,.28);
}
.landing-dot.is-active {
  background: var(--sc-cyan);
  box-shadow: 0 0 10px rgba(91,229,213,.55);
}
.landing-kicker,
.landing-title,
.landing-tagline,
#landing-start-btn,
#landing-howto-btn,
.landing-carousel-stage,
.landing-ride-name,
.landing-dots,
.landing-stats {
  position: relative;
  z-index: 1;
}
.landing-kicker,
.landing-title,
.landing-tagline,
.landing-ride-name,
.landing-dots,
#landing-screen .landing-stats,
#landing-start-btn,
#landing-howto-btn {
  flex: 0 0 auto;
}
#landing-screen .landing-stats {
  width: min(92%, 340px);
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(91, 229, 213, .26);
  border-radius: 8px;
  background: rgba(8, 13, 43, .68);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 8px 24px rgba(0, 0, 0, .18);
}
.landing-stats .hangar-stat-row {
  grid-template-columns: 16px minmax(74px, auto) 1fr 48px;
  gap: 6px;
}
.landing-stats .hangar-stat-icon {
  width: 14px;
  height: 14px;
}
.landing-stats .hangar-stat-label {
  font-size: 10px;
}
.landing-stats .hangar-stat-bar {
  padding: 3px 5px;
}
.landing-stats .hangar-segment {
  height: 10px;
}
.landing-stats .hangar-stat-value {
  font-size: 11px;
}
.landing-kicker { margin: 0; color: var(--sc-cyan); font-size: 11px; font-weight: 900; letter-spacing: .22em; flex: 0 0 auto; }
.landing-title {
  margin: 0;
  color: #fff;
  max-width: 100%;
  font-size: clamp(26px, 9.2cqw, 52px);
  line-height: .92;
  letter-spacing: -.04em;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  flex: 0 0 auto;
}
.landing-tagline { margin: 0 0 12px; color: rgba(244,232,204,.78); font-size: 15px; flex: 0 0 auto; }
#landing-start-btn {
  width: min(92%, 340px); min-height: 58px; margin: 0 0 8px; border: 0; border-radius: 17px;
  background: linear-gradient(135deg, var(--sc-orange), #ffac62); color: #17152c;
  font: 950 18px/1 Inter, system-ui, sans-serif; letter-spacing: .1em; cursor: pointer;
}
#landing-howto-btn {
  width: min(92%, 340px); min-height: 42px; margin: 0 0 12px; border-radius: 14px;
  border: 1px solid rgba(91,229,213,.45); background: transparent; color: var(--sc-cyan);
  font: 800 13px/1 Inter, system-ui, sans-serif; letter-spacing: .14em; cursor: pointer;
}

@container game-stage (max-height: 680px) and (max-aspect-ratio: 1 / 1) {
  #landing-screen {
    gap: 4px;
    padding-top: calc(var(--hud-sat) + 56px);
    padding-right: max(12px, var(--hud-sar));
    padding-bottom: max(10px, calc(var(--hud-sab) + 8px));
    padding-left: max(12px, var(--hud-sal));
  }
  .landing-carousel-stage {
    min-height: 0;
    margin-bottom: 0;
    flex: 1 1 auto;
  }
  .landing-pad-wrap {
    width: min(78cqw, 260px);
    height: min(46cqw, 150px);
  }
  .landing-ride-name { font-size: 18px; }
  .landing-dots { margin: 0 0 3px; }
  .landing-stats { gap: 3px; padding: 8px 10px; }
  .landing-stats .hangar-segment { height: 8px; }
  .landing-kicker { font-size: 9px; }
  .landing-title { font-size: clamp(24px, 8.6cqw, 34px); line-height: .92; }
  .landing-tagline { margin: 0 0 6px; font-size: 12px; }
  #landing-start-btn { min-height: 48px; margin: 0; }
  #landing-howto-btn { min-height: 34px; margin: 0; font-size: 11px; }
}

@container game-stage (max-width: 240px) and (max-aspect-ratio: 1 / 1) {
  #landing-screen {
    gap: 3px;
    padding-top: calc(var(--hud-sat) + 48px);
    padding-right: max(8px, var(--hud-sar));
    padding-bottom: max(8px, calc(var(--hud-sab) + 6px));
    padding-left: max(8px, var(--hud-sal));
  }
  .landing-carousel-stage {
    width: 100%;
    min-height: 86px;
    max-height: 96px;
    margin: 0;
    flex: 1 1 96px;
  }
  .landing-pad-wrap {
    width: min(76vw, 142px);
    height: 86px;
  }
  .landing-arrow {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 14px;
  }
  .landing-ride-name { font-size: 13px; }
  .landing-dots { gap: 5px; margin: 0 0 2px; }
  .landing-dot { width: 6px; height: 6px; }
  .landing-stats { width: 100%; gap: 2px; margin: 0; padding: 6px; }
  .landing-stats .hangar-stat-row {
    grid-template-columns: 12px 48px 1fr 34px;
    gap: 4px;
  }
  .landing-stats .hangar-stat-icon { width: 11px; height: 11px; }
  .landing-stats .hangar-stat-label { font-size: 8px; }
  .landing-stats .hangar-stat-bar { gap: 1px; padding: 2px 3px; border-width: 1px; }
  .landing-stats .hangar-segment { height: 6px; border-radius: 1px; }
  .landing-stats .hangar-stat-value { font-size: 8px; }
  .landing-kicker { font-size: 8px; }
  .landing-title { max-width: 100%; font-size: 22px; line-height: .95; }
  .landing-tagline { margin: 0 0 3px; font-size: 9px; }
  #landing-start-btn {
    min-height: 34px;
    margin: 0;
    border-radius: 10px;
    font-size: 11px;
  }
  #landing-howto-btn {
    min-height: 26px;
    margin: 0;
    border-radius: 8px;
    font-size: 9px;
    letter-spacing: .1em;
  }
}

.menu-chrome-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(91,229,213,.35);
  background: rgba(8,13,43,.86); color: var(--sc-cyan); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.chrome-icon-wrap { display: inline-flex; align-items: center; justify-content: center; }
.chrome-icon {
  width: 20px; height: 20px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.chrome-icon-sound-off { display: none; }
.menu-chrome-btn.is-muted .chrome-icon-sound-on { display: none; }
.menu-chrome-btn.is-muted .chrome-icon-sound-off { display: block; }
.menu-chrome-btn:hover { border-color: rgba(91,229,213,.65); color: #8ef5ea; }
@keyframes hangar-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.hangar-stat-row {
  display: grid;
  grid-template-columns: 20px minmax(88px, auto) 1fr 52px;
  align-items: center;
  gap: 8px;
}
.hangar-stat-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
}
.hangar-stat-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px currentColor);
}
.hangar-stat-icon.energy svg { fill: currentColor; stroke-width: 1.5; }
.hangar-stat-icon.speed { color: #00ffff; }
.hangar-stat-icon.handling { color: #ff66ff; }
.hangar-stat-icon.energy { color: #ffdd00; }
.hangar-stat-label {
  font-family: Inter, ui-rounded, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  white-space: nowrap;
}
.hangar-stat-label.speed { color: #00ffff; }
.hangar-stat-label.handling { color: #ff66ff; }
.hangar-stat-label.energy { color: #ffdd00; }
.hangar-stat-bar {
  display: flex;
  gap: 3px;
  padding: 5px 6px;
  border-radius: 8px;
  background: rgba(17,17,35,.85);
  border: 1.5px solid rgba(51,51,102,.65);
}
.hangar-segment {
  flex: 1;
  height: 14px;
  border-radius: 3px;
  background: rgba(255,255,255,.08);
  transform: skewX(-18deg);
}
.hangar-segment.is-filled.speed { background: linear-gradient(180deg, #66ffff, #00cccc); }
.hangar-segment.is-filled.handling { background: linear-gradient(180deg, #ff99ff, #cc44cc); }
.hangar-segment.is-filled.energy { background: linear-gradient(180deg, #ffee66, #ccaa00); }
.hangar-stat-value {
  font: 700 13px/1 Inter, system-ui, sans-serif;
  color: rgba(244,232,204,.88);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
html.sc-reduced-motion .landing-vehicle-fallback { animation: none; }

#menu-chrome, #hud-top-actions {
  position: absolute; top: calc(var(--hud-sat) + 12px); right: calc(var(--hud-sar) + 12px);
  z-index: 390; display: flex; gap: 8px;
}
#menu-sound-btn.is-muted, #hud-sound-btn.is-muted { color: #8aa0c0; }
html:not(.modal-open) #game-stage canvas[data-engine^="three.js"] {
  background: var(--sc-menu-bg);
}
html:not(.modal-open) body[data-game-phase="running"] #game-stage canvas:not([data-engine^="three.js"]):not(#landing-vehicle-canvas) {
  background: transparent !important;
}
#hud-top-actions .menu-chrome-btn {
  background: rgba(8,13,43,.94);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}

.modal-overlay {
  position: absolute; inset: 0; z-index: 280;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--hud-sat) + 16px) calc(var(--hud-sar) + 16px) calc(var(--hud-sab) + 16px) calc(var(--hud-sal) + 16px);
  background: rgba(4,7,26,.82);
  overflow: auto;
}
.modal-content {
  width: min(100%, 420px); padding: 24px; border-radius: 22px;
  border: 1px solid rgba(91,229,213,.4); background: #10183f; color: var(--sc-cream);
}
.modal-content h2 { margin: 0 0 16px; letter-spacing: .08em; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; font-size: 14px; }
.settings-row button {
  min-width: 64px; min-height: 36px; border-radius: 12px; border: 1px solid rgba(91,229,213,.35);
  background: transparent; color: var(--sc-cream); cursor: pointer; font-weight: 800;
}
.settings-row button.on { background: var(--sc-cyan); color: #111a4c; border-color: var(--sc-cyan); }
.modal-actions { display: grid; gap: 10px; margin-top: 18px; }
.modal-actions button, #settings-close-btn {
  min-height: 48px; border: 0; border-radius: 14px; cursor: pointer; font: 900 15px/1 Inter, sans-serif; letter-spacing: .06em;
}
#pause-resume-btn, #settings-close-btn { background: linear-gradient(135deg, var(--sc-orange), #ffac62); color: #17152c; }
#pause-settings-btn, #pause-leave-btn, #pause-howto-btn { background: transparent; color: var(--sc-cream); border: 1px solid rgba(91,229,213,.45); }

.howto-guide {
  position: absolute;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--hud-sat) + 10px) calc(var(--hud-sar) + 12px) calc(var(--hud-sab) + 12px) calc(var(--hud-sal) + 12px);
  touch-action: auto;
}
.howto-guide.hidden { display: none !important; }
.howto-guide__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 26, .78);
  backdrop-filter: blur(10px);
}
.howto-guide__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  max-height: 92%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 16px 14px;
  border-radius: 20px;
  border: 1px solid rgba(91, 229, 213, .5);
  background: linear-gradient(180deg, rgba(22, 32, 78, .96), rgba(10, 16, 46, .98));
  color: var(--sc-cream);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
  touch-action: auto;
}
.howto-guide__header { text-align: center; flex: 0 0 auto; }
.howto-guide__eyebrow {
  font: 800 10px/1 Inter, system-ui, sans-serif;
  letter-spacing: .22em;
  color: var(--sc-cyan);
}
.howto-guide__title {
  margin: 6px 0 4px;
  font: 950 28px/.9 Inter, system-ui, sans-serif;
  letter-spacing: .04em;
  color: #fff;
}
.howto-guide__steps {
  font: 700 12px/1 Inter, system-ui, sans-serif;
  letter-spacing: .12em;
  color: rgba(244, 232, 204, .62);
  margin-bottom: 12px;
}
.howto-guide__page {
  flex: 1 1 0%;
  min-height: 0;
  overflow: auto;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 6px;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(91, 229, 213, .5) rgba(8, 13, 43, .35);
}
.howto-guide__page::-webkit-scrollbar { width: 5px; }
.howto-guide__page::-webkit-scrollbar-thumb {
  background: rgba(91, 229, 213, .45);
  border-radius: 8px;
}
.howto-guide__summary,
.howto-guide__lede {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(62, 42, 28, .72);
  border: 1px solid rgba(232, 121, 58, .28);
  color: rgba(244, 232, 204, .92);
  font: 600 13px/1.4 Inter, system-ui, sans-serif;
}
.howto-guide__lede {
  background: rgba(8, 18, 48, .8);
  border-color: rgba(91, 229, 213, .22);
}
.howto-guide__section,
.howto-guide__subsection {
  margin: 0 0 8px;
  font: 800 12px/1 Inter, system-ui, sans-serif;
  letter-spacing: .16em;
  color: #c7b4ff;
}
.howto-guide__subsection { margin: 12px 0 8px; color: var(--sc-cyan); }
.howto-guide__controls {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.howto-guide__controls li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  font: 500 13px/1.4 Inter, system-ui, sans-serif;
  color: rgba(244, 232, 204, .88);
}
.howto-guide__controls b { color: #fff; }
.howto-guide__glyph {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(91, 229, 213, .12);
  border: 1px solid rgba(91, 229, 213, .45);
  color: var(--sc-cyan);
  font-size: 16px;
}
.howto-guide__pickup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.howto-guide__pickup {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border-radius: 12px;
  background: rgba(8, 13, 43, .72);
  border: 1px solid rgba(91, 229, 213, .22);
}
.howto-guide__pickup--featured {
  margin-bottom: 4px;
  background: rgba(62, 42, 28, .55);
  border-color: rgba(232, 121, 58, .3);
}
.howto-guide__pickup--hazard {
  border-color: rgba(255, 90, 106, .28);
}
.howto-guide__pickup--grid {
  grid-template-columns: 28px 1fr;
  gap: 7px;
  padding: 7px;
}
.howto-guide__pickup-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.howto-guide__pickup--grid .howto-guide__pickup-icon {
  width: 28px;
  height: 28px;
}
.howto-guide__pickup-icon svg { width: 100%; height: 100%; display: block; }
.howto-guide__pickup-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.howto-guide__pickup-head b {
  font: 800 13px/1.2 Inter, system-ui, sans-serif;
  color: #fff;
}
.howto-guide__pickup-head span {
  font: 800 9px/1 Inter, system-ui, sans-serif;
  letter-spacing: .12em;
  color: var(--sc-cyan);
}
.howto-guide__pickup--hazard .howto-guide__pickup-head span { color: #ff8b98; }
.howto-guide__pickup-copy p {
  margin: 4px 0 0;
  font: 500 12px/1.35 Inter, system-ui, sans-serif;
  color: rgba(244, 232, 204, .78);
}
.howto-guide__actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex: 0 0 auto;
}
.howto-guide__nav {
  flex: 1;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font: 900 15px/1 Inter, sans-serif;
  letter-spacing: .08em;
}
.howto-guide__nav[hidden] { display: none !important; }
.howto-guide__nav--ghost {
  background: transparent;
  color: var(--sc-cream);
  border: 1px solid rgba(91, 229, 213, .45);
}
.howto-guide__nav--primary {
  background: var(--sc-cyan);
  color: #111a4c;
}
.howto-guide__nav--cta {
  background: linear-gradient(135deg, var(--sc-orange), #ffac62);
  color: #17152c;
}

@container game-stage (min-aspect-ratio: 1.05 / 1) {
  .game-countdown span {
    font-size: clamp(56px, 22cqh, 110px);
  }
  .hud-stats-block {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px 10px;
  }
  .hud-stat-row { display: grid; gap: 1px; }
  .hud-stat-label { font-size: 8px; }
  .hud-stat-value { font-size: clamp(13px, 4cqh, 16px); }
  .hud-energy-block {
    left: max(16px, var(--hud-sal));
    right: auto;
    top: auto;
    bottom: max(14px, var(--hud-sab));
    transform: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .hud-energy-cell {
    width: clamp(18px, 5.5cqh, 24px);
    height: clamp(18px, 5.5cqh, 24px);
  }
  .hud-energy-label { font-size: 9px; }
  #laneControls {
    left: 50%;
    transform: translateX(-50%);
    bottom: max(14px, var(--hud-sab));
    gap: 12px;
  }
  .lane-control-btn,
  #mobile-jump-btn {
    width: clamp(44px, 14cqh, 58px);
    height: clamp(44px, 14cqh, 58px);
  }
  .lane-tap-jump {
    bottom: max(70px, calc(var(--hud-sab) + 54px));
  }
  .lane-tap-label { font-size: 13px; }
  .lane-tap-hint { font-size: 11px; }

  #landing-screen {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 0.95fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    justify-items: stretch;
    column-gap: clamp(10px, 2.2cqw, 18px);
    row-gap: 6px;
    text-align: left;
    overflow: hidden;
    padding: calc(var(--hud-sat) + 68px) calc(var(--hud-sar) + 18px) calc(var(--hud-sab) + 14px) calc(var(--hud-sal) + 18px);
  }
  #landing-screen > * { min-width: 0; }
  #landing-screen .landing-stats {
    grid-row: 2 / 4;
    align-self: center;
  }
  #landing-screen .landing-stats .hangar-stat-row {
    grid-template-columns: 14px minmax(52px, 5.4em) minmax(48px, 1fr) 32px;
    gap: 4px;
  }
  #landing-screen .landing-stats .hangar-stat-label {
    font-size: 8px;
    letter-spacing: .08em;
  }
  #landing-screen .landing-stats .hangar-stat-bar { min-width: 48px; }
  .landing-kicker { grid-column: 1; grid-row: 1; }
  .landing-title {
    grid-column: 1;
    grid-row: 2;
    font-size: clamp(18px, 3.4cqw, 34px);
  }
  .landing-tagline {
    grid-column: 1;
    grid-row: 3;
    align-self: start;
    margin: 0;
    max-width: 28ch;
  }
  .landing-carousel-stage {
    grid-column: 2;
    grid-row: 1 / 4;
    width: 100%;
    max-width: none;
    min-height: 0;
    height: 100%;
    margin: 0;
  }
  .landing-pad-wrap {
    width: min(100%, 340px);
    height: min(100%, 240px);
  }
  .landing-ride-name {
    grid-column: 2;
    grid-row: 4;
    text-align: center;
  }
  .landing-dots {
    grid-column: 2;
    grid-row: 5;
    margin: 0;
  }
  #landing-screen .landing-stats {
    grid-column: 3;
    grid-row: 2 / 4;
    width: 100%;
    align-self: center;
    justify-content: center;
  }
  #landing-start-btn,
  #landing-howto-btn {
    grid-column: 3;
    width: 100%;
    margin: 0;
    min-height: 44px;
  }
  #landing-start-btn { grid-row: 4; }
  #landing-howto-btn { grid-row: 5; }

  .howto-guide__panel {
    width: min(100%, 760px);
    max-height: 100%;
    height: 100%;
  }
  .howto-guide__controls {
    grid-template-columns: 1fr 1fr;
  }
  .howto-guide__pickup-grid {
    grid-template-columns: 1fr 1fr;
  }
  .howto-guide__pickup-grid:has(:nth-child(3)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .howto-guide__nav { min-height: 44px; }

  .modal-overlay {
    padding: calc(var(--hud-sat) + 10px) calc(var(--hud-sar) + 12px) calc(var(--hud-sab) + 10px) calc(var(--hud-sal) + 12px);
  }
  .modal-content {
    width: min(100%, 560px);
    padding: 16px 18px;
  }
  .modal-content h2 { margin-bottom: 10px; }
  .modal-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
  }
  #pause-resume-btn { grid-column: 1 / -1; }
  .modal-actions button, #settings-close-btn { min-height: 42px; }
}

@media (orientation: landscape) and (max-height: 430px) {
  .hud-stats-block { gap: 2px; padding: 6px 8px; }
  .landing-title { font-size: clamp(16px, 3.2cqw, 28px); }
  .landing-pad-wrap { height: min(100%, 170px); }
  #landing-start-btn, #landing-howto-btn { min-height: 38px; font-size: 13px; }
  .howto-guide {
    padding: calc(var(--hud-sat) + 6px) calc(var(--hud-sar) + 10px) calc(var(--hud-sab) + 8px) calc(var(--hud-sal) + 10px);
  }
  .howto-guide__panel { padding: 12px 14px 10px; max-height: 100%; height: 100%; }
  .howto-guide__title { font-size: 20px; margin: 2px 0; }
  .howto-guide__steps { margin-bottom: 4px; }
  .howto-guide__lede,
  .howto-guide__summary { padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
  .howto-guide__lede { display: none; }
  .howto-guide__pickup { padding: 6px; }
  .howto-guide__pickup-copy p { font-size: 11px; }
  .howto-guide__actions { margin-top: 8px; }
  .howto-guide__nav { min-height: 40px; }
  .modal-overlay {
    padding: calc(var(--hud-sat) + 8px) calc(var(--hud-sar) + 10px) calc(var(--hud-sab) + 8px) calc(var(--hud-sal) + 10px);
  }
  .modal-content { padding: 12px 14px; }
  .modal-actions button, #settings-close-btn { min-height: 38px; }
}

@container game-stage (max-height: 720px) and (max-aspect-ratio: 1 / 1) {
  .howto-guide__title { font-size: 24px; }
  .howto-guide__steps { margin-bottom: 8px; }
  .howto-guide__lede,
  .howto-guide__summary { padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
  .howto-guide__pickup { padding: 6px 7px; }
  .howto-guide__pickup-copy p { margin-top: 2px; font-size: 11px; }
  .howto-guide__controls { gap: 8px; }
  .howto-guide__nav { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .cosmic-result, .menu-screen { transition: none; }
}
html.sc-reduced-motion .cosmic-result,
html.sc-reduced-motion .menu-screen { transition: none; }
html.sc-reduced-motion .game-countdown { transition: none; }
