/* SAGA GAMES — interface styles. No framework; tokens first, then components. */

:root {
  --bg: #07080b;
  --bg-elev: #0c0e13;
  --surface: #111319;
  --surface-2: #171a22;
  --surface-3: #1e222d;
  --line: rgba(255, 255, 255, .065);
  --line-2: rgba(255, 255, 255, .11);
  --text: #f2f4f8;
  --text-2: #b9bfcc;
  --muted: #7e8598;
  --accent: #6b7bff;
  --accent-2: #9a6bff;
  --accent-ink: #fff;
  --accent-soft: rgba(107, 123, 255, .14);
  --accent-line: rgba(107, 123, 255, .45);
  --good: #36d399;
  --warn: #ffc24b;
  --hot: #ff6b3d;
  --love: #ff4d7d;
  --danger: #ff5a6a;
  --scrim: rgba(4, 5, 8, .72);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --radius: 14px;
  --radius-s: 10px;
  --top-h: 64px;
  --gutter: 24px;
  --maxw: 1480px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: .16s;
  --t: .24s;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Inter", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f6f9;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --surface-3: #e4e7ef;
  --line: rgba(10, 14, 30, .08);
  --line-2: rgba(10, 14, 30, .14);
  --text: #10131b;
  --text-2: #3b4152;
  --muted: #6b7285;
  --accent: #4f5ff0;
  --accent-2: #7b4ff0;
  --accent-soft: rgba(79, 95, 240, .1);
  --accent-line: rgba(79, 95, 240, .4);
  --scrim: rgba(10, 12, 20, .62);
  --shadow: 0 10px 30px -14px rgba(20, 24, 40, .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: var(--radius-s); font-weight: 600; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); font-size: .92em; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid transparent;
  font-size: 14px; font-weight: 650; white-space: nowrap; line-height: 1;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), color var(--t-fast);
}
.btn .icon { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-soft { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-soft:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-2); }
.btn-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-2); }
.icon-btn.is-on, .icon-btn[aria-pressed="true"] { color: var(--love); }
.icon-btn[aria-pressed="true"] .icon { fill: currentColor; }
.icon-btn-strong { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.icon-btn-strong:hover { background: var(--accent); color: #fff; }

/* Tooltip */
[data-tip] { position: relative; }
@media (hover: hover) {
  [data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%);
    background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); font-size: 12px; font-weight: 600;
    padding: 5px 8px; border-radius: 7px; white-space: nowrap; pointer-events: none; z-index: 60; box-shadow: var(--shadow);
  }
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 40; height: var(--top-h);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-space { height: var(--top-h); flex: none; }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; height: 100%; padding: 0 var(--gutter); display: flex; align-items: center; gap: 20px; }
.logo { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.logo-mark { width: 30px; height: 30px; color: var(--accent); }
.logo-word { display: inline-flex; gap: 5px; font-size: 16px; letter-spacing: .14em; line-height: 1; }
.logo-word b { font-weight: 850; }
.logo-word span { font-weight: 500; color: var(--text-2); }
.mainnav { display: flex; gap: 2px; }
.mainnav a { padding: 8px 11px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); transition: color var(--t-fast), background var(--t-fast); }
.mainnav a:hover { color: var(--text); background: var(--surface); }
.mainnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.search { position: relative; flex: 1 1 320px; max-width: 440px; margin-left: auto; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 13px; color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input {
  width: 100%; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 40px 0 40px; font-size: 14px; outline: none; transition: border-color var(--t-fast), background var(--t-fast);
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--accent-line); background: var(--surface-2); }
.search kbd { position: absolute; right: 10px; font: 600 11px var(--mono); color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 6px; pointer-events: none; }
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
.search-pop {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 50; background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); max-height: 70vh; overflow: auto;
}
.sr-item { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 10px; }
.sr-item img { width: 64px; height: 40px; object-fit: cover; border-radius: 7px; background: var(--surface-3); }
.sr-item b { display: block; font-size: 14px; font-weight: 650; }
.sr-item small { color: var(--muted); font-size: 12px; }
.sr-item:hover, .sr-item.is-sel { background: var(--surface-3); }
.sr-all { display: flex; align-items: center; gap: 8px; padding: 10px; font-size: 13px; color: var(--accent); font-weight: 600; }
.sr-empty { padding: 14px; color: var(--muted); font-size: 14px; }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.streak-chip { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 750; font-size: 14px; }
.streak-chip .icon { width: 18px; height: 18px; }
.streak-chip.is-on { color: var(--hot); background: color-mix(in srgb, var(--hot) 10%, var(--surface)); border-color: color-mix(in srgb, var(--hot) 30%, transparent); }
.streak-chip.is-on .icon { fill: color-mix(in srgb, var(--hot) 35%, transparent); }
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; padding: 2px 10px 2px 2px; border-radius: 999px; border: 1px solid transparent; }
.avatar-btn:hover { background: var(--surface); border-color: var(--line); }
.avatar-name { font-weight: 650; font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Level ring */
.lvl { position: relative; display: inline-grid; place-items: center; flex: none; }
.lvl svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.lvl circle { fill: none; stroke-width: 3; }
.lvl-track { stroke: var(--surface-3); }
.lvl-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .6s var(--ease); }
.lvl b { font-weight: 800; position: relative; }
.lvl-sm { width: 36px; height: 36px; } .lvl-sm b { font-size: 13px; }
.lvl-md { width: 52px; height: 52px; } .lvl-md b { font-size: 17px; }
.lvl-lg { width: 96px; height: 96px; } .lvl-lg b { font-size: 32px; }
.lvl-lg circle { stroke-width: 2.4; }

