:root {
  --bg: #0b0d1a;
  --panel: rgba(14, 16, 32, 0.78);
  --panel-solid: #12152a;
  --panel-2: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef0ff;
  --muted: #9aa0c3;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --gold: #ffcf3c;
  --silver: #d6dbe6;
  --bronze: #e08e4f;
  --good: #3ee89a;
  --bad: #ff5a6e;
  --grad: linear-gradient(135deg, #7c5cff 0%, #00d4ff 100%);
  --hot: linear-gradient(135deg, #ff5a3c 0%, #ffb800 100%);
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Outfit', 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
#stage { position: fixed; inset: 0; z-index: 0; touch-action: none; }
#stage canvas { display: block; }
.labels-layer { position: absolute; inset: 0; pointer-events: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%); }
#ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
#ui > * { pointer-events: auto; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#topbar { position: absolute; top: 0; left: 0; right: 0; height: 60px; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: linear-gradient(180deg, rgba(8, 9, 20, 0.85), rgba(8, 9, 20, 0)); z-index: 5; }
body.racing #topbar { background: none; height: 0; overflow: visible; }
body.racing #topbar nav, body.racing #topbar .top-right { display: none; }
body.racing #topbar .logo { display: none; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--text); letter-spacing: 0.3px; }
.logo b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.orb { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 32% 30%, #fff 0 8%, transparent 9%), conic-gradient(from 30deg, #7c5cff, #00d4ff, #ff3cac, #ffb800, #7c5cff); box-shadow: 0 0 18px #7c5cff88; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#nav { display: flex; gap: 4px; }
#nav a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; transition: 0.15s; }
#nav a:hover { color: var(--text); background: var(--panel-2); }
#nav a.active { color: var(--text); background: rgba(124, 92, 255, 0.22); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); color: var(--good); font-weight: 600; }
.chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chip .lvl { background: var(--grad); border-radius: 999px; padding: 2px 8px; font-size: 11px; }
.chip .coins { color: var(--gold); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }

/* ---------- generic ---------- */
#screen { position: absolute; top: 60px; left: 0; right: 0; bottom: 0; overflow-y: auto; padding: 10px 24px 40px; }
#screen:empty { pointer-events: none; }
.page { max-width: 1240px; margin: 0 auto; }
.panel { background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h3, .panel h2 { margin: 0 0 12px; font-family: var(--display); font-weight: 700; }
h1, h2, h3 { font-family: var(--display); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.grid { display: grid; gap: 16px; }
.btn { border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 14px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); transition: transform 0.08s, filter 0.15s, background 0.15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary { background: var(--grad); border: 0; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35); }
.btn.hot { background: var(--hot); border: 0; box-shadow: 0 8px 24px rgba(255, 120, 40, 0.35); color: #1a0d00; }
.btn.big { padding: 15px 24px; font-size: 16px; border-radius: 14px; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
input[type=text], input[type=number], select { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input[type=text]:focus, select:focus { border-color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 100%; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.badge.live { background: #ff3c5a; color: #fff; animation: pulse 1.4s infinite; }
.badge.open { background: var(--good); color: #002a14; }
.badge.common { color: #c8cde0; } .badge.rare { color: #5ab4ff; } .badge.epic { color: #c27bff; } .badge.legendary { color: var(--gold); }
@keyframes pulse { 50% { opacity: 0.6; } }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
tr.me td { background: rgba(124, 92, 255, 0.16); }
tr.click { cursor: pointer; } tr.click:hover td { background: rgba(255, 255, 255, 0.04); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13px; color: var(--muted); }
.tabs button.on { background: rgba(124, 92, 255, 0.25); color: var(--text); border-color: rgba(124, 92, 255, 0.6); }

/* marble swatch */
.sw { display: inline-block; width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset -3px -4px 8px rgba(0, 0, 0, 0.45), inset 2px 3px 6px rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4); position: relative; }
.sw.lg { width: 56px; height: 56px; }
.sw.xl { width: 96px; height: 96px; }
.sw::after { content: ''; position: absolute; left: 18%; top: 14%; width: 30%; height: 22%; border-radius: 50%; background: rgba(255, 255, 255, 0.55); filter: blur(1px); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: stretch; margin-top: 8px; }
.hero-main { padding: 30px; display: flex; flex-direction: column; gap: 18px; justify-content: center; background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(0, 212, 255, 0.08)), var(--panel); }
.hero-main h1 { font-size: 52px; line-height: 1.02; margin: 0; letter-spacing: -1px; font-weight: 900; }
.hero-main h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-main p { margin: 0; color: #c9cdf0; font-size: 16px; line-height: 1.5; max-width: 560px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.join-code { display: flex; gap: 8px; }
.join-code input { width: 120px; text-transform: uppercase; letter-spacing: 3px; font-weight: 700; text-align: center; }
.side-col { display: flex; flex-direction: column; gap: 16px; }
.room-list, .event-list { display: flex; flex-direction: column; gap: 8px; }
.room-item, .event-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid transparent; transition: 0.15s; }
.room-item:hover, .event-item:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.07); }
.room-item .meta, .event-item .meta { flex: 1; min-width: 0; }
.room-item .title, .event-item .title { font-weight: 700; }
.countdown-big { font-family: var(--display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.feature-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.feature { padding: 16px; }
.feature .ico { font-size: 26px; }
.feature b { display: block; margin: 6px 0 4px; font-family: var(--display); }
.feature span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.ticker { margin-top: 18px; }
.ticker .item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); font-size: 14px; }

/* ---------- lobby ---------- */
.lobby { display: grid; grid-template-columns: 360px 1fr; gap: 16px; max-width: 1400px; margin: 0 auto; }
.lobby .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.room-head h2 { margin: 0; font-size: 26px; }
.code-box { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.code-box .code { font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: 4px; padding: 4px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); }
.timer-big { font-family: var(--display); font-weight: 900; font-size: 44px; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.player-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.player { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 14px; }
.player .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .tag { font-size: 11px; color: var(--muted); }
.player .ready { color: var(--good); font-size: 12px; font-weight: 700; }
.marble-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; max-height: 46vh; overflow-y: auto; padding: 2px; }
.mcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 10px; border-radius: 14px; background: var(--panel-2); border: 2px solid transparent; cursor: pointer; transition: 0.12s; text-align: center; }
.mcard:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-2px); }
.mcard.sel { border-color: var(--accent); background: rgba(124, 92, 255, 0.18); }
.mcard.taken { opacity: 0.35; cursor: not-allowed; }
.mcard .nm { font-weight: 700; font-size: 13px; line-height: 1.15; }
.mcard .mat { font-size: 11px; color: var(--muted); }
.mcard .tr { font-size: 14px; letter-spacing: 2px; }
.mcard .owner { position: absolute; top: 6px; right: 6px; font-size: 10px; background: var(--accent); padding: 1px 6px; border-radius: 6px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marble-detail { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.ratings { display: grid; grid-template-columns: 70px 1fr 30px; gap: 6px 10px; align-items: center; font-size: 12px; }
.ratings .bar { height: 7px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.ratings .bar i { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.traits { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.trait { font-size: 13px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
.trait b { margin-right: 4px; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.settings-grid label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.track-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.track-pick button { text-align: left; padding: 10px; border-radius: 12px; border: 2px solid transparent; background: var(--panel-2); }
.track-pick button.on { border-color: var(--accent); background: rgba(124, 92, 255, 0.18); }
.track-pick b { display: block; font-size: 13px; }
.track-pick span { font-size: 11px; color: var(--muted); }
.diff { color: var(--gold); letter-spacing: 1px; font-size: 11px; }
.chat { display: flex; flex-direction: column; height: 220px; }
.chat .log { flex: 1; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.chat .log .sys { color: var(--muted); font-style: italic; font-size: 12px; }
.chat .log b { color: var(--accent-2); }
.chat form { display: flex; gap: 6px; margin-top: 8px; }
.chat input { flex: 1; }
.predict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.standings-mini { font-size: 13px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 8px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); pointer-events: none !important; }
.hud-track { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); font-weight: 600; max-width: 200px; }
.hud-track span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hud-event { color: var(--gold); }
#hud-trackname { color: var(--text); font-family: var(--display); font-size: 15px; }
#hud-timer { font-family: var(--display); font-weight: 800; font-size: 30px; font-variant-numeric: tabular-nums; min-width: 120px; text-align: center; }
#hud-record { font-size: 12px; color: var(--muted); }
#standings { position: absolute; top: 14px; left: 14px; width: 250px; max-height: calc(100vh - 290px); overflow-y: auto; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); padding: 6px; font-size: 13px; }
#standings .st { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; transition: background 0.2s; }
#standings .st:hover { background: rgba(255, 255, 255, 0.06); }
#standings .st.me { background: rgba(124, 92, 255, 0.28); }
#standings .st.focus { outline: 1px solid var(--accent-2); }
#standings .st .p { width: 22px; font-weight: 800; font-family: var(--display); text-align: right; color: var(--muted); }
#standings .st.p1 .p { color: var(--gold); } #standings .st.p2 .p { color: var(--silver); } #standings .st.p3 .p { color: var(--bronze); }
#standings .st .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#standings .st .n .cpu { color: var(--muted); font-weight: 500; }
#standings .st .g { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#standings .st.fin .g { color: var(--good); }
#standings .st .ic { font-size: 11px; width: 14px; }
#standings .sep { height: 1px; background: var(--line); margin: 4px 6px; }
#feed { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none !important; }
#feed .f { font-size: 13px; padding: 5px 12px; border-radius: 999px; background: rgba(10, 12, 24, 0.7); border: 1px solid var(--line); animation: feedIn 0.25s ease-out; font-weight: 600; }
#feed .f.gold { border-color: var(--gold); color: var(--gold); }
@keyframes feedIn { from { opacity: 0; transform: translateY(-6px); } }
#progress { position: absolute; left: 280px; right: 280px; bottom: 22px; height: 30px; }
#progress .bar { position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); }
#progress .finish-flag { position: absolute; right: -10px; top: -12px; font-size: 18px; }
#progress .dots { position: absolute; inset: 0; }
#progress .dot { position: absolute; top: 9px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.5); transition: left 0.2s linear; }
#progress .dot.me { width: 18px; height: 18px; top: 6px; margin-left: -9px; border: 2px solid #fff; z-index: 3; box-shadow: 0 0 12px #fff; }
#progress .dot.lead { z-index: 2; box-shadow: 0 0 10px var(--gold); }
#hud-right { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#cams { display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); }
#cams button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; font-size: 17px; }
#cams button:hover { background: rgba(255, 255, 255, 0.08); }
#cams button.on { background: rgba(124, 92, 255, 0.35); }
#cams .sep { width: 1px; background: var(--line); margin: 4px 2px; }
#focus-card { width: 250px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); font-size: 13px; }
#focus-card .hd { display: flex; gap: 10px; align-items: center; }
#focus-card .hd b { font-family: var(--display); font-size: 16px; display: block; }
#focus-card .tr { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
#focus-card .tr span { font-size: 11px; padding: 3px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); }
#focus-card .live { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; color: var(--muted); }
#focus-card .live b { color: var(--text); }
#boost-wrap { position: absolute; right: 30px; bottom: 30px; }
#boost-btn { position: relative; width: 120px; height: 120px; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #ffd86b, #ff6a00 60%, #b23a00); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12), 0 12px 40px rgba(255, 106, 0, 0.55); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #2a0f00; transition: transform 0.08s, filter 0.2s; }
#boost-btn:active { transform: scale(0.94); }
#boost-btn.cool { filter: grayscale(0.85) brightness(0.7); }
#boost-btn.empty { filter: grayscale(1) brightness(0.45); }
#boost-btn .b-label { font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: 1px; }
#boost-btn .b-key { font-size: 10px; font-weight: 800; opacity: 0.7; }
#boost-btn .pips { display: flex; gap: 4px; margin-top: 6px; }
#boost-btn .pips i { width: 10px; height: 10px; border-radius: 50%; background: #2a0f00; opacity: 0.25; }
#boost-btn .pips i.on { opacity: 1; background: #fff; box-shadow: 0 0 6px #fff; }
#boost-btn .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
#boost-btn .ring circle { fill: none; stroke: #fff; stroke-width: 4; stroke-dasharray: 289; stroke-dashoffset: 289; stroke-linecap: round; opacity: 0.8; }
#spectate-banner { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
#react-bar { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 2px; padding: 4px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
#react-bar button { border: 0; background: transparent; font-size: 20px; width: 36px; height: 36px; border-radius: 10px; }
#react-bar button:hover { background: rgba(255, 255, 255, 0.08); transform: scale(1.15); }
#countdown { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); font-family: var(--display); font-weight: 900; font-size: 160px; pointer-events: none !important; text-shadow: 0 10px 50px rgba(0, 0, 0, 0.6); }
#countdown.pop { animation: pop 0.9s ease-out; }
#countdown.go { background: var(--hot); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }
#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.floater { position: absolute; bottom: 60px; font-size: 34px; animation: floatUp 2.4s ease-out forwards; }
.floater small { display: block; font-size: 11px; text-align: center; color: #fff; text-shadow: 0 1px 3px #000; font-family: var(--font); }
@keyframes floatUp { from { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-30px) scale(1.1); } to { transform: translateY(-340px) scale(1); opacity: 0; } }
#replay-bar { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); }
#replay-bar button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; }
#replay-bar button.on { background: rgba(124, 92, 255, 0.35); }
#replay-bar input { width: 260px; }
#rp-time { font-variant-numeric: tabular-nums; width: 56px; font-size: 13px; }
.mlabel { display: flex; align-items: center; gap: 4px; padding: 2px 7px 2px 3px; border-radius: 99px; background: rgba(8, 10, 20, 0.7); color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; transform: translateY(-4px); border: 1px solid rgba(255, 255, 255, 0.15); }
.mlabel .dot { width: 10px; height: 10px; border-radius: 50%; }
.mlabel.me { background: #ffe14d; color: #1a1400; border: 2px solid #fff; font-size: 13px; padding: 3px 9px 3px 4px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); z-index: 1; }
#me-arrow { position: absolute; left: 0; top: 0; font-size: 40px; color: #ffe14d; text-shadow: 0 0 6px #000, 0 0 2px #000; pointer-events: none !important; will-change: transform; }
.mlabel.cpu { opacity: 0.85; }

/* ---------- results ---------- */
#results { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 6, 14, 0.45); padding: 20px; }
.results-card { width: min(1000px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.res-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.res-head h2 { font-size: 30px; margin: 0; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 14px 0 20px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 170px; }
.pod .blk { width: 100%; border-radius: 14px 14px 6px 6px; display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; font-family: var(--display); font-weight: 900; font-size: 32px; }
.pod.p1 .blk { height: 120px; background: linear-gradient(180deg, #ffcf3c, #a37a00); color: #3a2a00; }
.pod.p2 .blk { height: 86px; background: linear-gradient(180deg, #e8ecf5, #8a92a6); color: #22262f; }
.pod.p3 .blk { height: 64px; background: linear-gradient(180deg, #f0a36a, #8a4a1c); color: #2a1200; }
.pod .nm { font-weight: 700; text-align: center; font-size: 14px; }
.pod .tm { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pod .sw { animation: bounceIn 0.6s ease-out backwards; }
.pod.p1 .sw { animation-delay: 0.5s; } .pod.p2 .sw { animation-delay: 0.25s; }
@keyframes bounceIn { from { transform: translateY(-80px); opacity: 0; } 60% { transform: translateY(6px); opacity: 1; } }
.record-banner { text-align: center; padding: 10px; border-radius: 12px; background: var(--hot); color: #1a0d00; font-weight: 800; font-family: var(--display); font-size: 18px; margin-bottom: 12px; }
.gains { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; }
.gains span { padding: 6px 12px; border-radius: 99px; background: var(--panel-2); font-weight: 700; font-size: 13px; }
.res-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 20; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; animation: feedIn 0.2s ease-out; }
#modal { position: fixed; inset: 0; background: rgba(4, 5, 12, 0.6); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 20px; }
.modal-card { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; }

/* ---------- pages ---------- */
.page-title { display: flex; align-items: flex-end; justify-content: space-between; margin: 10px 0 16px; gap: 16px; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: 36px; font-weight: 900; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.mfull { display: flex; flex-direction: column; gap: 10px; }
.mfull .top { display: flex; gap: 14px; align-items: center; }
.mfull .top b { font-family: var(--display); font-size: 18px; display: block; }
.mfull .bio { font-size: 13px; color: #c9cdf0; font-style: italic; }
.mfull .stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.mfull .stats b { color: var(--text); font-size: 14px; }
.track-card .feats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.track-card .feats span { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi b { display: block; font-family: var(--display); font-size: 28px; }
.kpi span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.bar-inline { display: inline-block; height: 6px; border-radius: 99px; background: var(--grad); vertical-align: middle; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

@media (max-width: 1000px) {
  .hero, .lobby { grid-template-columns: 1fr; }
  .feature-strip, .kpis { grid-template-columns: repeat(2, 1fr); }
  #nav a { padding: 6px 8px; font-size: 13px; }
  #progress { left: 14px; right: 150px; bottom: 74px; }
  #standings { width: 190px; font-size: 12px; max-height: 40vh; }
  #focus-card { display: none; }
  #boost-btn { width: 96px; height: 96px; }
  .hero-main h1 { font-size: 38px; }
}
@media (max-width: 640px) {
  #topbar { gap: 8px; padding: 0 8px; }
  #online { display: none; }
  #hud-right { top: 62px; right: 8px; }
  #cams { width: auto; flex-wrap: nowrap; padding: 3px; }
  #cams button { width: 30px; height: 30px; font-size: 14px; }
  #cams #names-btn, #cams .sep { display: none; }
  #standings .g, #standings .ic { display: none; }
  #standings .st { padding: 4px 6px; gap: 6px; }
  #standings .st .sw { width: 16px; height: 16px; }
  #react-bar { bottom: 8px; left: 8px; right: 120px; overflow-x: auto; }
  #react-bar button { width: 30px; height: 30px; font-size: 16px; flex: none; }
  #boost-wrap { right: 12px; bottom: 12px; }
  #progress { left: 8px; right: 120px; bottom: 56px; }
  #feed { top: 104px; width: 70%; }
  #feed .f { font-size: 11px; }
  .logo span:last-child { display: none; }
  #nav { overflow-x: auto; }
  .chip .nm { display: none; }
  #screen { padding: 10px 12px 40px; }
  #hud-top { top: 8px; padding: 6px 10px; gap: 8px; }
  #hud-timer { font-size: 22px; min-width: 80px; }
  #hud-record { display: none; }
  #standings { top: 62px; left: 8px; width: 150px; max-height: 42vh; }
  #cams { flex-wrap: wrap; width: 132px; }
  #countdown { font-size: 110px; }
  .pod { width: 100px; }
}
#hud.hide-all > *:not(#boost-wrap):not(#countdown):not(#hud-right):not(#me-arrow) { display: none !important; }
#hud.hide-all #cams > :not(#hide-hud-btn), #hud.hide-all #focus-card { display: none !important; }

/* iPhone notch / home indicator: keep the HUD inside the safe area */
@supports (padding: env(safe-area-inset-top)) {
  #hud-top { top: calc(14px + env(safe-area-inset-top)); }
  #standings { top: calc(14px + env(safe-area-inset-top)); left: calc(14px + env(safe-area-inset-left)); }
  #hud-right { top: calc(14px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); }
  #boost-wrap { right: calc(30px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); }
  #react-bar { left: calc(14px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom)); }
  @media (max-width: 640px) {
    #hud-top { top: calc(8px + env(safe-area-inset-top)); }
    #standings, #hud-right { top: calc(62px + env(safe-area-inset-top)); }
    #standings { left: calc(8px + env(safe-area-inset-left)); }
    #hud-right { right: calc(8px + env(safe-area-inset-right)); }
    #boost-wrap { right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); }
    #react-bar { bottom: calc(8px + env(safe-area-inset-bottom)); }
    #progress { bottom: calc(56px + env(safe-area-inset-bottom)); }
  }
}

/* touch: finger-sized buttons */
@media (pointer: coarse) {
  #cams button { width: 40px; height: 40px; font-size: 18px; }
  #react-bar button { width: 40px; height: 40px; }
}
@media (pointer: coarse) and (max-width: 640px) {
  #cams { width: 184px; }
}

/* phone held sideways: short screen, so shrink and tuck panels away from each other */
@media (max-height: 500px) and (orientation: landscape) {
  #hud-top { top: calc(6px + env(safe-area-inset-top)); padding: 4px 12px; }
  #hud-timer { font-size: 20px; }
  #hud-record, #focus-card, #feed { display: none; }
  #standings { top: calc(6px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); width: 170px; max-height: calc(100dvh - 90px); font-size: 11px; }
  #hud-right { top: calc(6px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
  #cams { flex-wrap: wrap; width: 184px; }
  #boost-wrap { right: calc(12px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom)); }
  #boost-btn { width: 84px; height: 84px; }
  #progress { left: 190px; right: 120px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  #react-bar { left: 190px; right: 120px; bottom: calc(44px + env(safe-area-inset-bottom)); overflow-x: auto; }
}

body.clean #ui, body.clean #vignette { display: none; }
body.clean .labels-layer { display: block; }

#minimap { position: absolute; left: 14px; bottom: 66px; width: 180px; height: 180px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); }
@media (max-width: 1000px) { #minimap { display: none; } }
