/* Self-hosted fonts (SIL Open Font License, see fonts/) */
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-ext-wght-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-display: swap; font-weight: 500; src: url(fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-display: swap; font-weight: 700; src: url(fonts/space-grotesk-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #0b0d17;
  --panel: #151a2e;
  --panel-2: #1d2340;
  --border: #2a3156;
  --text: #eef0ff;
  --muted: #8d93b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --good: #2ecc71;
  --bad: #ff4d6d;
  --warn: #ffb020;
  --radius: 18px;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --nav-h: 64px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(124, 92, 255, 0.25), transparent 60%),
    radial-gradient(700px 400px at 110% 10%, rgba(34, 211, 238, 0.15), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

#app { max-width: 640px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)); }
#app:has(.navbar) { padding-bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
#app.wide { max-width: 1040px; }

.screen { display: flex; flex-direction: column; gap: 16px; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 12px 0 0; }
.muted { color: var(--muted); font-size: 13px; }

.logo { font-family: var(--display); font-size: 44px; font-weight: 700; letter-spacing: -0.03em; }
.result-title, .elo-big, .room-code b, .vs, .play-cta b, .big-name, .stat b, .tile b { font-family: var(--display); }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.small { font-size: 22px; }
.tagline { color: var(--muted); margin: -8px 0 8px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

.btn {
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; cursor: pointer;
  transition: transform 0.1s, filter 0.2s, opacity 0.2s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b3df5); border: none; box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35); }
.btn.big { font-size: 18px; padding: 16px; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.link:hover { color: var(--text); }

/* Onboarding */
.onboarding { padding-top: 8vh; }
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 600; color: var(--muted); font-size: 14px; }
.field input {
  font: inherit; font-size: 18px; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-pick { font-size: 28px; aspect-ratio: 1; background: var(--panel); border: 2px solid var(--border); border-radius: 14px; cursor: pointer; }
.avatar-pick.selected { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }

/* Home */
.topbar { display: flex; justify-content: space-between; align-items: center; }
.profile { display: flex; gap: 16px; align-items: center; }
.avatar { font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center; background: var(--panel-2); border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.avatar.big { font-size: 44px; width: 80px; height: 80px; }
.profile-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.name { font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.rating-line { display: flex; gap: 10px; align-items: center; }
.rank {
  display: inline-block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--rank); border: 1px solid var(--rank); border-radius: 999px; padding: 3px 10px;
  background: color-mix(in srgb, var(--rank) 12%, transparent);
}
.elo { font-weight: 700; }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; border-radius: 99px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stats b { font-size: 20px; }
.stats span { font-size: 12px; color: var(--muted); }
.achievements { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.achievement { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; opacity: 0.4; filter: grayscale(1); }
.achievement.unlocked { opacity: 1; filter: none; border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.achievement b { display: block; font-size: 14px; }
.achievement span { font-size: 12px; color: var(--muted); }
.ach-icon { font-size: 26px; }
.pop { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.rules summary { cursor: pointer; font-weight: 700; }
.rules li { margin: 8px 0; color: #c9cdea; line-height: 1.45; }
kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* Versus */
.versus { flex-direction: row; justify-content: space-around; align-items: center; min-height: 60vh; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: slide-l 0.6s ease; }
.vs-side:last-child { animation-name: slide-r; }
@keyframes slide-l { from { transform: translateX(-60px); opacity: 0; } }
@keyframes slide-r { from { transform: translateX(60px); opacity: 0; } }
.vs { font-size: 48px; font-weight: 900; font-style: italic; background: linear-gradient(135deg, var(--bad), var(--warn)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop 0.6s 0.3s both cubic-bezier(0.3, 1.6, 0.5, 1); }

/* Duel */
.fighters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.fighter { position: relative; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.fighter.opponent { flex-direction: row-reverse; text-align: right; }
.fighter-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.fighter-name { font-weight: 700; font-size: clamp(14px, 0.5vw + 11px, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock { font-size: 11px; color: var(--accent-2); font-weight: 600; }
.hp { height: clamp(12px, 1.4vh, 18px); background: #0e1224; border-radius: 99px; overflow: hidden; }
.hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #27ae60, var(--good)); border-radius: 99px; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.opponent .hp-fill { margin-left: auto; }
.hp-fill.low { background: linear-gradient(90deg, #c0392b, var(--bad)); }
.hp-text { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shake { animation: shake 0.45s; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater { position: absolute; left: 0; right: 0; top: 50%; margin-top: -18px; text-align: center; font-size: 26px; font-weight: 900; animation: float 1.6s ease-out forwards; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
.floater.hit { color: var(--bad); }
@keyframes float { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 15% { transform: translateY(-6px) scale(1.2); opacity: 1; } 100% { transform: translateY(-50px) scale(1); opacity: 0; } }

.round-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.diff { text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; margin-left: 8px; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.cat-history { border-color: #a0785a; } .cat-geography { border-color: #2e9d6b; } .cat-science { border-color: #4a8fe0; }
.cat-culture { border-color: #c45bd0; } .cat-sports { border-color: #e0873a; } .cat-language { border-color: #3fb8b0; }
.cat-film { border-color: #e04a6a; } .cat-music { border-color: #9b6cff; } .cat-tech { border-color: #36c2f0; }
.cat-gaming { border-color: #7ad64a; } .cat-food { border-color: #f2b33d; } .cat-nature { border-color: #4fbf5f; }
.cat-math { border-color: #f06292; } .cat-economy { border-color: #8d9db6; }
.diff.easy { color: var(--good); }
.diff.medium { color: var(--warn); }
.diff.hard { color: var(--bad); }
.timer { height: 8px; background: var(--panel); border-radius: 99px; overflow: hidden; }
#timer-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
#timer-fill.urgent { background: linear-gradient(90deg, var(--bad), var(--warn)); }
.status { min-height: 20px; font-size: 14px; text-align: center; color: var(--accent-2); font-weight: 600; }
.duel { min-height: calc(100dvh - 60px); }
.question { font-size: clamp(22px, 1.4vw + 14px, 36px); font-weight: 800; line-height: 1.3; text-align: center; padding: 18px 8px; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; flex: 1; }
.q-image svg { display: block; height: clamp(110px, 24vh, 240px); width: auto; max-width: 100%; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.question.enter { animation: fade 0.35s ease; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer {
  font: inherit; font-size: clamp(16px, 0.6vw + 13px, 22px); font-weight: 600; color: var(--text); text-align: left;
  background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 14px 12px;
  min-height: clamp(72px, 10vh, 104px); display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s, opacity 0.2s;
}
.answer:hover:not(:disabled) { border-color: var(--accent); background: var(--panel-2); }
.answer:active:not(:disabled) { transform: scale(0.97); }
.answer:disabled { cursor: default; }
.answer .key { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; flex-shrink: 0; }
.answer .marks { margin-left: auto; display: flex; gap: 2px; }
.mark { font-size: 18px; animation: pop 0.4s; }
.answer.picked { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, var(--panel)); }
.answer.removed { opacity: 0.15; }
.answer.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 22%, var(--panel)); }
.answer.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 20%, var(--panel)); }
.joker-row { display: flex; justify-content: center; }
.btn.joker small { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Result */
.result { align-items: stretch; text-align: center; padding-top: 6vh; }
.result-title { font-size: clamp(40px, 11vw, 56px); font-weight: 900; letter-spacing: -0.02em; animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
.result.win .result-title { background: linear-gradient(135deg, var(--warn), #ffe08a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result.loss .result-title { color: var(--bad); }
.result-sub { color: var(--muted); }
.result-rating { display: flex; gap: 16px; align-items: center; justify-content: center; text-align: left; }
.elo-big { font-size: 34px; font-weight: 900; margin-bottom: 6px; }
.up { color: var(--good); font-size: 20px; }
.down { color: var(--bad); font-size: 20px; }
.promo { margin-top: 8px; font-weight: 700; }
.result .achievements { text-align: left; }

/* Topbar buttons, modes */
.topbar-actions { display: flex; gap: 6px; }
.icon-btn { font-size: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; cursor: pointer; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.mode { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.btn.mode small { font-size: 12px; font-weight: 500; opacity: 0.8; }
.btn.danger { border-color: var(--bad); color: var(--bad); }

/* Practice */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.category-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; font-size: 14px; background: var(--panel); border-bottom-width: 3px; }
.category-pick small { font-size: 11px; font-weight: 500; color: var(--muted); }
.category-pick span { font-size: 30px; }
.weakness-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; margin-bottom: 12px; padding: 14px 12px; background: var(--panel); border: 2px solid var(--accent); border-bottom-width: 4px; text-align: center; }
.weakness-pick strong { font-size: 18px; }
.weakness-pick small { font-size: 12px; font-weight: 500; color: var(--muted); }
.weak-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.weak-chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.weak-chip b { color: var(--bad); }
.practice-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.practice-stats { display: flex; gap: 16px; font-size: 14px; color: var(--muted); }
.practice-stats b { color: var(--text); }

/* Admin */
h3 { margin: 0 0 12px; font-size: 15px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { font: inherit; font-weight: 700; color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
#tab-body { display: flex; flex-direction: column; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile b { font-size: 26px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--accent-2); stroke: var(--panel); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .pt:hover .dot { r: 6; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 80px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select, .setting select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
.filters input { flex: 1; min-width: 180px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.qtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.qtable th { text-align: left; padding: 10px; background: var(--panel-2); color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; position: sticky; top: 0; }
.qtable th.sorted { color: var(--text); }
.qtable td { padding: 10px; border-top: 1px solid var(--border); vertical-align: top; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qtable td:first-child { white-space: normal; min-width: 280px; }
.qmeta { margin-top: 6px; font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qmeta .chip { padding: 1px 8px; font-size: 11px; }
.qmeta .diff { margin-left: 0; }
.flag { font-size: 11px; font-weight: 800; text-transform: uppercase; padding: 1px 7px; border-radius: 99px; }
.flag.review { background: color-mix(in srgb, var(--bad) 25%, transparent); color: #ff8fa3; }
.flag.easy { background: color-mix(in srgb, var(--warn) 25%, transparent); color: #ffd27a; }
.history { display: flex; flex-direction: column; gap: 6px; }
.history-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.h-icon { font-size: 18px; }
.h-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; }
.h-side .mode { font-size: 11px; font-weight: 800; text-transform: uppercase; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); }
.mode.ranked { color: var(--accent-2); }
.mode.practice { color: var(--good); }
.settings { display: flex; flex-direction: column; gap: 12px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.setting > span { display: flex; flex-direction: column; gap: 2px; }
.setting input[type='range'] { width: 180px; accent-color: var(--accent); }
.switch { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); }
.setting-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 70px; }
}

@media (max-width: 420px) {
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 56px; }
  .question { font-size: 19px; min-height: 90px; }
  .achievements { grid-template-columns: 1fr; }
  .fighter .avatar { width: 40px; height: 40px; font-size: 22px; }
}
.qtable small { font-size: 12px; }
.chart .axis { font-size: 12px; }

/* Coins, level, rewards */
.coins { font: inherit; font-weight: 800; background: var(--panel); border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--border)); color: #ffd27a; border-radius: 10px; padding: 0 12px; height: 40px; cursor: pointer; display: inline-flex; align-items: center; }
.level { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--accent-2); vertical-align: middle; margin-left: 6px; }
.level-bar { width: 60px; height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; display: inline-block; }
.level-bar span { display: block; height: 100%; background: var(--accent-2); }
.reward { font-weight: 800; color: #ffd27a; font-size: 18px; }
.btn.mode.daily { border-color: color-mix(in srgb, var(--accent-2) 60%, var(--border)); }
.btn.mode.daily.done { opacity: 0.75; }
.round-right { display: inline-flex; align-items: center; gap: 10px; }
.round-right .icon-btn, .practice-stats .icon-btn { width: 34px; height: 34px; font-size: 16px; }
.practice-stats { align-items: center; }

/* Shop */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.shop-item { font: inherit; color: var(--text); background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.shop-item:disabled { opacity: 0.45; cursor: default; }
.shop-item.equipped { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.shop-avatar { font-size: 40px; }
.shop-label { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.shop-price { font-size: 12px; }
.shop-label small { display: block; font-size: 11px; font-weight: 500; margin-top: 2px; }

/* Daily */
.share { margin: 0; font: inherit; font-size: 18px; white-space: pre-wrap; text-align: center; line-height: 1.6; }
.history-row .mode.daily { color: var(--warn); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(5, 6, 14, 0.7); display: grid; place-items: center; padding: 16px; z-index: 10; animation: fade 0.2s; }
.modal { width: min(480px, 100%); display: flex; flex-direction: column; gap: 12px; }
.modal textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 80px; resize: vertical; }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.reason { font-weight: 600; font-size: 14px; padding: 10px; }
.btn.reason.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel)); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.mode-grid > :only-child { grid-column: 1 / -1; }

/* Party */
.connecting { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.spinner { width: 40px; height: 40px; border: 4px solid var(--panel-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card h3 { margin-bottom: 6px; }
.center { text-align: center; }
.join { display: flex; flex-direction: column; gap: 12px; }
.join input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; }
.room-code { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.room-code b { font-size: 48px; letter-spacing: 0.25em; font-weight: 900; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lobby-players { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.lobby-player { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.lobby-player.empty { border-style: dashed; opacity: 0.7; }
.lobby .vs { font-size: 32px; }
.invite { display: flex; flex-direction: column; gap: 8px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.end-hp { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vs.small { font-size: 24px; }
.round-info { flex-wrap: wrap; }

/* Accounts & leaderboard */
.small-btn { padding: 0 12px; height: 40px; font-size: 13px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.choice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; }
.btn.choice small { color: var(--accent-2); }
.board { display: flex; flex-direction: column; gap: 6px; }
.board-row { display: grid; grid-template-columns: 40px 44px 1fr auto; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.board-row.me { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.25); }
.board-row .avatar { width: 40px; height: 40px; font-size: 22px; }
.place { font-weight: 900; font-size: 18px; text-align: center; }
.board-name { display: flex; flex-direction: column; min-width: 0; }
.board-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-rating { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-variant-numeric: tabular-nums; }

/* Chat */
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 5; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.chat-toggle { position: relative; width: 48px; height: 48px; font-size: 22px; border-radius: 50%; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.chat-badge { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; border-radius: 99px; padding: 1px 6px; }
.chat-panel { width: min(320px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.chat-log { max-height: 200px; min-height: 60px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.msg { background: var(--panel-2); border-radius: 10px; padding: 6px 10px; align-self: flex-start; max-width: 90%; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--accent) 30%, var(--panel)); }
.chat-quick { display: flex; flex-wrap: wrap; gap: 4px; }
.chip.quick { font: inherit; font-size: 12px; cursor: pointer; padding: 3px 8px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.chat-toast { background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; max-width: 280px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); animation: fade 0.2s; overflow-wrap: anywhere; }
.username-row { display: flex; gap: 8px; }
.username-row input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; width: 180px; }
.elo-line { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 24px; }
.searching { align-items: center; padding-top: 10vh; }
.search-pulse { position: relative; display: grid; place-items: center; width: 160px; height: 160px; }
.search-pulse::before, .search-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent); animation: pulse 2s ease-out infinite; }
.search-pulse::after { animation-delay: 1s; }
@keyframes pulse { from { transform: scale(0.5); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }
.center-row { justify-content: center; }

/* ---------- v2 design: home, navigation, profiles, friends ---------- */
button.card { font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; transition: transform 0.12s, border-color 0.2s; }
button.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
button.card:active { transform: scale(0.99); }
.chev { margin-left: auto; font-size: 26px; color: var(--muted); }
.small { font-size: 12px; }
.profile.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--rank) 16%, var(--panel)), var(--panel) 55%);
  border-color: color-mix(in srgb, var(--rank) 35%, var(--border));
}
.play-cta {
  display: flex; align-items: center; gap: 16px; text-align: left; padding: 20px; border-radius: 22px;
  background: linear-gradient(120deg, #7c5cff, #5b3df5 55%, #22b8d8); position: relative; overflow: hidden;
}
.play-cta::after {
  content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.18) 50%, transparent 70%);
  transform: translateX(-100%); animation: shine 3.5s 1s infinite;
}
@keyframes shine { 40%, 100% { transform: translateX(100%); } }
.play-cta b { display: block; font-size: 24px; }
.play-cta small { display: block; font-weight: 500; opacity: 0.85; margin-top: 2px; }
.play-icon { font-size: 40px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3)); }
.btn.tile-mode { align-items: flex-start; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--panel); gap: 2px; }
.tile-mode .mode-icon { font-size: 28px; margin-bottom: 6px; }
.tile-mode b { font-size: 17px; }
.tile-mode small { color: var(--muted); }
.btn.mode.daily:not(.done) { border-color: color-mix(in srgb, var(--accent-2) 60%, var(--border)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.friends-strip { display: flex; align-items: center; gap: 12px; }
.friends-strip > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.avatar-stack { display: flex; align-items: center; margin-left: auto; }
.avatar.mini { width: 34px; height: 34px; font-size: 18px; margin-left: -8px; border-color: var(--panel); }
.badge { background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; border-radius: 99px; padding: 1px 7px; vertical-align: middle; }
.install-banner { display: flex; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border)); }
.install-banner > div { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.install-icon img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.footer-links { text-align: center; }
.footer-links .link { font-size: 12px; }

.navbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 6;
  width: min(440px, calc(100% - 24px)); height: var(--nav-h); display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); padding: 6px;
}
.nav-item { font: inherit; font-size: 11px; font-weight: 700; color: var(--muted); background: none; border: none; border-radius: 16px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav-item span { font-size: 20px; position: relative; }
.nav-item.active { color: var(--text); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.nav-badge { position: absolute; top: -4px; right: -10px; background: var(--bad); color: #fff; font-size: 10px; font-style: normal; font-weight: 800; border-radius: 99px; padding: 0 5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 16px; font-weight: 600; z-index: 20;
  box-shadow: var(--shadow); transition: opacity 0.3s, transform 0.3s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Profile page */
.hero-card { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--panel)), var(--panel)); }
.avatar.huge { font-size: 56px; width: 96px; height: 96px; }
.hero-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.big-name { font-size: 26px; }
.profile-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.stat b { font-size: 18px; white-space: nowrap; }
.stat span { font-size: 11px; color: var(--muted); }
.spark { width: 100%; height: 80px; display: block; }
.spark-range { display: flex; justify-content: space-between; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-bars { display: flex; flex-direction: column; gap: 8px; }
.cat-bar { display: grid; grid-template-columns: 150px 1fr 44px 32px; gap: 10px; align-items: center; font-size: 13px; }
.cat-bar .bar { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.cat-bar .bar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.cat-bar b { text-align: right; font-variant-numeric: tabular-nums; }
.match-list { display: flex; flex-direction: column; gap: 6px; }
.match-row { display: grid; grid-template-columns: 30px 40px 1fr auto; gap: 10px; align-items: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.match-row .avatar { width: 36px; height: 36px; font-size: 18px; }
.match-name { display: flex; flex-direction: column; min-width: 0; }
.match-name .link { padding: 0; text-align: left; color: var(--text); font-size: 14px; font-weight: 600; }
.result-pill { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 900; font-size: 13px; }
.result-pill.win { background: color-mix(in srgb, var(--good) 25%, transparent); color: var(--good); }
.result-pill.loss { background: color-mix(in srgb, var(--bad) 25%, transparent); color: var(--bad); }
.result-pill.draw { background: var(--panel-2); color: var(--muted); }
.match-row .up, .match-row .down { font-size: 14px; font-weight: 700; }
.achievements.compact .achievement { padding: 8px; }
.board-row { cursor: pointer; }
.board-row:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }

/* Friends */
.add-friend { display: flex; flex-direction: column; gap: 6px; }
.add-friend .username-row input { flex: 1; width: auto; font-size: 16px; padding: 10px 12px; }
.friend-list { display: flex; flex-direction: column; gap: 6px; }
.friend-row { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 8px 10px; }
.link-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: none; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.friend-row .avatar { position: relative; width: 44px; height: 44px; font-size: 22px; }
.online-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--good); border: 2px solid var(--panel); }
.friend-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.friend-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-name .rank { font-size: 10px; padding: 1px 6px; }
.friend-actions { display: flex; gap: 6px; align-items: center; }
.challenge-pop { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.challenge-pop .avatar { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-bar { grid-template-columns: 110px 1fr 40px; }
  .cat-bar small { display: none; }
  .play-cta b { font-size: 21px; }
  .avatar.huge { font-size: 44px; width: 76px; height: 76px; }
}

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 4px; }
.seg { font: inherit; font-weight: 700; color: var(--muted); background: none; border: none; border-radius: 10px; padding: 10px; cursor: pointer; }
.seg.selected { color: var(--text); background: var(--panel-2); box-shadow: 0 0 0 1px var(--accent); }

/* Survival */
.lives { font-size: 18px; letter-spacing: 2px; display: inline-block; }
.lives .lost { opacity: 0.45; }
.survival-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.survival-score b { font-family: var(--display); font-size: 64px; line-height: 1; background: linear-gradient(135deg, var(--warn), var(--bad)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.survival-score span { color: var(--muted); }
.footer-links a, .settings a { color: var(--muted); }

/* First-duel tutorial */
.tutorial { display: flex; flex-direction: column; gap: 12px; }
.tutorial-step { display: flex; gap: 12px; align-items: flex-start; }
.tutorial-step > div { display: flex; flex-direction: column; gap: 2px; }
.tutorial-icon { font-size: 26px; width: 36px; text-align: center; flex-shrink: 0; }

/* Weekly league */
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.season-strip { font: inherit; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 14%, var(--panel)), var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); border-radius: 14px; padding: 10px 14px; cursor: pointer; font-size: 14px; }
.season-strip .muted { font-size: 12px; }
.season-card { display: flex; justify-content: space-between; align-items: center; }
.season-card > div { display: flex; flex-direction: column; gap: 2px; }
.season-me { align-items: flex-end; }
.season-me b { font-family: var(--display); font-size: 28px; }
.btn.share-btn { background: linear-gradient(135deg, #22b8d8, #2a8fd8); border: none; }
.board-row.zone-up { box-shadow: inset 4px 0 0 var(--good); }
.board-row.zone-down { box-shadow: inset 4px 0 0 var(--bad); }
.promo.up { color: var(--good); font-weight: 800; }
.promo.down { color: var(--bad); font-weight: 800; }

/* Shop cosmetics: avatar frames, name colors, titles (ids in src/progression.js) */
@property --frame-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.avatar.framed { border: 3px solid transparent; background: linear-gradient(var(--panel-2), var(--panel-2)) padding-box, var(--frame) border-box; box-shadow: 0 0 14px var(--frame-glow, transparent); }
.avatar.big.framed, .avatar.huge.framed { border-width: 4px; }
.frame-silver { --frame: linear-gradient(135deg, #f4f6fa, #8a93a6, #f4f6fa); }
.frame-ocean { --frame: linear-gradient(135deg, #22d3ee, #2563eb); --frame-glow: rgba(34, 211, 238, 0.35); }
.frame-forest { --frame: linear-gradient(135deg, #a3e635, #15803d); --frame-glow: rgba(46, 204, 113, 0.3); }
.frame-gold { --frame: linear-gradient(135deg, #fff1a8, #f5c542, #b8860b, #f5c542); --frame-glow: rgba(245, 197, 66, 0.45); }
.frame-fire { --frame: conic-gradient(from var(--frame-angle), #ff4d6d, #ffb020, #ffe66d, #ff4d6d); --frame-glow: rgba(255, 120, 60, 0.55); animation: frame-spin 3s linear infinite; }
.frame-neon { --frame: linear-gradient(135deg, #ff2bd6, #7c5cff); --frame-glow: rgba(255, 43, 214, 0.6); animation: frame-glow 1.6s ease-in-out infinite alternate; }
.frame-galaxy { --frame: conic-gradient(from var(--frame-angle), #1e1b4b, #7c5cff, #22d3ee, #f0abfc, #1e1b4b); --frame-glow: rgba(124, 92, 255, 0.55); animation: frame-spin 6s linear infinite; }
.frame-sharpshooter { --frame: conic-gradient(from var(--frame-angle), #ff4d6d 0 25%, #ffffff 0 50%, #ff4d6d 0 75%, #ffffff 0); --frame-glow: rgba(255, 77, 109, 0.5); animation: frame-spin 4s linear infinite; }
.frame-infallible { --frame: conic-gradient(from var(--frame-angle), #ffffff, #a5f3fc, #22d3ee, #ffffff, #fde68a, #ffffff); --frame-glow: rgba(165, 243, 252, 0.9); animation: frame-spin 1.8s linear infinite; }
.frame-centurion { --frame: linear-gradient(135deg, #7f1d1d, #dc2626, #fde68a, #dc2626, #7f1d1d); --frame-glow: rgba(220, 38, 38, 0.55); animation: frame-glow 2s ease-in-out infinite alternate; }
.frame-marathon { --frame: conic-gradient(from var(--frame-angle), #0f766e, #2ecc71, #fde047, #f97316, #0f766e); --frame-glow: rgba(46, 204, 113, 0.6); animation: frame-spin 3.5s linear infinite; }
.frame-devoted { --frame: linear-gradient(135deg, #fbcfe8, #db2777, #7c3aed, #db2777, #fbcfe8); --frame-glow: rgba(219, 39, 119, 0.5); animation: frame-glow 1.4s ease-in-out infinite alternate; }
.frame-rainbow { --frame: conic-gradient(from var(--frame-angle), #ff4d6d, #ffb020, #ffe66d, #2ecc71, #22d3ee, #7c5cff, #ff4d6d); --frame-glow: rgba(255, 255, 255, 0.35); animation: frame-spin 2.5s linear infinite; }
@keyframes frame-spin { to { --frame-angle: 360deg; } }
@keyframes frame-glow { from { box-shadow: 0 0 6px var(--frame-glow); } to { box-shadow: 0 0 20px var(--frame-glow); } }
.name-sky { color: #7dd3fc; }
.name-mint { color: #6ee7b7; }
.name-coral { color: #ff8a7a; }
.name-gold { color: #f5c542; text-shadow: 0 0 10px rgba(245, 197, 66, 0.35); }
.name-sunset, .name-aurora, .name-rainbow, .name-obsidian, .name-infallible { -webkit-background-clip: text; background-clip: text; color: transparent; }
.name-sunset { background-image: linear-gradient(90deg, #ff4d6d, #ffb020); }
.name-aurora { background-image: linear-gradient(90deg, #22d3ee, #2ecc71, #a78bfa); }
.name-obsidian { background-image: linear-gradient(90deg, #6b7280, #f4f4f5, #111827, #a78bfa, #6b7280); background-size: 200% 100%; animation: name-shift 6s linear infinite; }
.name-infallible { background-image: linear-gradient(90deg, #ffffff, #22d3ee, #fde68a, #ffffff); background-size: 200% 100%; animation: name-shift 2.5s linear infinite; }
.name-rainbow { background-image: linear-gradient(90deg, #ff4d6d, #ffb020, #ffe66d, #2ecc71, #22d3ee, #7c5cff, #ff4d6d); background-size: 200% 100%; animation: name-shift 4s linear infinite; }
@keyframes name-shift { to { background-position: 200% 0; } }
.player-title { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-2); }
.shop-me { display: flex; align-items: center; gap: 14px; }
.shop-name { font-size: 16px; padding: 12px 0; }
.shop-title { padding: 14px 0; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .avatar.framed, .name-rainbow, .name-obsidian, .name-infallible { animation: none; }
}
.shop .tabs .tab { padding: 10px 8px; flex: 1; }

/* Category ban before a duel */
.ban-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ban-pick { font-size: 14px; padding: 10px; text-align: left; }
.ban-pick.banned { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 20%, var(--panel)); text-decoration: line-through; }
.ban-result { display: flex; justify-content: space-between; align-items: center; }
#ban-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Duel review */
.review summary { cursor: pointer; font-weight: 700; }
.review-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 14px; }
.review-item { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.review-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.review-item .q-text { font-size: 15px; }
.review-item .q-image { max-height: 140px; }
.review-item .q-image svg { max-height: 140px; }
.review-answers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.review-answers li { padding: 6px 10px; border-radius: 10px; background: var(--panel-2); }
.review-answers li.correct { background: color-mix(in srgb, var(--good) 22%, var(--panel)); }
.review-answers li.wrong { background: color-mix(in srgb, var(--bad) 22%, var(--panel)); }
.review-answers .mark { font-size: 14px; margin-left: 4px; }
.review { text-align: left; }

/* League frames (unlocked by finishing a week in that league) */
.frame-league-silver { --frame: linear-gradient(135deg, #ffffff, #c0c7d1 40%, #6b7280, #c0c7d1); --frame-glow: rgba(192, 199, 209, 0.45); }
.frame-league-gold { --frame: conic-gradient(from var(--frame-angle), #fff4c2, #f5c542, #a8760a, #f5c542, #fff4c2); --frame-glow: rgba(245, 197, 66, 0.6); animation: frame-spin 5s linear infinite; }
.frame-league-emerald { --frame: conic-gradient(from var(--frame-angle), #b9f6ca, #2ecc71, #0b6b3a, #2ecc71, #b9f6ca); --frame-glow: rgba(46, 204, 113, 0.6); animation: frame-spin 5s linear infinite; }
.frame-league-diamond { --frame: conic-gradient(from var(--frame-angle), #ffffff, #5ac8fa, #1e3a8a, #a5f3fc, #ffffff); --frame-glow: rgba(90, 200, 250, 0.75); animation: frame-spin 3s linear infinite; }
.frame-league-master { --frame: conic-gradient(from var(--frame-angle), #f0abfc, #b06cff, #3b0764, #ffd166, #f0abfc); --frame-glow: rgba(176, 108, 255, 0.8); animation: frame-spin 2.5s linear infinite; }
.league-frame-unlock { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; }
.rank.placement { --rank: var(--muted); }
.rank { white-space: nowrap; }

/* Puzzles (fun mode) */
.mode-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.puzzle-kinds { display: grid; gap: 10px; }
.puzzle-kind small + small { margin-top: 4px; }
.cat-puzzle { border-color: #f2b33d; }
.emoji-puzzle { font-size: clamp(44px, 11vw, 84px); line-height: 1.2; letter-spacing: 0.08em; text-align: center; padding: 8px 4px; word-break: break-word; }
.q-image svg.outline-puzzle { height: clamp(150px, 30vh, 280px); color: var(--text); border-radius: 0; box-shadow: none; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45)); }
.puzzle-progress { display: flex; gap: 4px; }
.puzzle-progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--panel-2); }
.puzzle-progress i.good { background: var(--good); }
.puzzle-progress i.bad { background: var(--bad); }
.puzzle-missed { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.puzzle-missed li { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; }
.puzzle-missed .emoji-puzzle { font-size: 28px; padding: 0; }
.puzzle-missed .q-image svg.outline-puzzle { height: 90px; }

/* Rivals */
.h2h-block { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; }
.h2h-line { text-align: center; color: var(--muted); }
.h2h-line b, .h2h-record { font-weight: 800; color: var(--text); }
.h2h-line.lead b, .h2h-record.lead { color: var(--good); }
.h2h-line.behind b, .h2h-record.behind { color: var(--bad); }
.h2h-record { margin-left: auto; font-size: 17px; white-space: nowrap; padding-left: 6px; }
.profile-page .h2h-line { margin-top: -4px; }
#revenge-hint:empty { display: none; }
.revenge-hint { display: flex; align-items: center; gap: 10px; border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.revenge-hint .avatar { position: relative; width: 40px; height: 40px; font-size: 20px; flex: none; }
.revenge-hint > div { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.rivals .chip { font-size: 12px; padding: 3px 8px; white-space: nowrap; }
/* ---------- Daily quests ---------- */
.quests { padding: 14px 16px; }
.quests h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.quests h3 small { margin-left: auto; font-weight: 400; font-size: 12px; }
.quest-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.quest { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; }
.quest-icon { font-size: 20px; text-align: center; }
.quest-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.quest-text { font-size: 14px; line-height: 1.25; }
.quest-progress { display: flex; align-items: center; gap: 8px; }
.quest-progress .progress { flex: 1; height: 6px; }
.quest-progress .progress div { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.quest-progress small { font-size: 11px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.quest.done .quest-progress .progress div { background: var(--good); }
.quest.claimed { opacity: 0.55; }
.quest-reward { font-size: 12px; white-space: nowrap; }
.quest-claimed { color: var(--good); font-weight: 800; font-size: 18px; width: 28px; text-align: center; }
.quest-claim { height: 34px; white-space: nowrap; animation: quest-pulse 1.6s ease-in-out infinite; }
@keyframes quest-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); } }
/* ---------- Community questions ---------- */
.sub-form, .review-card { display: flex; flex-direction: column; gap: 10px; }
.sub-form h4, .review-card h4 { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.sub-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sub-form select, .review-card select, .sub-form textarea, .review-card textarea, .sub-answer input, .rv-note {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; width: 100%; min-width: 0;
}
.sub-form textarea, .review-card textarea { resize: vertical; }
.sub-form :focus, .review-card :focus { outline: none; border-color: var(--accent); }
.sub-lang { display: flex; flex-direction: column; gap: 6px; }
.sub-answer { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 6px; }
.sub-answer > span { font-weight: 800; text-align: center; }
.sub-answer.right > span { color: var(--good); }
.sub-answer.right input { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.sub-answer.wrong > span { color: var(--bad); }
.sub-more summary { cursor: pointer; font-weight: 700; color: var(--muted); font-size: 14px; padding: 4px 0; }
.sub-more[open] summary { margin-bottom: 6px; }
.sub-errors { margin: 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 15%, transparent); color: #ff8fa3; font-size: 14px; }
.sub-errors[hidden] { display: none; }
.sub-status { font-size: 12px; font-weight: 800; white-space: nowrap; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); }
.sub-status.approved { color: var(--good); }
.sub-status.rejected { color: #ff8fa3; }
.sub-status.pending { color: var(--warn); }
.sub-row-item .h-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sub-review-note { font-size: 13px; margin-top: 4px; color: var(--text); opacity: 0.85; }
.review-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.review-card { margin-bottom: 12px; }
/* ---------- Clans ---------- */
.segmented.four { display: flex; gap: 2px; }
.segmented.four .seg { flex: 1 1 auto; padding: 10px 5px; font-size: 12.5px; white-space: nowrap; }
.member-name { display: flex; align-items: center; gap: 4px; min-width: 0; }
.clan-strip { background: linear-gradient(90deg, color-mix(in srgb, var(--accent-2) 10%, var(--panel)), var(--panel)); }
.clan-badge { font-size: 44px; width: 76px; height: 76px; display: grid; place-items: center; flex-shrink: 0; border-radius: 22px; background: var(--panel-2); border: 2px solid color-mix(in srgb, var(--accent-2) 45%, var(--border)); }
.challenge-pop .clan-badge { margin: 0 auto; }
.clan-hero .hero-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.clan-desc { overflow-wrap: anywhere; }
.clan-chip { font: inherit; font-size: 13px; cursor: pointer; align-self: flex-start; margin-top: 2px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.badge-grid .avatar-pick { font-size: 22px; border-radius: 12px; }
.clan-create { display: flex; flex-direction: column; gap: 12px; }
.clan-create h3 { margin: 0; }
.clan-create .field input { font-size: 16px; padding: 10px 12px; }
.clan-page .invite { display: flex; flex-direction: column; gap: 8px; }
.clan-page .invite input { letter-spacing: 0.2em; font-weight: 800; text-align: center; }
.clan-page .board-rating { flex-direction: row; align-items: center; gap: 6px; }
.member-menu { font-size: 18px; padding: 2px 8px; }
.danger-btn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.solo-list { display: flex; flex-direction: column; gap: 10px; }
.btn.solo-mode { flex-direction: row; align-items: center; gap: 14px; }
.solo-mode .mode-icon { margin-bottom: 0; }
.solo-mode span:last-child { display: flex; flex-direction: column; gap: 2px; }
.social-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.social-row .friends-strip { align-items: flex-start; justify-content: space-between; text-align: left; }
.social-row .avatar-stack .avatar { display: none; }

/* Home hero: level (XP) instead of Elo rank */
.level-chip { font-family: var(--display); font-weight: 800; font-size: 15px; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--accent-2) 18%, var(--panel-2)); color: var(--accent-2); }
.xp-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.mode-grid .tile-mode small + small { margin-top: 2px; }

/* Sign-in dialog */
.signin-google { width: 100%; margin-top: 8px; }
.signin-google b { font-family: var(--display); }
.signin-or { text-align: center; margin: 14px 0 8px; }
.signin-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.signin-form .field input { font-size: 16px; padding: 10px 12px; }
.form-msg { min-height: 1em; margin: 0; color: var(--bad, #ff4d6d); }
.form-msg.ok { color: var(--good); }
.verify-box { margin: 10px 0; }

/* Ranked + unranked buttons */
.play-row { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }
.btn.unranked-cta { flex-direction: column; justify-content: center; gap: 0; padding: 10px 16px; border-radius: 22px; background: var(--panel); min-width: 0; text-align: center; }
.unranked-cta span { font-size: 24px; }
.unranked-cta small { color: var(--muted); font-weight: 500; }

/* Rating per day card */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.segmented.mini { padding: 2px; border-radius: 10px; }
.segmented.mini .seg { padding: 4px 8px; font-size: 12px; }
.btn.unranked-cta b, .btn.unranked-cta small { display: block; }
.btn.unranked-cta b { font-size: 13px; }
.btn.unranked-cta small { font-size: 11px; }
