/* osudesu — minimal swiss + JP accent, dark/light tokens */

:root, [data-theme="dark"] {
  --bg: #0a0d0a;
  --bg-2: #0e1310;
  --surface: #11161a;
  --surface-2: #161c1c;
  --hair: rgba(255,255,255,.07);
  --hair-2: rgba(255,255,255,.14);
  --text: #e7ece7;
  --text-2: #b8c2b8;
  --muted: #7a8a7d;
  --dim: #4d574f;
  --accent: #22c55e;
  --accent-dim: rgba(34,197,94,.18);
  --accent-glow: rgba(34,197,94,.35);
  --accent-fg: #03210d;
  --danger: #ef4444;
  --warn: #f59e0b;
  --info: #38bdf8;
  --shadow-1: 0 1px 0 rgba(255,255,255,.04) inset;
}
[data-theme="light"] {
  --bg: #f4f4ee;
  --bg-2: #ecece5;
  --surface: #ffffff;
  --surface-2: #fafaf3;
  --hair: rgba(10,13,10,.08);
  --hair-2: rgba(10,13,10,.18);
  --text: #0a0d0a;
  --text-2: #2d3530;
  --muted: #5d6b60;
  --dim: #9aa69d;
  --accent: #15803d;
  --accent-dim: rgba(21,128,61,.10);
  --accent-glow: rgba(21,128,61,.22);
  --accent-fg: #f5fff7;
  --danger: #b91c1c;
  --warn: #b45309;
  --info: #0369a1;
  --shadow-1: 0 1px 0 rgba(10,13,10,.04) inset;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter Tight', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01","cv11","cv02"; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { font-size: 14px; line-height: 1.5; min-height: 100vh; overflow-x: hidden; }
::selection { background: var(--accent); color: var(--accent-fg); }

/* fonts */
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.jp   { font-family: 'Noto Sans JP', 'Inter Tight', sans-serif; font-weight: 400; }
.cap  { font-family: 'JetBrains Mono', ui-monospace, monospace; text-transform: uppercase;
        letter-spacing: .14em; font-size: 11px; color: var(--muted); font-weight: 500; }
.cap.lg { font-size: 12px; letter-spacing: .18em; }
.tab { font-variant-numeric: tabular-nums; }

/* Hairline rules */
.hr   { height: 1px; background: var(--hair); border: 0; }
.hr-2 { height: 1px; background: var(--hair-2); border: 0; }
.vhr  { width: 1px; background: var(--hair); align-self: stretch; }

/* link reset */
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Shell layout */
.app { min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg);
  background-image:
    linear-gradient(var(--hair) 1px, transparent 1px),
    linear-gradient(90deg, var(--hair) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}
.app::before {
  content:""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(1100px 600px at 80% -10%, var(--accent-dim), transparent 60%);
  opacity: .55;
}
[data-theme="light"] .app::before { opacity: .9; }

/* Top nav */
.nav { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--hair); }
.nav::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
}
.nav-inner { display: grid; grid-template-columns: 220px 1fr auto; align-items: center;
  height: 64px; padding: 0 32px; gap: 24px; max-width: 1600px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; position: relative;
  border: 1.5px solid var(--text); display: grid; place-items: center; }
.brand-mark::after { content:""; position:absolute; inset: 5px;
  border-radius: 50%; border: 1.5px solid var(--accent); }
.brand-mark::before { content:""; position:absolute; width: 5px; height: 5px;
  background: var(--accent); border-radius: 50%; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-name .desu { color: var(--accent); }
.brand-sub { font-size: 10px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; }

.nav-links { display: flex; gap: 4px; justify-self: center;}
.nav-link { padding: 8px 14px; font-size: 13px; color: var(--text-2); font-weight: 500;
  border: 1px solid transparent; display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, background .15s, border-color .15s; cursor: default;
  position: relative;
}
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="true"] { color: var(--text); background: var(--surface);
  border-color: var(--hair); }
