:root {
  --purple-900: #24113d;
  --purple-800: #35165d;
  --purple-700: #55239a;
  --purple-600: #7434d7;
  --purple-500: #8d4df2;
  --purple-300: #c6a8ff;
  --purple-200: #e8dcff;
  --purple-100: #f4efff;
  --ink: #241a31;
  --muted: #6e6478;
  --white: #ffffff;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f7f3ff; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(145deg, #faf8ff 0%, #f2ebff 48%, #fff 100%);
  overflow-x: hidden;
}
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
body, .car-page, .car-shell, .play-area, canvas, .touch-controls, .steer-button, .game-message {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.page-glow { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.page-glow span { position: absolute; width: 320px; height: 320px; border-radius: 50%; opacity: .3; filter: blur(7px); }
.page-glow span:first-child { top: -150px; right: -70px; background: radial-gradient(circle, #b68cff, #8d4df2 62%, transparent 72%); }
.page-glow span:nth-child(2) { bottom: -160px; left: -80px; background: radial-gradient(circle, #d3b8ff, #8d4df2 62%, transparent 72%); }
.page-glow i { position: absolute; inset: 0; opacity: .15; background-image: linear-gradient(rgba(116,52,215,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(116,52,215,.12) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(to bottom, #000, transparent 85%); }

.car-page { position: relative; z-index: 1; min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 14px; }
.car-shell { width: min(980px, 100%); padding: clamp(16px, 3vw, 30px); border: 1px solid rgba(116,52,215,.14); border-radius: 27px; background: rgba(255,255,255,.86); box-shadow: 0 25px 75px rgba(57,22,97,.15); backdrop-filter: blur(14px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.wordmark { color: var(--purple-900); font-size: 1.18rem; font-weight: 950; letter-spacing: -.075em; text-decoration: none; }
.wordmark span { color: var(--purple-500); }
.back-link { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid var(--purple-200); border-radius: 999px; background: var(--purple-100); color: var(--purple-700); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-decoration: none; }
.back-link span { font-size: 1rem; line-height: .7; }
.back-link:focus-visible, .start-button:focus-visible, .steer-button:focus-visible { outline: 3px solid rgba(141,77,242,.38); outline-offset: 3px; }

.intro { margin: 16px 0 15px; text-align: center; }
.eyebrow { margin: 0 0 5px; color: var(--purple-500); font-size: .64rem; font-weight: 950; letter-spacing: .22em; }
h1 { margin: 0; color: var(--purple-900); font-size: clamp(2rem, 5.5vw, 3.5rem); font-weight: 1000; letter-spacing: -.065em; line-height: .98; }
h1 span { color: var(--purple-600); }
.subtitle { margin: 9px 0 0; color: var(--muted); font-size: clamp(.82rem, 2vw, 1rem); }

.hud { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin: 0 auto 11px; width: min(540px, 100%); }
.stat { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; padding: 9px 12px; border: 1px solid var(--purple-200); border-radius: 13px; background: var(--purple-100); }
.stat-label { color: var(--purple-600); font-size: .61rem; font-weight: 950; letter-spacing: .12em; }
.stat strong { color: var(--purple-900); font: 900 clamp(.94rem, 2.8vw, 1.16rem)/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }

.play-area { position: relative; width: 100%; height: min(78svh, 820px); min-height: 500px; overflow: hidden; border: 1px solid rgba(116,52,215,.24); border-radius: 19px; background: var(--purple-100); box-shadow: inset 0 0 0 4px rgba(255,255,255,.48); touch-action: none; }
#gameCanvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: default; }
.game-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px; text-align: center; background: rgba(36,17,61,.28); }
.game-message[hidden] { display: none; }
.message-kicker { margin: 0 0 8px; color: #e8dcff; font-size: .66rem; font-weight: 950; letter-spacing: .2em; text-shadow: 0 2px 7px rgba(36,17,61,.25); }
.game-message h2 { margin: 0; color: white; font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 1000; letter-spacing: -.055em; line-height: .98; text-shadow: 0 4px 0 rgba(36,17,61,.22); }
.game-message p#messageText { max-width: 300px; margin: 12px 0 18px; color: #fff; font-size: .94rem; font-weight: 650; line-height: 1.5; text-shadow: 0 2px 6px rgba(36,17,61,.26); }
.start-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 50px; padding: 0 22px; border: 2px solid #fff; border-radius: 13px; background: var(--purple-600); color: white; font-size: .8rem; font-weight: 950; letter-spacing: .1em; cursor: pointer; box-shadow: 0 8px 0 var(--purple-900), 0 15px 25px rgba(36,17,61,.3); }
.start-button:active { transform: translateY(3px); box-shadow: 0 5px 0 var(--purple-900), 0 9px 18px rgba(36,17,61,.24); }
.start-button span { font-size: 1.15rem; }
.pause-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); padding: 12px 17px; border-radius: 10px; background: rgba(244,239,255,.95); color: var(--purple-800); font-weight: 950; letter-spacing: .14em; }
.pause-label[hidden] { display: none; }

.touch-controls { display: grid; grid-template-columns: minmax(82px, 1fr) auto minmax(82px, 1fr); align-items: center; gap: 12px; margin-top: 12px; }
.steer-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 70px; padding: 8px 16px; border: 2px solid var(--purple-200); border-radius: 17px; background: #fff; color: var(--purple-800); font-size: .75rem; font-weight: 950; letter-spacing: .13em; cursor: pointer; box-shadow: 0 5px 0 rgba(85,35,154,.12); }
.steer-button:active { transform: translateY(2px); background: var(--purple-100); box-shadow: 0 2px 0 rgba(85,35,154,.1); }
.steer-arrow { color: var(--purple-600); font-size: 1.9rem; line-height: .8; }
.control-note { display: flex; align-items: center; justify-content: center; gap: 8px; color: #90879a; font-size: .59rem; font-weight: 900; letter-spacing: .09em; text-align: center; white-space: nowrap; }
.pixel-dot { width: 6px; height: 6px; background: var(--purple-500); }
.game-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 7px 18px; margin-top: 14px; padding: 0 3px; color: #90879a; font-size: .6rem; font-weight: 850; letter-spacing: .07em; }

@media (pointer: fine) and (min-width: 761px) { .touch-controls { grid-template-columns: minmax(82px, 1fr) auto minmax(82px, 1fr); } }
@media (max-width: 760px) {
  .car-page { padding: 8px; place-items: start center; }
  .car-shell { padding: 15px 12px 12px; border-radius: 22px; }
  .play-area { height: min(55svh, 528px); min-height: 352px; border-radius: 16px; }
  .touch-controls { gap: 8px; grid-template-columns: minmax(76px, 1fr) minmax(54px, .65fr) minmax(76px, 1fr); }
  .steer-button { min-height: 72px; padding: 6px 9px; border-radius: 15px; gap: 7px; }
  .control-note { gap: 4px; font-size: .48rem; letter-spacing: .03em; white-space: normal; }
  .game-footer { font-size: .54rem; letter-spacing: .04em; }
}
@media (max-width: 390px) {
  .car-shell { padding: 13px 10px 10px; }
  .play-area { height: min(50.6svh, 462px); min-height: 319px; }
  .stat { flex-direction: column; gap: 4px; padding: 7px 5px; }
  .stat-label { font-size: .55rem; }
  .touch-controls { grid-template-columns: minmax(70px,1fr) 44px minmax(70px,1fr); gap: 6px; }
  .steer-button { flex-direction: column; gap: 4px; min-height: 70px; font-size: .63rem; }
  .steer-arrow { font-size: 1.65rem; }
  .pixel-dot { display: none; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .car-page { place-items: start center; }
  .car-shell { padding: 12px 18px; }
  .intro { margin: 8px 0; }
  .eyebrow { display: none; }
  h1 { font-size: 1.8rem; }
  .subtitle { margin-top: 4px; }
  .hud { margin-bottom: 7px; }
  .play-area { height: 52svh; min-height: 250px; }
  .touch-controls { margin-top: 7px; }
  .steer-button { min-height: 54px; }
  .game-footer { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
