:root {
  color-scheme: dark;
  --bg: #121619;
  --bg-elevated: #171c20;
  --panel: #1d2327;
  --panel-2: #252c31;
  --panel-3: #0f1316;
  --text: #f4f6f7;
  --muted: #97a3aa;
  --line: #30383e;
  --accent: #ef3e42;
  --accent-2: #ff6265;
  --accent-soft: rgba(239, 62, 66, .14);
  --good: #45b883;
  --good-soft: rgba(69, 184, 131, .13);
  --bad: #ef5b5b;
  --bad-soft: rgba(239, 91, 91, .13);
  --gold: #e5b64f;
  --gold-soft: rgba(229,182,79,.10);
  --shadow: 0 16px 44px rgba(0,0,0,.22);
  --nav-bg: rgba(18, 22, 25, .94);
  --hero-grad: radial-gradient(circle at 82% 12%, rgba(239,62,66,.18), transparent 36%), linear-gradient(145deg, #20272b 0%, #171c20 100%);
  --option-hover: #2a3237;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f5;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f7f8;
  --panel-3: #eef0f2;
  --text: #1b2024;
  --muted: #6c767d;
  --line: #dde1e4;
  --accent: #db2f35;
  --accent-2: #ef4a4f;
  --accent-soft: rgba(219,47,53,.09);
  --good: #238b61;
  --good-soft: rgba(35,139,97,.09);
  --bad: #d94646;
  --bad-soft: rgba(217,70,70,.08);
  --gold: #a87512;
  --gold-soft: rgba(168,117,18,.08);
  --shadow: 0 12px 34px rgba(32,39,44,.08);
  --nav-bg: rgba(255,255,255,.94);
  --hero-grad: radial-gradient(circle at 84% 10%, rgba(219,47,53,.12), transparent 38%), linear-gradient(145deg, #ffffff 0%, #f6f7f8 100%);
  --option-hover: #f0f2f4;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html { transition: background .2s ease; }
body { padding: env(safe-area-inset-top) 0 calc(78px + env(safe-area-inset-bottom)); transition: background .2s ease, color .2s ease; }
button { font: inherit; }
button:disabled { opacity: .46; cursor: default; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.muted { color: var(--muted); }
.eyebrow { font-size: 10px; line-height: 1.2; font-weight: 900; letter-spacing: .13em; color: var(--muted); text-transform: uppercase; }
.brand-red { color: var(--accent); }
.tiny-label { font-size: 10px; letter-spacing: .08em; font-weight: 800; }

.shell { width: min(760px, 100%); margin: 0 auto; padding: 12px 18px 24px; }
.topbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-seal { position: relative; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px 5px 11px 5px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px rgba(239,62,66,.22); transform: rotate(-2deg); }
.brand-seal::after { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(255,255,255,.28); border-radius: 8px 3px 8px 3px; }
.brand-seal span { font-family: Georgia, serif; font-size: 22px; font-weight: 900; line-height: 1; transform: rotate(2deg); }
.brand-seal.large { width: 78px; height: 78px; border-radius: 22px 9px 22px 9px; margin: 0 auto 18px; }
.brand-seal.large span { font-size: 44px; }
.player-name { margin-top: 2px; font-size: 17px; font-weight: 850; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.xp-chip { display: flex; align-items: baseline; gap: 5px; min-height: 38px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); font-weight: 900; }
.xp-chip small { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.xp-star { color: var(--gold); }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.04); }
.theme-toggle { font-size: 18px; }

.view { display: none; animation: viewIn .18s ease-out; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hero { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; padding: 20px; background: var(--hero-grad); box-shadow: var(--shadow); }
.hero-watermark { position: absolute; right: 14px; top: -24px; font-family: Georgia, serif; font-size: 142px; font-weight: 900; color: var(--text); opacity: .035; pointer-events: none; transform: rotate(7deg); }
.level-row { position: relative; display: flex; align-items: center; gap: 13px; }
.level-badge { width: 48px; height: 48px; border-radius: 15px 7px 15px 7px; display: grid; place-items: center; background: var(--accent); color: white; font-weight: 950; font-size: 20px; box-shadow: 0 9px 22px rgba(239,62,66,.2); }
.level-row h2 { margin: 2px 0 0; font-size: 21px; letter-spacing: -.025em; }
.league-badge { border: 1px solid color-mix(in srgb, var(--gold) 32%, transparent); background: var(--gold-soft); color: var(--gold); border-radius: 999px; padding: 8px 11px; font-size: 11px; font-weight: 900; }
.progress-track { height: 9px; margin-top: 17px; border-radius: 99px; overflow: hidden; background: var(--panel-3); border: 1px solid color-mix(in srgb, var(--line) 76%, transparent); }
.progress-track.slim { height: 7px; margin: 8px 0 14px; }
.progress-track.micro { height: 6px; margin: 8px 0 0; }
.progress-fill, .knowledge-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .32s ease; }
.knowledge-fill { background: linear-gradient(90deg, var(--gold), #f0cf78); }
.progress-hint { margin-top: 8px; color: var(--muted); font-size: 11px; }

.card { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.knowledge-strip { margin-top: 12px; display: flex; gap: 13px; align-items: center; padding: 13px 14px; }
.knowledge-icon { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-family: Georgia, serif; font-size: 22px; font-weight: 900; }
.knowledge-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.knowledge-line span { color: var(--gold); font-weight: 900; white-space: nowrap; }
.bank-note { margin-top: 7px; font-size: 10px; line-height: 1.35; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 12px 0; }
.metric { min-height: 88px; display: grid; align-content: center; gap: 2px; padding: 11px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.metric-icon { font-size: 16px; }
.metric-value { font-size: 22px; line-height: 1.1; font-weight: 950; letter-spacing: -.03em; }
.metric-label { color: var(--muted); font-size: 9px; line-height: 1.2; }

.primary { width: 100%; border: 0; border-radius: 16px; padding: 14px 16px; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: white; font-weight: 900; cursor: pointer; box-shadow: 0 10px 24px rgba(239,62,66,.18); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary.big { min-height: 64px; }
.sword-button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; text-align: left; }
.sword-button b, .sword-button small { display: block; }
.sword-button b { font-size: 15px; }
.sword-button small { margin-top: 2px; color: rgba(255,255,255,.76); font-size: 10px; font-weight: 700; }
.button-emblem { font-size: 24px; }
.button-arrow { font-size: 28px; font-weight: 300; opacity: .8; }
.section-kicker { display: flex; align-items: center; gap: 10px; margin: 20px 2px 10px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.section-kicker .line { flex: 1; height: 1px; background: var(--line); }

.mode-grid { display: grid; gap: 10px; }
.mode-card { position: relative; display: flex; gap: 13px; align-items: center; min-height: 94px; padding: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); overflow: hidden; }
.mode-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line); }
.daily-card::before { background: #e8ad34; }
.boss-card::before { background: var(--accent); }
.duel-card::before { background: #6f6ee8; }
.mode-icon { flex: 0 0 auto; width: 45px; height: 45px; display: grid; place-items: center; border-radius: 15px; font-size: 23px; background: var(--panel-2); }
.daily-card .mode-icon { background: rgba(232,173,52,.12); }
.boss-card .mode-icon { background: var(--accent-soft); }
.duel-card .mode-icon { background: rgba(111,110,232,.12); }
.mode-card h3 { margin: 3px 0 4px; font-size: 14px; }
.mode-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.mini-action { flex: 0 0 auto; min-width: 68px; border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; background: var(--panel-2); color: var(--text); font-size: 11px; font-weight: 900; cursor: pointer; }
.mini-action.danger { border-color: color-mix(in srgb, var(--accent) 26%, var(--line)); color: var(--accent); background: var(--accent-soft); }
.invite { position: relative; margin-top: 12px; padding: 18px; overflow: hidden; }
.invite-sigil { position: absolute; right: 16px; top: 12px; font-size: 35px; opacity: .12; }
.invite h3 { margin: 5px 0 6px; }
.invite p { font-size: 12px; line-height: 1.45; }

.quiz-head, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.quiz-meta { display: flex; align-items: center; gap: 8px; }
.tag, .difficulty-chip { display: inline-flex; align-items: center; min-height: 27px; border-radius: 999px; padding: 6px 9px; font-size: 9px; font-weight: 900; letter-spacing: .05em; }
.tag { background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.difficulty-chip { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.lives { font-size: 13px; letter-spacing: 1px; }
.round-progress { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px; font-size: 12px; }
.round-progress b { font-size: 21px; }
.slash { padding: 0 2px; color: var(--muted); }
.question-card { border: 1px solid var(--line); border-radius: 24px; padding: 19px 17px 17px; background: var(--panel); box-shadow: var(--shadow); }
.question-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.question-card h2 { margin: 17px 2px 20px; font-size: clamp(21px, 5.2vw, 30px); line-height: 1.14; letter-spacing: -.035em; }
.options { display: grid; gap: 9px; }
.option { width: 100%; display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; min-height: 61px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); color: var(--text); text-align: left; cursor: pointer; transition: transform .1s ease, border-color .12s ease, background .12s ease; }
.option:active:not(:disabled) { transform: scale(.993); }
.option-letter { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--panel-3); color: var(--muted); border: 1px solid var(--line); font-weight: 950; }
.option.correct { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 48%, var(--line)); }
.option.correct .option-letter { background: var(--good); border-color: var(--good); color: white; }
.option.wrong { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 48%, var(--line)); }
.option.wrong .option-letter { background: var(--bad); border-color: var(--bad); color: white; }
.feedback { margin-top: 12px; border: 1px solid var(--line); border-radius: 20px; padding: 16px; background: var(--panel); box-shadow: var(--shadow); }
.feedback-title { font-size: 20px; font-weight: 950; }
.feedback-xp { margin-top: 3px; color: var(--gold); font-size: 12px; font-weight: 900; }
.feedback p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.achievement-toast { border-radius: 13px; padding: 10px 12px; margin: 10px 0; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent); color: var(--gold); font-size: 12px; font-weight: 850; }
.result-card { margin-top: 16px; text-align: center; border: 1px solid var(--line); background: radial-gradient(circle at top, var(--accent-soft), transparent 52%), var(--panel); border-radius: 24px; padding: 28px 20px 20px; box-shadow: var(--shadow); }
.result-icon { font-size: 52px; margin-bottom: 8px; }
.result-card h2 { margin: 5px 0 16px; }
.result-score { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.result-score > * { background: var(--panel-3); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-size: 17px; }

.section-head h2 { margin: 3px 0 0; letter-spacing: -.025em; }
.season-card { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 16px; }
.season-card h3 { color: var(--gold); margin: 2px 0 0; }
.season-card b { display: block; margin-top: 3px; }
.leaderboard { display: grid; gap: 7px; }
.rank-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; border: 1px solid transparent; border-bottom-color: var(--line); padding: 13px 8px; border-radius: 14px; }
.rank-row.me { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.rank-no { font-size: 18px; font-weight: 950; color: var(--muted); }
.rank-name { font-weight: 850; }
.rank-sub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.rank-xp { font-weight: 950; }

.profile-title-row { display: flex; align-items: center; gap: 11px; }
.avatar-fallback { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; background: var(--accent-soft); color: var(--accent); font-family: Georgia, serif; font-size: 24px; font-weight: 900; background-size: cover; background-position: center; }
.profile-summary { display: grid; gap: 12px; padding: 16px; }
.profile-rank { color: var(--accent); font-weight: 950; font-size: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.summary-grid > div { background: var(--panel-3); border: 1px solid var(--line); border-radius: 13px; padding: 11px; }
.summary-grid b, .summary-grid span { display: block; }
.summary-grid span { margin-top: 4px; font-size: 9px; }
.subhead { margin: 22px 0 10px; }
.achievement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.achievement { display: flex; gap: 9px; align-items: center; min-height: 76px; border: 1px solid var(--line); border-radius: 16px; padding: 11px; background: var(--panel); }
.achievement.locked { opacity: .42; filter: grayscale(.9); }
.achievement.unlocked { border-color: color-mix(in srgb, var(--gold) 26%, var(--line)); background: var(--gold-soft); }
.achievement-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; background: var(--panel-3); font-size: 20px; }
.achievement b { display: block; font-size: 12px; }
.achievement span { display: block; color: var(--muted); font-size: 9px; margin-top: 3px; line-height: 1.3; }
.category-stats { display: grid; gap: 13px; }
.category-row { display: grid; gap: 7px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.category-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.category-bar { height: 7px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.category-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.bottom-nav { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: 0; width: min(760px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); background: var(--nav-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
.nav-btn { border: 0; background: transparent; color: var(--muted); padding: 4px 2px; display: grid; gap: 2px; justify-items: center; cursor: pointer; }
.nav-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn small { font-size: 9px; font-weight: 700; }
.nav-btn.active { color: var(--accent); }

.gate { min-height: 78vh; display: grid; place-content: center; text-align: center; padding: 30px; }
.gate h1 { margin: 5px 0 8px; letter-spacing: -.04em; }
.gate p { color: var(--muted); max-width: 330px; line-height: 1.45; }

@media (hover:hover) {
  .option:hover:not(:disabled), .mini-action:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: var(--option-hover); }
}

@media (max-width: 420px) {
  .shell { padding-inline: 14px; }
  .league-badge { padding-inline: 8px; }
  .mode-card { align-items: flex-start; }
  .mini-action { align-self: center; }
  .achievement-grid { grid-template-columns: 1fr; }
  .question-topline { align-items: flex-start; flex-direction: column; }
  .bank-note { display: none; }
}
