/* ==========================================================================
   Kings of Accounting — design system v2
   Dark navy + gold. RTL-first using logical properties.
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #090d1b;
  --bg-2: #0d1326;
  --surface: #121a33;
  --surface-2: #18213f;
  --surface-3: #1f2a4d;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .13);
  --text: #eef0f8;
  --text-2: #c4c9db;
  --muted: #8d96b3;
  --gold: #e7b54b;
  --gold-2: #f6d488;
  --gold-ink: #241a06;
  --gold-soft: rgba(231, 181, 75, .12);
  --green: #3ccf8e;
  --green-soft: rgba(60, 207, 142, .12);
  --red: #f26a72;
  --red-soft: rgba(242, 106, 114, .12);
  --blue: #6ea8ff;
  --blue-soft: rgba(110, 168, 255, .12);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px rgba(0, 0, 0, .28);
  --font: "Vazirmatn", "Vazir", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --tabbar-h: 0px;
}


/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(231, 181, 75, .08), transparent 60%),
    radial-gradient(800px 600px at 0% 0%, rgba(110, 120, 255, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
body.has-tabbar { --tabbar-h: 0px; }
h1, h2, h3 { line-height: 1.35; margin: 0; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(22px, 3vw, 30px); }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { color: #fff; }
small { font-size: 12.5px; }
b, strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 20px; }
.inline { display: inline; margin: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--gold); color: var(--gold-ink); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }

.icon {
  width: 1.15em; height: 1.15em;
  flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.2em;
}
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
main.container { flex: 1; padding-top: 28px; padding-bottom: 48px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(9, 13, 27, .78);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(145deg, var(--gold-2), #b07d22);
  color: var(--gold-ink);
  box-shadow: 0 6px 18px rgba(231, 181, 75, .25);
}
.brand-mark .icon { width: 20px; height: 20px; stroke-width: 2; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark.lg .icon { width: 30px; height: 30px; }
.brand-text { font-size: 16px; direction: ltr; }
.brand-text strong { font-weight: 900; color: var(--gold-2); }
.brand-text span { color: var(--text-2); font-weight: 500; }

.mainnav { display: flex; gap: 4px; margin-inline-start: 8px; }
.mainnav a {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.mainnav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.mainnav a.is-active { background: var(--gold-soft); color: var(--gold-2); }

.topbar-tools { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
.lang-switch { display: flex; padding: 3px; border: 1px solid var(--border-2); border-radius: 10px; }
.lang-switch a { padding: 3px 9px; border-radius: 7px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lang-switch a.is-active { background: var(--surface-3); color: var(--text); }
.coin-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--gold-soft); border: 1px solid rgba(231, 181, 75, .28);
  color: var(--gold-2); font-weight: 700; font-size: 14px;
}
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--border-2);
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-size: 14.5px; font-weight: 700; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, filter .15s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--gold-ink);
  box-shadow: 0 8px 22px rgba(231, 181, 75, .22), 0 1px 0 rgba(255,255,255,.35) inset;
}
.btn-primary:hover { color: var(--gold-ink); filter: brightness(1.06); }
.btn-ghost { background: rgba(255,255,255,.03); border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.07); color: var(--text); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { min-height: 50px; padding: 13px 24px; font-size: 15.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
form.is-busy button { pointer-events: none; opacity: .7; }

.link { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; font-weight: 600; }

/* ---------- Cards & layout ---------- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.split > .section { margin-top: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--gold-2);
  letter-spacing: .02em;
}

/* ---------- Alerts / badges / chips ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; margin-bottom: 18px;
  border-radius: 12px; border: 1px solid; font-size: 14px;
}
.alert > .icon { margin-top: 3px; }
.alert-error   { background: var(--red-soft);   border-color: rgba(242,106,114,.35); color: #ffd4d7; }
.alert-success { background: var(--green-soft); border-color: rgba(60,207,142,.35); color: #c9f6e1; }
.alert-info    { background: var(--blue-soft);  border-color: rgba(110,168,255,.3);  color: #d5e5ff; }
.feedback > div { display: flex; flex-direction: column; gap: 2px; }
.feedback .muted { color: inherit; opacity: .8; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-win     { background: var(--green-soft); color: var(--green); }
.badge-loss    { background: var(--red-soft);   color: var(--red); }
.badge-draw, .badge-neutral { background: rgba(255,255,255,.07); color: var(--text-2); }
.badge-turn    { background: var(--gold-soft);  color: var(--gold-2); }
.badge-wait    { background: var(--blue-soft);  color: var(--blue); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.chip-lg { padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.chip-lg b { color: var(--gold-2); }

/* ---------- Avatars & ranks ---------- */
.avatar-sm, .avatar-md, .avatar-lg {
  display: grid; place-items: center; flex-shrink: 0;
  border-radius: 50%; font-weight: 800;
  background: linear-gradient(145deg, #2c3864, #1c2546);
  border: 1px solid var(--border-2); color: var(--gold-2);
}
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 19px; }
.avatar-md.is-empty { color: var(--muted); border-style: dashed; background: transparent; }
.avatar-lg {
  width: 88px; height: 88px; font-size: 36px; border-radius: 26px;
  background: linear-gradient(145deg, var(--gold-2), #a8761f); color: var(--gold-ink); border: 0;
  box-shadow: 0 12px 30px rgba(231,181,75,.22);
}
.rank {
  display: inline-grid; place-items: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 8px; font-size: 13px; font-weight: 800;
  background: rgba(255,255,255,.05); color: var(--muted);
}
.rank-1 { background: linear-gradient(145deg, #ffe08f, #d39c2b); color: var(--gold-ink); }
.rank-2 { background: linear-gradient(145deg, #e8edf6, #9aa5ba); color: #1d2333; }
.rank-3 { background: linear-gradient(145deg, #f0b98b, #a7663a); color: #2b160a; }

/* ---------- Lists ---------- */
.list { padding: 6px; }
.rank-row, .match-row, .ledger-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px;
}
.rank-row + .rank-row, .match-row + .match-row, .ledger-row + .ledger-row { border-top: 1px solid var(--border); }
.rank-row.is-me { background: var(--gold-soft); }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-xp { font-weight: 700; color: var(--gold-2); }
.rank-xp small, .stat b small { color: var(--muted); font-weight: 600; font-size: 11px; }

.match-row { color: var(--text); transition: background .15s; }
.match-row:hover { background: rgba(255,255,255,.04); color: var(--text); }
.match-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-3); color: var(--gold-2); }
.match-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.match-meta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-meta small { color: var(--muted); }
.match-score { display: flex; gap: 6px; font-weight: 800; color: var(--text-2); }
.match-score i { font-style: normal; color: var(--muted); }
.match-row .chevron { color: var(--muted); }
.ledger-row span:first-child { flex: 1; }
.ledger-row .pos { color: var(--green); }
.ledger-row .neg { color: var(--red); }

.empty { text-align: center; padding: 44px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); color: var(--gold-2); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty .btn { margin-top: 8px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 14px; margin-top: 20px; }
.stats-grid:not(:has(.stat-wide)) { grid-template-columns: repeat(4, 1fr); }
.stat {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.stat-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--gold-soft); color: var(--gold-2); flex-shrink: 0; }
.stat-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat b { font-size: 24px; font-weight: 800; line-height: 1.3; }

.level { margin-top: 10px; width: 100%; }
.level-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; color: var(--text-2); }
.level-top b { color: var(--gold-2); }
.progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
.progress::-webkit-progress-value { background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 99px; }
.progress::-moz-progress-bar { background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 99px; }

/* ---------- Landing ---------- */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; padding: 36px 0 20px; }
.hero h1 { font-size: clamp(30px, 4.6vw, 50px); font-weight: 900; line-height: 1.25; margin: 14px 0 16px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 16.5px; color: var(--text-2); max-width: 560px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-metrics { display: flex; gap: 32px; margin: 36px 0 0; padding-top: 22px; border-top: 1px solid var(--border); }
.hero-metrics div { display: flex; flex-direction: column-reverse; }
.hero-metrics dt { font-size: 12.5px; color: var(--muted); }
.hero-metrics dd { margin: 0; font-size: 26px; font-weight: 800; }
.hero-visual { position: relative; }
.hero-visual::before { content: ""; position: absolute; inset: 10% 5%; background: radial-gradient(closest-side, rgba(231,181,75,.25), transparent); filter: blur(30px); }
.mock-card { position: relative; background: linear-gradient(180deg, var(--surface-3), var(--surface)); border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 24px; box-shadow: 0 30px 60px rgba(0,0,0,.4); transform: rotate(-1.5deg); }
[dir="ltr"] .mock-card { transform: rotate(1.5deg); }
.mock-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.mock-q { font-weight: 700; font-size: 17px; margin: 16px 0 14px; }
.mock-opt { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border-2); border-radius: 12px; margin-top: 8px; font-size: 14px; }
.mock-opt b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3); font-size: 12px; }
.mock-opt.is-right { border-color: rgba(60,207,142,.5); background: var(--green-soft); }
.mock-opt.is-right b { background: var(--green); color: #052b1a; }
.mock-opt .icon { margin-inline-start: auto; color: var(--green); }

.feature { display: flex; flex-direction: column; gap: 10px; }
.feature p { color: var(--text-2); font-size: 14px; }
.feature-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--gold-soft); color: var(--gold-2); }
.feature-icon .icon { width: 22px; height: 22px; }

