:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #080d0b;
  --panel: rgba(14, 22, 18, .97);
  --panel-soft: rgba(12, 19, 15, .9);
  --line: rgba(210, 233, 218, .14);
  --line-strong: rgba(210, 233, 218, .24);
  --text: #f3f6f2;
  --muted: #b2bdb5;
  --subtle: #84938a;
  --accent: #ffad45;
  --accent-bright: #ffc46f;
  --mint: #72d9b2;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--bg); overflow-x: clip; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; overflow-x: clip; background: var(--bg); }
body::before { content: ""; position: fixed; inset: -30px; z-index: 0; pointer-events: none; background: radial-gradient(ellipse at 15% 10%, rgba(255, 173, 69, .09), transparent 43%), linear-gradient(145deg, rgba(5, 16, 12, .32), rgba(5, 10, 8, .8)); }
button, select, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.topbar { position: relative; z-index: 1; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px max(3vw, calc((100vw - 1620px) / 2)); background: rgba(7, 12, 10, .91); border-bottom: 1px solid var(--line-strong); box-shadow: 0 8px 30px rgba(0, 0, 0, .16); }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; color: var(--text); text-decoration: none; font-size: 19px; line-height: .98; font-style: italic; font-weight: 950; letter-spacing: -.65px; white-space: nowrap; }
.brand-logo { width: 39px; height: 39px; flex: 0 0 39px; object-fit: contain; }
.brand small, .footer-brand small { display: block; margin-top: 5px; color: #a5b6aa; font-size: 8px; font-style: normal; letter-spacing: 2.8px; }
.header-tools { display: flex; align-items: center; gap: 18px; }
.service-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .65px; white-space: nowrap; }
.service-state i, .side-status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #747f79; }
.language-picker select { min-height: 34px; padding: 5px 25px 5px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #111a15; color: var(--text); font-size: 11px; }

.layout { position: relative; z-index: 1; width: min(1620px, calc(100% - 48px)); display: grid; grid-template-areas: "leaderboard player settings"; grid-template-columns: minmax(190px, .72fr) minmax(0, 2.6fr) minmax(310px, 1.15fr); align-items: start; gap: 16px; margin: 28px auto 22px; flex: 0 0 auto; }
.leaderboard-rail { grid-area: leaderboard; display: grid; align-content: start; gap: 12px; min-width: 0; }
.player-column { grid-area: player; min-width: 0; }
.sidebar-column { grid-area: settings; min-width: 0; }
.screen { position: relative; display: grid; place-items: center; min-width: 0; overflow: hidden; aspect-ratio: 16 / 9; background: #020403; border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; box-shadow: 0 22px 70px rgba(0, 0, 0, .46), 0 0 0 1px rgba(255, 173, 69, .035); }
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; border: 0; background: #000; }
.start-panel { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: 28px 20px; text-align: center; background: linear-gradient(90deg, rgba(3, 7, 5, .91), rgba(3, 7, 5, .56) 47%, rgba(3, 7, 5, .79)), radial-gradient(ellipse at 50% 48%, rgba(31, 58, 44, .72), transparent 50%), url('/racing-night.svg') center 55% / cover, #030605; }
.start-panel::before { content: ""; position: absolute; inset: 16px; border: 1px solid rgba(255, 255, 255, .06); border-radius: 9px; pointer-events: none; }
.start-panel::after { content: ""; position: absolute; width: 72%; height: 1px; bottom: 24%; background: linear-gradient(90deg, transparent, rgba(255, 173, 69, .4), transparent); box-shadow: 0 0 38px rgba(255, 173, 69, .2); }
.start-emblem { z-index: 1; margin-bottom: 16px; color: var(--text); font-size: 19px; font-weight: 950; font-style: italic; letter-spacing: 2px; text-shadow: 0 0 26px rgba(255, 173, 69, .2); }
.start-emblem span { margin-left: 3px; color: var(--accent); }
.screen-kicker, .panel-eyebrow { margin: 0 0 8px; color: var(--accent-bright); font-size: 9px; font-weight: 800; letter-spacing: 1.7px; }
.start-panel h1 { z-index: 1; max-width: 680px; margin: 0 0 14px; font-size: clamp(25px, 3.2vw, 38px); line-height: 1.02; letter-spacing: -.8px; }
.start-copy { z-index: 1; max-width: 520px; margin: 0 0 21px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.primary, .player-actions button, .wide { min-height: 39px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255, 255, 255, .045); color: var(--text); font-size: 11px; font-weight: 720; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.primary { z-index: 1; min-width: 185px; border-color: rgba(255, 173, 69, .45); background: var(--accent); color: #20140a; letter-spacing: .55px; }
.primary:not(:disabled):hover { background: var(--accent-bright); transform: translateY(-1px); }
button:not(:disabled):hover { border-color: rgba(255, 196, 111, .6); background-color: rgba(255, 173, 69, .1); }
button:disabled { opacity: .45; cursor: not-allowed; }
.start-panel small { z-index: 1; margin-top: 12px; color: var(--subtle); font-size: 10px; }
.runtime-indicator { position: absolute; z-index: 3; top: 10px; left: 10px; max-width: min(520px, calc(100% - 20px)); padding: 7px 10px; border: 1px solid rgba(255, 196, 111, .35); border-radius: 6px; color: #f4eee4; background: rgba(5, 10, 8, .78); font-size: 10px; line-height: 1.4; pointer-events: none; backdrop-filter: blur(8px); }
#fullscreen-exit { display: none; position: absolute; z-index: 10; top: 12px; right: 12px; width: 42px; height: 42px; padding: 0; border: 1px solid rgba(255, 255, 255, .32); border-radius: 50%; color: #fff; background: rgba(7, 12, 10, .82); font-size: 27px; line-height: 1; cursor: pointer; }
.screen.fullscreen-active { width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; max-width: none; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; background: #000; }
.screen.fullscreen-active #fullscreen-exit { display: block; }
body.pseudo-fullscreen { overflow: hidden; }
body.pseudo-fullscreen::before, body.pseudo-fullscreen > .topbar, body.pseudo-fullscreen > footer, body.pseudo-fullscreen .leaderboard-rail, body.pseudo-fullscreen .sidebar-column, body.pseudo-fullscreen .player-status, body.pseudo-fullscreen .player-actions, body.pseudo-fullscreen .gamepad-hint { display: none !important; }
body.pseudo-fullscreen .layout { position: fixed; z-index: 10000; inset: 0; display: block; width: 100vw; width: 100dvw; height: 100vh; height: 100dvh; margin: 0; }
body.pseudo-fullscreen .player-column, body.pseudo-fullscreen .screen { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; }
.player-status { display: none; }
#runtime-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#runtime-fps { flex: 0 0 auto; color: var(--accent-bright); font-variant-numeric: tabular-nums; }
.player-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.player-actions button { min-height: 35px; color: #d9e1db; font-size: 10px; }
.gamepad-hint { display: flex; align-items: center; gap: 11px; margin: 10px 0 0; padding: 11px 14px; border: 1px solid rgba(255, 190, 94, .34); border-radius: 9px; background: linear-gradient(105deg, rgba(255, 177, 68, .1), rgba(255, 255, 255, .025)); color: var(--muted); font-size: 11px; line-height: 1.5; }
.gamepad-hint strong { color: var(--accent-bright); }
.hint-icon { color: var(--accent); font-size: 20px; }

.sidebar-column { display: grid; gap: 12px; }
.leaderboard-card, .rail-note { min-width: 0; padding: 15px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel); box-shadow: 0 18px 44px rgba(0, 0, 0, .2); }
.leaderboard-heading h2 { margin: 0 0 5px; font-size: 14px; line-height: 1.2; }
.leaderboard-heading p, .rail-note > p:last-child { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.leaderboard-empty { display: grid; justify-items: start; gap: 7px; margin-top: 14px; padding: 13px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .018); }
.leaderboard-empty-mark { color: var(--accent); font-size: 20px; font-weight: 800; }
.leaderboard-empty strong { font-size: 11px; }
.leaderboard-empty p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.leaderboard-footnote { margin: 10px 0 0; color: var(--subtle); font-size: 8px; font-weight: 750; letter-spacing: .7px; }
.rail-note h2 { margin: 0 0 7px; font-size: 14px; line-height: 1.25; }
.rail-note .panel-eyebrow { margin-bottom: 7px; }
.settings-panel { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel); box-shadow: 0 22px 60px rgba(0, 0, 0, .22); }
.tabs { display: grid; grid-template-columns: 1fr 1.2fr .8fr .65fr 1.45fr; gap: 2px; padding: 9px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .025); }
.tabs button { min-width: 0; min-height: 35px; padding: 0 5px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 730; white-space: nowrap; cursor: pointer; }
.tabs button[aria-selected="true"] { border-color: rgba(255, 173, 69, .35); color: var(--accent-bright); background: rgba(255, 173, 69, .09); }
.tab-panel { min-height: 334px; padding: 20px 18px 18px; }
.panel-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 19px; }
.section-mark { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid rgba(255, 173, 69, .31); border-radius: 8px; color: var(--accent); background: rgba(255, 173, 69, .075); font-size: 10px; font-weight: 800; }
.panel-eyebrow { margin: 0 0 4px; font-size: 8px; }
.panel-heading h2 { margin: 0; font-size: 19px; line-height: 1.15; letter-spacing: -.2px; }
.state-card { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .025); }
.state-light { width: 9px; height: 9px; flex: 0 0 9px; margin-top: 4px; border-radius: 50%; background: #747f79; }
.state-light.is-ready { background: var(--mint); box-shadow: 0 0 12px rgba(114, 217, 178, .5); }
.state-light.is-error { background: #ed715a; box-shadow: 0 0 12px rgba(237, 113, 90, .4); }
.state-card strong { font-size: 12px; }
.state-card p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.hint { margin: 13px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.settings-note { display: grid; gap: 5px; padding: 12px; border-left: 2px solid var(--accent); background: rgba(255, 173, 69, .06); }
.settings-note strong { color: var(--accent-bright); font-size: 10px; }
.settings-note span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.key-row { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.key-group { display: flex; align-items: center; gap: 4px; }
kbd { min-width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--text); background: #17211b; font-family: inherit; font-size: 9px; font-weight: 750; }
.key-row + .hint { margin-bottom: 0; }
.empty-state { min-height: 180px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(140deg, rgba(255, 255, 255, .035), transparent); }
.empty-mark { margin-bottom: 10px; color: var(--accent); font-size: 24px; font-weight: 800; }
.empty-state strong { font-size: 12px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.wide { width: 100%; margin-top: 12px; }
.chat-compose { display: flex; gap: 7px; margin-top: 12px; }
.chat-compose input { min-width: 0; flex: 1; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); background: #0b110e; font-size: 10px; }
.chat-compose button { width: 40px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); background: #17211b; }
.ranking-foot { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 8px; font-weight: 750; letter-spacing: .8px; }
.side-status { display: flex; align-items: center; gap: 8px; padding: 9px 3px; color: var(--subtle); font-size: 9px; font-weight: 750; letter-spacing: .7px; }
.side-status-dot { background: #ed715a; }
.build-label { margin-left: auto; }
footer { position: relative; z-index: 1; width: min(1620px, calc(100% - 48px)); display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: auto auto 0; padding: 17px 0; border-top: 1px solid var(--line); color: var(--subtle); font-size: 9px; }
.footer-brand { flex: 0 0 auto; color: var(--text); font-size: 12px; font-style: italic; font-weight: 900; letter-spacing: .8px; }
.footer-brand small { display: inline; margin-left: 6px; color: var(--subtle); font-size: 8px; }

@media (max-width: 1100px) {
  .layout { grid-template-areas: "player settings" "leaderboard leaderboard"; grid-template-columns: minmax(0, 1fr) minmax(290px, .55fr); width: min(1000px, calc(100% - 40px)); gap: 18px; }
  .leaderboard-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-column { grid-template-columns: minmax(0, 1fr); }
  .tab-panel { min-height: 0; }
  footer { width: min(1000px, 94vw); }
}
@media (min-width: 1101px) and (max-width: 1399px) {
  .layout { grid-template-columns: minmax(170px, .68fr) minmax(0, 2.5fr) minmax(290px, 1.12fr); gap: 14px; }
  .tab-panel { padding-right: 14px; padding-left: 14px; }
  .tabs { padding-right: 6px; padding-left: 6px; }
}
@media (max-width: 720px) {
  .topbar { min-height: 62px; flex-wrap: wrap; gap: 8px 14px; padding: 10px 3vw; }
  .brand { font-size: 16px; }
  .brand-logo { width: 33px; height: 33px; flex-basis: 33px; }
  .header-tools { gap: 8px; }
  .service-state { max-width: 112px; font-size: 8px; line-height: 1.3; }
  .layout { grid-template-areas: "player" "settings" "leaderboard"; grid-template-columns: minmax(0, 1fr); width: 100%; margin: 14px auto 24px; gap: 14px; }
  .leaderboard-rail { grid-template-columns: minmax(0, 1fr); padding: 0 3vw; }
  .screen { border-right: 0; border-left: 0; border-radius: 0; }
  .start-panel { padding: 17px; }
  .start-panel h1 { font-size: clamp(22px, 6vw, 34px); }
  .start-copy { max-width: 420px; font-size: 10px; }
  .start-emblem { margin-bottom: 7px; font-size: 14px; }
  .screen-kicker { margin-bottom: 5px; font-size: 8px; }
  .start-panel small { font-size: 9px; }
  .player-status, .player-actions, .gamepad-hint { margin-right: 3vw; margin-left: 3vw; }
  .player-actions button { flex: 1 1 calc(50% - 8px); }
  .settings-panel { border-right: 0; border-left: 0; border-radius: 0; }
  .tabs { padding: 7px 3vw; }
  .tabs button { font-size: 8px; }
  .tab-panel { padding: 17px 4vw; }
  .side-status { margin: 0 4vw; }
  footer { width: 92vw; align-items: flex-start; flex-direction: column; gap: 9px; }
  .about-seo { width: 92vw; grid-template-columns: 1fr; gap: 20px; margin: 4px auto 28px; }
}
@media (max-width: 420px) {
  .service-state { display: none; }
  .screen { aspect-ratio: 4 / 3; }
  .start-panel h1 { max-width: 280px; }
  .tabs { grid-template-columns: 1fr 1.1fr .8fr .6fr 1.25fr; }
  .tabs button { padding: 0 2px; font-size: 7px; }
  .player-actions button { min-height: 33px; padding: 0 8px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
body:has(.screen:fullscreen) > .topbar, body:has(.screen:fullscreen) > footer, body:has(.screen:fullscreen) .leaderboard-rail, body:has(.screen:fullscreen) .sidebar-column, body:has(.screen:fullscreen) .player-status, body:has(.screen:fullscreen) .player-actions, body:has(.screen:fullscreen) .gamepad-hint { display: none !important; }

.ad-slot { position: relative; display: grid; justify-items: center; gap: 8px; min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(8, 14, 11, .72); }
.ad-label { color: var(--subtle); font-size: 8px; font-weight: 750; letter-spacing: 1px; text-transform: uppercase; }
.ad-content { display: flex; width: 100%; min-height: 50px; align-items: center; justify-content: center; overflow: hidden; }
.ad-main-banner { margin-top: 14px; }
.ad-main-banner .ad-content { min-height: 90px; }
.ad-sidebar-slot .ad-content { min-height: 250px; }
.ad-sidebar-slot ins { display: block; width: 300px; min-height: 250px; max-width: 100%; }