/* ---------- Main ---------- */
main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 22px var(--gutter) 56px; outline: none; }
.block, .rail-section { margin-top: 36px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 750; }
.section-head h2 .icon { color: var(--accent); width: 20px; height: 20px; }
.section-sub { color: var(--muted); font-size: 13px; }
.section-more { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 650; color: var(--muted); padding: 6px 8px; border-radius: 8px; }
.section-more:hover { color: var(--text); background: var(--surface); }
.section-more .icon { width: 16px; height: 16px; }
.muted-line { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted-line a { color: var(--accent); font-weight: 600; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); }
.eyebrow .icon { width: 15px; height: 15px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 18px 16px; }
.grid-dense { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.card { position: relative; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t); min-width: 0; }
.card-link { display: block; border-radius: inherit; }
.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s var(--ease); }
.card-body { padding: 10px 12px 12px; }
.card-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.card-meta { display: flex; align-items: center; gap: 10px; margin-top: 3px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.card-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-pop, .card-lb { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.card-pop .icon { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.card-lb .icon { width: 14px; height: 14px; color: var(--warn); }
.card-lb { margin-left: auto; }
.card-play {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 8px 24px -6px rgba(60, 70, 200, .7);
  opacity: 0; transform: scale(.8); transition: opacity var(--t-fast), transform var(--t) var(--ease);
}
.card-play .icon { width: 22px; height: 22px; fill: currentColor; stroke: none; margin-left: 3px; }
.card-flags { position: absolute; left: 8px; top: 8px; display: flex; gap: 5px; }
.flag { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--scrim); color: #fff; backdrop-filter: blur(6px); }
.flag .icon { width: 12px; height: 12px; }
.flag-new { background: var(--accent); }
.flag-hot { color: #fff; background: color-mix(in srgb, var(--hot) 88%, #000); }
.flag-hot .icon { fill: rgba(255, 255, 255, .35); }
.card-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0, 0, 0, .4); }
.card-progress span { display: block; height: 100%; background: var(--accent); }
.card-fav {
  position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--scrim); color: #fff; opacity: 0; transform: scale(.9); transition: opacity var(--t-fast), transform var(--t-fast), color var(--t-fast);
  backdrop-filter: blur(6px);
}
.card-fav .icon { width: 18px; height: 18px; }
.card-fav[aria-pressed="true"] { opacity: 1; transform: none; color: var(--love); }
.card-fav[aria-pressed="true"] .icon { fill: currentColor; }
.card-fav:hover { transform: scale(1.08); }
.card:focus-within .card-fav, .card:hover .card-fav { opacity: 1; transform: none; }
@media (hover: hover) {
  .card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); }
  .card:hover .card-media img { transform: scale(1.045); }
  .card:hover .card-play { opacity: 1; transform: none; }
}
@media (hover: none) { .card-fav { opacity: 1; transform: none; } }
.card-link:focus-visible { outline-offset: 3px; }

/* Row card (sidebar) */
.card-row { display: flex; background: transparent; border-color: transparent; }
.card-row .card-link { display: flex; gap: 12px; align-items: center; width: 100%; padding: 6px; border-radius: 12px; }
.card-row .card-media { width: 112px; flex: none; border-radius: 9px; }
.card-row .card-body { padding: 0; min-width: 0; }
.card-row .card-play { width: 34px; height: 34px; margin: -17px 0 0 -17px; }
.card-row .card-play .icon { width: 15px; height: 15px; }
.card-row .card-fav, .card-row .card-flags { display: none; }
.card-row:hover { transform: none !important; box-shadow: none !important; }
.card-row .card-link:hover { background: var(--surface); }