/* ---------- Dashboard CTA ---------- */
.cta-card {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 28px 30px;
  background:
    radial-gradient(600px 220px at 100% 0%, rgba(231,181,75,.16), transparent 70%),
    linear-gradient(180deg, var(--surface-3), var(--surface));
  border-color: rgba(231,181,75,.18);
}
[dir="rtl"] .cta-card { background: radial-gradient(600px 220px at 0% 0%, rgba(231,181,75,.16), transparent 70%), linear-gradient(180deg, var(--surface-3), var(--surface)); }
.cta-copy h1 { margin: 6px 0 4px; }
.cta-actions form { margin: 0; }

/* ---------- Match ---------- */
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 18px 22px; margin-bottom: 18px; }
.vs-player { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vs-player > div { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.vs-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-opp { flex-direction: row-reverse; text-align: end; }
.vs-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vs-label { font-size: 12px; color: var(--muted); }
.vs-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--gold-soft); color: var(--gold-2); }
.vs-score { display: flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 900; }
.vs-score i { font-style: normal; color: var(--muted); }

.question-card { padding: 28px; }
.question-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.timer { display: flex; align-items: center; gap: 10px; margin: -6px 0 18px; color: var(--text-2); }
.timer-icon { display: grid; place-items: center; }
.timer-track { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.timer-fill { display: block; width: 100%; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .25s linear; }
.timer-num { min-width: 44px; text-align: end; font-weight: 800; font-size: 15px; color: var(--text); }
.timer.is-low, .timer.is-low .timer-num { color: var(--red); }
.timer.is-low .timer-fill { background: var(--red); }
.timer.is-low .timer-num { animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: .45; } }
.timer.is-over + .question-top ~ .choices .choice, form.choices.is-busy .choice { opacity: .6; }
.tiebreak { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; background: var(--gold-soft); color: var(--gold-2); font-size: 13.5px; }
.result-times { display: flex; gap: 28px; margin: 6px 0 0; }
.result-times div { display: flex; flex-direction: column; align-items: center; }
.result-times dt { font-size: 12.5px; color: var(--muted); }
.result-times dd { margin: 0; font-size: 20px; font-weight: 800; }
.review-time { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: auto; color: var(--muted); }
.question-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.diff-1 { color: var(--green); border-color: rgba(60,207,142,.3); }
.chip.diff-2 { color: var(--gold-2); border-color: rgba(231,181,75,.3); }
.chip.diff-3 { color: var(--red); border-color: rgba(242,106,114,.35); }
.steps { display: flex; gap: 6px; margin: 16px 0 22px; }
.steps i { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-3); }
.steps i.current { background: var(--gold); }
.steps i.done, .steps i.ok { background: var(--green); }
.steps i.bad { background: var(--red); }
.question-text { font-size: clamp(19px, 2.4vw, 24px); font-weight: 800; margin-bottom: 22px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 15px 16px; min-height: 64px;
  text-align: start; font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px;
  cursor: pointer; transition: border-color .15s, background .15s, transform .12s;
}
.choice:hover { border-color: rgba(231,181,75,.6); background: var(--surface-2); transform: translateY(-1px); }
.choice-key {
  display: grid; place-items: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--surface-3); color: var(--gold-2); font-weight: 800; font-size: 13px;
}
.choice.is-picked { border-color: var(--gold); background: var(--gold-soft); }
.choice:hover .choice-key, .choice.is-picked .choice-key { background: var(--gold); color: var(--gold-ink); }
.hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.hint.center { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; }