.nav-link[aria-current="true"]::after {
  content:""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 1px;
  background: var(--accent);
}
.nav-link .idx { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--dim); }

.nav-right { display: flex; gap: 8px; align-items: center; }
.nav-theme { display: inline-flex; align-items: center; gap: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--hair-2); background: transparent; color: var(--text);
  cursor: default; transition: background .14s, border-color .14s, transform .08s;
  letter-spacing: -.005em;
}
.btn:hover { background: var(--surface); border-color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
  font-weight: 600; }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, white);
  border-color: var(--accent); color: var(--accent-fg);
  box-shadow: 0 0 0 4px var(--accent-dim); }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { border-color: var(--hair-2); background: var(--surface); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }
.btn-corner { position: relative; }
.btn-corner::before, .btn-corner::after {
  content:""; position:absolute; width: 6px; height: 6px;
  border: 1px solid var(--accent);
}
.btn-corner::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.btn-corner::after  { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }
/* jp-mark inside a button relies on flex gap — no extra side margin needed */
.btn .jp-mark { margin-left: 0; }
/* On primary buttons the background IS var(--accent), so jp-mark must use fg color */
.btn-primary .jp-mark { color: var(--accent-fg); opacity: 0.72; }

/* Beatmap status filter buttons */
.bm-filter-btn {
  appearance: none; width: 100%; text-align: left; font-family: inherit; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; border-radius: 1px; cursor: pointer;
  transition: background .14s, border-color .14s, box-shadow .14s, transform .08s;
}
.bm-filter-btn.inactive {
  background: var(--surface); border: 1px solid var(--hair-2); color: var(--text-2);
  box-shadow: 0 1px 3px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.05);
}
.bm-filter-btn.inactive:hover {
  background: var(--bg-2); border-color: var(--hair); color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.07);
}
.bm-filter-btn.active-tab {
  background: var(--surface); border: 1px solid var(--accent); color: var(--text);
  box-shadow: 0 2px 8px var(--accent-dim), inset 0 1px 0 rgba(255,255,255,.07);
}
.bm-filter-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0,0,0,.12) !important; }

/* main */
.main { flex: 1; position: relative; z-index: 1; }
.container { max-width: 1600px; margin: 0 auto; padding: 0 32px; }
.container-narrow { max-width: 1200px; margin: 0 auto; padding: 0 32px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--hair);
  position: relative; }
.card-h { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--hair); }
.card-b { padding: 16px; }
.card-tick { position:absolute; left: -1px; top: -1px; width: 14px; height: 14px;
  border-top: 1px solid var(--accent); border-left: 1px solid var(--accent); }
.card-tick.br { left: auto; top: auto; right: -1px; bottom: -1px;
  border: 0; border-bottom: 1px solid var(--accent); border-right: 1px solid var(--accent); }

/* JP accents */
.jp-mark { font-family: 'Noto Sans JP', sans-serif; color: var(--accent);
  font-weight: 400; font-size: .8em; vertical-align: middle; margin-left: 4px; }
.kicker { display: inline-flex; align-items: center; gap: 10px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase;
  letter-spacing: .2em; color: var(--muted); }
.kicker::before { content:""; width: 24px; height: 1px; background: var(--accent); }
.kicker .jp { color: var(--accent); letter-spacing: .05em; text-transform: none; }

/* Section title */
.section-title { display: grid; grid-template-columns: auto 1fr auto; align-items: end;
  gap: 24px; padding: 48px 0 24px; }
.section-title h2 { margin: 0; font-weight: 700; font-size: 32px; letter-spacing: -.02em;
  line-height: 1; }
.section-title .meta { color: var(--muted); font-size: 12px; }
.section-title .rule { height: 1px; background: var(--hair); margin-bottom: 8px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-lbl { display: flex; align-items: baseline; justify-content: space-between;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-family: 'JetBrains Mono', monospace; font-weight: 500;}
.field-lbl .hint { letter-spacing: 0; text-transform: none; color: var(--dim); font-size: 10px; }
.input { height: 44px; padding: 0 14px; background: var(--surface); color: var(--text);
  border: 1px solid var(--hair-2); font: inherit; font-size: 14px; outline: 0;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: 'JetBrains Mono', monospace;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.18);}
