/* The race page: a full-screen 3D track with the HUD, the garage before the start and the result card. */
.race-page { overflow: hidden; background: #7cc8ff; touch-action: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }

/* ---------- HUD ---------- */
body.racing .top { display: none; }
body.racing .hud-stock, body.racing .hud-rank { top: 16px; }
body.racing .hud-timer { top: 16px; }
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { position: absolute; }
.hud-stock { top: 84px; left: 16px; display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: 20px; }
.hs-sym { font-family: var(--display); font-weight: 900; font-size: 20px; line-height: 1; }
.hs-win { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-top: 3px; }
.hud-timer { top: 16px; left: 50%; transform: translateX(-50%); padding: 10px 26px 12px; text-align: center; border-radius: 20px; }
.hud-timer .led { font-size: 44px; line-height: 1; }
.hud-timer .split { font-family: var(--dotfont); font-weight: 900; font-size: 20px; min-height: 22px; margin-top: 4px; }
.split.faster { color: #6dff9e; } .split.slower { color: #ff7db4; }
.hud-rank { top: 84px; right: 16px; padding: 10px 18px; text-align: right; border-radius: 20px; }
.hud-rank .led { font-size: 30px; line-height: 1; }
.hud-rank .sub, .hud-speed .sub { font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; color: #b9b3e8; margin-top: 4px; }
.hud-chart { left: 16px; bottom: 16px; width: 290px; padding: 8px; border-radius: 20px; }
.hud-chart canvas { width: 100%; height: auto; display: block; border-radius: 12px; }
.mc-label { display: flex; justify-content: space-between; font-weight: 800; font-size: 12px; padding: 4px 6px 0; }
.hud-speed { right: 16px; bottom: 16px; padding: 10px 20px 12px; text-align: right; border-radius: 20px; min-width: 150px; }
.hud-speed .led { font-size: 46px; line-height: 1; }
.hud-speed .boost { position: absolute; top: -14px; left: 12px; font-family: var(--display); font-weight: 900; font-size: 12px; letter-spacing: 0.1em; padding: 4px 10px; border-radius: 999px; background: var(--lime); color: var(--ink); border: 2px solid var(--ink); opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.15s; }
.hud.boosting .hud-speed .boost { opacity: 1; transform: scale(1); }
.hud.boosting::after { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(155, 226, 45, 0.28) 100%); }
.hud-keys { left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; }
.hud-keys span { background: rgba(23, 20, 46, 0.72); color: #fff; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; }
.hud-keys b { font-family: var(--display); font-weight: 800; margin-right: 4px; }
@media (max-width: 760px) {
  body.racing .hud-timer { top: 10px; padding: 8px 14px; }
  body.racing .hud-stock { top: 86px; } body.racing .hud-rank { top: 86px; }
  .hud-timer .split { min-height: 0; font-size: 15px; }
  .hud-stock .pct { display: none; }
  .hud-keys { display: none; }
  .hud-timer .led { font-size: 26px; }
  .hud-stock { top: 74px; padding: 6px 10px 6px 6px; } .hud-stock .stock-tile { width: 34px; height: 34px; } .hs-win { display: none; }
  .hud-rank { top: 74px; padding: 8px 12px; } .hud-rank .led { font-size: 22px; }
  .hud-chart { width: 150px; bottom: auto; top: 150px; padding: 5px; } .mc-label { display: none; }
  .hud-speed { bottom: auto; top: 150px; min-width: 0; padding: 8px 12px; } .hud-speed .led { font-size: 26px; }
}

/* ---------- start lights ---------- */
.lights { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); z-index: 20; display: flex; gap: 14px; padding: 16px 22px; background: var(--led); border: var(--border); border-radius: 999px; box-shadow: var(--pop); }
.lights i { width: 46px; height: 46px; border-radius: 50%; background: #2c2850; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3); transition: background 0.08s; }
.lights i.on { background: radial-gradient(circle at 35% 30%, #ff9fc6, #ff3d86 60%); box-shadow: 0 0 22px #ff3d86; }
.lights.green i { background: radial-gradient(circle at 35% 30%, #c6ffd9, #22d46a 60%); box-shadow: 0 0 22px #22d46a; }
.go { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); z-index: 20; font-family: var(--display); font-weight: 900; font-size: clamp(64px, 12vw, 150px); color: var(--lime); -webkit-text-stroke: 4px var(--ink); text-shadow: 7px 8px 0 var(--ink); animation: goPop 0.7s ease-out forwards; }
@keyframes goPop { 0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }

/* ---------- touch ---------- */
.touch { position: fixed; inset: auto 0 0 0; z-index: 15; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.touch button { pointer-events: auto; width: 74px; height: 74px; border-radius: 50%; border: var(--border); background: rgba(255, 255, 255, 0.85); font-size: 24px; box-shadow: var(--pop-sm); touch-action: none; }
.touch button.on { background: var(--sun); transform: translate(2px, 3px); box-shadow: none; }
.touch > button:nth-child(2) { margin-right: auto; margin-left: 12px; }
.touch-r { display: flex; gap: 10px; }
.touch .tb, .touch .tj { font-family: var(--display); font-weight: 900; font-size: 12px; }
.touch .tj { background: rgba(155, 226, 45, 0.92); width: 86px; height: 86px; }

/* ---------- garage ---------- */
.garage { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 22px; padding: 96px 24px 24px; overflow-y: auto; background: linear-gradient(180deg, rgba(71, 194, 255, 0.55), rgba(255, 95, 179, 0.5)); }
.g-left { padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.g-stock { display: flex; align-items: center; gap: 16px; }
.stock-tile.big { width: 72px; height: 72px; border-radius: 20px; }
.g-stock h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); }
.g-name { font-weight: 800; color: var(--ink-2); }
.pct.big { font-size: 18px; padding: 6px 14px; margin-left: auto; border: var(--border); box-shadow: var(--pop-sm); }
.g-line { margin: 0; font-size: 17px; font-weight: 600; }
.g-chart { width: 100%; height: auto; border-radius: 18px; border: var(--border); background: var(--led); }
.g-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.fact { border: var(--border); border-radius: 16px; padding: 10px 12px; background: var(--paper); }
.fact b { display: block; font-family: var(--display); font-weight: 900; font-size: 20px; }
.fact span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.fact.lime { background: #e9fbcf; } .fact.pink { background: #ffe0ef; } .fact.sky { background: #dcf3ff; } .fact.sun { background: #fff3c4; } .fact.grape { background: #ece4ff; }
.gb-head { display: flex; justify-content: space-between; align-items: baseline; }
.runs { font-weight: 800; font-size: 13px; color: var(--ink-2); }
.board { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li { display: grid; grid-template-columns: 34px 34px minmax(0, 1fr) auto auto auto; align-items: center; gap: 10px; padding: 7px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--white); font-weight: 800; }
.board li.me { background: #fff3c4; }
.board .rk { font-family: var(--display); font-weight: 900; text-align: center; }
.board li:nth-child(1) .rk { color: #e0a800; } .board li:nth-child(2) .rk { color: #8c8fa6; } .board li:nth-child(3) .rk { color: #d27a3a; }
.board .av { width: 34px; height: 34px; }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .tm { font-family: var(--dotfont); font-weight: 900; font-size: 18px; }
.tag { font-size: 10px; font-weight: 900; letter-spacing: 0.08em; padding: 3px 7px; border-radius: 999px; background: var(--paper); border: 2px solid var(--ink); }
.tag.house { background: #ece4ff; } .tag.dot { background: #dcf3ff; } .tag.wallet { background: #e9fbcf; }
.g-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.g-me { padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; background: linear-gradient(180deg, #dcf3ff, #fff); }
#meDot { width: 220px; height: 220px; }
.me-name { display: flex; gap: 8px; width: 100%; }
.me-name input { flex: 1; min-width: 0; border: var(--border); border-radius: 14px; padding: 10px 14px; font: 800 17px var(--body); background: #fff; }
.start { width: 100%; font-size: 24px; padding: 24px; }
.g-hint { font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; }
@media (max-width: 900px) { .garage { grid-template-columns: 1fr; padding: 84px 14px 20px; } .g-right { order: -1; } #meDot { width: 150px; height: 150px; } }

/* ---------- customizer ---------- */
.custom { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(23, 20, 46, 0.4); }
.custom-in { width: min(640px, 100%); padding: 24px; max-height: 92vh; overflow: auto; }
.custom-in h2 { margin: 0 0 16px; font-size: 30px; }
.cust-grid { display: grid; gap: 16px; }
.swatches, .opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; border: var(--border); cursor: pointer; box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.15), inset 4px 4px 0 rgba(255, 255, 255, 0.35); }
.swatches button.on, .opts button.on { outline: 4px solid var(--sun); outline-offset: 2px; }
.opts button { border: var(--border); border-radius: 999px; padding: 8px 14px; background: var(--paper); font-weight: 800; cursor: pointer; text-transform: capitalize; }
.num-in { margin-top: 8px; width: 110px; border: var(--border); border-radius: 14px; padding: 10px 12px; font: 900 20px var(--display); }
.cust-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

/* ---------- result ---------- */
.result { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center end; padding: 16px 48px; pointer-events: none; }
@media (max-width: 900px) { .result { place-items: end center; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); } }
.result-in { pointer-events: auto; width: min(560px, 100%); padding: 24px; text-align: center; animation: rise 0.35s ease-out; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.r-time { margin: 10px auto 14px; padding: 12px 20px; display: inline-block; }
.r-time .led { font-size: clamp(44px, 9vw, 72px); line-height: 1; }
.r-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.r-row div { border: 2px solid var(--ink); border-radius: 14px; padding: 8px 4px; background: var(--paper); }
.r-row b { display: block; font-family: var(--display); font-weight: 900; font-size: 18px; }
.r-row span { font-size: 11px; font-weight: 800; color: var(--ink-2); }
.r-line { font-weight: 700; margin: 14px 0; }
.r-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.r-note { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 12px 0 0; }
@media (max-width: 520px) { .r-row { grid-template-columns: repeat(2, 1fr); } }

.newheat { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-radius: 999px; }

.r-link { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 12px; border: 2px dashed var(--ink); border-radius: 16px; background: #fff6cc; font-weight: 800; font-size: 14px; }

/* ---------- sound button ---------- */
.chip.sound { cursor: pointer; font: inherit; font-weight: 800; font-size: 13px; }
.snd-ico { width: 14px; height: 12px; background: var(--ink); clip-path: polygon(0 30%, 35% 30%, 75% 0, 75% 100%, 35% 70%, 0 70%); }
.chip.sound.off .snd-ico { opacity: 0.35; }

/* ---------- race picker ---------- */
.ev-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border: var(--border); border-radius: 20px; background: var(--paper); }
.ev-tabs button { border: 0; border-radius: 14px; padding: 10px 12px; background: transparent; cursor: pointer; text-align: left; display: flex; flex-direction: column; }
.ev-tabs button b { font-family: var(--display); font-weight: 900; font-size: 16px; }
.ev-tabs button span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ev-tabs button.on { background: var(--ink); color: #fff; box-shadow: 3px 4px 0 var(--pink); }
.ev-tabs button.on span { color: #b9b3e8; }
.ev-tabs button:not(.on):hover { background: #fff3c4; }

/* ---------- medals ---------- */
.medals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.medal { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); border-radius: 16px; padding: 8px 10px; background: #fff; opacity: 0.75; }
.medal.got { opacity: 1; background: #fffbe0; box-shadow: 3px 4px 0 var(--ink); }
.medal b { display: block; font-family: var(--display); font-weight: 900; font-size: 13px; }
.medal span { font-family: var(--dotfont); font-weight: 900; font-size: 16px; }
.medal span.who { font-family: var(--body); font-weight: 700; font-size: 12px; color: var(--ink-2); }
.medal-coin { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: 13px; border: 2px solid var(--ink); box-shadow: inset -3px -4px 0 rgba(0, 0, 0, 0.18), inset 3px 3px 0 rgba(255, 255, 255, 0.5); }
.medal-coin.bronze { background: #e0965a; } .medal-coin.silver { background: #d7dbe6; } .medal-coin.gold { background: #ffd43b; } .medal-coin.pip { background: conic-gradient(#ff5fb3, #ffd43b, #9be22d, #47c2ff, #8b5cf6, #ff5fb3); color: #fff; text-shadow: 0 1px 0 var(--ink); }
.medal-coin.sm { width: 22px; height: 22px; font-size: 10px; }
@media (max-width: 620px) { .medals { grid-template-columns: repeat(2, 1fr); } }
.board li { grid-template-columns: 34px 34px minmax(0, 1fr) auto auto auto; }

/* ---------- hints ---------- */
.hint { position: fixed; top: 34%; left: 50%; transform: translateX(-50%); z-index: 12; font-family: var(--display); font-weight: 900; font-size: clamp(22px, 3.4vw, 40px); color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 5px 0 var(--ink); white-space: nowrap; animation: hintPop 1.6s ease-out forwards; pointer-events: none; }
.hint.jump { color: var(--sun); } .hint.boost { color: var(--lime); } .hint.whale { color: var(--pink); }
@keyframes hintPop { 0% { transform: translateX(-50%) scale(0.6); opacity: 0; } 12% { transform: translateX(-50%) scale(1.08); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateX(-50%) translateY(-14px); opacity: 0; } }

/* ---------- result extras ---------- */
.r-medal { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: -6px 0 10px; animation: medalIn 0.7s cubic-bezier(.2, 1.6, .4, 1) both; }
.r-medal .medal-coin { width: 74px; height: 74px; font-size: 28px; border-width: 3px; box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.18), inset 6px 6px 0 rgba(255, 255, 255, 0.5), 4px 5px 0 var(--ink); }
.r-medal b { font-family: var(--display); font-weight: 900; font-size: 18px; }
@keyframes medalIn { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.r-share { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }
.r-share .link { background: none; border: 0; font-weight: 800; font-size: 14px; text-decoration: underline; cursor: pointer; color: var(--ink-2); padding: 0; }

/* ---------- tutorial ---------- */
.tut { position: fixed; inset: 0; z-index: 42; display: grid; place-items: center; padding: 16px; background: rgba(23, 20, 46, 0.45); }
.tut-in { width: min(860px, 100%); max-height: 94vh; overflow: auto; padding: 26px; text-align: center; animation: rise 0.35s ease-out; }
.tut-in h2 { font-size: clamp(30px, 4.4vw, 50px); margin: 8px 0 18px; }
.tut-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; text-align: left; }
.tut-card { border: var(--border); border-radius: 18px; padding: 14px; }
.tut-card .tk { display: inline-block; font-family: var(--display); font-weight: 900; font-size: 15px; background: var(--ink); color: #fff; border-radius: 10px; padding: 4px 10px; }
.tut-card h3 { font-family: var(--display); font-weight: 900; font-size: 17px; margin: 10px 0 6px; }
.tut-card p { margin: 0; font-size: 14px; font-weight: 600; }
.tut-medals { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.tut-medals p { margin: 0 0 0 6px; font-weight: 700; font-size: 14px; max-width: 460px; text-align: left; }
@media (max-width: 760px) { .tut-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .top .chip.sound { display: inline-flex; padding: 9px 11px; } .chip.sound #soundLbl { display: none; } }

/* ---------- share ---------- */
.share { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(23, 20, 46, 0.5); }
.share-in { width: min(820px, 100%); max-height: 94vh; overflow: auto; padding: 20px; animation: rise 0.3s ease-out; }
.share-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.share-head b { font-size: 26px; }
.share-x { width: 40px; height: 40px; border-radius: 50%; border: var(--border); background: var(--paper); font-weight: 900; font-size: 16px; cursor: pointer; }
.share-pic { position: relative; aspect-ratio: 16 / 9; border: var(--border); border-radius: 18px; overflow: hidden; background: linear-gradient(180deg, #3f8dff, #8ed0ff 60%, #ffd3ea); box-shadow: var(--pop-sm); }
.share-pic img { width: 100%; height: 100%; display: block; object-fit: cover; }
.share-pic img:not([src]) { visibility: hidden; }
.share-wait { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.share-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.share-actions .btn svg { width: 20px; height: 20px; }
#sharePost { background: var(--ink); color: #fff; box-shadow: 5px 6px 0 var(--pink); }
.share-tip { margin: 12px 0 0; font-weight: 700; font-size: 14px; color: var(--ink-2); min-height: 20px; }
.share-tip b { color: var(--ink); }
@media (max-width: 560px) { .share-actions .btn { flex: 1 1 100%; } .share-actions .btn.big { font-size: 17px; padding: 17px 18px; } .share-head b { font-size: 22px; } }