.result { text-align: center; padding: 36px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.result-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 20px; background: var(--surface-3); color: var(--gold-2); }
.result-icon .icon { width: 32px; height: 32px; }
.result.is-win { border-color: rgba(60,207,142,.35); background: radial-gradient(500px 200px at 50% 0%, rgba(60,207,142,.14), transparent), linear-gradient(180deg, var(--surface-2), var(--surface)); }
.result.is-win .result-icon { background: var(--green-soft); color: var(--green); }
.result.is-loss .result-icon { background: var(--red-soft); color: var(--red); }
.result p { max-width: 520px; }
.result-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }

.review { display: grid; gap: 12px; }
.review-item { padding: 18px 20px; border-inline-start: 3px solid var(--border-2); }
.review-item.is-ok { border-inline-start-color: var(--green); }
.review-item.is-bad { border-inline-start-color: var(--red); }
.review-head { display: flex; align-items: center; gap: 10px; font-size: 12.5px; margin-bottom: 8px; }
.review-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; }
.is-ok .review-mark { background: var(--green-soft); color: var(--green); }
.is-bad .review-mark { background: var(--red-soft); color: var(--red); }
.review-answers { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 10px 0 0; font-size: 14px; }
.review-answers div { display: flex; gap: 6px; }
.review-answers dt { color: var(--muted); }
.review-answers dt::after { content: ":"; }
.review-answers dd { margin: 0; }
.review-answers .is-correct dd { color: var(--green); }
.explain { display: flex; gap: 8px; margin-top: 12px; padding: 10px 12px; background: rgba(255,255,255,.03); border-radius: 10px; font-size: 13.5px; color: var(--text-2); }
.explain .icon { margin-top: 3px; color: var(--gold-2); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  width: 100%; padding: 11px 13px;
  font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(231,181,75,.18); }
