:root {
  --bg: #0a0f1d;
  --bg-2: #0f1628;
  --panel: #131c33;
  --panel-2: #18233f;
  --line: #24314f;
  --line-2: #31406a;
  --text: #e8ecf6;
  --muted: #8f9bb8;
  --gold: #f5b942;
  --gold-2: #ffd27a;
  --teal: #2dd4bf;
  --ally: #4f9dff;
  --enemy: #ff5d6c;
  --win: #34d399;
  --loss: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(79, 157, 255, .12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(245, 185, 66, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body.in-match { overflow: hidden; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 650; }
.center { text-align: center; justify-content: center; }
.right { text-align: right; white-space: nowrap; }
.grow { flex: 1; }
.gold { color: var(--gold); }
.win { color: var(--win); }
.loss { color: var(--loss); }
.sep { color: var(--line-2); margin: 0 .4em; }
.clamp { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 24px;
  background: rgba(10, 15, 29, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.1rem; letter-spacing: .02em; white-space: nowrap; }
.nav a, .btn { white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 600; }
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--gold); }
.nav .admin-link { color: var(--gold); }
.stats-pill { display: flex; align-items: center; gap: 2px; font-size: .82rem; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.userbox { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.user-chip:hover { text-decoration: none; border-color: var(--line-2); }
.user-name { font-weight: 650; }

/* ---------- layout ---------- */
.view { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.notice { background: rgba(245, 185, 66, .08); border: 1px solid rgba(245, 185, 66, .3); border-radius: 10px; padding: 10px 14px; color: var(--gold-2); }
.error-panel { border-color: var(--loss); }
.two-col { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 700; color: var(--gold); margin-bottom: .5em; }
.link { color: var(--gold-2); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  color: var(--text); background: var(--panel-2);
  transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .answer:focus-visible, .tab:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1b1300; box-shadow: 0 4px 18px rgba(245, 185, 66, .25); }
.btn-teal { background: linear-gradient(180deg, #5eead4, var(--teal)); color: #032620; }
.btn-outline { background: transparent; border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-danger { background: rgba(248, 113, 113, .12); color: var(--loss); border-color: rgba(248, 113, 113, .35); }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .88rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 185, 66, .15); }
textarea { resize: vertical; }
.form-error { color: var(--loss); min-height: 1.2em; margin: 0; font-size: .9rem; }
.inline-form { display: flex; gap: 10px; align-items: flex-start; }

.tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tab { flex: 1; text-align: center; font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px 14px; border-radius: 7px; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--gold); }
.tabs-lg { align-self: flex-start; }
.tabs-lg .tab { min-width: 90px; }

/* ---------- tiers ---------- */
.tier { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 3px 10px 3px 6px; border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line-2); white-space: nowrap; }
.tier b { color: var(--text); font-weight: 800; }
.tier-gem { width: 12px; height: 12px; transform: rotate(45deg); border-radius: 2px; background: currentColor; box-shadow: 0 0 8px currentColor; }
.tier-iron { color: #9aa3b5; }
.tier-bronze { color: #d08a52; }
.tier-silver { color: #c9d3e6; }
.tier-gold { color: #f5c542; }
.tier-platinum { color: #3fd6c0; }
.tier-diamond { color: #7fb4ff; }
.tier-master { color: #c084fc; }

/* ---------- auth ---------- */
.auth-page { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; min-height: 70vh; }
.hero h1 { font-size: clamp(2rem, 4vw, 3rem); }
.lead { font-size: 1.1rem; color: #c5cde0; max-width: 52ch; }
.hero-points { padding: 0; list-style: none; display: grid; gap: 10px; margin: 18px 0 22px; }
.hero-points li { padding-left: 26px; position: relative; color: #c5cde0; }
.hero-points li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; transform: rotate(45deg); background: var(--gold); border-radius: 2px; }
.auth-card { max-width: 420px; width: 100%; justify-self: end; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- play ---------- */
.topic-pick { min-width: 260px; }
.arena-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.casual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: stretch; }
.section-title { margin: 6px 0 -4px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.arena { display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.arena::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; }
.arena-1v1::before { background: linear-gradient(90deg, var(--gold), transparent); }
.arena-2v2::before { background: linear-gradient(90deg, var(--teal), transparent); }
.arena-10v10::before { background: linear-gradient(90deg, var(--ally), transparent); }
.arena p { margin: 0; }
.arena-head { display: flex; align-items: center; gap: 10px; }
.arena-head h2 { margin: 0; }
.bracket-tag { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line-2); color: var(--gold-2); }
.bracket-tag.sm { font-size: .68rem; padding: 1px 6px; }
.arena-rating { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 12px; border-radius: 10px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.record { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.record b { color: var(--text); }
.record .win b { color: var(--win); }
.record .loss b { color: var(--loss); }
.team-link { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.empty-team { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px dashed var(--line-2); border-radius: 10px; text-align: center; color: var(--muted); }

.lobby { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.lobby-member { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, .02); }
.lm-name { flex: 1; font-weight: 600; }
.lm-status { font-size: .78rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4b5672; flex: none; }
.dot-online, .st-online .dot { background: var(--gold); }
.st-ready .dot { background: var(--win); box-shadow: 0 0 8px var(--win); }
.st-ready .lm-status { color: var(--win); }
.st-busy .dot { background: var(--ally); }
.st-offline { opacity: .55; }
.crown { color: var(--gold); margin-left: 6px; }

.queue-box { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 10px; border: 1px solid rgba(45, 212, 191, .4); background: rgba(45, 212, 191, .07); }
.queue-box > div:nth-child(2) { flex: 1; }
.queue-meta { font-size: .85rem; color: var(--teal); font-variant-numeric: tabular-nums; }
.radar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--teal); position: relative; flex: none; }
.radar::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--teal); animation: ping 1.4s ease-out infinite; }
@keyframes ping { from { transform: scale(1); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }

.how-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: #c5cde0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid rgba(36, 49, 79, .6); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.table tr.mine { background: rgba(245, 185, 66, .07); box-shadow: inset 3px 0 0 var(--gold); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td .btn + .btn { margin-left: 6px; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.lb .pos { font-weight: 800; color: var(--muted); width: 40px; }
.lb .pos-1 { color: #ffd27a; }
.lb .pos-2 { color: #d6deee; }
.lb .pos-3 { color: #e3a26b; }

.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recent li { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(0, 0, 0, .2); border-radius: 8px; }
.recent .r-name:first-child { text-align: right; }
.recent .r-name.win { color: var(--win); font-weight: 700; }
.recent .r-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.recent .r-meta { grid-column: 1 / -1; text-align: center; }

.result { display: inline-block; width: 26px; text-align: center; font-weight: 800; border-radius: 6px; }
.result-W { background: rgba(52, 211, 153, .15); color: var(--win); }
.result-L { background: rgba(248, 113, 113, .15); color: var(--loss); }
.result-D { background: rgba(255, 255, 255, .08); color: var(--muted); }

/* ---------- teams & profile ---------- */
.my-team h2 { font-size: 1.4rem; }
.my-team { display: flex; flex-direction: column; gap: 10px; }
.my-team p { margin: 0; }
.pending { margin-top: 16px; }
.pending ul { margin: 0; padding-left: 18px; }
.team-hero { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.team-hero h1 { margin: 10px 0 6px; }
.team-stats { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.requests { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.requests li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(0, 0, 0, .2); border-radius: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stat-card h3 { margin: 4px 0 0; }
.stat-card p { margin: 0; }

/* ---------- match overlay ---------- */
.match-layer {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(79, 157, 255, .18), transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(255, 93, 108, .16), transparent 60%),
    var(--bg);
}
.match { max-width: 980px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.match-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.ms-side { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.ms-side.ms-right { flex-direction: row-reverse; text-align: right; }
.ms-side.ally { border-color: rgba(79, 157, 255, .5); box-shadow: inset 4px 0 0 var(--ally); }
.ms-side.enemy { border-color: rgba(255, 93, 108, .45); box-shadow: inset -4px 0 0 var(--enemy); }
.ms-name { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-score { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.ally .ms-score { color: var(--ally); }
.enemy .ms-score { color: var(--enemy); }
.ms-center { text-align: center; }
.ms-topic { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.ms-q { font-weight: 800; white-space: nowrap; }

.timerbar { position: relative; height: 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); overflow: visible; }
.timer-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .1s linear; }
.timer-fill.low { background: linear-gradient(90deg, var(--enemy), #ff9a5d); }
.ph-reveal .timer-fill, .ph-countdown .timer-fill { background: var(--line-2); }
.timer-text { position: absolute; right: 0; top: 14px; font-size: .85rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

.countdown { text-align: center; padding: 30px 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: start; width: 100%; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.vs-side.ally { border-color: rgba(79, 157, 255, .5); }
.vs-side.enemy { border-color: rgba(255, 93, 108, .45); }
.vs-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 20px; }
.vs { font-size: 2.4rem; font-weight: 900; color: var(--gold); text-shadow: 0 0 24px rgba(245, 185, 66, .5); }
.count { font-size: 3rem; font-weight: 900; font-variant-numeric: tabular-nums; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.roster { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.roster li { padding: 3px 10px; border-radius: 999px; font-size: .85rem; background: rgba(255, 255, 255, .05); }
.roster.ally li { color: #b9d7ff; }
.roster.enemy li { color: #ffc0c6; }

.qbody { display: flex; flex-direction: column; gap: 18px; }
.qtext { font-size: clamp(1.25rem, 2.6vw, 1.75rem); text-align: center; margin: 18px auto 4px; max-width: 34ch; line-height: 1.3; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  font: inherit; font-size: 1.02rem; font-weight: 600; color: var(--text);
  padding: 16px 18px; min-height: 76px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line-2);
  transition: transform .1s ease, border-color .15s ease, background .15s ease, opacity .2s;
}
.answer:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-2px); }
.answer:disabled { cursor: default; }
.answer .letter { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--bg); border: 1px solid var(--line-2); font-weight: 900; color: var(--gold-2); }
.answer .opt { flex: 1; }
.answer.picked { border-color: var(--gold); background: rgba(245, 185, 66, .1); }
.answer.correct { border-color: var(--win); background: rgba(52, 211, 153, .14); animation: pop .35s ease; }
.answer.correct .letter { background: var(--win); color: #03261a; border-color: var(--win); }
.answer.wrong { border-color: var(--loss); background: rgba(248, 113, 113, .13); animation: shake .35s ease; }
.answer.wrong .letter { background: var(--loss); color: #2b0507; border-color: var(--loss); }
.answer.dim { opacity: .45; }
@keyframes pop { 50% { transform: scale(1.03); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.pickers { position: absolute; right: 10px; bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
.pk { font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.pk.ally { background: rgba(79, 157, 255, .25); color: #cfe3ff; }
.pk.enemy { background: rgba(255, 93, 108, .25); color: #ffd3d7; }

.feedback { text-align: center; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.feedback p { margin: 6px 0 0; color: #c5cde0; }
.feedback.good { border-color: rgba(52, 211, 153, .5); }
.feedback.good strong { color: var(--win); font-size: 1.1rem; }
.feedback.bad { border-color: rgba(248, 113, 113, .45); }
.feedback.bad strong { color: var(--loss); font-size: 1.1rem; }
.feedback.wait { color: var(--muted); }

.answered-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answered { display: flex; flex-wrap: wrap; gap: 6px; }
.answered.enemy { justify-content: flex-end; }
.chip { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.chip.st-done { color: var(--text); border-color: var(--gold); }
.chip.st-right { color: var(--win); border-color: rgba(52, 211, 153, .6); }
.chip.st-miss { color: var(--loss); border-color: rgba(248, 113, 113, .5); }
.chip.st-none { opacity: .55; }

.end { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 0; text-align: center; }
.end-title { font-size: clamp(2.6rem, 8vw, 4.5rem); font-weight: 900; letter-spacing: .04em; text-transform: uppercase; animation: rise .5s ease; }
.end-victory .end-title { color: var(--gold); text-shadow: 0 0 40px rgba(245, 185, 66, .5); }
.end-defeat .end-title { color: var(--enemy); text-shadow: 0 0 40px rgba(255, 93, 108, .35); }
.end-draw .end-title { color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.95); } }
.end-mmr { font-size: 1.5rem; font-weight: 800; }
.final { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; margin-top: 10px; text-align: left; }
.final-side { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.final-side.ally { border-color: rgba(79, 157, 255, .5); }
.final-side.enemy { border-color: rgba(255, 93, 108, .45); }
.final-side h3 { display: flex; justify-content: space-between; gap: 10px; }
.final-score { font-variant-numeric: tabular-nums; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 600; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-error { border-color: var(--loss); }
.toast-success { border-color: var(--win); }
.toast-warn { border-color: var(--gold); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .arena-grid, .stat-grid, .stat-grid.three, .casual-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 1180px) {
  .stats-pill { display: none !important; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; gap: 0; }
  .nav a { padding: 6px 9px; font-size: .9rem; }
  .userbox { margin-left: auto; }
  .user-chip .user-name { display: none; }
  .view { padding: 20px 16px 50px; }
  .arena-grid, .stat-grid, .stat-grid.three, .casual-grid, .auth-page, .final, .answered-wrap { grid-template-columns: 1fr; }
  .auth-card { justify-self: stretch; max-width: none; }
  .auth-page { gap: 24px; min-height: 0; }
  .topic-pick { min-width: 0; width: 100%; }
  .answers { grid-template-columns: 1fr; }
  .answer { min-height: 60px; padding: 12px 14px; }
  .match { padding: 12px 16px 30px; }
  .match-head { grid-template-columns: 1fr 1fr; }
  .ms-center { grid-column: 1 / -1; grid-row: 1; }
  .ms-side { padding: 8px 10px; }
  .ms-score { font-size: 1.3rem; }
  .versus { grid-template-columns: 1fr; gap: 12px; }
  .vs-mid { padding-top: 0; }
  .answered.enemy { justify-content: flex-start; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .team-stats { align-items: flex-start; }
}
/* ---------- achievements ---------- */
.ach-badge {
  flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  font-size: 1.6rem; line-height: 1; border: 2px solid currentColor;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .18), rgba(0, 0, 0, .25));
  box-shadow: 0 0 18px -4px currentColor;
}
.ach-badge.sm { width: 36px; height: 36px; font-size: 1.1rem; border-radius: 10px; }
.tier-bg-bronze { color: #d08a52; }
.tier-bg-silver { color: #c9d3e6; }
.tier-bg-gold { color: #f5c542; }
.ach-badge.locked { color: #3a4566; box-shadow: none; filter: grayscale(1); opacity: .55; }
.ach-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ach-head h2 { margin: 0; }
.ach-streaks { display: flex; gap: 16px; flex-wrap: wrap; }
.ach-streaks b { color: var(--text); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ach-card { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: 12px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.ach-card.unlocked { border-color: rgba(245, 185, 66, .35); background: linear-gradient(135deg, rgba(245, 185, 66, .08), rgba(0, 0, 0, .2)); }
.ach-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ach-name { font-weight: 800; }
.ach-card.locked .ach-name { color: var(--muted); }
.ach-progress { display: flex; align-items: center; gap: 8px; }
.ach-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.ach-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 999px; }
.ach-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.ach-date { color: var(--gold-2); }
.ach-toast { display: flex; align-items: center; gap: 10px; }
.ach-toast small { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); }
.toast-achievement { border-color: var(--gold); background: linear-gradient(135deg, #2a2210, var(--panel-2)); animation: rise .4s ease; }
.end-ach { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.end-ach-mine { padding: 14px 18px; border-radius: 14px; border: 1px solid rgba(245, 185, 66, .45); background: rgba(245, 185, 66, .07); }
.end-ach-mine .eyebrow { margin-bottom: 10px; }
.end-ach-list { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.end-ach-item { display: flex; align-items: center; gap: 10px; text-align: left; animation: rise .5s ease; }

/* ---------- casual: practice, rooms, challenges ---------- */
.arena-casual::before { background: linear-gradient(90deg, #a78bfa, transparent); }
.arena-flexi::before { background: linear-gradient(90deg, #f472b6, transparent); }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; }
.room-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
.room-code { font-size: 3.4rem; font-weight: 900; letter-spacing: .25em; color: var(--gold); line-height: 1.1; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.room-link { font-size: .85rem; color: var(--muted); }
.room-side { display: flex; flex-direction: column; gap: 10px; }
.room-topic { color: var(--text); font-weight: 700; padding: 10px 0; }
.room-players { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.room-players li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); }
.room-players li.st-offline { opacity: .5; }
.challenges { position: fixed; top: 74px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.challenge-card { padding: 14px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; animation: rise .3s ease; }
.challenge-card.incoming { border-color: var(--gold); background: linear-gradient(135deg, #2a2210, var(--panel-2)); }
.ch-title { font-weight: 800; color: var(--gold-2); }
.challenge-box { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.challenge-box select { width: auto; }
.player-hero { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.player-hero h1 { margin: 0 0 6px; }
.ach-grid.compact { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ach-grid.compact .ach-card { padding: 10px; gap: 10px; align-items: center; }
.ms-side.ffa { border-color: rgba(167, 139, 250, .5); box-shadow: inset -4px 0 0 #a78bfa; }
.ms-side.ffa .ms-score { color: #c4b5fd; }
.answered-wrap.single { grid-template-columns: 1fr; }
.ranking { width: 100%; max-width: 560px; padding: 12px; }
.ranking .place { font-size: 1.1rem; width: 60px; }

/* ---------- question review ---------- */
.review { width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.review summary { cursor: pointer; font-weight: 800; color: var(--gold-2); }
.review-list { margin: 14px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; }
.review-item { padding-left: 4px; }
.review-q { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; }
.review-mark { flex: none; font-weight: 900; }
.review-item.ok .review-mark { color: var(--win); }
.review-item.bad .review-mark { color: var(--loss); }
.review-opts { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.review-opts li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0, 0, 0, .15); font-size: .92rem; }
.review-opts .letter { font-weight: 900; color: var(--muted); width: 14px; }
.review-opts li.is-correct { border-color: rgba(52, 211, 153, .6); background: rgba(52, 211, 153, .1); }
.review-opts li.is-correct .letter { color: var(--win); }
.review-opts li.is-wrong { border-color: rgba(248, 113, 113, .55); background: rgba(248, 113, 113, .1); }
.review-opts .tag { margin-left: auto; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.review-expl { color: #c5cde0; font-size: .9rem; margin: 6px 0; }
.review-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.report-form select, .report-form input { width: auto; padding: 6px 8px; font-size: .85rem; }
@media (max-width: 720px) {
  .review-opts { grid-template-columns: 1fr; }
  .room-hero { grid-template-columns: 1fr; }
  .room-code { font-size: 2.6rem; }
  .challenges { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; }
}

/* Connection warning stays visible on every screen size. */
.stats-pill.offline { display: flex !important; color: var(--gold-2); border-color: rgba(245, 185, 66, .5); }
.dot-wait { background: var(--gold); animation: blink 1s ease-in-out infinite; margin-right: 6px; }
@keyframes blink { 50% { opacity: .25; } }
@media (max-width: 720px) {
  .stats-pill.offline { order: 2; flex-basis: 100%; justify-content: center; }
}

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

/* ---------- accounts: email confirmation, password reset, profile account panel ---------- */
.form-ok { color: var(--win); min-height: 1.2em; margin: 0; font-size: .9rem; }
.auth-fields { display: flex; flex-direction: column; gap: 14px; }
.auth-footer { text-align: center; }
.auth-footer p { margin: 0; }
.auth-form h2 { margin: 0; }
.confirm-box { text-align: center; align-items: center; }
.confirm-box p { margin: 0; }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800;
  color: var(--gold-2); background: rgba(245, 185, 66, .1); border: 1px solid rgba(245, 185, 66, .35); }
.confirm-icon.bad { color: var(--loss); background: rgba(255, 90, 90, .08); border-color: rgba(255, 90, 90, .35); }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 8px; }
.account-panel .notice { margin: 0 0 4px; }
@media (max-width: 720px) { .account-grid { grid-template-columns: 1fr; } }

/* ---------- footer, privacy notice, delete-account zone ---------- */
.site-footer { max-width: 1180px; margin: 0 auto; padding: 20px 16px 28px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.site-footer p { margin: 0 0 6px; }
.prose { line-height: 1.6; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.privacy-sec + .privacy-sec { margin-top: 18px; }
.privacy-sec h2 { font-size: 1.1rem; margin-bottom: 6px; }
.privacy-sec p { margin: 0; }
.danger-zone { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.danger-zone summary { cursor: pointer; font-weight: 700; color: var(--loss); }
.danger-zone[open] summary { margin-bottom: 8px; }
.danger-zone .stack { max-width: 360px; }
