: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: #0c0709;
  --panel: rgba(24, 12, 16, .96);
  --panel-soft: rgba(20, 10, 13, .9);
  --line: rgba(240, 205, 210, .14);
  --line-strong: rgba(240, 205, 210, .26);
  --text: #f6f1f1;
  --muted: #c4b3b6;
  --subtle: #92808a;
  --accent: #ff3b3b;
  --accent-bright: #ff7a5c;
  --gold: #ffc857;
  --ok: #72d9b2;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; background: var(--bg); }
body::before {
  content: ""; position: fixed; inset: -30px; z-index: 0;
  background: radial-gradient(circle at 20% 10%, rgba(255, 59, 59, .20), transparent 55%),
    radial-gradient(circle at 85% 90%, rgba(255, 122, 92, .12), transparent 50%),
    linear-gradient(145deg, rgba(20, 6, 9, .85), rgba(8, 4, 6, .95));
}
header {
  position: relative; z-index: 1; min-height: 72px; display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(4vw, calc((100vw - 1360px) / 2));
  background: rgba(12, 6, 8, .9); border-bottom: 1px solid var(--line-strong); box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
}
.brand {
  display: block; flex: 0 1 220px; width: clamp(132px, 18vw, 220px); height: clamp(52px, 6.4vw, 87px); color: var(--text); text-decoration: none; line-height: 1;
}
.brand img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; filter: drop-shadow(0 3px 12px rgba(255, 59, 59, .22)); }
.header-tools { display: flex; align-items: center; gap: 20px; }
.header-note { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.header-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 12px rgba(114, 217, 178, .5); }
.language-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.language-picker select {
  min-height: 34px; padding: 5px 28px 5px 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: rgba(30, 14, 19, .92); color: var(--text); font: inherit;
}
select:focus-visible, button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout {
  position: relative; z-index: 1; width: min(1360px, 94vw); margin: 32px auto 54px; display: grid;
  grid-template-columns: minmax(0, 1fr) 370px; gap: 22px; align-items: start;
}
.player-column { min-width: 0; }
.screen {
  position: relative; aspect-ratio: 16 / 9; width: 100%; background: #000; border: 1px solid var(--line-strong);
  border-radius: 13px; overflow: hidden; box-shadow: 0 18px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 59, 59, .08);
}
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
#fullscreen-exit {
  position: absolute; top: 10px; right: 10px; z-index: 6; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: rgba(0, 0, 0, .6); color: #fff; font-size: 20px; cursor: pointer; display: none;
}
.screen.is-fullscreen #fullscreen-exit { display: block; }
#loading-indicator {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 4; padding: 8px 16px; border-radius: 999px;
  background: rgba(0, 0, 0, .72); border: 1px solid var(--line-strong); font-size: 13px; color: var(--muted);
}
#start-panel {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 20px;
  background: radial-gradient(circle at 50% 30%, rgba(255, 59, 59, .28), transparent 60%), linear-gradient(160deg, #1b080d, #070304);
}
#start-panel h1 { margin: 6px 0 0; font-size: clamp(22px, 4vw, 40px); font-style: italic; font-weight: 950; letter-spacing: -1px; }
#start-panel h1 span { color: var(--accent); }
#start-panel p { margin: 0 0 8px; color: var(--muted); max-width: 520px; font-size: 14px; }
#start-panel small { color: var(--subtle); font-size: 12px; }
.emblem-logo { width: min(280px, 80vw); height: 110px; object-fit: contain; object-position: center; filter: drop-shadow(0 6px 24px rgba(255, 59, 59, .45)); }
button {
  font: inherit; color: var(--text); background: rgba(40, 20, 26, .9); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 16px; cursor: pointer; transition: background .15s, transform .05s, border-color .15s;
}
button:hover:not(:disabled) { background: rgba(70, 28, 36, .95); border-color: rgba(255, 122, 92, .55); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #ff4a4a, #c91f2c); border-color: #ff8a7a; font-weight: 800; letter-spacing: .02em; }
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ff6060, #dc2634); }
button.wide, .wide { width: 100%; margin-top: 10px; }
.gamepad-hint { margin: 12px 2px; color: var(--muted); font-size: 12.5px; line-height: 1.5; display: flex; gap: 8px; }
.player-status { display: flex; justify-content: space-between; gap: 12px; margin: 4px 2px 10px; color: var(--muted); font-size: 13px; }
#fps { font-variant-numeric: tabular-nums; color: var(--gold); }
.player-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ad-slot { display: none; position: relative; min-width: 0; align-items: center; justify-content: center; flex-direction: column; gap: 6px; }
.ad-slot.ad-requested { display: flex; }
.ad-slot.has-ad { padding: 0; border: 0; border-radius: 0; background: transparent; }
.ad-slot > div { display: flex; width: 100%; min-width: 0; align-items: center; justify-content: center; overflow: hidden; }
.ad-label { color: var(--subtle); font-size: 9px; line-height: 1.2; letter-spacing: .14em; text-transform: uppercase; }
.ad-horizontal { margin-top: 18px; min-height: 50px; }
.ad-sidebar { min-height: 250px; }
.ad-rail { position: absolute; top: 0; z-index: 2; width: 160px; align-items: center; }
.ad-rail-left { left: -180px; }
.ad-rail-right { right: -180px; }
.ad-rail > div { min-height: 300px; }
.ad-native { position: relative; z-index: 1; width: min(1360px, 100% - 8vw); min-height: 180px; margin: 18px auto; }
.ad-native > div { max-width: 970px; min-height: 300px; }
.ad-consent {
  position: fixed; z-index: 20; inset: auto 16px 16px; width: min(850px, calc(100% - 32px)); margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px;
  border: 1px solid var(--line-strong); border-radius: 14px; background: rgba(20, 10, 13, .98);
  box-shadow: 0 16px 60px rgba(0, 0, 0, .72); color: var(--text);
}
.ad-consent[hidden] { display: none; }
.ad-consent-copy { max-width: 520px; }
.ad-consent h2 { margin: 0 0 5px; font-size: 15px; }
.ad-consent p { margin: 0 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ad-consent a { color: var(--accent-bright); font-size: 12px; }
.ad-consent-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ad-consent-actions button { flex: 1 1 180px; min-height: 40px; white-space: nowrap; font-size: 12px; }

.sidebar-column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-panel, .leaderboard {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; padding: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tabs button { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; background: transparent; border-color: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { background: rgba(255, 59, 59, .16); color: var(--text); border-color: rgba(255, 122, 92, .5); }
.tab-panel h2, .leaderboard h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-bright); margin: 14px 0 8px; }
.tab-panel h2:first-child { margin-top: 2px; }
.hint { color: var(--subtle); font-size: 12.5px; line-height: 1.5; margin: 8px 0; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; font-size: 13.5px; }
.setting select, .setting input[type="text"] {
  background: rgba(30, 14, 19, .92); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); padding: 6px 8px; font: inherit;
}
.range-control { display: flex; align-items: center; gap: 8px; }
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
.control-steps { margin: 8px 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: var(--muted); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  background: rgba(255, 255, 255, .06); font: 600 12px ui-monospace, Consolas, monospace; color: var(--text); text-align: center;
}
.keymap { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.online-note { padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: rgba(255, 59, 59, .06); color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.online-note strong { display: block; color: var(--text); margin-bottom: 4px; }
.leaderboard-rail { grid-column: 1 / -1; display: grid; align-content: start; gap: 12px; min-width: 0; margin-top: 4px; }
.leaderboard { min-width: 0; margin: 0; padding: 16px; }
.leaderboard-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.leaderboard-heading h2 { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.leaderboard-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.leaderboard-period { display: flex; flex: 0 0 auto; gap: 4px; }
.leaderboard-period button { padding: 6px 9px; font-size: 11px; }
.leaderboard-period button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent-bright); color: #fff; }
.leaderboard #leaderboard-status { margin: 5px 0 8px; }
.leaderboard-scroll { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.leaderboard table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.leaderboard th, .leaderboard td { text-align: left; padding: 8px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.leaderboard thead { position: sticky; top: 0; color: var(--muted); background: #1c0d12; }
.leaderboard tbody tr:last-child > * { border-bottom: 0; }
.leaderboard tbody th { color: var(--text); font-weight: 650; }
.leaderboard tbody td:first-child { color: var(--muted); }
.leaderboard tbody td:last-child { color: var(--accent-bright); font-weight: 750; }
.leaderboard-footnote { margin: 10px 0 0; font-size: 10px; }
.legal-note {
  position: relative; z-index: 1; width: min(1360px, 100% - 8vw); margin: 0 auto 8px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel-soft); color: var(--muted); font-size: 12.5px; line-height: 1.6;
}
footer { position: relative; z-index: 1; margin-top: auto; border-top: 1px solid var(--line-strong); background: rgba(10, 5, 7, .9); padding: 18px max(4vw, calc((100vw - 1360px) / 2)); }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; color: var(--subtle); font-size: 12px; line-height: 1.6; }
.footer-meta { display: flex; flex-direction: column; gap: 4px; }
footer a { color: var(--muted); }
.legal-links { display: flex; flex-wrap: wrap; gap: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; width: 96vw; }
  .tabs { gap: 3px; }
  .tabs button { padding-inline: 8px; }
  .header-note { display: none; }
  .keymap { grid-template-columns: 1fr; }
}
@media (min-width: 1800px) {
  .layout { width: min(1360px, calc(100vw - 644px)); }
  .layout > .leaderboard-rail { position: absolute; top: 0; right: calc(100% + 14px); width: 250px; margin: 0; }
  .layout > .leaderboard-rail .leaderboard { max-height: 760px; overflow: auto; padding: 14px; }
  .layout > .leaderboard-rail .leaderboard-heading { display: grid; gap: 12px; }
  .layout > .leaderboard-rail .leaderboard-period button { flex: 1; }
  .layout > .leaderboard-rail .leaderboard-scroll { max-height: 410px; }
  .layout > .leaderboard-rail .leaderboard-footnote { line-height: 1.5; }
  .ad-rail-left { left: -430px; }
  .ad-rail { display: flex; }
}
@media (max-width: 740px) {
  header { gap: 12px; min-height: 64px; padding: 11px 5vw; }
  .header-tools { gap: 10px; }
  .language-picker > span { display: none; }
  .language-picker select { max-width: 116px; }
  .layout { grid-template-columns: 1fr; width: 92vw; gap: 14px; margin: 20px auto 34px; }
  .sidebar-column { position: static; }
  .settings-panel { position: static; }
  .tab-panel { min-height: unset; }
  .player-actions { gap: 7px; }
  .player-actions button { min-height: 40px; padding: 8px; font-size: 12px; }
  .leaderboard-heading { flex-direction: column; }
  .leaderboard-period { width: 100%; }
  .leaderboard-period button { flex: 1; }
  footer { padding: 18px 4vw; }
  .footer-bottom { align-items: flex-start; }
  .ad-consent { inset: auto 8px 8px; width: calc(100% - 16px); flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .ad-consent-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .ad-consent-actions button { padding-inline: 8px; white-space: normal; }
  .ad-native { width: calc(100% - 24px); }
}