input:disabled { opacity: .6; }
textarea { resize: vertical; min-height: 64px; }
select { cursor: pointer; }
.input-group { display: flex; position: relative; }
.input-group input { padding-inline-end: 72px; }
.input-addon { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--gold-2); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 6px 8px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }
.lang-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lang-col { border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lang-col legend { padding: 0 8px; font-weight: 800; color: var(--gold-2); }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.field-inline label.choice-key { color: var(--gold-2); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
.toolbar select { width: auto; }

/* ---------- Auth ---------- */
.auth { display: grid; place-items: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 430px; padding: 32px; }
.auth-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 24px; }
.auth-head h1 { font-size: 24px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: var(--muted); }

/* ---------- Profile ---------- */
.profile-hero { display: flex; align-items: center; gap: 24px; padding: 28px; }
.profile-info { flex: 1; min-width: 0; }
.profile-info h1 { margin: 4px 0 0; }
.profile-info .level { max-width: 380px; }
.profile-rank { display: flex; flex-direction: column; align-items: center; padding: 14px 22px; border-radius: 14px; background: var(--gold-soft); }
.profile-rank b { font-size: 28px; color: var(--gold-2); }

/* ---------- Leaderboard ---------- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; max-width: 620px; margin: 0 auto 26px; }
.podium-item { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.podium-item strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-block { width: 100%; margin-top: 8px; border-radius: 14px 14px 6px 6px; display: grid; place-items: center; font-size: 28px; font-weight: 900; border: 1px solid var(--border-2); }
.place-1 .podium-block { height: 130px; background: linear-gradient(180deg, rgba(246,212,136,.35), rgba(231,181,75,.06)); color: var(--gold-2); }
.place-2 .podium-block { height: 96px; background: linear-gradient(180deg, rgba(220,228,240,.22), rgba(220,228,240,.04)); }
.place-3 .podium-block { height: 74px; background: linear-gradient(180deg, rgba(240,185,139,.25), rgba(240,185,139,.04)); }
.place-1 .avatar-md { width: 60px; height: 60px; border-color: var(--gold); }

.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table tr.is-me { background: var(--gold-soft); }
.table tr.is-muted td { opacity: .55; }
.table .end { text-align: end; }
.table .w-rank { width: 60px; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-question { min-width: 260px; }
.pager { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.pager a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border-2); color: var(--text-2); font-size: 13px; }
.pager a.is-active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 800; }

/* ---------- Store ---------- */
.pack { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 28px 20px 20px; }
.pack.is-featured { border-color: rgba(231,181,75,.4); }
.pack-tag { position: absolute; top: -11px; padding: 2px 12px; border-radius: 99px; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 800; }
.pack-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--gold-soft); color: var(--gold-2); margin-bottom: 8px; }
.pack-icon .icon { width: 26px; height: 26px; }
.pack h2 { font-size: 30px; font-weight: 900; }
.pack-price { margin: 12px 0 16px; font-size: 14px; color: var(--text-2); }
.pack-price b { font-size: 18px; color: var(--text); }

