[hidden] { display: none !important; }
:root {
  --ink: #1b1f3a;
  --sky: #2e8bff;
  --sky2: #20c7ff;
  --gold: #ffd23f;
  --orange: #ff8a00;
  --red: #ff3b4e;
  --green: #3ccf4e;
  --pink: #ff5fd2;
  --panel: rgba(255, 255, 255, 0.96);
  --head: 'Lilita One', 'Arial Rounded MT Bold', 'Arial Black', sans-serif;
  --body: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #6fd0ff; color: var(--ink); font-family: var(--body); }
button { font-family: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 0.35em; border-radius: 6px; background: #fff; border: 2px solid #c9d3e6; border-bottom-width: 4px; font: 700 0.85em var(--body); color: var(--ink); text-align: center; }
#stage { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* outlined game text */
.outline, .lapbox, .clock, .place, .speedo, #center-text, .gems b, .logo h1 span {
  -webkit-text-stroke: 0;
  text-shadow:
    3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink),
    2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink),
    0 6px 0 rgba(0, 0, 0, 0.35);
}

/* ---------- full screens ---------- */
.screen { position: absolute; inset: 0; display: none; align-items: center; justify-content: safe center; flex-direction: column; padding: 16px; overflow-y: auto; }
.screen.show { display: flex; }
#loading, #title { background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.0) 0, rgba(20,60,160,0.35) 100%); }
#loading { background: linear-gradient(#36a6ff, #8fe0ff 60%, #7fd65a 60%, #4cb83a); }
.bar { width: min(420px, 80vw); height: 26px; border-radius: 20px; background: #fff; border: 4px solid var(--ink); overflow: hidden; margin-top: 24px; }
#load-bar { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--gold) 0 14px, var(--orange) 14px 28px); transition: width 0.2s; }
#load-text { font: 600 18px var(--body); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.3); }

.logo { position: relative; display: flex; flex-direction: column; align-items: center; transform: rotate(-4deg); }
.logo img { width: 150px; filter: drop-shadow(0 8px 0 rgba(0,0,0,.25)); animation: bob 2.4s ease-in-out infinite; }
.logo.small img { width: 90px; }
.logo h1 { margin: -18px 0 0; font: 400 clamp(56px, 11vw, 128px)/0.9 var(--head); display: flex; gap: 0.18em; letter-spacing: 1px; }
.logo.small h1 { font-size: 56px; }
.logo h1 span:first-child { color: #fff; background: linear-gradient(#fff, #bdf0ff); -webkit-background-clip: text; background-clip: text; }
.logo h1 span { color: var(--gold); }
.logo h1 span:last-child { color: var(--gold); }
.kart-word { margin-top: 16px; padding: 2px 22px; background: var(--red); color: #fff; font: 400 clamp(20px, 3vw, 32px) var(--head); border: 4px solid var(--ink); border-radius: 14px; transform: rotate(3deg); box-shadow: 0 6px 0 rgba(0,0,0,.3); letter-spacing: 6px; }
.tag { margin: 22px 0 18px; font: 700 clamp(16px, 2.2vw, 24px) var(--body); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35); text-align: center; }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: stretch; width: min(340px, 86vw); }
@keyframes bob { 50% { transform: translateY(-10px) rotate(6deg); } }

.big { font: 400 24px var(--head); letter-spacing: 1px; padding: 12px 28px; border-radius: 18px; border: 4px solid var(--ink); color: #fff; box-shadow: 0 6px 0 var(--ink); transition: transform .08s, box-shadow .08s; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.big.go { background: linear-gradient(#ffdf4a, #ff9d00); color: var(--ink); text-shadow: 0 2px 0 rgba(255,255,255,.5); }
.big.alt { background: linear-gradient(#45b4ff, #1f6dff); }
.big:hover { filter: brightness(1.08); }
.big:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

.panel { background: var(--panel); border: 5px solid var(--ink); border-radius: 28px; padding: 22px 26px; box-shadow: 0 10px 0 rgba(0,0,0,.25); max-width: 100%; }
.panel.wide { width: min(980px, 100%); flex-shrink: 0; }
.panel h2 { font: 400 34px var(--head); margin: 0 0 12px; color: var(--sky); text-align: center; }
.panel h3 { font: 400 22px var(--head); margin: 6px 0; color: var(--orange); }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.row.end { justify-content: flex-end; margin-top: 18px; }
label { display: flex; flex-direction: column; font: 700 15px var(--body); gap: 4px; flex: 1 1 200px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; }
input { font: 600 20px var(--body); padding: 10px 14px; border-radius: 14px; border: 3px solid #c9d3e6; outline: none; color: var(--ink); }
input:focus { border-color: var(--sky); }
.step-head { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; }
.step-head h2 { margin: 0; text-align: left; font-size: 26px; }
.step { width: 36px; height: 36px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; font: 400 22px var(--head); border: 3px solid var(--ink); }

.cups { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.cup { border: 4px solid #d5def0; border-radius: 18px; padding: 12px; background: #f6f9ff; text-align: left; transition: transform .1s; }
.cup b { display: block; font: 400 22px var(--head); color: var(--ink); }
.cup em { font-style: normal; font-weight: 700; color: var(--sky); }
.cup small { display: block; font-size: 14px; color: #556; margin-top: 4px; }
.cup.on { border-color: var(--ink); background: linear-gradient(#fff6c8, #ffe07a); transform: translateY(-3px); box-shadow: 0 5px 0 var(--ink); }
.cup .trophy { font-size: 28px; float: right; }

.racers { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.racer { position: relative; border: 4px solid #d5def0; border-radius: 20px; background: linear-gradient(#c8ecff, #8fd6ff); padding: 0 0 8px; overflow: hidden; transition: transform .1s; }
.racer img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.racer b { display: block; font: 400 22px var(--head); color: #fff; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.racer small { font-weight: 700; color: var(--ink); }
.racer.on { border-color: var(--ink); transform: translateY(-4px) scale(1.03); box-shadow: 0 6px 0 var(--ink); background: linear-gradient(#fff6c8, #ffc94a); }
.racer.on::after { content: '1P'; position: absolute; top: 6px; left: 6px; background: var(--red); color: #fff; font: 400 16px var(--head); padding: 2px 8px; border-radius: 10px; border: 2px solid var(--ink); }

.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px 26px; font-size: 17px; line-height: 1.45; }
.help-grid p { margin: 6px 0; }
.tools { list-style: none; padding: 0; margin: 0; }
.tools li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.tools img { width: 44px; height: 44px; }
.tools b { margin-right: 4px; }
b.blue { color: #1fa8ff; } b.green { color: #1fb144; } b.red { color: #e0303e; } b.orange { color: #ff8a00; } b.pink { color: #d43bff; }
#help .big, #board .big { display: block; margin: 16px auto 0; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--head); color: #fff; }
.hud-tl { position: absolute; top: 18px; left: 22px; display: flex; gap: 16px; align-items: flex-start; }
.lapbox { font-size: 26px; display: flex; align-items: baseline; gap: 4px; font-style: italic; }
.lapbox small { font-size: 24px; color: var(--gold); }
.lapbox b { font-size: 58px; font-weight: 400; line-height: 1; }
.lapbox i { font-size: 30px; }
.itembox { display: flex; flex-direction: column; align-items: center; }
.item-ring { position: relative; width: 96px; height: 96px; border-radius: 26px; background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.95), rgba(220,235,255,.75)); border: 5px solid var(--ink); box-shadow: inset 0 0 0 4px #fff, 0 6px 0 rgba(0,0,0,.3); display: grid; place-items: center; }
.item-ring img { width: 78px; height: 78px; object-fit: contain; }
.item-ring img:not([src]), .item-ring img[src=""] { visibility: hidden; }
.item-ring b { position: absolute; right: -8px; bottom: -8px; background: var(--red); border: 3px solid var(--ink); border-radius: 12px; padding: 0 7px; font-size: 22px; font-weight: 400; }
.item-ring b:empty { display: none; }
.itembox small { margin-top: 4px; background: var(--ink); padding: 0 8px; border-radius: 8px; font-size: 14px; opacity: 0; }
.itembox.full small { opacity: 1; }
.itembox.full .item-ring { animation: ring 0.9s ease-in-out infinite; }
.itembox.roll .item-ring img { animation: roll .12s linear infinite; }
@keyframes ring { 50% { box-shadow: inset 0 0 0 4px var(--gold), 0 6px 0 rgba(0,0,0,.3), 0 0 22px var(--gold); } }
@keyframes roll { from { transform: translateY(-30%); opacity: .3; } to { transform: translateY(30%); opacity: 1; } }
.gems { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.gems img { width: 44px; }
.gems b { font-size: 40px; font-weight: 400; }
.gems small { font: 700 14px var(--body); color: #fff; text-shadow: 0 2px 0 var(--ink); }

.hud-tr { position: absolute; top: 16px; right: 22px; text-align: right; }
.clock { font-size: 44px; font-style: italic; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.splits { list-style: none; margin: 2px 0 0; padding: 0; font-size: 22px; }
.splits li { text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); font-variant-numeric: tabular-nums; }
.splits li span { color: var(--gold); margin-right: 8px; }
.splits li.best { color: #7dffb0; }
.paused-tag { display: inline-block; margin-top: 6px; background: var(--red); border: 3px solid var(--ink); border-radius: 12px; padding: 2px 10px; font-size: 18px; }

#minimap { position: absolute; left: 14px; bottom: 14px; width: 200px; height: 200px; opacity: .95; }
.hud-br { position: absolute; right: 24px; bottom: 12px; display: flex; align-items: flex-end; gap: 18px; }
.speedo { font-style: italic; text-align: right; }
.speedo b { font-size: 40px; font-weight: 400; display: block; line-height: 1; }
.speedo small { font-size: 18px; color: var(--gold); }
.place { font-size: 130px; line-height: .9; font-style: italic; color: var(--gold); background: linear-gradient(#fff9b8 10%, #ffd23f 45%, #ff8a00 90%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(4px 0 0 var(--ink)) drop-shadow(-4px 0 0 var(--ink)) drop-shadow(0 4px 0 var(--ink)) drop-shadow(0 -4px 0 var(--ink)) drop-shadow(0 6px 0 rgba(0,0,0,.35)); text-shadow: none; transition: transform .2s; }
.place sup { font-size: 52px; vertical-align: top; position: relative; top: 14px; }
.place.p1 { background-image: linear-gradient(#fffbd0 10%, #ffd23f 45%, #ffb000 90%); }
.place.p2, .place.p3 { background-image: linear-gradient(#ffffff 10%, #cfe6ff 45%, #6eb4ff 90%); }
.place.p4, .place.p5, .place.p6 { background-image: linear-gradient(#ffffff 10%, #d7dbe8 50%, #8f97ad 90%); }
.place.pop { transform: scale(1.18) rotate(-4deg); }

#center-text { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(70px, 14vw, 180px); font-style: italic; color: #fff; opacity: 0; transform: scale(.4); transition: none; }
#center-text.show { animation: pop 1s ease-out forwards; }
#center-text.go { color: var(--gold); }
#center-text.lap { font-size: clamp(50px, 9vw, 110px); color: var(--gold); }
@keyframes pop { 0% { opacity: 0; transform: scale(.3); } 20% { opacity: 1; transform: scale(1.12); } 35% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05); } }
#toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font: 400 30px var(--head); color: #fff; background: rgba(27,31,58,.82); border: 3px solid #fff; padding: 6px 18px; border-radius: 16px; opacity: 0; transition: opacity .25s; white-space: nowrap; }
#toast.show { opacity: 1; }
#lights { position: absolute; top: 12%; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; background: #2b2f45; padding: 12px 18px; border-radius: 26px; border: 5px solid var(--ink); box-shadow: 0 8px 0 rgba(0,0,0,.3); }
#lights i { width: 54px; height: 54px; border-radius: 50%; background: #50556b; border: 4px solid #1b1f30; }
#lights i.red { background: radial-gradient(circle at 40% 35%, #ffb3b3, #ff2b2b 60%); box-shadow: 0 0 24px #ff2b2b; }
#lights i.green { background: radial-gradient(circle at 40% 35%, #d6ffd0, #2ee84a 60%); box-shadow: 0 0 24px #2ee84a; }

#speedlines { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: repeating-conic-gradient(from 0deg at 50% 52%, rgba(255,255,255,0) 0deg 4deg, rgba(255,255,255,.55) 4.4deg 4.8deg, rgba(255,255,255,0) 5.2deg 11deg);
  -webkit-mask: radial-gradient(ellipse at 50% 52%, transparent 0 42%, #000 75%); mask: radial-gradient(ellipse at 50% 52%, transparent 0 42%, #000 75%); }
#speedlines.on { opacity: .5; animation: lines 1.6s ease-in-out infinite alternate; }
@keyframes lines { to { transform: scale(1.04); } }
#flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(255,214,120,.55) 100%); opacity: 0; transition: opacity .6s ease-out; }
#flash.on { opacity: 1; transition: opacity .08s; }

/* ---------- overlays ---------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20,40,110,.35), rgba(10,15,50,.7)); padding: 16px; z-index: 5; }
.overlay[hidden] { display: none; }
.q-panel { width: min(860px, 100%); background: var(--panel); border: 6px solid var(--ink); border-radius: 30px; padding: 0 26px 22px; box-shadow: 0 12px 0 rgba(0,0,0,.3); text-align: center; animation: drop .35s cubic-bezier(.2,1.6,.4,1); max-height: calc(100vh - 32px); overflow-y: auto; }
.q-panel.narrow { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
@keyframes drop { from { transform: translateY(-40px) scale(.9); opacity: 0; } }
.q-head { margin: 0 -26px 10px; padding: 12px 20px; background: linear-gradient(#3bc0ff, #1f6dff); border-bottom: 6px solid var(--ink); border-radius: 24px 24px 0 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; font: 400 34px var(--head); text-shadow: 0 3px 0 var(--ink); position: relative; }
.q-head img { width: 52px; margin: -18px 0; }
.q-head em { position: absolute; right: 18px; font: 600 18px var(--body); font-style: normal; background: rgba(0,0,0,.25); padding: 2px 10px; border-radius: 10px; text-shadow: none; }
.q-head.good { background: linear-gradient(#5cf06b, #1fb144); }
.q-head.bad { background: linear-gradient(#ff7a7a, #e0303e); }
.q-paused { font: 700 16px var(--body); color: #e0303e; margin: 4px 0; }
#q-text, #w-answer { font: 400 clamp(36px, 6vw, 64px) var(--head); color: var(--ink); margin: 10px 0 18px; line-height: 1.1; }
#w-answer { color: #1fb144; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice { position: relative; font: 400 clamp(26px, 4vw, 40px) var(--head); padding: 16px 12px 16px 56px; border-radius: 20px; border: 5px solid var(--ink); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35); box-shadow: 0 7px 0 var(--ink); transition: transform .08s; }
.choice:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.choice:nth-child(1) { background: linear-gradient(#ff6b6b, #e22c3c); }
.choice:nth-child(2) { background: linear-gradient(#4fb6ff, #1f6dff); }
.choice:nth-child(3) { background: linear-gradient(#63e46f, #1fb144); }
.choice:nth-child(4) { background: linear-gradient(#ffd84a, #ff9d00); }
.choice i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.9); color: var(--ink); font: 400 22px/36px var(--head); font-style: normal; text-shadow: none; }
.choice.right { outline: 6px solid #fff; animation: glow .5s ease-in-out 3; }
.choice.miss { opacity: .45; }
@keyframes glow { 50% { transform: scale(1.05); } }
.q-hint { font: 600 15px var(--body); color: #556; margin: 14px 0 0; }
.q-sub { font: 700 20px var(--body); margin: 8px 0 0; }
.explain { font: 600 22px var(--body); background: #f1f6ff; border-radius: 16px; padding: 12px; }

.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 8px; }
.tool-card { position: relative; border: 5px solid var(--ink); border-radius: 22px; background: linear-gradient(#ffffff, #dff1ff); padding: 10px 12px 14px; box-shadow: 0 7px 0 var(--ink); transition: transform .1s; text-align: center; }
.tool-card:hover { transform: translateY(-4px); }
.tool-card img { width: 120px; height: 120px; object-fit: contain; }
.tool-card b { display: block; font: 400 26px var(--head); }
.tool-card small { display: block; font: 600 15px var(--body); color: #445; }
.tool-card i { position: absolute; top: 8px; left: 8px; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font: 400 20px/34px var(--head); font-style: normal; }
.tool-card.rare { background: linear-gradient(#fff9cf, #ffd75a); }
.tool-card.rare::after { content: 'FAST BONUS'; position: absolute; top: -14px; right: 10px; background: var(--red); color: #fff; font: 400 14px var(--head); padding: 2px 8px; border-radius: 8px; border: 2px solid var(--ink); }

/* ---------- results & board ---------- */
.res-top { display: flex; align-items: center; gap: 20px; justify-content: center; }
.res-top img { width: 160px; border-radius: 24px; background: linear-gradient(#c8ecff, #8fd6ff); border: 4px solid var(--ink); }
.res-place { font: 400 96px var(--head); color: var(--gold); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; line-height: 1; }
#res-msg { font: 700 22px var(--body); margin: 4px 0; }
.laps-table, .board-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; font: 600 20px var(--body); margin-top: 10px; }
.laps-table td, .board-table td { background: #eef4ff; padding: 8px 12px; }
.laps-table td:first-child, .board-table td:first-child { border-radius: 12px 0 0 12px; font-family: var(--head); }
.laps-table td:last-child, .board-table td:last-child { border-radius: 0 12px 12px 0; }
.laps-table th, .board-table th { text-align: left; font: 700 14px var(--body); color: #778; padding: 0 12px; }
.laps-table .t, .board-table .t { font-family: var(--head); font-size: 24px; font-variant-numeric: tabular-nums; }
.laps-table tr.total td { background: #fff3c4; }
.badge { display: inline-block; background: var(--green); color: #fff; font: 400 15px var(--head); padding: 2px 8px; border-radius: 8px; border: 2px solid var(--ink); }
.badge.pb { background: var(--pink); }
.res-stats { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.res-stats div { background: #eef4ff; border-radius: 16px; padding: 8px 16px; text-align: center; }
.res-stats b { display: block; font: 400 30px var(--head); color: var(--sky); }
.small-note { font: 600 14px var(--body); color: #667; text-align: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tabs button { font: 400 18px var(--head); padding: 8px 14px; border-radius: 14px; border: 3px solid var(--ink); background: #fff; color: var(--ink); }
.tabs button.on { background: var(--gold); }
.board-ctrl { justify-content: space-between; align-items: center; }
.board-table img { width: 36px; height: 36px; vertical-align: middle; border-radius: 50%; background: #c8ecff; }
.board-table tr.me td { background: #fff3c4; }
.board-table td.small { font-size: 15px; color: #556; }

/* ---------- touch ---------- */
#touch { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#touch > * { pointer-events: auto; }
.stick { position: absolute; left: 24px; bottom: 24px; width: 190px; height: 190px; touch-action: none; }
.stick-ring { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.18) 0 55%, rgba(27,31,58,.38) 56%); border: 5px solid rgba(255,255,255,.85); box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 86px; height: 86px; margin: -43px 0 0 -43px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #cfe6ff 60%, #8fb8e8); border: 4px solid var(--ink); box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.stick small { position: absolute; left: 0; right: 0; bottom: -2px; text-align: center; font: 400 14px var(--head); color: #fff; text-shadow: 0 2px 0 var(--ink); pointer-events: none; }
.pad { position: absolute; right: 20px; bottom: 22px; width: 260px; height: 250px; }
.pb { position: absolute; border-radius: 50%; border: 5px solid var(--ink); color: #fff; font-family: var(--head); box-shadow: 0 7px 0 var(--ink); touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 0; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.pb b { font-size: 46px; font-weight: 400; }
.pb span { font-size: 13px; letter-spacing: .5px; }
.pb.down { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); filter: brightness(1.2); }
.pb-a { width: 112px; height: 112px; right: 0; bottom: 70px; background: radial-gradient(circle at 40% 30%, #8dff9a, #1fb144 70%); }
.pb-b { width: 96px; height: 96px; right: 118px; bottom: 6px; background: radial-gradient(circle at 40% 30%, #ff9a9a, #e0303e 70%); }
.pb-b span { font-size: 10px; }
.pb-tool { width: 84px; height: 84px; right: 128px; bottom: 132px; background: radial-gradient(circle at 40% 30%, #ffffff, #cfe6ff 70%); color: var(--ink); text-shadow: none; }
.pb-tool img { width: 50px; height: 50px; object-fit: contain; margin-bottom: -4px; }
.pb-tool img:not([src]) { display: none; }
.pb-drift { width: 78px; height: 78px; right: 18px; bottom: 192px; background: radial-gradient(circle at 40% 30%, #ffe680, #ff9d00 70%); color: var(--ink); text-shadow: none; }
.pb-drift span { font-size: 15px; }
#touch.on ~ #hud #minimap, body.touch #minimap { left: auto; right: 14px; top: 130px; bottom: auto; width: 150px; height: 150px; }
body.touch .hud-br { right: auto; left: 230px; bottom: 16px; }
body.touch .speedo { display: none; }

#controls-hint { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; z-index: 3; max-width: 92vw; pointer-events: none; }
#controls-hint div { background: rgba(27,31,58,.82); color: #fff; border: 3px solid #fff; border-radius: 14px; padding: 6px 12px; font: 600 15px var(--body); display: flex; align-items: center; gap: 6px; }
#controls-hint b { font: 400 18px var(--head); }
#controls-hint .ab { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; font: 400 16px var(--head); }

@media (max-width: 760px), (max-height: 520px) {
  .lapbox b { font-size: 40px; }
  .item-ring { width: 72px; height: 72px; border-radius: 20px; }
  .item-ring img { width: 58px; height: 58px; }
  .clock { font-size: 30px; }
  .splits { font-size: 16px; }
  .place { font-size: 84px; }
  .place sup { font-size: 34px; top: 8px; }
  #minimap { width: 130px; height: 130px; }
  .stick { width: 150px; height: 150px; left: 14px; bottom: 14px; }
  .stick-knob { width: 70px; height: 70px; margin: -35px 0 0 -35px; }
  .pad { transform: scale(.82); transform-origin: right bottom; right: 10px; bottom: 10px; }
  body.touch .hud-br { left: 170px; }
  .speedo { display: none; }
  .choices { gap: 10px; }
  .q-head { font-size: 26px; }
}

.clock.frozen { color: #8fe3ff; animation: frozen 1s steps(2) infinite; }
@keyframes frozen { 50% { opacity: .55; } }

/* racer picker: 3D stage plus bouncing cards */
.racer-pick { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.stage { position: relative; min-height: 280px; border: 4px solid var(--ink); border-radius: 22px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 115%, #9fe27a 0 34%, transparent 35%), linear-gradient(#7fd0ff, #cdeeff 70%, #e9f8ff); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-name { position: absolute; left: 12px; top: 10px; display: flex; flex-direction: column; pointer-events: none; }
.stage-name b { font: 400 34px var(--head); color: #fff; text-shadow: 0 3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink); animation: namepop .45s cubic-bezier(.3,1.6,.5,1); }
.stage-name small { font-weight: 700; color: var(--ink); background: #fff8; border-radius: 8px; padding: 0 8px; align-self: flex-start; }
.racer-pick .racers { grid-template-columns: repeat(3, 1fr); align-content: start; }
.racer img { animation: cardbob 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
.racer:nth-child(2) img { animation-delay: -.4s; } .racer:nth-child(3) img { animation-delay: -.9s; }
.racer:nth-child(4) img { animation-delay: -1.3s; } .racer:nth-child(5) img { animation-delay: -1.8s; } .racer:nth-child(6) img { animation-delay: -2.2s; }
.racer:hover img { animation: cardwiggle .5s ease-in-out infinite; }
.racer.on img { animation: cardjump .9s cubic-bezier(.3,1.5,.5,1), cardbob 1.3s ease-in-out .9s infinite; }
@keyframes cardbob { 50% { transform: translateY(-5px) rotate(-2deg) scale(1.02); } }
@keyframes cardwiggle { 25% { transform: rotate(-5deg) scale(1.05); } 75% { transform: rotate(5deg) scale(1.05); } }
@keyframes cardjump { 0% { transform: scale(.8) translateY(10px); } 40% { transform: scale(1.12) translateY(-14px) rotate(-6deg); } 100% { transform: none; } }
@keyframes namepop { from { transform: scale(.4); opacity: 0; } }
@media (max-width: 720px) { .racer-pick { grid-template-columns: 1fr; } .stage { min-height: 230px; } }
@media (prefers-reduced-motion: reduce) { .racer img, .racer.on img, .racer:hover img, .stage-name b { animation: none; } }

/* look-behind */
.pb-look { width: 64px; height: 64px; right: 200px; bottom: 228px; background: radial-gradient(circle at 40% 30%, #e6d6ff, #8a5cff 70%); }
.pb-look i { font-style: normal; font-size: 24px; line-height: 1; }
.pb-look span { font-size: 11px; }
.rear-tag { margin-top: 6px; display: inline-block; background: var(--ink); color: #fff; font: 400 20px var(--head); padding: 4px 14px; border-radius: 12px; border: 3px solid #fff; letter-spacing: 1px; }

/* drift meter: fills while you drift, gives a free Rocket Boost when full */
.driftbox { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.drift-ring { --c: #ffb02e; position: relative; width: 78px; height: 78px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff, #dfe9ff 75%); border: 5px solid var(--ink); box-shadow: 0 6px 0 rgba(0,0,0,.3); display: grid; place-items: center; transition: transform .15s; }
.drift-ring svg { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); transform: rotate(-90deg); }
.drift-ring circle { fill: none; stroke-width: 11; }
.drift-ring .bg { stroke: rgba(27,31,58,.14); }
.drift-ring .fill { stroke: var(--c); stroke-linecap: round; stroke-dasharray: calc(var(--m, 0) * 1) 100; transition: stroke-dasharray .12s linear, stroke .2s; }
.drift-ring img { width: 40px; height: 40px; object-fit: contain; opacity: .35; filter: grayscale(.8); transition: opacity .2s, filter .2s; }
.drift-ring b { position: absolute; bottom: -12px; background: var(--ink); color: #fff; border-radius: 8px; padding: 0 6px; font: 400 13px var(--head); letter-spacing: .5px; }
.driftbox small { margin-top: 14px; background: var(--ink); color: #fff; padding: 0 8px; border-radius: 8px; font: 700 12px var(--body); }
.driftbox.on .drift-ring { transform: scale(1.08) rotate(-4deg); }
.driftbox[data-level="1"] .drift-ring { --c: #38b6ff; }
.driftbox[data-level="2"] .drift-ring { --c: #ff9a1e; }
.driftbox[data-level="3"] .drift-ring { --c: #ff4fe0; }
.driftbox.on .drift-ring img { opacity: .75; filter: none; }
.driftbox.ready .drift-ring { --c: #3ccf4e; animation: ring .9s ease-in-out infinite; }
.driftbox.ready .drift-ring img { opacity: 1; filter: none; }
.itembox.gift .item-ring { animation: gift .9s ease-out; }
@keyframes gift { 0% { transform: scale(.6) rotate(-20deg); } 45% { transform: scale(1.25) rotate(8deg); box-shadow: 0 0 0 10px rgba(60,207,78,.6), 0 6px 0 rgba(0,0,0,.3); } 100% { transform: none; } }
/* the touch DRIFT button shows the same meter as a ring */
.pb-drift { background: radial-gradient(circle closest-side at 50% 50%, #ffe680 20%, #ff9d00 74%, transparent 75%), conic-gradient(#3ccf4e calc(var(--m, 0) * 1%), #5a3a10 0); }
.pb-drift.on { filter: brightness(1.15); }
.pb-drift.ready { animation: ring .9s ease-in-out infinite; }
body.touch .driftbox small { display: none; }
@media (max-width: 760px), (max-height: 520px) {
  .drift-ring { width: 60px; height: 60px; }
  .drift-ring img { width: 30px; height: 30px; }
}

/* track picker */
.tracks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.track-card { --tc: #2e8bff; position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 0 10px; border-radius: 18px; overflow: hidden;
  border: 4px solid var(--ink); background: #fff; color: var(--ink); text-align: left; cursor: pointer; box-shadow: 0 5px 0 var(--ink); transition: transform .12s; }
.track-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--tc); display: block; margin-bottom: 4px; }
.track-card .te { position: absolute; top: 8px; left: 8px; font-size: 26px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.track-card b { font: 400 22px var(--head); padding: 0 12px; color: var(--tc); text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.track-card small { font: 600 13px/1.3 var(--body); padding: 0 12px; color: #4a5068; }
.track-card:hover { transform: translateY(-2px); }
.track-card.on { outline: 5px solid var(--tc); outline-offset: 2px; transform: translateY(-3px) scale(1.02); }
.track-card.on::after { content: '✓'; position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; background: var(--tc); color: #fff;
  border: 3px solid var(--ink); display: grid; place-items: center; font: 400 20px var(--head); }
@media (max-width: 760px) { .tracks { grid-template-columns: 1fr; } .track-card img { aspect-ratio: 3 / 1; } }
#board-tracks { margin-bottom: 6px; }

/* glider picker */
.glide-note { margin: -4px 0 8px; font: 600 14px var(--body); color: #4a5068; }
.gliders { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.glider-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 8px; border-radius: 14px; border: 3px solid var(--ink);
  background: linear-gradient(#e8f6ff, #fff); cursor: pointer; box-shadow: 0 4px 0 var(--ink); color: var(--ink); transition: transform .12s; }
.glider-card img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.glider-card b { font: 400 13px/1.1 var(--head); text-align: center; }
.glider-card:hover img { animation: cardbob .6s ease-in-out; }
.glider-card.on { background: linear-gradient(#fff3b0, #ffd23f); transform: translateY(-3px); }
.glider-card.on img { animation: cardjump .5s ease-out; }
@media (max-width: 900px) { .gliders { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 520px) { .gliders { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) and (min-width: 761px) { .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