.input.is-ok { border-color: var(--accent); }
textarea.input { padding: 12px 14px; height: auto; min-height: 96px; resize: vertical; line-height: 1.5; }

.checkbox { display:flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2);}
.checkbox input { appearance: none; width: 16px; height: 16px; border: 1px solid var(--hair-2);
  background: var(--surface); display: grid; place-items: center; }
.checkbox input:checked { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked::after { content:""; width: 9px; height: 5px;
  border-left: 1.5px solid var(--accent-fg); border-bottom: 1.5px solid var(--accent-fg);
  transform: rotate(-45deg) translate(1px, -1px); }

/* Badges / chips */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 8px; border: 1px solid var(--hair-2); color: var(--text-2); height: 22px; }
.badge.acc { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.badge.dot::before { content:""; width:6px;height:6px;background:currentColor;border-radius:50%; }

/* Stat */
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 0; }
.stat .num { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  font-family: 'JetBrains Mono', monospace; }
.stat .delta { color: var(--accent); font-size: 11px; font-family: 'JetBrains Mono', monospace; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 12px 14px; border-bottom: 1px solid var(--hair); text-align: left;
  font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  font-family: 'JetBrains Mono', monospace; font-weight: 500; padding-top: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--hair-2); background: var(--bg-2);}
.tbl tr:hover td { background: var(--surface); }
.tbl td.num, .tbl th.num { text-align: right; font-family: 'JetBrains Mono', monospace; }
.tbl td.rank { color: var(--muted); width: 60px; font-family: 'JetBrains Mono', monospace; }
.tbl td.rank.top { color: var(--accent); font-weight: 600; }

/* Avatar */
.avatar { width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--surface-2) 100%);
  display: grid; place-items: center; color: var(--accent-fg); font-weight: 700;
  font-size: 12px; border: 1px solid var(--hair-2); }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; }
.avatar.xl { width: 144px; height: 144px; font-size: 48px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

/* Diff bar */
.diff { display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.diff .star { color: var(--accent); }

/* Toast */
.toast { position: fixed; top: 80px; right: 32px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--accent);
  font-size: 13px; z-index: 60; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.toast .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%;
  box-shadow: 0 0 0 4px var(--accent-dim); }

/* Side rail vertical katakana */
.side-rail { position: fixed; left: 12px; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl; text-orientation: mixed; font-family: 'Noto Sans JP', sans-serif;
  font-size: 10px; color: var(--dim); letter-spacing: .4em; text-transform: uppercase;
  z-index: 1; pointer-events: none; user-select: none; display: flex; gap: 12px; align-items: center;
}
.side-rail::after { content:""; height: 56px; width: 1px; background: var(--hair-2); }

/* footer */
.foot { border-top: 1px solid var(--hair); padding: 32px 0 24px; margin-top: 96px;
  position: relative; z-index: 1; }
.foot-inner { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px;
  align-items: start; }
.foot h4 { margin: 0 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.foot a { display: block; padding: 4px 0; font-size: 13px; color: var(--text-2); }
.foot a:hover { color: var(--accent); }
.foot-bottom { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--hair);
  display: flex; justify-content: space-between; font-size: 11px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace; }

/* Page transitions */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-enter { animation: fadeUp .35s ease both; }

@keyframes glowPulse { 0%,100%{ box-shadow: 0 0 0 0 var(--accent-glow);} 50%{ box-shadow: 0 0 0 8px transparent;} }
.live::before { content:""; display:inline-block;width:8px;height:8px;border-radius:50%;
  background: var(--accent); margin-right: 8px; animation: glowPulse 1.6s infinite; }

/* Difficulty meter */
.bar { width: 100%; height: 4px; background: var(--hair); position: relative; overflow: hidden;}
.bar > i { position: absolute; left:0; top:0; bottom:0; background: var(--accent); display: block;}

/* tile grid for beatmaps */
.tile { background: var(--surface); border: 1px solid var(--hair); position: relative;
  overflow: hidden; transition: border-color .2s, transform .2s; }
.tile:hover { border-color: var(--accent); }
.tile .bg { position: absolute; inset: 0; opacity: .12;
  background-size: cover; background-position: center; }
[data-theme="light"] .tile .bg { opacity: .14; }

/* Code block / log */
.log { background: var(--bg-2); border: 1px solid var(--hair); padding: 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.6;
  color: var(--text-2); }
.log .ok { color: var(--accent); }
.log .warn { color: var(--warn); }
.log .err { color: var(--danger); }
.log .dim { color: var(--dim); }

/* Hero shapes */
.x-grid { position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--hair) 1px, transparent 1px),
    linear-gradient(90deg, var(--hair) 1px, transparent 1px);
  background-size: 56px 56px; opacity: .6; mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