/* ---------- Footer & tab bar ---------- */
.footer { border-top: 1px solid var(--border); padding: 22px 0; color: var(--muted); font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-brand { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-2); font-weight: 700; direction: ltr; }
.tabbar { display: none; }

/* ---------- Fatal page ---------- */
.fatal { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.fatal .card { max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.fatal-code { font-size: 54px; font-weight: 900; line-height: 1; background: linear-gradient(90deg, var(--gold-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding-top: 16px; }
  .hero-visual { max-width: 460px; }
  .split { grid-template-columns: 1fr; gap: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); row-gap: 24px; }
  .stats-grid, .stats-grid:not(:has(.stat-wide)) { grid-template-columns: repeat(3, 1fr); }
  .stat-wide { grid-column: 1 / -1; }
  .stats-grid:not(:has(.stat-wide)) { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .mainnav { display: none; }
  body.has-tabbar { --tabbar-h: 64px; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(12, 17, 34, .92);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.is-active { color: var(--gold-2); }
  .grid-3 { grid-template-columns: 1fr; }
  .lang-columns, .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .container { padding-inline: 16px; }
  main.container { padding-top: 18px; }
  .topbar-inner { height: 58px; gap: 10px; }
  .brand-text span { display: none; }
  .hide-xs { display: none; }
  .card { padding: 18px; }
  .cta-card { padding: 22px; }
  .cta-actions, .cta-actions form, .cta-actions .btn { width: 100%; }
  .choices { grid-template-columns: 1fr; }
  .question-card { padding: 20px; }
  .versus { grid-template-columns: 1fr auto 1fr; padding: 14px; gap: 8px; }
  .vs-player { flex-direction: column; text-align: center; gap: 6px; }
  .vs-opp { flex-direction: column; text-align: center; }
  .vs-player small { font-size: 11px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stats-grid:not(:has(.stat-wide)) { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 14px; gap: 10px; flex-direction: column; }
  .stat-wide { flex-direction: row; }
  .stat b { font-size: 20px; }
  .profile-hero { flex-direction: column; text-align: center; }
  .profile-info .level { margin-inline: auto; }
  .hero-metrics { gap: 20px; }
  .hero-metrics dd { font-size: 21px; }
  .match-score { display: none; }
  .podium-block { font-size: 22px; }
  .place-1 .podium-block { height: 100px; }
  .place-2 .podium-block { height: 74px; }
  .place-3 .podium-block { height: 56px; }
  .auth-card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
