@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(../assets/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(../assets/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(../assets/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(../assets/fonts/inter-latin-700-normal.woff2) format('woff2'); }
:root { --ink: #fff8ee; --dim: #c8bce8; --panel: rgba(28, 18, 60, 0.94); --edge: #ffd23a; --hot: #ff5a3a; --cool: #3ac8ff; --mint: #5fffa8; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140c2c; color: var(--ink); font: 500 15px/1.4 Inter, system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
canvas#view { width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
canvas#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
body.racing canvas#bg { display: none; }
button { font: inherit; color: var(--ink); background: linear-gradient(#4a3a8a, #2e2264); border: 2px solid #6a5ab0; border-radius: 12px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--edge); } button:active:not(:disabled) { transform: translateY(2px); } button:disabled { opacity: 0.45; cursor: default; }
button.big { font-weight: 800; font-size: 18px; padding: 12px 24px; background: linear-gradient(#ffe066, #ffb000); color: #2a1600; border-color: #fff2a8; box-shadow: 0 4px 0 #b87800; letter-spacing: 0.02em; }
button.hot { background: linear-gradient(#ff7a5a, #e0402a); border-color: #ffb8a0; }
button.sel { border-color: var(--edge); box-shadow: 0 0 0 2px var(--edge) inset; }
.hidden { display: none !important; }
.small { font-size: 12px; color: var(--dim); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
input, select { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 2px solid #5a4aa0; background: #120a2a; color: var(--ink); margin: 4px 0; user-select: text; -webkit-user-select: text; }
input[type=range] { padding: 0; }
h1, h2, h3 { margin: 0 0 8px; } h2 { font-size: 22px; letter-spacing: 0.02em; }
.coin { color: #ffd23a; font-weight: 800; } .coin::before { content: '⚙ '; }

/* menus */
#menu { position: fixed; inset: 0; z-index: 10; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; display: flex; flex-direction: column; align-items: center; padding: max(14px, env(safe-area-inset-top)) 12px 24px; }
#menu.clear { pointer-events: none; } #menu.clear > * { pointer-events: auto; }
#menu:empty { display: none; }
#menu:not(.clear) { background: radial-gradient(ellipse at 50% 40%, rgba(20,10,48,.25), rgba(20,10,48,.72)); }
.logo { font-weight: 900; font-size: clamp(34px, 7vw, 68px); line-height: 0.95; text-align: center; letter-spacing: -0.01em; margin: 10px 0 2px; color: #ffe066; text-shadow: 0 4px 0 #e0402a, 0 8px 0 #2a1a5a, 0 12px 24px rgba(0,0,0,.5); transform: rotate(-2deg); }
.logo small { display: block; font-size: 0.42em; color: #9effe8; text-shadow: 0 3px 0 #1a6a8a, 0 6px 12px rgba(0,0,0,.4); letter-spacing: 0.3em; margin-top: 6px; }
.tag { color: var(--dim); text-align: center; margin: 14px 0; }
.panel { background: var(--panel); border: 2px solid #5a4aa0; border-radius: 18px; padding: 16px; width: min(940px, 100%); margin: 8px 0; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.panel.narrow { width: min(460px, 100%); }
.bar-top { width: min(940px, 100%); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { display: flex; gap: 10px; align-items: center; background: rgba(0,0,0,.35); border-radius: 999px; padding: 6px 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card { position: relative; background: linear-gradient(#3a2c78, #251a52); border: 2px solid #5a4aa0; border-radius: 14px; padding: 10px; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); }
.card:hover { border-color: var(--edge); } .card.sel { border-color: var(--edge); box-shadow: 0 0 0 3px rgba(255,210,58,.35); }
.card.locked { opacity: .55; filter: grayscale(.6); cursor: default; }
.card b { font-size: 15px; } .card canvas { max-width: 100%; }
.card .lock { position: absolute; top: 6px; right: 8px; font-size: 18px; }
.mainbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; width: min(940px, 100%); }
.mainbtns button { padding: 16px 12px; font-size: 18px; font-weight: 800; border-radius: 16px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.mainbtns button span { font-size: 12px; font-weight: 500; color: var(--dim); }
.mainbtns button.gp { background: linear-gradient(135deg, #ff7a3a, #e0302a); border-color: #ffb88a; } .mainbtns button.gp span { color: #ffe8d8; }
.mainbtns button.tt { background: linear-gradient(135deg, #2a9ad8, #1a5aa8); border-color: #8ad8ff; } .mainbtns button.tt span { color: #d8f0ff; }
.mainbtns button.dash { background: linear-gradient(135deg, #3ac87a, #1a8a5a); border-color: #9affc8; } .mainbtns button.dash span { color: #d8ffe8; }
.mainbtns button.qr { background: linear-gradient(135deg, #b85aff, #6a2ac8); border-color: #e0b8ff; } .mainbtns button.qr span { color: #f0e0ff; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; width: 100%; font-size: 12px; align-items: center; text-align: left; }
.sbar { height: 8px; background: rgba(0,0,0,.4); border-radius: 4px; overflow: hidden; } .sbar i { display: block; height: 100%; background: linear-gradient(90deg, #5fffa8, #ffd23a); border-radius: 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
table.lb { width: 100%; border-collapse: collapse; } table.lb td, table.lb th { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; } table.lb tr.me { background: rgba(255,210,58,.15); }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(0,0,0,.25); } .ach.got { background: linear-gradient(90deg, rgba(255,210,58,.25), rgba(0,0,0,.2)); }
.ach i { font-style: normal; font-size: 22px; width: 30px; text-align: center; }
.trophy { font-size: 26px; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 10px 0; }
.podium div { display: flex; flex-direction: column; align-items: center; gap: 4px; } .podium .step { width: 90px; border-radius: 10px 10px 0 0; background: linear-gradient(#ffe066, #c88a00); color: #2a1600; font-weight: 900; font-size: 28px; text-align: center; }
.results li { display: flex; gap: 10px; padding: 4px 8px; border-radius: 8px; } .results li.me { background: rgba(255,210,58,.2); font-weight: 800; }
.results { list-style: none; padding: 0; margin: 0; }
.err { color: #ff9a8a; min-height: 1.2em; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-weight: 800; }
#hTop { position: absolute; left: 14px; top: max(10px, env(safe-area-inset-top)); text-shadow: 0 2px 0 #000, 0 0 8px rgba(0,0,0,.6); }
#hLap { font-size: 22px; letter-spacing: .05em; } #hLap b { font-size: 30px; color: #ffe066; }
#hTime { font-size: 20px; font-variant-numeric: tabular-nums; } #hBest { font-weight: 600; text-shadow: 0 1px 0 #000; }
#hMap { position: absolute; right: 12px; top: max(10px, env(safe-area-inset-top)); width: 130px; height: 130px; opacity: .92; }
#hItem { position: absolute; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); width: 76px; height: 76px; border-radius: 18px; background: rgba(20,10,50,.65); border: 3px solid #fff; box-shadow: 0 0 0 3px #3ac8ff, 0 4px 14px rgba(0,0,0,.5); }
#hItem canvas { width: 100%; height: 100%; } #hItemN { position: absolute; right: -6px; bottom: -6px; background: #ff5a3a; border-radius: 50%; width: 24px; height: 24px; text-align: center; line-height: 24px; font-size: 14px; }
#hItemN:empty { display: none; }
#hGears { position: absolute; left: 14px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 6px; font-size: 24px; color: #ffd23a; text-shadow: 0 2px 0 #000; }
#hGears i { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(#ffe066 40%, #c8901a 42%, #c8901a 60%, transparent 62%); border: 3px dashed #c8901a; }
#hPlace { position: absolute; right: 18px; bottom: max(10px, env(safe-area-inset-bottom)); font-size: 76px; line-height: 1; color: #ffe066; text-shadow: 0 4px 0 #e0402a, 0 8px 0 #2a1a5a; font-style: italic; }
#hPlace sup { font-size: 30px; } #hPlace.p1 { color: #fff6a0; } #hPlace.bump { animation: bump .35s; }
#hDrift { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); display: flex; gap: 6px; opacity: 0; transition: opacity .15s; } #hDrift.on { opacity: 1; }
#hDrift i { width: 34px; height: 10px; border-radius: 5px; background: rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.6); } #hDrift i.t1 { background: #5fffa8; } #hDrift i.t2 { background: #ff4fd2; } #hDrift i.t3 { background: #fff7d0; box-shadow: 0 0 12px #fff; }
#hCount { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 110px; color: #ffe066; text-shadow: 0 6px 0 #e0402a, 0 12px 0 #2a1a5a; font-style: italic; }
#hCount.pop { animation: pop .5s ease-out; }
#hBanner { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); text-align: center; font-size: 26px; color: #fff; text-shadow: 0 3px 0 #2a1a5a; white-space: nowrap; }
#hBanner small { display: block; font-size: 14px; color: #ffe066; }
#hBanner.show { animation: banner 3.2s forwards; }
#hPops { position: absolute; left: 0; right: 0; top: 38%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.popup { font-size: 24px; color: #fff; text-shadow: 0 3px 0 #2a1a5a, 0 0 10px rgba(0,0,0,.5); animation: popup 1.1s forwards; font-style: italic; white-space: nowrap; }
.popup.t1 { color: #5fffa8; } .popup.t2 { color: #ff7ae0; } .popup.t3 { color: #fff7d0; font-size: 30px; } .popup.gold { color: #ffd23a; } .popup.bad { color: #ff8a7a; } .popup.combo { color: #9effe8; font-size: 18px; }
#hPause { position: absolute; right: 150px; top: max(10px, env(safe-area-inset-top)); pointer-events: auto; padding: 6px 12px; font-size: 14px; background: rgba(20,10,50,.6); }
@keyframes pop { 0% { transform: scale(2.2); opacity: 0; } 40% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes popup { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; } }
@keyframes banner { 0% { transform: translate(-50%, -30px) scale(.6); opacity: 0; } 10% { transform: translate(-50%, 0) scale(1.1); opacity: 1; } 18% { transform: translate(-50%, 0) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* touch */
#touch { position: fixed; left: 0; right: 0; bottom: 0; height: 42%; z-index: 6; pointer-events: none; }
#tSteer { position: absolute; left: 0; bottom: 0; width: 52%; height: 100%; pointer-events: auto; display: flex; align-items: flex-end; justify-content: center; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
#tSteer span { font-size: 12px; color: rgba(255,255,255,.55); font-weight: 700; }
#tKnob { position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; border: 3px solid rgba(255,255,255,.7); background: rgba(255,255,255,.15); display: none; pointer-events: none; }
#tBtns { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); width: 46%; height: 92%; pointer-events: none; }
#tBtns button { position: absolute; pointer-events: auto; border-radius: 50%; font-weight: 900; font-size: 13px; line-height: 1.1; padding: 0; color: #fff; background: rgba(40,20,90,.55); border: 3px solid rgba(255,255,255,.7); }
#tDrift { right: 0; bottom: 4%; width: 92px; height: 92px; background: rgba(255,80,200,.4) !important; }
#tItem { right: 98px; bottom: 30%; width: 78px; height: 78px; background: rgba(58,200,255,.4) !important; }
#tBack { right: 112px; bottom: 4%; width: 50px; height: 50px; } #tBack.on { background: rgba(255,210,58,.6) !important; }
#tBrake { right: 6px; bottom: 54%; width: 60px; height: 60px; font-size: 11px !important; }
#tBtns button.on { filter: brightness(1.6); transform: scale(.94); }
body.touch #hPlace { bottom: auto; top: 46%; right: 12px; font-size: 54px; } body.touch #hPlace sup { font-size: 22px; }
body.touch #hGears { bottom: auto; top: 50%; }
body.touch #hDrift { bottom: 46%; }

#toasts { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--panel); border: 2px solid var(--edge); border-radius: 12px; padding: 8px 14px; animation: popup 4s forwards; text-align: center; max-width: 92vw; }
.toast b { color: #ffe066; }
@media (max-width: 640px) { #hMap { width: 96px; height: 96px; } #hPause { right: 112px; } #hItem { width: 62px; height: 62px; } #hLap { font-size: 16px; } #hLap b { font-size: 22px; } #hTime { font-size: 15px; } #hCount { font-size: 80px; } .popup { font-size: 19px; } .mainbtns button { padding: 12px 10px; font-size: 16px; } }

/* GRAND-TOUR */
.mainbtns button.tour { background: linear-gradient(135deg, #f2c230, #c8761a); border-color: #ffe08a; color: #2a1600; } .mainbtns button.tour span { color: #4a2a00; }
.tour .pill { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: rgba(255,210,58,.2); color: #ffd23a; vertical-align: middle; }
.tl-bar { position: relative; height: 26px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin: 6px 0 10px; }
.tl-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3ac87a, #ffd23a); }
.tl-bar span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 3px #000; }
.tl-tabs { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.tl-tabs button { padding: 7px 0; min-width: 0; font-weight: 900; }
.tl-tabs button.sel { background: linear-gradient(135deg, #ff7a3a, #e0302a); color: #fff; }
.tl-tabs button:disabled { opacity: .35; }
.tl-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tl-ev { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 9px; border-radius: 12px; text-align: left; min-width: 0; }
.tl-ev span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-ev .st { color: #ffd23a; letter-spacing: 1px; }
.tl-ev.won { background: rgba(95,255,168,.12); }
.tl-ev.next { outline: 2px solid #ffd23a; }
.tl-ev.final { background: rgba(255,210,58,.14); }
.tl-ev:disabled { opacity: .4; }
.tl-big { font-size: 26px; font-weight: 900; color: #ffd23a; letter-spacing: 2px; }
@media (max-width: 640px) { .tl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tl-tabs { gap: 3px; } .tl-tabs button { font-size: 12px; padding: 6px 0; } }