/* Slim scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--hair-2); }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }
*::-webkit-scrollbar-track { background: transparent; }

/* corners decoration */
.deco-corners { position: relative; }
.deco-corners::before, .deco-corners::after,
.deco-corners > .tl, .deco-corners > .tr {
  content:""; position: absolute; width: 10px; height: 10px;
}
.deco-corners::before { top: -1px; left: -1px; border-top: 1px solid var(--accent); border-left:1px solid var(--accent);}
.deco-corners::after  { bottom: -1px; right:-1px; border-bottom:1px solid var(--accent); border-right:1px solid var(--accent);}
.deco-corners > .tl   { top:-1px; right:-1px; border-top:1px solid var(--accent); border-right:1px solid var(--accent);}
.deco-corners > .tr   { bottom:-1px; left:-1px; border-bottom:1px solid var(--accent); border-left:1px solid var(--accent);}

/* News/article */
.article { display: grid; grid-template-columns: 200px 1fr; gap: 32px; padding: 24px 0;
  border-bottom: 1px solid var(--hair); }
.article:last-child { border-bottom: 0; }
.article-meta { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; gap: 8px; }
.article-title { font-size: 22px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.01em;
  font-weight: 600; }
.article-body { color: var(--text-2); font-size: 14px; line-height: 1.6; max-width: 64ch;}
.article-tags { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--hair); }
.tabs button { background: transparent; border: 0; padding: 10px 16px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; cursor: default; position: relative; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { content:""; position: absolute; left: 0; right: 0;
  bottom: -1px; height: 2px; background: var(--accent); }
.tabs button:hover { color: var(--text); }

/* select */
.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; padding: 0 32px 0 12px;
  height: 32px; border: 1px solid var(--hair-2); background: var(--surface); color: var(--text);
  font: inherit; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.select::after { content: "▾"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 10px; pointer-events: none; }

/* progress bar slim */
.pbar { height: 2px; background: var(--hair); overflow: hidden; }
.pbar > i { display:block; height: 100%; background: var(--accent); }

/* mod chip */
.mod { display:inline-flex; align-items:center; justify-content:center;
  height: 22px; min-width: 26px; padding: 0 6px; font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg);} }
.spin { animation: spin 1s linear infinite; }

/* Auth split */
.auth-shell { display: grid; grid-template-columns: 1.1fr 1fr; min-height: calc(100vh - 64px); }
@media (max-width: 960px) { .auth-shell { grid-template-columns: 1fr; } .auth-side{ display:none;} }
.auth-side { background: var(--bg-2); position: relative; padding: 48px;
  border-right: 1px solid var(--hair); display:flex; flex-direction:column; justify-content:space-between; overflow: hidden;}
.auth-side .grid-bg { position: absolute; inset: 0;
  background-image: linear-gradient(var(--hair) 1px, transparent 1px),
                    linear-gradient(90deg, var(--hair) 1px, transparent 1px);
  background-size: 64px 64px; opacity: .8; }
