/* ============ Themes ============ */
:root,
[data-theme='classic'] {
  --bg: #121318;
  --bg-2: #16181e;
  --panel: #1c1f27;
  --panel-2: #242833;
  --panel-3: #2c3140;
  --line: #2d3240;
  --line-soft: #252a35;
  --text: #eceef3;
  --muted: #8d95a7;
  --accent: #7fc94e;
  --accent-2: #5ea935;
  --accent-ink: #0d1a06;
  --accent-soft: rgba(127, 201, 78, 0.14);
  --cyan: #45b4ff;
  --danger: #f0525f;
  --warn: #f5a524;
  --good: #7fc94e;
  --glow: rgba(127, 201, 78, 0.35);
  --stage: radial-gradient(120% 90% at 50% 20%, #2a2f3c 0%, #1a1d25 55%, #14161c 100%);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --backview: rgba(10, 12, 16, 0.55);
  color-scheme: dark;
}

[data-theme='neon'] {
  --bg: #07070d;
  --bg-2: #0a0a13;
  --panel: #0f0f1b;
  --panel-2: #161628;
  --panel-3: #1e1e36;
  --line: #262648;
  --line-soft: #1c1c35;
  --text: #f2f1ff;
  --muted: #8e8bbd;
  --accent: #ff2fb9;
  --accent-2: #c21bff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(255, 47, 185, 0.15);
  --cyan: #22e4ff;
  --danger: #ff4d6d;
  --warn: #ffcc00;
  --good: #2bff88;
  --glow: rgba(255, 47, 185, 0.45);
  --stage: radial-gradient(110% 80% at 50% 15%, #1f1440 0%, #0d0b1f 55%, #07070d 100%);
  --shadow: 0 10px 40px rgba(120, 0, 255, 0.18);
  --backview: rgba(20, 10, 45, 0.6);
  color-scheme: dark;
}

[data-theme='pastel'] {
  --bg: #f5f1ea;
  --bg-2: #efe9df;
  --panel: #fffdf9;
  --panel-2: #f4efe6;
  --panel-3: #ebe4d8;
  --line: #e2dacb;
  --line-soft: #ece5d9;
  --text: #2a2833;
  --muted: #7c7688;
  --accent: #6c63ff;
  --accent-2: #554bf0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(108, 99, 255, 0.12);
  --cyan: #2f9bf0;
  --danger: #e5484d;
  --warn: #e08a00;
  --good: #2fa86a;
  --glow: rgba(108, 99, 255, 0.3);
  --stage: radial-gradient(120% 90% at 50% 15%, #ffffff 0%, #f2ece2 60%, #e9e1d4 100%);
  --shadow: 0 10px 30px rgba(60, 40, 10, 0.08);
  --backview: rgba(255, 255, 255, 0.6);
  color-scheme: light;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.pad { padding: 8px 2px; }
.strong { font-weight: 700; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.link { color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.icon { flex: none; vertical-align: -0.15em; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px; margin: 0 2px;
  font: 600 12px 'JetBrains Mono', monospace;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 7px;
}

/* ============ Shell ============ */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px;
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 18px; }
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
.brand-name b { color: var(--accent); }
.logo { display: grid; grid-template-columns: repeat(3, 9px); gap: 2px; padding: 4px; background: #0d0e12; border-radius: 8px; box-shadow: 0 4px 14px var(--glow); }
.logo i { width: 9px; height: 9px; border-radius: 2px; background: #f5f5f2; }
.logo i:nth-child(1), .logo i:nth-child(8) { background: #d81b3a; }
.logo i:nth-child(3), .logo i:nth-child(4) { background: #00a651; }
.logo i:nth-child(5) { background: var(--accent); }
.logo i:nth-child(6) { background: #ffd60a; }
.logo i:nth-child(7) { background: #1565e8; }
.logo i:nth-child(9) { background: #ff6d00; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 13px; border-radius: 11px;
  font-weight: 600; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.nav a svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.online-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 0 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: livepulse 2s infinite; display: inline-block; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 13px; background: var(--panel); border: 1px solid var(--line-soft); min-height: 56px; }
.me-chip:hover { border-color: var(--line); }
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; }

.view { min-width: 0; padding: 26px 30px 40px; }
.page { max-width: 1180px; margin: 0 auto; }
.page.center { min-height: 70vh; display: grid; place-items: center; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 34px; font-weight: 800; }
.page-head p { margin: 6px 0 0; }

.offline-banner {
  position: fixed; top: 0; left: 50%; transform: translate(-50%, -110%);
  background: var(--warn); color: #1a1200; font-weight: 700; font-size: 13px;
  padding: 8px 16px; border-radius: 0 0 12px 12px; z-index: 100; transition: transform 0.25s;
}
body.offline .offline-banner { transform: translate(-50%, 0); }

/* ============ Primitives ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; align-items: center; gap: 7px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent-2) 60%, #000), 0 8px 24px var(--glow);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary kbd { background: rgba(0, 0, 0, 0.15); border-color: rgba(0, 0, 0, 0.18); color: inherit; height: 20px; min-width: 20px; font-size: 11px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.big { padding: 14px 18px; font-size: 16px; }
.btn.icon-btn { padding: 9px; }
.btn.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--accent-soft), 0 8px 24px var(--glow); } }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-soft);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badges { display: flex; gap: 6px; }

.avatar {
  --s: 40px;
  width: var(--s); height: var(--s); flex: none;
  display: inline-grid; place-items: center;
  border-radius: 30%;
  font-weight: 800; font-size: calc(var(--s) * 0.38); color: #fff;
  background: linear-gradient(135deg, hsl(var(--a, 200) 70% 55%), hsl(calc(var(--a, 200) + 50) 70% 42%));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.bot-av { background: var(--panel-3); font-size: calc(var(--s) * 0.6); text-shadow: none; }

.seg { display: inline-flex; padding: 4px; gap: 3px; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 12px; flex-wrap: wrap; }
.seg-btn { border: 0; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }

input:not([type]), input[type='text'], .chat-form input, .copy-row input, .modal input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  background: var(--bg-2); border: 1px solid var(--line); outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }

.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 34px 16px; grid-column: 1 / -1; }
.empty h3 { margin: 16px 0 6px; font-size: 20px; }
.empty .btn { margin-top: 14px; }
.empty-cube, .search-cube { display: inline-grid; grid-template-columns: repeat(3, 18px); gap: 4px; padding: 8px; background: #0d0e12; border-radius: 12px; }
.empty-cube i, .search-cube i { width: 18px; height: 18px; border-radius: 4px; background: var(--panel-3); }
.empty-cube i:nth-child(odd) { background: var(--accent-soft); }

/* ============ Toasts & modals ============ */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--cyan);
  padding: 11px 15px; border-radius: 11px; box-shadow: var(--shadow); font-weight: 550; max-width: 340px;
  transform: translateY(12px); opacity: 0; transition: 0.25s;
}
.toast.show { transform: none; opacity: 1; }
.toast.good { border-left-color: var(--good); }
.toast.error { border-left-color: var(--danger); }

.modal-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5, 6, 10, 0.6); backdrop-filter: blur(6px); z-index: 150; opacity: 0; transition: opacity 0.2s; padding: 16px; }
.modal-wrap.show { opacity: 1; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 26px; width: min(440px, 100%); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); transform: translateY(10px) scale(0.98); transition: transform 0.2s; }
.modal-wrap.show .modal { transform: none; }
.modal h2 { margin-bottom: 6px; }
.modal .stack { margin-top: 16px; gap: 12px; }

.search { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.search h2 { margin-top: 8px; }
.search p { margin: 0; display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; }
.search-cube i { animation: tile 1.8s infinite; }
.search-cube i:nth-child(1) { animation-delay: 0s; } .search-cube i:nth-child(2) { animation-delay: 0.1s; } .search-cube i:nth-child(3) { animation-delay: 0.2s; }
.search-cube i:nth-child(6) { animation-delay: 0.3s; } .search-cube i:nth-child(9) { animation-delay: 0.4s; } .search-cube i:nth-child(8) { animation-delay: 0.5s; }
.search-cube i:nth-child(7) { animation-delay: 0.6s; } .search-cube i:nth-child(4) { animation-delay: 0.7s; } .search-cube i:nth-child(5) { animation-delay: 0.8s; }
@keyframes tile {
  0%, 100% { background: var(--panel-3); }
  15% { background: #d81b3a; } 30% { background: #ffd60a; } 45% { background: #00a651; } 60% { background: #1565e8; } 75% { background: var(--accent); }
}
.search-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.search-meta .mono { color: var(--text); font-size: 15px; }

/* ============ Confetti ============ */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -12px; left: var(--x); width: 9px; height: 13px; border-radius: 2px; animation: fall var(--d) ease-in var(--delay) forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(var(--r)); opacity: 0.2; } }

/* ============ Home ============ */
.home { max-width: 1240px; margin: 0 auto; }
.hero { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 20px; align-items: center; min-height: 540px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; padding: 6px 13px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.eyebrow b { color: var(--text); }
.hero h1 { font-size: clamp(38px, 5vw, 62px); font-weight: 800; margin: 18px 0 14px; letter-spacing: -0.045em; }
.grad { background: linear-gradient(95deg, #ff6d00, #ffd60a 30%, var(--accent) 55%, var(--cyan) 80%, #b46bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 17px; color: var(--muted); max-width: 520px; margin: 0 0 26px; line-height: 1.7; }
.lead kbd { height: 22px; min-width: 22px; font-size: 11px; }
.play-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 600px; }
.play-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; text-align: left;
  padding: 16px; border-radius: 16px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-soft);
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.play-card:hover { transform: translateY(-2px); border-color: var(--line); background: var(--panel-2); }
.pc-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--panel-3); color: var(--accent); flex: none; }
.pc-text { display: flex; flex-direction: column; min-width: 0; }
.pc-text b { font-size: 17px; }
.pc-text small { color: var(--muted); font-size: 13px; }
.play-card.primary { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 16px; padding: 20px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: var(--accent-ink); box-shadow: 0 6px 0 color-mix(in srgb, var(--accent-2) 55%, #000), 0 14px 40px var(--glow); }
.play-card.primary:hover { filter: brightness(1.05); }
.play-card.primary .pc-icon { background: rgba(0, 0, 0, 0.14); color: inherit; width: 54px; height: 54px; }
.play-card.primary b { font-size: 22px; }
.play-card.primary small { color: inherit; opacity: 0.8; }
.hero-stage { position: relative; height: 520px; }
.hero-cube { position: absolute; inset: 0; }
.hero-glow { position: absolute; inset: 12% 10%; border-radius: 50%; background: radial-gradient(circle, var(--glow), transparent 65%); filter: blur(30px); }

.home-grid { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 16px; margin-top: 10px; }
.live-list { display: flex; flex-direction: column; gap: 8px; }
.live-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border-radius: 11px; background: var(--panel-2); }
.live-row:hover { background: var(--panel-3); }
.lr-names { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-names i { color: var(--muted); font-style: normal; font-weight: 500; }
.lr-meta { font-size: 12px; color: var(--muted); }
.lr-bars { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lr-bars i { height: 4px; border-radius: 4px; background: var(--accent); display: block; min-width: 3px; }
.me-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel-2); border-radius: 11px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat b { font-size: 20px; }

.keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.key-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 8px; font-weight: 550; }
.key-row kbd { justify-self: start; }
.key-row .arrow { color: var(--accent); font-weight: 800; font-size: 17px; }
.key-mods { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.keys-card.compact .key-row { font-size: 13px; }

/* ============ Race ============ */
.race { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; max-width: 1400px; margin: 0 auto; height: calc(100vh - 66px); min-height: 600px; }
.race-board { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.race-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding-bottom: 4px; }
.race-side .card { padding: 14px; }

.pbar {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(90px, 200px) auto; align-items: center; gap: 12px;
  padding: 9px 10px 9px 9px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line-soft);
}
.pbar.winner { border-color: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.pinfo { min-width: 0; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.prating { color: var(--muted); font-weight: 500; }
.pdev { color: var(--muted); display: inline-flex; }
.pstatus { font-size: 12px; color: var(--muted); min-height: 18px; }
.pstatus.good { color: var(--good); font-weight: 650; }
.pstatus.warn { color: var(--warn); font-weight: 650; }
.pprogress { position: relative; height: 22px; border-radius: 8px; background: var(--panel-2); overflow: hidden; }
.pprogress i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); opacity: 0.85; transition: width 0.25s; }
.pprogress span { position: relative; font-size: 11px; font-weight: 650; padding: 0 9px; line-height: 22px; white-space: nowrap; }
.ptimer {
  font-size: 26px; font-weight: 700; min-width: 128px; text-align: right;
  padding: 4px 14px; border-radius: 10px; background: var(--panel-2); color: var(--muted);
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}
.pbar.running .ptimer { background: var(--text); color: var(--bg); box-shadow: 0 0 22px var(--glow); }
.pbar.me.running .ptimer { background: var(--accent); color: var(--accent-ink); }

.stage-wrap { position: relative; flex: 1; min-height: 340px; border-radius: 20px; background: var(--stage); border: 1px solid var(--line-soft); overflow: hidden; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow); }
.stage { position: absolute; inset: 0; }
.cube-canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; z-index: 1; }
.backview { position: absolute; z-index: 0; border-radius: 16px; background: var(--backview); border: 1px dashed var(--line); }
.backview span { position: absolute; top: 7px; left: 10px; font-size: 10px; font-weight: 800; letter-spacing: 0.14em; color: var(--muted); }
.stage-hint { position: absolute; right: 14px; bottom: 10px; font-size: 12px; color: var(--muted); z-index: 2; pointer-events: none; opacity: 0.8; }

.opp-mini { position: absolute; top: 12px; right: 12px; width: clamp(110px, 22%, 172px); aspect-ratio: 0.88; z-index: 3; border-radius: 16px; background: var(--backview); border: 1px solid var(--line-soft); backdrop-filter: blur(4px); }
.mini-cube { position: absolute; inset: 0 0 26px; }
.mini-label { position: absolute; left: 0; right: 0; bottom: 7px; text-align: center; font-size: 12px; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }

.overlay { position: absolute; inset: 0; z-index: 5; display: none; place-items: center; pointer-events: none; }
.overlay.show { display: grid; }
.overlay.show:not(.soft):not(.go) { background: color-mix(in srgb, var(--bg) 35%, transparent); backdrop-filter: blur(1.5px); }
.overlay.result { pointer-events: auto; background: color-mix(in srgb, var(--bg) 55%, transparent) !important; backdrop-filter: blur(5px) !important; }
.overlay.soft { place-items: start center; padding-top: 18px; pointer-events: auto; }

.countdown { text-align: center; }
.count-num { font-size: 120px; font-weight: 700; line-height: 1; color: var(--text); text-shadow: 0 6px 30px rgba(0, 0, 0, 0.35); }
.count-num.warn { color: var(--danger); }
.countdown.shake { animation: shake 0.35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.count-label { color: var(--muted); font-weight: 600; margin-top: 6px; }
.ready-row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.ready-chip { padding: 5px 13px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--muted); }
.ready-chip.on { color: var(--good); border-color: var(--good); }
.go-text { font-size: 150px; font-weight: 800; color: var(--accent); text-shadow: 0 0 60px var(--glow); animation: goPop 0.65s ease-out forwards; letter-spacing: -0.04em; }
@keyframes goPop { 0% { transform: scale(0.6); opacity: 0; } 25% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.solved-pill { padding: 10px 18px; border-radius: 999px; background: var(--panel); border: 1px solid var(--good); color: var(--text); font-weight: 650; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); display: flex; gap: 8px; align-items: center; }
.solved-pill b { color: var(--good); font-size: 18px; }

.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 26px 30px; text-align: center; min-width: min(420px, 92%); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); animation: rise 0.35s cubic-bezier(0.2, 1.3, 0.4, 1); }
@keyframes rise { from { transform: translateY(20px) scale(0.95); opacity: 0; } }
.result-title { font-size: 40px; font-weight: 800; letter-spacing: -0.04em; }
.overlay.win .result-title { color: var(--good); }
.overlay.loss .result-title { color: var(--danger); }
.result-reason { color: var(--muted); margin-top: 4px; }
.result-vs { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 20px 0 6px; }
.rv { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px; border-radius: 14px; min-width: 130px; background: var(--panel-2); border: 1px solid transparent; }
.rv.winner { border-color: var(--good); }
.rv b { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv .mono { font-size: 20px; font-weight: 700; }
.rv-sep { color: var(--muted); font-weight: 700; }
.result-rating { margin-top: 14px; font-size: 16px; display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; background: var(--panel-2); border-radius: 12px; }
.result-rating .delta { font-weight: 800; }
.result-rating.up .delta { color: var(--good); }
.result-rating.down .delta { color: var(--danger); }
.result-links { margin-top: 14px; display: flex; justify-content: center; gap: 8px; }

.scramble-card .scramble { font-size: 15px; line-height: 1.7; word-spacing: 4px; font-weight: 500; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .btn { width: 100%; }
.tabs-card { display: flex; flex-direction: column; min-height: 240px; }
.tabs { display: flex; gap: 4px; margin: -4px -4px 10px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 10px; font-weight: 650; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; position: relative; }
.tab.on { background: var(--panel-2); color: var(--text); }
.dot-new { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.tab-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.move-stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.move-stats b { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.move-list { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; max-height: 190px; overflow-y: auto; font-size: 13px; }
.mv { padding: 3px 8px; border-radius: 7px; background: var(--panel-2); font-weight: 600; }
.mv.last { background: var(--accent); color: var(--accent-ink); }
.chat-log { flex: 1; min-height: 120px; max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 14px; padding-right: 4px; }
.chat-log.short { max-height: 160px; min-height: 80px; }
.chat-msg b { color: var(--cyan); }
.chat-msg.mine b { color: var(--accent); }
.chat-msg.spec b { color: var(--muted); }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { padding: 9px 11px; }
.emotes { display: flex; gap: 6px; margin-top: 10px; }
.emote { flex: 1; border: 1px solid var(--line-soft); background: var(--panel-2); border-radius: 10px; padding: 6px 0; cursor: pointer; font-size: 17px; font-weight: 800; transition: transform 0.1s; }
.emote:hover:not(:disabled) { transform: translateY(-2px) scale(1.06); }
.emote:disabled { opacity: 0.35; cursor: default; }
.emote-float { position: absolute; left: 54px; top: -6px; font-size: 30px; font-weight: 800; z-index: 9; animation: floatUp 1.8s ease-out forwards; pointer-events: none; }
@keyframes floatUp { 0% { transform: translateY(8px) scale(0.6); opacity: 0; } 15% { transform: translateY(-6px) scale(1.15); opacity: 1; } 100% { transform: translateY(-46px) scale(1); opacity: 0; } }

/* Thumb pads (touch) */
.thumbpads { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; padding: 10px; pointer-events: none; }
.pad { position: relative; height: 150px; border-radius: 22px; background: color-mix(in srgb, var(--panel) 70%, transparent); border: 1px solid var(--line); backdrop-filter: blur(6px); pointer-events: auto; touch-action: none; user-select: none; transition: background 0.1s; }
.pad.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.pad.flash, .pad-btn.flash { animation: flash 0.18s; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--accent-soft), inset 0 0 30px var(--glow); } }
.pad-hint { position: absolute; font-size: 12px; font-weight: 800; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.pad-hint.top { top: 8px; left: 50%; transform: translateX(-50%); }
.pad-hint.bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.pad-hint.left { left: 10px; top: 50%; transform: translateY(-50%); }
.pad-hint.right { right: 10px; top: 50%; transform: translateY(-50%); }
.pad-hint.center { left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 11px; opacity: 0.7; }
.pad-mid { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; pointer-events: auto; }
.stage-wrap.with-pads .stage { bottom: 170px; }
.stage-wrap.with-pads { min-height: 520px; }
.overlay-ready { pointer-events: auto; margin-top: 18px; padding: 12px 28px; font-size: 16px; }
.pad-btn { width: 52px; height: 52px; border-radius: 15px; border: 1px solid var(--line); background: var(--panel); font-weight: 800; font-family: 'JetBrains Mono', monospace; touch-action: none; }

/* ============ Practice ============ */
.practice .race-board { gap: 12px; }
.scramble-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; flex-wrap: wrap; }
.scramble-bar .scramble { font-size: 18px; font-weight: 600; word-spacing: 5px; }
.big-timer { text-align: center; font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.big-timer.warn { color: var(--danger); }
.big-timer.done { color: var(--good); }
.practice-hint { text-align: center; font-size: 13px; min-height: 18px; }
.pb-line { margin-top: 10px; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 9px 12px; border-radius: 11px; background: var(--accent-soft); }
.pb-line b { color: var(--accent); }
.times-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.time-row { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.time-row:nth-child(odd) { background: var(--panel-2); }
.time-row.best b { color: var(--good); }

/* ============ Bots ============ */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.bot-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line-soft); transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.bot-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 40px var(--glow); }
.bot-emoji { font-size: 54px; line-height: 1.1; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3)); }
.bot-name { font-weight: 800; font-size: 18px; }
.bot-rating { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--accent); }
.bot-blurb { font-size: 13px; min-height: 40px; }
.bot-time { font-size: 13px; padding: 5px 12px; border-radius: 999px; background: var(--panel-2); }

