* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --ink: #1f292b;
  --muted: #66777a;
  --mint: #a8d7cf;
  --mint-dark: #63978e;
  --cream: #fff1c9;
  --surface: #ffffff;
  --border: #d8e1df;
  --accent: #29796e;
  --accent-press: #20665d;
}
html, body { margin: 0; min-height: 100%; background: #eef4f1; }
body {
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #72a99f; outline-offset: 3px; }
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}
/*
  The game has a fixed logical/native size of 390 × 844.
  Responsive behavior is DOWN-SCALE ONLY: it can shrink to fit a smaller
  viewport, but never grows beyond the original 390px game width.
*/
.game-wrap {
  --native-game-width: 390;
  --native-game-height: 844;
  width: min(390px, calc(100vw - 24px));
  width: min(390px, calc(100vw - 24px), calc((100dvh - 24px) * 390 / 844));
  display: grid;
  gap: 8px;
}
.phone-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 390 / 844;
  overflow: hidden;
  border-radius: clamp(18px, 5vw, 30px);
  border: 1px solid rgba(31,41,43,.16); background: #b9ddb1;
  box-shadow: 0 20px 50px rgba(45,74,67,.12); touch-action: pan-y; user-select: none;
}
canvas { display: block; width: 100%; height: 100%; background: #b9ddb1; }
.hidden { display: none !important; }
.hud { position: absolute; inset: 0; pointer-events: none; padding: 14px; }
.distance-pill {
  position: absolute; top: 14px; left: 14px; min-width: 108px; padding: 9px 13px 10px;
  border-radius: 16px; background: rgba(20,29,32,.78); color: #fff; backdrop-filter: blur(8px);
  display: grid; gap: 1px;
}
.distance-label { font-size: 11px; opacity: .74; letter-spacing: .03em; }
.distance-pill strong { font-size: 19px; letter-spacing: -.02em; }
.hud-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; pointer-events: auto; }
.icon-button {
  width: 46px; height: 46px; border: 0; border-radius: 50%; background: rgba(20,29,32,.8);
  color: #fff; font-weight: 750; cursor: pointer; backdrop-filter: blur(8px);
  transition: transform 120ms ease, background 120ms ease;
}
.icon-button:active { transform: scale(.92); background: rgba(20,29,32,.95); }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(21,34,34,.18); backdrop-filter: blur(2px); animation: fadeIn 180ms ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.panel {
  width: min(100%, 320px); padding: 24px 22px; border-radius: 24px;
  background: rgba(255,255,255,.96); border: 1px solid rgba(31,41,43,.12); text-align: center;
  box-shadow: 0 16px 45px rgba(21,34,34,.13); animation: panelPop 220ms cubic-bezier(.2,.9,.2,1.1) both;
}
@keyframes panelPop {
  from { transform: translateY(10px) scale(.975); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.compact-panel { padding-top: 28px; }
.logo-wrap { width: 96px; height: 96px; margin: 0 auto 16px; }
.user-icon-wrap { border-radius: 24px; overflow: hidden; background: #fff; border: 1px solid rgba(31,41,43,.10); }
.user-home-icon { display: block; width: 100%; height: 100%; object-fit: cover; }
.eyebrow { margin: 0 0 4px; color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .11em; font-weight: 750; }
h1, h2 { margin: 0; letter-spacing: -.045em; line-height: 1; }
h1 { font-size: 40px; }
h2 { font-size: 30px; }
.subhead { margin: 8px 0 20px; color: var(--muted); font-size: 14px; }
.primary-button, .secondary-button {
  width: 100%; min-height: 48px; border-radius: 15px; cursor: pointer; font-weight: 760;
  transition: transform 120ms ease, background 120ms ease;
}
.primary-button { border: 0; background: var(--accent); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.primary-button:hover { background: #257166; }
.primary-button:active { transform: translateY(1px) scale(.985); background: var(--accent-press); }
.secondary-button { border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
.secondary-button:active { transform: scale(.985); }
.text-button {
  min-height: 40px; border: 0; background: transparent; color: #4f6966; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
.button-stack { display: grid; gap: 9px; margin-top: 18px; }
.bonk-badge {
  width: fit-content; margin: -4px auto 10px; padding: 5px 10px 6px; border-radius: 999px;
  background: #fff1c9; color: #634d18; font-weight: 850; font-size: 12px; transform: rotate(-3deg);
}
.prototype-controls { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 12px; display: grid; gap: 11px; text-align: left; }
.control-group { display: grid; gap: 6px; }
.control-group > span { color: var(--muted); font-size: 11px; font-weight: 700; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: #edf2f1; border-radius: 12px; }
.segmented button { border: 0; min-height: 34px; border-radius: 9px; background: transparent; color: #5e706e; cursor: pointer; font-size: 12px; font-weight: 700; }
.segmented button.selected { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(31,41,43,.09); }
.toast {
  position: absolute; top: 82px; left: 50%; transform: translateX(-50%); padding: 7px 12px;
  border-radius: 999px; background: rgba(255,255,255,.93); border: 1px solid rgba(31,41,43,.1);
  color: var(--ink); font-size: 12px; font-weight: 800; box-shadow: 0 8px 24px rgba(31,41,43,.1);
  animation: toastIn 700ms ease both; pointer-events: none;
}
@keyframes toastIn {
  0% { transform: translate(-50%, 8px) scale(.94); opacity: 0; }
  18% { transform: translate(-50%, 0) scale(1.03); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -5px) scale(1); opacity: 0; }
}
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 60px; font-weight: 900; color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.2);
  animation: countdownPulse 520ms ease both;
}
@keyframes countdownPulse {
  from { transform: scale(.6); opacity: 0; }
  40% { transform: scale(1.08); opacity: 1; }
  to { transform: scale(1); opacity: 0; }
}
.flash-layer { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: rgba(255,255,255,.34); }
.flash-layer.flash { animation: flash 170ms ease; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Compact UI at very small render sizes without changing gameplay geometry. */
@media (max-width: 360px), (max-height: 700px) {
  .hud { padding: 10px; }
  .distance-pill { top: 10px; left: 10px; transform: scale(.92); transform-origin: top left; }
  .hud-actions { top: 10px; right: 10px; transform: scale(.9); transform-origin: top right; }
  .panel { transform: scale(.92); }
}

.home-panel .subhead { margin-bottom: 22px; }
.home-panel .text-button { margin-top: 10px; }

.score-meta {
  margin: -8px 0 4px;
  color: #4f6966;
  font-size: 13px;
  font-weight: 700;
}


.end-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 10px;
  margin-top: 18px;
  align-items: stretch;
}
.end-drive-again { min-width: 0; }
.share-icon-button {
  width: 54px;
  min-width: 54px;
  height: 48px;
  padding: 0;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.share-icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.share-icon-button:hover {
  background: #f3f8f6;
  border-color: #c9d8d4;
}
.share-icon-button:active {
  transform: translateY(1px) scale(.96);
  background: #eaf3f0;
}
.end-home-link { margin-top: 6px; }

.creator-credit {
  margin: 2px 0 0;
  text-align: center;
  color: #7a8b8a;
  font-size: 12px;
  line-height: 1.4;
}
.creator-credit a {
  color: #4f6966;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(79,105,102,.45);
  padding-bottom: 1px;
}
.creator-credit a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.creator-credit a:focus-visible {
  outline: 3px solid #72a99f;
  outline-offset: 3px;
  border-radius: 4px;
}


.creator-credit {
  margin-top: 18px !important;
  margin-bottom: -8px !important;
}


/* Home header refinement */
.home-panel .logo-wrap {
  width: 80px !important;
  height: 80px !important;
  margin-bottom: 12px !important;
  transform: translateY(-6px);
}

.home-panel .eyebrow {
  margin-bottom: 10px !important;
  line-height: 1.35;
  letter-spacing: .105em;
}

.home-panel h1 {
  color: var(--accent) !important;
  line-height: 1.02;
  margin-bottom: 12px !important;
}

.home-panel .subhead {
  margin-top: 0 !important;
  margin-bottom: 24px !important;
  font-size: 13px !important;
  line-height: 1.45;
}

.music-volume-button .volume-icon,
.music-volume-button .volume-icon svg {
  display: block;
  width: 22px;
  height: 22px;
}
.music-volume-button .volume-icon svg {
  overflow: visible;
}
.music-volume-button .speaker-shape {
  fill: currentColor;
  stroke: none;
}
.music-volume-button .volume-wave,
.music-volume-button .mute-slash {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.music-volume-button .mute-slash {
  display: none;
}
.music-volume-button[data-music-level="0"] .volume-wave {
  display: none;
}
.music-volume-button[data-music-level="0"] .mute-slash {
  display: block;
}
.music-volume-button[data-music-level="1"] .wave-2,
.music-volume-button[data-music-level="1"] .wave-3 {
  display: none;
}
.music-volume-button[data-music-level="2"] .wave-3 {
  display: none;
}

/* Refined HUD icon alignment */
.music-volume-button {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}
.music-volume-button .volume-icon {
  display: grid;
  place-items: center;
  margin: 0;
}
.music-volume-button .volume-icon svg {
  display: block;
  margin: 0;
}

/* Five speed levels */
.control-group .segmented:has([data-speed="veryfast"]) {
  grid-auto-flow: initial;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.control-group .segmented:has([data-speed="veryfast"]) button {
  padding-inline: 3px;
  font-size: 10.5px;
  line-height: 1.05;
}