.auth-form { padding: 64px 64px; max-width: 560px; width: 100%; margin: 0 auto; }
@media (max-width: 720px) { .auth-form { padding: 32px;} }

/* Admin grid */
.admin { display: grid; grid-template-columns: 220px 1fr; gap: 0; min-height: calc(100vh - 64px); }
.admin-side { border-right: 1px solid var(--hair); padding: 24px 16px; background: var(--bg-2); }
.admin-side h5 { margin: 16px 0 6px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .16em; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-weight: 500;}
.admin-side a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px;
  font-size: 13px; color: var(--text-2); border: 1px solid transparent; }
.admin-side a[aria-current="true"] { background: var(--surface); border-color: var(--hair);
  color: var(--text);}
.admin-side a:hover { background: var(--surface); color: var(--text); }
.admin-main { padding: 32px; }

/* ── Score-stream card header ────────────────────────────────────────────── */
.ss-card-hdr {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--hair);
}
@media (max-width: 900px) {
  .ss-card-hdr {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }
  .ss-card-hdr > :nth-child(2) { display: none; }  /* hide "STREAM · GLOBAL" */
  .ss-card-hdr > :nth-child(3) { display: none; }  /* hide scores counter */
}
@media (max-width: 600px) {
  .ss-card-hdr > :last-child { flex-wrap: wrap; }
}

/* ── Mobile nav burger (hidden on desktop) ───────────────────────────────── */
.nav-burger { display: none !important; }

/* ── Scroll wrapper for wide tables ─────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap .tbl { min-width: 560px; }

/* ── Score-stream grid (7 cols) ──────────────────────────────────────────── */
.ss-hdr,
.ss-row {
  display: grid;
  grid-template-columns: 86px 1fr 2fr 56px 96px 92px 110px;
  gap: 12px;
}

/* ── ≤ 1024px — tablet: drop mods column ────────────────────────────────── */
@media (max-width: 1024px) {
  .ss-hdr,
  .ss-row { grid-template-columns: 70px 110px 1fr 48px 80px 78px; }
  .ss-hdr > :last-child,
  .ss-row > .ss-mods { display: none; }
}

/* ── ≤ 768px — mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav */
  .nav-inner { grid-template-columns: 1fr auto; padding: 0 16px; gap: 8px; }
  .nav-links { display: none; }
  .nav-links.mob-open {
    display: flex; flex-direction: column;
    position: fixed; top: 64px; left: 0; right: 0;
    max-height: calc(100vh - 64px); overflow-y: auto;
    background: var(--bg); border-top: 1px solid var(--hair);
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    z-index: 48; padding: 8px;
  }
  .nav-links.mob-open .nav-link {
    padding: 14px 16px; border: 0; border-bottom: 1px solid var(--hair); font-size: 15px;
  }
  .nav-links.mob-open .nav-link[aria-current="true"]::after { display: none; }
  .nav-burger { display: inline-flex !important; }
  .nav-right > :not(.nav-burger):not(.nav-theme) { display: none !important; }

  /* Containers */
  .container, .container-narrow { padding: 0 16px; }

  /* Side rail */
  .side-rail { display: none; }

  /* Section title */
  .section-title {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 24px 0 16px !important;
  }
  .section-title .rule { display: none; }

  /* Footer */
  .foot-inner { grid-template-columns: 1fr !important; gap: 24px; }
  .foot-bottom { flex-direction: column; gap: 6px; }
  .foot { margin-top: 48px; }

  /* Article (news) */
  .article { grid-template-columns: 1fr !important; gap: 12px !important; }

  /* Admin: hide sidebar, full-width main */
  .admin { grid-template-columns: 1fr !important; }
  .admin-side { display: none; }
  .admin-main { padding: 16px !important; }

  /* Auth */
  .auth-form { padding: 24px 16px !important; }

  /* Toast */
  .toast { right: 16px; left: 16px; }

  /* Score stream: 2-col reflow */
  .ss-hdr { display: none; }
  .ss-row {
    grid-template-columns: 1fr 1fr !important;
    padding: 10px 12px !important;
    gap: 6px !important;
  }
  .ss-row .ss-time { order: 6; grid-column: 1 / -1; }
  .ss-row .ss-player { order: 1; }
  .ss-row .ss-map { order: 2; grid-column: 1 / -1; }
  .ss-row .ss-rank { order: 3; }
  .ss-row .ss-pp { order: 3; text-align: left !important; }
  .ss-row .ss-acc { order: 4; text-align: left !important; }
  .ss-row .ss-mods { order: 4; }
}