/* ============ Room ============ */
.room-card { width: min(520px, 100%); text-align: center; padding: 34px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.room-card .row { justify-content: center; }
.room-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.copy-row { display: flex; gap: 8px; width: 100%; margin-top: 6px; }
.copy-row input { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.room-code { color: var(--muted); }
.room-code b { color: var(--text); font-size: 20px; letter-spacing: 0.15em; margin-left: 6px; }
.waiting { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 8px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ============ Watch / spectate / replay ============ */
.watch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.watch-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line-soft); transition: border-color 0.15s, transform 0.15s; }
.watch-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.watch-card .btn { align-self: flex-start; }
.wc-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.wc-player { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; gap: 2px 10px; align-items: center; }
.wc-player .avatar { grid-row: span 2; }
.wc-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-bar { grid-column: 2 / -1; height: 5px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.wc-bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }

.watch-section { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 20px; }
.live-pill { color: var(--danger); font-weight: 700; animation: livepill 1.6s infinite; }
@keyframes livepill { 50% { opacity: 0.55; } }
.video-hub { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--line-soft); box-shadow: var(--shadow); display: grid; place-items: center; }
.video-frame iframe, .video-lite, .video-lite img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-lite { padding: 0; cursor: pointer; background: #000; }
.video-lite img { object-fit: cover; opacity: 0.85; }
.play-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); color: #fff; padding-left: 4px; }
.video-lite:hover .play-btn { background: var(--danger); }
.video-meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 4px 0; }
.video-meta b { font-size: 16px; }
.video-list { display: flex; flex-direction: column; gap: 8px; max-height: min(64vh, 560px); overflow-y: auto; padding-right: 4px; }
.video-item { display: grid; grid-template-columns: 128px 1fr; gap: 10px; align-items: start; text-align: left; padding: 6px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.video-item:hover { background: var(--panel); }
.video-item.on { background: var(--panel); border-color: var(--accent); }
.vi-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.vi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vi-badge { position: absolute; right: 5px; bottom: 5px; padding: 1px 6px; border-radius: 5px; font-size: 11px; font-weight: 700; background: rgba(0, 0, 0, 0.8); color: #fff; }
.vi-badge.live { background: var(--danger); left: 5px; right: auto; top: 5px; bottom: auto; }
.vi-badge.new { background: var(--accent); color: var(--accent-ink); left: 5px; right: auto; top: 5px; bottom: auto; }
.vi-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.vi-text b { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vi-text small { font-size: 12px; }
.races-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; grid-column: 1 / -1; }
@media (max-width: 980px) {
  .video-hub { grid-template-columns: 1fr; }
  .video-list { max-height: none; }
}

.spectate, .replay { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.spec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spec-status { margin-left: auto; font-weight: 700; color: var(--accent); }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.spec-grid.single { grid-template-columns: minmax(0, 760px); justify-content: center; }
.spec-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.spec-col .stage-wrap { height: min(56vh, 560px); flex: none; }
.spec-col .pbar { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 8px; }
.spec-col .pbar .pprogress { grid-column: 1 / -1; grid-row: 2; height: 6px; }
.spec-col .pbar .pprogress span { display: none; }
.spec-col .ptimer { min-width: 110px; }
.spec-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.replay-title { font-size: 20px; }
.replay-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; position: sticky; bottom: 12px; z-index: 5; }
.replay-bar input[type='range'] { flex: 1; accent-color: var(--accent); }
.replay-clock { font-size: 14px; min-width: 130px; text-align: center; }
.replay .pbar { grid-template-columns: auto minmax(0, 1fr) auto; }
.replay-moves { max-height: 96px; }
.replay-moves .mv { opacity: 0.45; }
.replay-moves .mv.done { opacity: 1; }

/* ============ Leaderboard / profile ============ */
.table-card { margin-top: 14px; padding: 6px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 10px 12px; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line-soft); white-space: nowrap; }
.table tbody tr:hover { background: var(--panel-2); }
.table.compact td { padding: 8px 10px; font-size: 14px; }
.player-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; }
.player-link:hover { color: var(--accent); }
.rank { display: inline-block; width: 28px; text-align: center; color: var(--muted); font-weight: 700; }
.medal { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: 13px; color: #1b1300; }
.medal.m1 { background: linear-gradient(135deg, #ffe17a, #e6a800); }
.medal.m2 { background: linear-gradient(135deg, #eef1f5, #a9b2bf); }
.medal.m3 { background: linear-gradient(135deg, #f3b98a, #b8692c); }
.w { color: var(--good); font-weight: 650; }
.l { color: var(--danger); font-weight: 650; }

.profile-head { display: flex; align-items: center; gap: 20px; padding: 24px; }
.profile-head h1 { font-size: 32px; display: flex; align-items: center; gap: 8px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0; }
.rating-card { display: flex; flex-direction: column; gap: 4px; }
.rc-label { font-size: 13px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.rc-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.rc-value.small-val { font-size: 24px; }
.rc-sub { font-size: 13px; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.game-rows { display: flex; flex-direction: column; gap: 6px; }
.game-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); }
.game-row:hover { background: var(--panel-3); }
.gr-main { display: flex; flex-direction: column; min-width: 0; }
.gr-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-times { font-size: 13px; }
.gr-delta { font-weight: 800; font-size: 14px; min-width: 36px; text-align: right; }
.gr-delta.up { color: var(--good); }
.gr-delta.down { color: var(--danger); }
.result-dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.result-dot.win { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.result-dot.loss { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.result-dot.draw { background: var(--panel-3); color: var(--muted); }

/* ============ Settings ============ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border-radius: 14px; background: var(--panel-2); border: 2px solid transparent; cursor: pointer; text-align: left; }
.theme-card.on { border-color: var(--accent); }
.theme-card small { font-size: 12px; }
.theme-swatch { display: grid; grid-template-columns: repeat(3, 14px); gap: 3px; padding: 5px; border-radius: 9px; margin-bottom: 6px; }
.theme-swatch i { width: 14px; height: 14px; border-radius: 4px; }
.theme-swatch.classic { background: #0d0e12; }
.theme-swatch.classic i:nth-child(1) { background: #f5f5f2; } .theme-swatch.classic i:nth-child(2) { background: #ffd60a; } .theme-swatch.classic i:nth-child(3) { background: #00a651; }
.theme-swatch.classic i:nth-child(4) { background: #1565e8; } .theme-swatch.classic i:nth-child(5) { background: #d81b3a; } .theme-swatch.classic i:nth-child(6) { background: #ff6d00; }
.theme-swatch.neon { background: #06060c; box-shadow: 0 0 14px rgba(255, 47, 185, 0.4); }
.theme-swatch.neon i { box-shadow: 0 0 8px currentColor; }
.theme-swatch.neon i:nth-child(1) { background: #eef0ff; color: #eef0ff; } .theme-swatch.neon i:nth-child(2) { background: #fff23a; color: #fff23a; } .theme-swatch.neon i:nth-child(3) { background: #2bff88; color: #2bff88; }
.theme-swatch.neon i:nth-child(4) { background: #2ab8ff; color: #2ab8ff; } .theme-swatch.neon i:nth-child(5) { background: #ff2d78; color: #ff2d78; } .theme-swatch.neon i:nth-child(6) { background: #ff9b2b; color: #ff9b2b; }
.theme-swatch.pastel { background: #34323f; }
.theme-swatch.pastel i:nth-child(1) { background: #fff; } .theme-swatch.pastel i:nth-child(2) { background: #ffe27a; } .theme-swatch.pastel i:nth-child(3) { background: #7ad9a5; }
.theme-swatch.pastel i:nth-child(4) { background: #7fb0f2; } .theme-swatch.pastel i:nth-child(5) { background: #f2899b; } .theme-swatch.pastel i:nth-child(6) { background: #ffb27a; }
.preview-cube { position: relative; height: 260px; margin-top: 12px; border-radius: 16px; background: var(--stage); border: 1px solid var(--line-soft); overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.field > span { font-weight: 650; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); cursor: pointer; }
.toggle-row span { display: flex; flex-direction: column; gap: 2px; }
.toggle-row small { font-size: 12.5px; }
.toggle-row input { display: none; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--panel-3); flex: none; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); transition: transform 0.2s; }
.toggle-row input:checked + .switch { background: var(--accent); }
.toggle-row input:checked + .switch::after { transform: translateX(18px); }

/* ============ Accounts & fair play ============ */
.account-card { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.account-card.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-soft)); }
.account-card.ok { border-color: color-mix(in srgb, var(--good) 40%, var(--line-soft)); }
.ac-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; font-weight: 800; background: var(--panel-2); flex: none; }
.account-card.ok .ac-icon { color: var(--good); }
.ac-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 220px; font-size: 14px; }
.ac-text b:first-child { font-size: 16px; }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-color: transparent; }
.result-note { margin-top: 12px; font-size: 13px; color: var(--warn); font-weight: 600; }
.solved-pill.flagged { border-color: var(--warn); max-width: 92%; text-align: center; }
.solved-pill.flagged b { color: var(--warn); }
.chat-tools { display: flex; justify-content: flex-end; margin: -4px 0 6px; }

/* ============ Learn (guide) ============ */
.guide-prompt {
  display: inline-flex; align-items: center; gap: 8px; margin: -10px 0 22px;
  padding: 9px 15px; border-radius: 12px; font-size: 14px;
  background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.12s;
}
.guide-prompt:hover { transform: translateX(3px); }
.guide-prompt span { color: var(--accent); font-weight: 800; }

.learn { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.learn-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.learn-side { display: flex; flex-direction: column; gap: 14px; }
.learn-stage { flex: none; height: min(48vh, 460px); min-height: 300px; }

.guide-card { padding: 18px 20px; border-color: color-mix(in srgb, var(--accent) 30%, var(--line-soft)); }
.guide-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.guide-lesson { font-size: 13px; color: var(--muted); }
.guide-lesson b { color: var(--text); }
.guide-dots { display: flex; gap: 5px; }
.guide-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--panel-3); }
.guide-dots i.done { background: var(--accent); }
.guide-dots i.now { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.guide-text { font-size: 19px; line-height: 1.6; font-weight: 500; min-height: 60px; }
.guide-text kbd { height: 28px; min-width: 30px; font-size: 13px; vertical-align: 2px; }
.guide-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.gchip { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-soft); font-weight: 700; font-family: 'JetBrains Mono', monospace; opacity: 0.55; }
.gchip kbd { height: 22px; min-width: 22px; font-size: 11px; }
.gchip.now { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gchip.done { opacity: 1; background: var(--accent-soft); }
.guide-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; min-height: 34px; flex-wrap: wrap; }
.guide-feedback { font-size: 14px; flex: 1; min-width: 180px; }
.guide-feedback .good { color: var(--good); font-weight: 800; font-size: 16px; }
.guide-feedback .warn { color: var(--warn); font-weight: 650; }
.guide-feedback kbd { height: 22px; min-width: 22px; font-size: 11px; }
.guide-done { text-align: center; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.guide-done-title { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.row.wrap { flex-wrap: wrap; justify-content: center; }

.lesson-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lesson-list li { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 11px; cursor: pointer; font-weight: 600; color: var(--muted); }
.lesson-list li:hover { background: var(--panel-2); color: var(--text); }
.lesson-list li.now { background: var(--accent-soft); color: var(--text); }
.ll-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--panel-3); flex: none; }
.lesson-list li.now .ll-mark { background: var(--accent); color: var(--accent-ink); }
.lesson-list li.done .ll-mark { background: color-mix(in srgb, var(--good) 25%, transparent); color: var(--good); }
.tip-card p { margin: 8px 0 0; line-height: 1.6; }

/* On-screen keyboard (left half of a real one) */
.vkbd { --u: clamp(40px, 5.2vw, 58px); display: flex; flex-direction: column; gap: 6px; align-self: center; padding: 12px; border-radius: 18px; background: var(--bg-2); border: 1px solid var(--line-soft); }
.vk-row { display: flex; gap: 6px; }
.vk {
  width: calc(var(--u) * var(--w) + 6px * (var(--w) - 1)); height: var(--u);
  border-radius: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px;
  background: var(--panel); border: 1px solid var(--line); border-bottom-width: 4px;
  transition: transform 0.06s, background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.vk b { font: 700 14px 'JetBrains Mono', monospace; }
.vk small { font-size: 10px; color: var(--muted); font-weight: 650; line-height: 1; }
.vk.dim { opacity: 0.25; }
.vk.live { background: var(--panel-2); }
.vk.want { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 22px var(--glow); animation: wantPulse 1.1s infinite; }
.vk.want small { color: var(--accent); }
@keyframes wantPulse { 50% { box-shadow: 0 0 0 6px var(--accent-soft), 0 0 26px var(--glow); } }
.vk.down { transform: translateY(3px); border-bottom-width: 1px; background: var(--accent); color: var(--accent-ink); }
.vk.down small { color: inherit; }

.cheat { margin-top: 34px; }
.cheat h2 { font-size: 26px; margin-bottom: 14px; }
.cheat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.cheat-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; font-size: 14px; }
.cheat-list kbd { height: 20px; min-width: 20px; font-size: 11px; }
.notation { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 10px; }
.notation b { display: inline-block; min-width: 26px; font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.notation span:last-child { grid-column: 1 / -1; }

/* ============ Tournaments ============ */
.badge.t-phase.live { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: transparent; }
.badge.t-phase.live .live-dot { background: var(--danger); width: 7px; height: 7px; }
.badge.t-phase.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-color: transparent; }
.badges.wrap { flex-wrap: wrap; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }

.t-list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.t-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.t-card {
  display: flex; flex-direction: column; gap: 9px; padding: 16px; border-radius: 16px; min-width: 0;
  background: var(--panel); border: 1px solid var(--line-soft); box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.t-card:hover { transform: translateY(-2px); border-color: var(--line); }
.t-card.running { border-color: color-mix(in srgb, var(--danger) 45%, var(--line-soft)); }
.t-card.cancelled { opacity: 0.6; }
.t-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.t-card-top .muted { display: inline-flex; align-items: center; gap: 4px; }
.t-card h3 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.t-when { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.t-when b { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.t-prize { display: flex; gap: 6px; font-size: 13.5px; color: var(--text); }
.t-prize .icon { flex: none; margin-top: 2px; color: var(--accent); }
.t-prize span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.t-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 9px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.t-card-foot > span { display: inline-flex; align-items: center; gap: 5px; }
.t-go, .t-champ { color: var(--accent); font-weight: 700; }
.how-card { margin-top: 8px; }
.how-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); line-height: 1.55; }
.how-steps b { color: var(--text); }

.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.t-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px;
  background: radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 55%), var(--panel);
}
.t-hero-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.t-hero h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.t-hero .t-when { font-size: 15px; }
.t-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.t-main, .t-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.t-action { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-color: color-mix(in srgb, var(--accent) 35%, var(--line-soft)); }
.t-act-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--panel-2); flex: none; }
.t-act-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 220px; font-size: 14px; line-height: 1.5; }
.t-act-text > b { font-size: 17px; }
.t-act-text b[data-countdown] { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.t-act-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.t-note { color: var(--warn); font-weight: 600; }
.t-prizes .pre { font-size: 15px; line-height: 1.6; }
.t-lucky-note { margin-top: 10px; }
.t-desc { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.t-rules { margin: 0; padding-left: 18px; display: grid; gap: 7px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.t-stream { width: 100%; }
.t-admin { border-style: dashed; }
.t-admin-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* Bracket: one column per round; later rounds spread out so each match sits between its feeders. */
.bracket-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; overscroll-behavior-x: contain; }
.bracket { display: flex; gap: 22px; min-width: max-content; }
.b-round { display: flex; flex-direction: column; width: 212px; }
.b-round-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.b-matches { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; flex: 1; }
.b-match {
  display: block; width: 100%; padding: 0; text-align: left; font: inherit; color: inherit;
  border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-soft); overflow: hidden;
}
button.b-match { cursor: pointer; transition: border-color 0.15s; }
button.b-match:hover { border-color: var(--line); }
.b-match.live, .b-match.break { border-color: color-mix(in srgb, var(--danger) 55%, var(--line-soft)); }
.b-match.ready { border-color: color-mix(in srgb, var(--warn) 50%, var(--line-soft)); }
.b-p { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 10px; font-size: 14px; }
.b-p + .b-p { border-top: 1px solid var(--line-soft); }
.b-seed { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.b-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.b-name i { color: var(--muted); font-weight: 500; }
.b-score { font-weight: 800; min-width: 14px; text-align: right; color: var(--muted); }
.b-p.win .b-name { color: var(--text); font-weight: 800; }
.b-p.win .b-score { color: var(--accent); }
.b-p.lose .b-name { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.b-p.me { box-shadow: inset 3px 0 0 var(--accent); }
.b-p.joined .b-score { color: var(--good); }
.b-foot { display: flex; justify-content: space-between; gap: 6px; padding: 5px 10px; font-size: 11.5px; background: var(--panel-2); color: var(--muted); }
.b-status { display: inline-flex; align-items: center; gap: 5px; }
.b-status.live { color: var(--danger); font-weight: 700; }
.b-status .live-dot { background: var(--danger); width: 6px; height: 6px; }
.b-status b { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.b-bronze { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); max-width: 212px; }

.t-players { display: flex; flex-direction: column; }
.t-player { display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--line-soft); }
.t-player:first-child { border-top: 0; }
.t-player.me { background: var(--accent-soft); border-radius: 10px; }
.t-player.out { opacity: 0.55; }
.t-num { font-size: 12px; text-align: center; }
.t-pname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-pname:hover { color: var(--accent); }
.t-tick { color: var(--good); font-weight: 800; }

.podium-card { padding-top: 22px; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 150px; min-width: 0; text-align: center; }
.pod b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-block { width: 100%; margin-top: 4px; border-radius: 12px 12px 4px 4px; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #1a1406; }
.pod.p1 .pod-block { height: 96px; background: linear-gradient(180deg, #ffd60a, #e0a800); }
.pod.p2 .pod-block { height: 70px; background: linear-gradient(180deg, #e3e6ec, #aab1bd); }
.pod.p3 .pod-block { height: 52px; background: linear-gradient(180deg, #f0a46a, #c26a2c); }
.lucky { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); font-size: 14px; }
.standings { margin-top: 14px; }
.standings summary { cursor: pointer; color: var(--accent); font-weight: 650; font-size: 14px; }
.st-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px; border-top: 1px solid var(--line-soft); font-size: 14px; margin-top: 6px; }

.modal.wide { width: min(640px, 100%); }
.modal { max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal textarea, .modal select { width: 100%; padding: 10px 12px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); outline: none; resize: vertical; font: inherit; color: inherit; }
.modal textarea:focus, .modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal textarea.mono { font-family: 'JetBrains Mono', monospace; font-size: 13px; margin-top: 12px; }
.t-form .field { margin-bottom: 0; }
.t-form .field > span { font-size: 13.5px; }
.t-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.45; cursor: pointer; }
.modal .check input { width: 18px; height: 18px; padding: 0; margin-top: 1px; flex: none; accent-color: var(--accent); }
.t-match-admin { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.t-modal-btns { margin-top: 16px; flex-wrap: wrap; }

.series-card { display: flex; flex-direction: column; gap: 4px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line-soft)); }
.series-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-score { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; }
.series-score span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-score span:last-child { text-align: right; }
.series-score b { font-size: 24px; color: var(--accent); }
.series-line { margin-top: 12px; font-size: 14px; color: var(--muted); }
.series-line b { color: var(--text); font-size: 16px; }

.t-banner {
  display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(100deg, color-mix(in srgb, #ffd60a 14%, var(--panel)), var(--panel) 60%);
  border: 1px solid color-mix(in srgb, #ffd60a 35%, var(--line-soft)); box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.t-banner:hover { transform: translateY(-1px); }
.t-banner.live { border-color: color-mix(in srgb, var(--danger) 50%, var(--line-soft)); }
.t-banner[hidden] { display: none; }
.tb-cup { font-size: 30px; flex: none; }
.tb-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.tb-text > b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-text .muted { font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-text .muted b { color: var(--text); font-family: 'JetBrains Mono', monospace; }
.tb-prize { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-prize .icon { color: var(--accent); vertical-align: -2px; }

.alert-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(640px, calc(100vw - 24px)); pointer-events: none; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; pointer-events: auto;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  animation: alertIn 0.3s ease-out;
}
.alert.checkin { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); }
.alert-icon { font-size: 22px; flex: none; }
.alert-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; }
.alert-text [data-to] { font-family: 'JetBrains Mono', monospace; }
.alert-btns { display: flex; gap: 6px; flex: none; }
@keyframes alertIn { from { transform: translateY(-12px); opacity: 0; } }

@media (max-width: 1080px) {
  .t-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .t-hero { flex-direction: column; }
  .t-form-grid { gap: 10px; }
  .t-player { grid-template-columns: 22px auto minmax(0, 1fr) auto auto; gap: 8px; }
  .t-player > .mono.small { display: none; }
  .pod { width: 31%; }
  .b-round { width: 180px; }
  .alert { flex-wrap: wrap; }
  .alert-text { flex-basis: calc(100% - 40px); }
  .alert-btns { margin-left: auto; }
  .t-banner { flex-wrap: wrap; }
  .t-banner .btn { margin-left: auto; }
}

/* ============ Accounts: sign up / log in ============ */
.auth-card { width: min(440px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.auth-card > p { margin: 0; }
.auth-head { display: flex; align-items: center; gap: 14px; }
.auth-head h1, .auth-head h2 { margin: 0; }
.auth-perks { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 8px; border-radius: 12px; background: var(--panel-2); font-size: 14px; }
.auth-perks li { display: flex; align-items: center; gap: 9px; }
.auth-perks .icon { color: var(--accent); flex: none; }
.auth-form { gap: 12px; }
.auth-form .field { margin-bottom: 0; }
.auth-form .field > span { font-size: 13.5px; }
.auth-form input { width: 100%; padding: 11px 13px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); outline: none; }
.auth-switch { text-align: center; }
.wrap-row { flex-wrap: wrap; }
.auth-cta { display: flex; gap: 6px; padding: 0 4px; }
.auth-cta[hidden] { display: none; }
.auth-cta .btn { flex: 1; }
.account-prompt { margin-top: -14px; }
.account-prompt[hidden] { display: none; }
[data-admin-only][hidden] { display: none !important; }

/* ============ Admin ============ */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px; }
.admin-stat b { font-size: 26px; }
.admin-stat.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--line-soft)); }
.admin-stat.warn b { color: var(--warn); }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-wide { grid-column: 1 / -1; }
.admin-sub { margin: 16px 0 6px; }
.admin-list { display: flex; flex-direction: column; margin-top: 6px; }
.admin-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 6px; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line-soft); color: inherit; font: inherit; cursor: pointer; border-radius: 8px;
}
.admin-row:first-child { border-top: 0; }
.admin-row:hover { background: var(--panel-2); }
.admin-main { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.admin-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin .card input[data-search] { width: 100%; padding: 10px 12px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); outline: none; }
.table-wrap { overflow-x: auto; }
.admin-games { max-height: 240px; overflow-y: auto; margin: 4px 0; border: 1px solid var(--line-soft); border-radius: 12px; padding: 4px; }
.admin-reset { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.admin-reset .copy-row { display: flex; gap: 6px; }
.admin-reset input { flex: 1; min-width: 0; }

@media (max-width: 1240px) and (min-width: 821px) {
  .auth-cta { display: none; } /* icon-only sidebar: guests use the home page and profile buttons */
}
@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  /* The phone tab bar is full; organizers reach Admin from their profile. */
  .nav [data-admin-only] { display: none !important; }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stat b { font-size: 22px; }
  .auth-card { padding: 20px; }
}

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .home-grid { grid-template-columns: 1fr 1fr; }
  .home-grid .keys-card { grid-column: 1 / -1; }
  .profile-stats { grid-template-columns: 1fr 1fr; }
}

/* Medium screens: icon-only sidebar so the cube gets the room. */
@media (max-width: 1240px) and (min-width: 821px) {
  .app { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 4px 0 16px; }
  .brand-name, .nav a span, .online-pill, .me-text { display: none; }
  .nav a { padding: 12px; justify-content: center; }
  .me-chip { padding: 8px; min-height: 0; justify-content: center; }
  .race { grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; }
  .view { padding: 20px 22px 32px; }
}

@media (max-width: 980px) {
  .race { grid-template-columns: 1fr; height: auto; }
  .race-board .stage-wrap { flex: none; height: min(62vh, 560px); }
  .race-board .stage-wrap.with-pads { height: min(76vh, 700px); }
  .race-side { overflow: visible; }
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-stage { height: 340px; order: -1; margin-bottom: -10px; }
  .hero h1 { margin-top: 12px; }
  .profile-grid, .settings-grid, .spec-bottom { grid-template-columns: 1fr; }
  .learn { grid-template-columns: 1fr; }
  .cheat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto;
    flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line-soft);
    background: color-mix(in srgb, var(--bg-2) 92%, transparent); backdrop-filter: blur(10px);
  }
  .brand, .sidebar-foot { display: none; }
  body.in-race .sidebar { display: none; }
  body.in-race .view { padding-bottom: 16px; }
  body.in-race .race-board .stage-wrap { height: min(58vh, 520px); }
  body.in-race .race-board .stage-wrap.with-pads { height: min(70vh, 640px); }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .nav a { flex-direction: column; gap: 2px; padding: 7px 2px; font-size: 10px; flex: 1; min-width: 0; }
  .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a span[data-short] { font-size: 0; }
  .nav a span[data-short]::after { content: attr(data-short); font-size: 10px; }
  .cheat-grid { grid-template-columns: 1fr; }
  .guide-text { font-size: 17px; }
  .learn-stage { height: 46vh; }
  .nav a svg { width: 22px; height: 22px; }
  .view { padding: 14px 12px 92px; }
  .page-head h1 { font-size: 26px; }
  .home-grid { grid-template-columns: 1fr; }
  .play-card { padding: 12px; gap: 8px; }
  .play-card .pc-icon { width: 38px; height: 38px; }
  .pc-text b { font-size: 15px; }
  .pc-text small { font-size: 12px; }
  .lead { font-size: 15px; }
  .pbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 7px; }
  .pbar .pprogress { grid-column: 1 / -1; grid-row: 2; height: 6px; }
  .pbar .pprogress span { display: none; }
  .ptimer { font-size: 20px; min-width: 96px; padding: 3px 10px; }
  .opp-mini { width: 112px; top: 8px; right: 8px; }
  .stage-hint { display: none; }
  .spec-grid { grid-template-columns: 1fr; }
  .spec-col .stage-wrap { height: 42vh; }
  .big-timer { font-size: 48px; }
  .count-num { font-size: 88px; }
  .go-text { font-size: 100px; }
  .result-card { padding: 20px 16px; }
  .result-title { font-size: 30px; }
  .rv { min-width: 0; padding: 10px; }
  .theme-grid { grid-template-columns: 1fr 1fr 1fr; }
  .profile-head { padding: 16px; }
  .game-row { grid-template-columns: auto 1fr auto; }
  .gr-times { display: none; }
  .replay-bar { flex-wrap: wrap; }
  #toasts { left: 12px; right: 12px; bottom: 84px; align-items: center; }
}