/* Rails */
.rail { position: relative; }
.rail-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: 224px; gap: 16px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding: 0 var(--gutter); padding: 4px var(--gutter) 10px; margin: -4px calc(var(--gutter) * -1) -10px;
  scrollbar-width: none;
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track > .card { scroll-snap-align: start; }
.rail-btn {
  position: absolute; top: 34%; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface-2);
  display: grid; place-items: center; color: var(--text); box-shadow: var(--shadow); opacity: 0; transition: opacity var(--t-fast); z-index: 3;
}
.rail-prev { left: -14px; } .rail-next { right: -14px; }
@media (hover: hover) { .rail:hover .rail-btn:not([disabled]) { opacity: 1; } }
.rail-btn[disabled] { opacity: 0 !important; pointer-events: none; }

/* ---------- Home ---------- */
.spotlight { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 16px; }
.gotd { position: relative; display: block; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); min-height: 300px; isolation: isolate; }
.gotd-media { position: absolute; inset: 0; z-index: -1; }
.gotd-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.gotd::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(5, 6, 10, .9) 0%, rgba(5, 6, 10, .55) 45%, rgba(5, 6, 10, 0) 75%); }
.gotd-body { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 10px; height: 100%; padding: 28px; max-width: 460px; color: #fff; }
.gotd-body h2 { font-size: 34px; font-weight: 850; letter-spacing: -.025em; }
.gotd-body p { color: rgba(255, 255, 255, .78); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gotd-body .eyebrow { color: #aab4ff; }
.gotd-body .btn { margin-top: 6px; }
.gotd-body .btn .icon { fill: currentColor; stroke: none; }
@media (hover: hover) { .gotd:hover .gotd-media img { transform: scale(1.03); } }
.spot-side { display: flex; flex-direction: column; gap: 16px; }
.challenge { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); flex: 1; transition: border-color var(--t); }
.challenge:hover { border-color: var(--accent-line); }
.challenge-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.challenge-icon .icon { width: 28px; height: 28px; }
.challenge-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.challenge-text strong { font-size: 17px; font-weight: 750; }
.challenge-text small { color: var(--muted); font-size: 13px; }
.challenge-xp { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.challenge.is-done .challenge-icon { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.challenge.is-done .challenge-xp { opacity: .5; text-decoration: line-through; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-btn { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); transition: border-color var(--t), transform var(--t) var(--ease); }
.quick-btn > .icon { width: 42px; height: 42px; padding: 10px; border-radius: 12px; background: var(--surface-3); }
.quick-play > .icon { color: var(--warn); }
.quick-random > .icon { color: var(--accent-2); }
.quick-btn strong { display: block; font-size: 15px; }
.quick-btn small { color: var(--muted); font-size: 12.5px; }
.quick-btn:hover { border-color: var(--line-2); transform: translateY(-2px); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 22px calc(var(--gutter) * -1) 0; padding: 2px var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; font-weight: 650; color: var(--text-2); white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.chip .icon { width: 17px; height: 17px; color: var(--muted); }
.chip small { color: var(--muted); font-weight: 600; }
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.chip.is-active .icon { color: var(--accent); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.cat-tile { --hue: var(--accent); position: relative; display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color var(--t), transform var(--t) var(--ease); }
.cat-tile .icon { width: 40px; height: 40px; padding: 9px; border-radius: 12px; color: var(--hue); background: color-mix(in srgb, var(--hue) 13%, transparent); }
.cat-name { font-weight: 750; font-size: 15px; }
.cat-count { position: absolute; right: 14px; top: 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cat-tile:hover { border-color: color-mix(in srgb, var(--hue) 40%, transparent); transform: translateY(-2px); }
.cat-grid-lg .cat-tile { padding: 20px; }
.cat-arcade { --hue: #6b7bff; } .cat-puzzle { --hue: #36d399; } .cat-action { --hue: #ff6b3d; } .cat-strategy { --hue: #c084fc; }
.cat-racing { --hue: #f43f5e; } .cat-sports { --hue: #22c55e; } .cat-platformer { --hue: #38bdf8; } .cat-tower-defense { --hue: #f59e0b; }
.cat-idle { --hue: #a3e635; } .cat-card { --hue: #fb7185; } .cat-board { --hue: #eab308; } .cat-retro { --hue: #e879f9; }
.cat-physics { --hue: #2dd4bf; } .cat-typing { --hue: #94a3b8; } .cat-music { --hue: #f472b6; } .cat-multiplayer { --hue: #60a5fa; } .cat-casual { --hue: #fbbf24; }

.more { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- Page heads, lists ---------- */
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { font-size: 28px; font-weight: 850; letter-spacing: -.025em; }
.page-head .count { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-icon { --hue: var(--accent); width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; color: var(--hue); background: color-mix(in srgb, var(--hue) 13%, transparent); flex: none; }
.page-icon .icon { width: 26px; height: 26px; }
.page-head .seg { margin-left: auto; }
.page-head + .grid, .page-head + .chips + .ad-slot + .grid, .page-head + .ad-slot + .grid { margin-top: 20px; }
.chips + .grid, .chips + .ad-slot + .grid { margin-top: 20px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.seg a, .seg label span { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 9px; font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg a .icon, .seg label .icon { width: 17px; height: 17px; }
.seg a:hover, .seg label:hover span { color: var(--text); }
.seg a.is-active, .seg input:checked + span { background: var(--surface-3); color: var(--text); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg label { position: relative; }
.seg-full { display: flex; }
.seg-full label { flex: 1; }
.seg-full label span { width: 100%; justify-content: center; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 28px; color: var(--muted); font-weight: 600; font-size: 14px; }

.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: .5; }
.crumbs a:hover { color: var(--text); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 44px 20px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 18px; margin-top: 16px; }
.empty > .icon { width: 36px; height: 36px; color: var(--text-2); opacity: .7; }
.empty p { font-size: 15px; }

.search-big { position: relative; display: flex; gap: 10px; margin: 18px 0 4px; }
.search-big > .icon { position: absolute; left: 16px; top: 15px; color: var(--muted); }
.search-big input { flex: 1; height: 50px; padding: 0 16px 0 48px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); font-size: 16px; outline: none; }
.search-big input:focus { border-color: var(--accent-line); }
.search-big .btn { height: 50px; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 26px; align-items: start; }
.player-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.player { position: relative; width: min(100%, calc(max(360px, 100vh - 300px) * var(--ar, 1.7778))); aspect-ratio: var(--ar, 16 / 9); margin: 0 auto; background: #000; }
.player[data-aspect="16x9"] { --ar: 1.7778; } .player[data-aspect="16x10"] { --ar: 1.6; } .player[data-aspect="4x3"] { --ar: 1.3333; }
.player[data-aspect="3x2"] { --ar: 1.5; } .player[data-aspect="1x1"] { --ar: 1; } .player[data-aspect="3x4"] { --ar: .75; }
.player[data-aspect="2x3"] { --ar: .6667; } .player[data-aspect="9x16"] { --ar: .5625; } .player[data-aspect="21x9"] { --ar: 2.3333; }
.player-wrap .player { background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; color-scheme: normal; }
.player-loading { position: absolute; inset: 0; display: grid; place-items: center; background: #000; transition: opacity .35s; pointer-events: none; }
.player-loading img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; filter: blur(14px) saturate(1.2); transform: scale(1.1); }
.player-loading.is-done { opacity: 0; }
.spinner { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-bar { display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.player-title { min-width: 0; flex: 1 1 220px; }
.player-title h1 { font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-by { font-size: 13px; color: var(--muted); }
.player-session { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.player-session span { display: inline-flex; align-items: center; gap: 5px; }
.player-session .icon { width: 16px; height: 16px; color: var(--muted); }
.player-session b { font-variant-numeric: tabular-nums; font-weight: 700; }
.player-actions { display: flex; gap: 6px; }
.player-wrap:fullscreen { display: flex; flex-direction: column; border-radius: 0; border: 0; background: #000; }
.player-wrap:fullscreen .player { flex: 1; width: 100%; max-width: none; aspect-ratio: auto; }
.player-wrap:fullscreen .player-bar { background: #0b0c10; }
.player-wrap.is-pseudo-fs { position: fixed; inset: 0; z-index: 90; border-radius: 0; display: flex; flex-direction: column; }
.player-wrap.is-pseudo-fs .player { flex: 1; width: 100%; aspect-ratio: auto; }

.challenge-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 16px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 14px; }
.challenge-bar > .icon { color: var(--accent); }
.challenge-bar em { margin-left: auto; font-style: normal; font-weight: 800; font-size: 12px; color: var(--good); }
.challenge-bar.is-done { background: color-mix(in srgb, var(--good) 10%, transparent); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.challenge-bar.is-done > .icon { color: var(--good); }

.game-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; margin-top: 20px; align-items: start; }
.game-desc p { color: var(--text-2); font-size: 15px; max-width: 70ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { height: 28px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.tag:hover { color: var(--text); border-color: var(--line-2); }
.tag-cat { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.control { display: inline-flex; align-items: center; gap: 6px; }
.control .icon { width: 18px; height: 18px; }
.howto { flex-basis: 100%; color: var(--text-2); }
.stat-row { display: flex; gap: 8px; }
.stat-row > div { min-width: 96px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.stat-row dt { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-row dt .icon { width: 14px; height: 14px; }
.stat-row dd { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-row dd small { font-size: 12px; color: var(--muted); font-weight: 700; }

.lb-mini .lb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; counter-reset: none; }
.lb-list li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.lb-list li.is-me { border-color: var(--accent-line); background: var(--accent-soft); }
.lb-pos { width: 22px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-list li:nth-child(1) .lb-pos { color: #f5c451; } .lb-list li:nth-child(2) .lb-pos { color: #c7d0e0; } .lb-list li:nth-child(3) .lb-pos { color: #d89a64; }
.lb-name { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }

.game-side { position: sticky; top: calc(var(--top-h) + 16px); }
.side-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 750; margin: 4px 0 8px; }
.side-title .icon { color: var(--accent); width: 18px; height: 18px; }
.side-list { display: flex; flex-direction: column; gap: 2px; }

.credits-box { margin-top: 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.credits-box summary { display: flex; align-items: center; gap: 9px; padding: 14px 16px; cursor: pointer; font-weight: 650; font-size: 14px; color: var(--text-2); list-style: none; }
.credits-box summary::-webkit-details-marker { display: none; }
.credits-box summary .icon { color: var(--muted); }
.credits-box dl { padding: 0 16px 16px; display: grid; gap: 8px; }
.credits-box dl > div { display: grid; grid-template-columns: 100px 1fr; gap: 10px; font-size: 14px; }
.credits-box dt { color: var(--muted); }
.credits-box dd { color: var(--text-2); overflow-wrap: anywhere; }
.credits-box a { color: var(--accent); }

/* ---------- Modal, palette, toasts ---------- */
.modal { border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface-2); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); }
.modal::backdrop { background: rgba(3, 4, 7, .66); backdrop-filter: blur(3px); }
.modal form { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal header { display: flex; align-items: center; justify-content: space-between; }
.modal h2 { display: flex; align-items: center; gap: 9px; font-size: 18px; }
.modal h2 .icon { color: var(--accent); }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; }
.radio-list { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.radio-list label { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; font-size: 14px; font-weight: 600; }
.radio-list input { accent-color: var(--accent); width: 16px; height: 16px; }
.radio-list label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }

.palette { position: fixed; inset: 0; z-index: 95; display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh; background: rgba(3, 4, 7, .6); backdrop-filter: blur(3px); }
.palette-box { width: min(560px, calc(100vw - 24px)); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input .icon { color: var(--muted); }
.palette-input input { flex: 1; height: 56px; background: transparent; border: 0; outline: none; font-size: 16px; }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.palette-item .icon { color: var(--muted); width: 18px; height: 18px; }
.palette-item small { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }
.palette-item img { width: 48px; height: 30px; border-radius: 6px; object-fit: cover; }
.palette-item.is-sel { background: var(--surface-3); }
.palette-item.is-sel .icon { color: var(--accent); }
.palette-sep { padding: 10px 12px 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
kbd { font: 600 11px var(--mono); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; color: var(--text-2); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 99; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 220px; max-width: 360px; padding: 12px 16px 12px 12px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 14px; pointer-events: auto; animation: toast-in .3s var(--ease); }
.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
.toast-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.toast-xp .toast-icon { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.toast-ach .toast-icon { color: #f5c451; background: color-mix(in srgb, #f5c451 14%, transparent); }
.toast-level .toast-icon { color: #fff; background: var(--accent); }
.toast-err .toast-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.toast b { display: block; font-weight: 750; }
.toast small { color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.navbar-progress { position: fixed; left: 0; top: 0; height: 2px; z-index: 100; background: var(--accent); width: 0; opacity: 0; transition: width .3s var(--ease), opacity .3s; }
.navbar-progress.is-on { opacity: 1; }
main.is-entering { animation: page-in .28s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.field small { color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select, .admin-filter input, .admin-filter select, .lb-game select {
  height: 44px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 13px; font-size: 15px; font-weight: 500; color: var(--text); outline: none; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field textarea { height: auto; padding: 10px 13px; resize: vertical; }
.field input:focus, .field textarea:focus, select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.pw { position: relative; display: block; }
.pw input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--text); }
.hint { font-size: 12px; }
.form-error { display: flex; align-items: center; gap: 7px; color: var(--danger); font-size: 13px; font-weight: 600; }
.form-error .icon { width: 16px; height: 16px; }
.notice { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); font-weight: 650; font-size: 14px; margin: 12px 0; }

.auth { display: grid; place-items: center; min-height: calc(100vh - var(--top-h) - 200px); padding: 20px 0; }
.auth-card { width: min(410px, 100%); padding: 30px 28px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.auth-brand { width: 52px; height: 52px; margin-bottom: 16px; }
.auth-brand .icon { width: 52px; height: 52px; color: var(--accent); }
.auth-card h1 { font-size: 26px; font-weight: 850; letter-spacing: -.02em; }
.perks { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 22px; }
.perks li { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 650; color: var(--text-2); }
.perks .icon { width: 14px; height: 14px; color: var(--accent); }
.auth-switch { margin-top: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-switch a { color: var(--accent); font-weight: 650; }

/* Switches */
.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row:first-of-type { border-top: 0; }
.switch-row > .icon { color: var(--muted); }
.switch-text { flex: 1; display: flex; flex-direction: column; }
.switch-text b { font-size: 14.5px; font-weight: 650; }
.switch-text small { font-size: 12.5px; color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background var(--t-fast); flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.switch-row input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Settings / panels ---------- */
.settings { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 26px; margin-top: 18px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.settings-nav a:hover { background: var(--surface); color: var(--text); }
.settings-nav .icon { width: 18px; height: 18px; }
.settings-body { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.panel { padding: 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.panel h2 { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 750; margin-bottom: 14px; }
.panel h2 .icon { color: var(--accent); width: 19px; height: 19px; }
.panel h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }
.panel-danger h2 .icon { color: var(--danger); }
.panel .form-inline { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; padding: 12px 0; border-top: 1px solid var(--line); }
.panel .form-inline:first-of-type { border-top: 0; padding-top: 0; }
.panel .form-inline .form-error { grid-column: 1 / -1; }
.panel .form-inline .btn { height: 44px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.sessions { display: flex; flex-direction: column; gap: 6px; }
.sessions li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--surface-2); }
.sessions li .icon { color: var(--good); width: 16px; height: 16px; }
.sessions li span { display: flex; flex-direction: column; font-size: 14px; }
.sessions small { color: var(--muted); font-size: 12px; }
.link-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.link-list a { display: inline-flex; height: 34px; align-items: center; padding: 0 12px; border-radius: 9px; background: var(--surface-2); font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.link-list a:hover { color: var(--text); }
.dev-line { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.dev-line .mono { color: var(--text); font-size: 14px; }

/* ---------- Profile ---------- */
.profile-hero { display: flex; align-items: center; gap: 22px; padding: 24px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.profile-id { flex: 1; min-width: 0; }
.profile-id h1 { font-size: 28px; font-weight: 850; letter-spacing: -.02em; }
.xpbar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 10px 0 8px; max-width: 520px; }
.xpbar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.w-0 { width: 2%; } .w-1 { width: 10%; } .w-2 { width: 20%; } .w-3 { width: 30%; } .w-4 { width: 40%; } .w-5 { width: 50%; }
.w-6 { width: 60%; } .w-7 { width: 70%; } .w-8 { width: 80%; } .w-9 { width: 90%; } .w-10 { width: 100%; }
.xp-line { font-size: 14px; color: var(--muted); }
.xp-line b { color: var(--text); }
.xp-line a { color: var(--accent); font-weight: 650; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }
.stat-grid > div { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.stat-grid dt { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.stat-grid dt .icon { width: 16px; height: 16px; }
.stat-grid dd { font-size: 28px; font-weight: 850; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-grid dd small { font-size: 13px; font-weight: 650; color: var(--muted); margin-left: 5px; }
.stat-grid .dd-text { font-size: 20px; padding-top: 5px; }
.cal { display: grid; grid-template-rows: repeat(7, 14px); grid-auto-flow: column; grid-auto-columns: 14px; gap: 4px; }
.cal-d { border-radius: 4px; background: var(--surface-2); }
.cal-d.l1 { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.cal-d.l2 { background: color-mix(in srgb, var(--accent) 65%, var(--surface-2)); }
.cal-d.l3 { background: var(--accent); }
.best-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.best-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.best-list a { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best-list b { font-variant-numeric: tabular-nums; }
.xp-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.xp-rules li { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.xp-rules .icon { color: var(--accent); width: 18px; height: 18px; }
.xp-rules b { color: var(--good); }

/* Badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.badge { --tier: #d0925c; display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.tier-silver { --tier: #c3cddf; } .tier-gold { --tier: #f5c451; }
.badge-hex { width: 50px; height: 56px; flex: none; display: grid; place-items: center; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--tier) 55%, #fff) 0%, var(--tier) 45%, color-mix(in srgb, var(--tier) 55%, #000) 100%); color: #1a1408; }
.badge-hex .icon { width: 24px; height: 24px; stroke-width: 2.1; }
.badge-text { display: flex; flex-direction: column; min-width: 0; }
.badge-text strong { font-size: 14px; font-weight: 750; }
.badge-text small { font-size: 12.5px; color: var(--muted); }
.badge-text em { font-style: normal; font-size: 11.5px; font-weight: 800; color: var(--good); margin-top: 2px; }
.badge.is-locked { opacity: .55; }
.badge.is-locked .badge-hex { background: var(--surface-3); color: var(--muted); }
.badge.is-locked em { color: var(--muted); }
.badge-sm { padding: 0; border: 0; background: none; }
.badge-sm .badge-hex { width: 34px; height: 38px; }
.badge-sm .badge-hex .icon { width: 17px; height: 17px; }

/* ---------- Leaderboard ---------- */
.lb-tabs { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0; }
.lb-game select { height: 42px; min-width: 230px; }
.lb-for { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 12px; font-size: 14px; }
.lb-for a { color: var(--text); font-weight: 700; }
.board { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.board li { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.board li.is-me { border-color: var(--accent-line); background: var(--accent-soft); }
.board-pos { display: inline-flex; align-items: center; gap: 4px; width: 46px; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--muted); }
.board-pos .icon { width: 16px; height: 16px; }
.top-1 .board-pos { color: #f5c451; } .top-2 .board-pos { color: #c3cddf; } .top-3 .board-pos { color: #d0925c; }
.top .board-pos .icon { fill: currentColor; fill-opacity: .25; }
.board-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-streak { display: inline-flex; align-items: center; gap: 3px; color: var(--hot); font-size: 13px; font-weight: 750; }
.board-streak .icon { width: 15px; height: 15px; }
.board-val { font-weight: 850; font-variant-numeric: tabular-nums; }

/* ---------- Tables / admin / prose ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); margin-top: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 750; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-size: 12px; }
td a { color: var(--text); font-weight: 650; }
.credits td a[target] { color: var(--accent); }
.admin-nav { margin: 14px 0 18px; }
.admin-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.admin-filter input { max-width: 320px; }
.admin-filter select { width: auto; }
.admin-table tr.is-off td { opacity: .5; }
.admin-table select { height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0 8px; }
.inline-form { display: inline; }
.flags { white-space: nowrap; }
.pill { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; }
.pill.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.tiny-link { font-size: 12px; color: var(--accent) !important; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.plain-list { display: flex; flex-direction: column; gap: 6px; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain-list li span:last-child { color: var(--muted); }
.health { display: inline-flex; align-items: center; gap: 7px; }
.health::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.h-working::before { background: var(--good); } .h-review::before { background: var(--warn); } .h-broken::before { background: var(--danger); }
.report-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.report-list li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.report-list small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.report-list p { margin-top: 8px; color: var(--text-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

.prose { max-width: 720px; }
.prose h1 { font-size: 30px; font-weight: 850; margin-bottom: 18px; }
.prose h2 { font-size: 18px; margin: 26px 0 8px; }
.prose p, .prose li { color: var(--text-2); font-size: 15px; }
.prose ul { list-style: disc; padding-left: 20px; display: grid; gap: 6px; }
.prose a { color: var(--accent); }
.draft { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn) !important; font-weight: 650; font-size: 14px !important; }

.error-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 60px 0; }
.error-code { font-size: 96px; font-weight: 900; line-height: 1; letter-spacing: -.05em; color: transparent; -webkit-text-stroke: 2px var(--line-2); }
.error-page h1 { font-size: 26px; }
.error-page p { color: var(--muted); }

/* ---------- Ads ---------- */
.ad-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; margin: 26px auto; overflow: hidden; contain: layout; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-slot ins { display: block; width: 100%; }
.ad-slot-top { max-width: 970px; min-height: 90px; margin-top: 0; }
.ad-slot-inline { max-width: 970px; min-height: 90px; }
.ad-slot-game-top { max-width: 728px; min-height: 90px; margin: 0 auto 14px; }
.ad-slot-game-bottom { max-width: 728px; min-height: 90px; }
.ad-slot-sidebar { min-height: 250px; margin: 0 0 18px; }
.ad-slot-mobile { display: none; min-height: 100px; max-width: 320px; }
.ad-placeholder { border: 1px dashed var(--line-2); border-radius: 12px; background: repeating-linear-gradient(135deg, transparent 0 10px, var(--line) 10px 11px); }
.ad-placeholder span { font: 600 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .75; }

/* ---------- Footer & tab bar ---------- */
.footer { border-top: 1px solid var(--line); margin-top: 20px; }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 26px var(--gutter) 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13.5px; color: var(--muted); }
.footer nav a:hover { color: var(--text); }
.footer p { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.footer p a { text-decoration: underline; text-underline-offset: 2px; }
.logo-sm .logo-mark { width: 24px; height: 24px; }
.logo-sm .logo-word { font-size: 13px; }
.tabbar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .mainnav a { padding: 8px 8px; }
  .hide-md { display: none; }
}
@media (max-width: 1180px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-side { position: static; }
  .side-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .ad-slot-sidebar { display: none; }
}
@media (max-width: 1060px) {
  .mainnav { display: none; }
  .search { margin-left: 8px; }
}
@media (max-width: 900px) {
  .spotlight { grid-template-columns: 1fr; }
  .gotd { min-height: 260px; }
  .game-info { grid-template-columns: 1fr; }
  .stat-row { flex-wrap: wrap; }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .admin-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --gutter: 14px; --top-h: 58px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .hide-sm { display: none !important; }
  .topbar-inner { gap: 10px; }
  .logo-word { display: none; }
  .search { flex: 1; max-width: none; margin-left: 0; }
  .search kbd { display: none; }
  main { padding-top: 16px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 650; color: var(--muted); }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .tabbar a[aria-current="page"] .icon { color: var(--accent); }
  .tab-play { flex: none !important; width: 52px; height: 52px; margin: 6px 6px 0; align-self: flex-start; border-radius: 16px; background: var(--accent); color: #fff !important; }
  .tab-play .icon { fill: rgba(255, 255, 255, .25); }
  .grid, .grid-dense { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .rail-track { grid-auto-columns: 44vw; gap: 10px; }
  .card-body { padding: 8px 10px 10px; }
  .card-title { font-size: 13.5px; }
  .card-meta { font-size: 11.5px; }
  .card-fav { width: 30px; height: 30px; right: 6px; top: 6px; }
  .flag { height: 20px; padding: 0 6px; font-size: 10px; }
  .block, .rail-section { margin-top: 28px; }
  .section-head h2 { font-size: 17px; }
  .gotd-body { padding: 20px; }
  .gotd-body h2 { font-size: 26px; }
  .gotd::after { background: linear-gradient(0deg, rgba(5, 6, 10, .92) 0%, rgba(5, 6, 10, .4) 60%, rgba(5, 6, 10, .1) 100%); }
  .quick-btn { padding: 12px; gap: 10px; }
  .quick-btn > .icon { width: 36px; height: 36px; padding: 8px; }
  .page-head h1 { font-size: 23px; }
  .page-head .seg { margin-left: 0; }
  .player { width: 100%; }
  .player-wrap { margin: 0 calc(var(--gutter) * -1); border-radius: 0; border-left: 0; border-right: 0; }
  .player-bar { padding: 10px 12px; gap: 10px; }
  .player-title h1 { font-size: 17px; }
  .player-actions { width: 100%; justify-content: space-between; }
  .player-session { order: 3; }
  .ad-slot-top, .ad-slot-inline, .ad-slot-game-top { display: none; }
  .ad-slot-mobile { display: flex; }
  .panel .form-inline { grid-template-columns: 1fr; }
  .profile-hero { flex-wrap: wrap; padding: 18px; gap: 16px; }
  .lvl-lg { width: 76px; height: 76px; } .lvl-lg b { font-size: 26px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid dd { font-size: 23px; }
  .toasts { left: 12px; right: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
  .footer-inner { padding-bottom: 20px; }
  .search-pop { position: fixed; top: calc(var(--top-h) + 6px); left: 8px; right: 8px; }
}

/* ---------- Motion & performance preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
[data-anim="0"] *, [data-anim="0"] *::before, [data-anim="0"] *::after,
[data-perf="1"] *, [data-perf="1"] *::before, [data-perf="1"] *::after { animation: none !important; transition: none !important; }
[data-anim="0"] .spinner, [data-perf="1"] .spinner { animation: spin .8s linear infinite !important; }
[data-effects="0"] .topbar, [data-effects="0"] .tabbar, [data-perf="1"] .topbar, [data-perf="1"] .tabbar,
[data-effects="0"] .flag, [data-perf="1"] .flag, [data-effects="0"] .card-fav, [data-perf="1"] .card-fav { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
[data-effects="0"] .topbar, [data-perf="1"] .topbar { background: var(--bg); }
[data-effects="0"] .card:hover, [data-perf="1"] .card:hover { box-shadow: none; }
[data-perf="1"] .player-loading img, [data-effects="0"] .player-loading img { display: none; }
[data-previews="0"] .card-media img { display: none; }
[data-previews="0"] .card-media { background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); }
[data-previews="0"] .gotd-media img { display: none; }