/* ── ≤ 768px — landing / page-specific ──────────────────────────────────── */
@media (max-width: 768px) {
  /* Landing editorial hero (1fr auto → 1 col, hide JP decor) */
  .landing-hero-section { padding: 28px 0 20px !important; }
  .g-hero {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    margin-bottom: 16px !important;
  }
  .g-hero > :last-child { display: none !important; }

  /* Landing stat bar (5 col → 2 col) */
  .g-stat-bar {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .g-stat-bar > :nth-child(5) {
    grid-column: span 2;
    border-right: none !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  /* Landing pillars (3 col → 1 col) */
  .g-pillars { grid-template-columns: 1fr !important; }

  /* Landing data variant (1.4fr+1fr → 1 col) */
  .g-data-top { grid-template-columns: 1fr !important; gap: 24px !important; }

  /* Landing split (1fr+1fr → 1 col) */
  .g-split { grid-template-columns: 1fr !important; min-height: auto !important; }

  /* News (1fr+320px → 1 col, sidebar moves down) */
  .g-news { grid-template-columns: 1fr !important; gap: 24px !important; }

  /* Beatmaps sidebar layout (260px+1fr → 1 col) */
  .g-bm-layout { grid-template-columns: 1fr !important; }
  /* Disable sticky aside on mobile — prevents overlap with results column */
  .g-bm-layout > aside { position: static !important; top: auto !important; }

  /* Featured beatmap (320px+1fr → 1 col) */
  .g-featured-bm { grid-template-columns: 1fr !important; }
  .g-featured-bm > :first-child { min-height: 160px !important; border-right: none !important; border-bottom: 1px solid var(--hair); }

  /* Beatmap row (hide action buttons col) */
  .g-bm-row { grid-template-columns: 72px 1fr !important; }
  .g-bm-row > :last-child { display: none; }

  /* Profile header (auto+1fr+auto → 2col, pp block goes full-width) */
  .g-profile-hdr { grid-template-columns: auto 1fr !important; gap: 16px !important; }
  .g-profile-hdr > :nth-child(3) {
    grid-column: 1 / -1;
    border-left: none !important;
    padding-left: 0 !important;
    text-align: left !important;
    border-top: 1px solid var(--hair);
    padding-top: 16px;
  }

  /* Top score cards (5 col → 2 col) */
  .g-top-score { grid-template-columns: 40px 1fr auto !important; gap: 12px !important; }
  .g-top-score > :nth-child(4),
  .g-top-score > :nth-child(5) { display: none; }

  /* Tournament cards (5 col → 2 row, name+button full-width) */
  .tourn-card {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  .tourn-card > :first-child { grid-column: 1 / -1; }
  .tourn-card > :last-child  { grid-column: 1 / -1; }

  /* Leaderboard filter bar (4-col grid → 2-col) */
  .g-lb-filter {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .g-lb-filter > :nth-child(3) { grid-column: span 2; }
}

/* ── ≤ 480px — small phones ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .nav-inner { height: 56px; }
  .nav-links.mob-open { top: 56px; }
  .main { min-height: calc(100vh - 56px); }
  .g-stat-bar > :nth-child(5) { grid-column: 1; }
  .g-stat-bar { grid-template-columns: 1fr 1fr !important; }
}
