/* =========================================================
   کوییز لند — Telegram style (جایگزین style.css و theme.css)
   فونت: Vazirmatn را در پوشه fonts/ بگذار (Vazirmatn-Variable.woff2)
========================================================= */

@font-face {
    font-family: "Vazirmatn";
    src: local("Vazirmatn"), url("fonts/Vazirmatn-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --c: 42, 171, 238;
    --ok: 76, 217, 130;
    --bad: 255, 91, 107;
    --gold: 255, 197, 66;
    --bg: #0e1621;
    --panel: #17212b;
    --panel2: #1f2c3a;
    --line: rgba(255, 255, 255, 0.07);
    --muted: #8b9bb0;
    --font: "Vazirmatn", "Segoe UI", Tahoma, -apple-system, Roboto,
        "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; min-height: 100%; }

body {
    font-family: var(--font);
    direction: rtl;
    color: #fff;
    background: var(--bg);
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(75% 38% at 50% 0%, rgba(var(--c), 0.18), transparent 72%);
}

button { font-family: inherit; border: 0; outline: none; cursor: pointer; color: inherit; background: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input { font-family: inherit; outline: none; border: 0; }
.hidden { display: none !important; }

.app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px calc(32px + env(safe-area-inset-bottom, 0px));
}

section > * + * { margin-top: 14px; }

h1, h2, h3, strong { font-weight: 800; }

/* ---------- HOME HEADER ---------- */
.home-header { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; font-size: 26px; background: linear-gradient(135deg, #2aabee, #7b6cff); }
.brand-text h1 { font-size: 23px; }
.brand-text span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.lb-button { display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 13px; border-radius: 21px; background: var(--panel); border: 1px solid var(--line); font-size: 18px; transition: transform 0.15s; }
.lb-button strong { font-size: 14px; color: rgb(var(--gold)); }
.lb-button:active { transform: scale(0.94); }

/* ---------- HERO ---------- */
.hero-card { position: relative; min-height: 170px; padding: 24px 22px; border-radius: 22px; overflow: hidden; background: linear-gradient(135deg, #2ea6ff 0%, #6a6cff 60%, #9b5cff 100%); box-shadow: 0 16px 36px rgba(70, 110, 255, 0.3); }
.hero-content { position: relative; z-index: 2; max-width: 260px; }
.hero-small { display: block; font-size: 14px; font-weight: 700; color: rgba(255, 255, 255, 0.85); margin-bottom: 6px; }
.hero-content h2 { font-size: 29px; line-height: 1.4; }
.hero-content p { margin-top: 8px; font-size: 12px; line-height: 1.8; color: rgba(255, 255, 255, 0.85); }
.hero-emoji { position: absolute; left: 20px; bottom: 14px; font-size: 68px; transform: rotate(-7deg); animation: float 3.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-9px) rotate(-2deg); } }

/* ---------- SECTION TITLE ---------- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 22px !important; }
.section-title > div { display: flex; align-items: center; gap: 8px; }
.section-title h3 { font-size: 17px; }
.category-count { padding: 5px 10px; border-radius: 10px; color: #fff; background: rgba(var(--c), 0.16); font-size: 11px; font-weight: 700; }

/* ---------- CATEGORIES ---------- */
.categories-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.category-card { --c: 42, 171, 238; min-height: 134px; padding: 13px 10px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; border-radius: 18px; background: linear-gradient(160deg, rgba(var(--c), 0.18), var(--panel) 65%); border: 1px solid rgba(var(--c), 0.35); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25); transition: transform 0.15s; animation: pop 0.45s both; }
.category-card:nth-child(3n + 2) { animation-delay: 0.05s; }
.category-card:nth-child(3n) { animation-delay: 0.1s; }
.category-card:active { transform: scale(0.95); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.95); } }
.category-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; font-size: 28px; line-height: 1; background: rgba(var(--c), 0.2); }
.category-name { font-size: 14px; font-weight: 800; margin-top: 6px; white-space: nowrap; }
.category-progress-wrapper { width: 100%; margin-top: 8px; }
.category-progress-text { font-size: 10px; color: var(--muted); margin-bottom: 5px; }
.category-progress { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.category-progress-fill { display: block; height: 100%; border-radius: inherit; background: rgb(var(--c)); transition: width 0.5s; }

/* ---------- GAME MODES ---------- */
.game-modes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.game-mode-card { min-height: 118px; padding: 14px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: right; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); transition: transform 0.15s; }
.game-mode-card:active { transform: scale(0.97); }
.game-mode-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; font-size: 22px; background: rgba(var(--c), 0.18); }
.game-mode-content strong { display: block; font-size: 13px; }
.game-mode-content span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }

.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 18px !important; }
.info-card { min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.info-card > div { text-align: center; }
.info-icon { font-size: 16px; }
.info-card strong { display: block; font-size: 19px; color: rgb(var(--c)); }
.info-card small { color: var(--muted); font-size: 10px; }

/* ---------- PAGE HEADERS / BUTTONS ---------- */
.page-header, .stage-header { display: flex; align-items: center; gap: 12px; }
.page-title span, .stage-title-area span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.page-title h2, .stage-title-area h2 { font-size: 19px; }
.icon-button { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); font-size: 22px; transition: transform 0.15s; }
.icon-button:active { transform: scale(0.92); }

.primary-button { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 15px; color: #fff; background: rgb(var(--c)); box-shadow: 0 8px 22px rgba(var(--c), 0.3); font-size: 15px; font-weight: 800; transition: transform 0.15s; }
.primary-button:active { transform: scale(0.98); }
.primary-button:disabled { opacity: 0.55; }
.secondary-button { width: 100%; min-height: 48px; margin-top: 10px; border-radius: 14px; background: var(--panel2); border: 1px solid rgba(var(--c), 0.4); font-size: 13px; font-weight: 700; }
.secondary-button:active { background: #263646; }
.text-button { width: 100%; min-height: 44px; margin-top: 4px; border-radius: 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
.text-button:active { background: rgba(255, 255, 255, 0.05); }

/* ---------- LEADERBOARD ---------- */
.lb-me { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lb-me > div { padding: 14px; text-align: center; border-radius: 16px; background: linear-gradient(135deg, rgba(var(--c), 0.25), var(--panel)); border: 1px solid rgba(var(--c), 0.3); }
.lb-me span { display: block; font-size: 11px; color: var(--muted); }
.lb-me strong { display: block; margin-top: 4px; font-size: 26px; }
.lb-list { border-radius: 16px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-row.me { background: rgba(var(--c), 0.16); }
.lb-rank { width: 30px; text-align: center; font-weight: 800; color: var(--muted); }
.lb-row:nth-child(1) .lb-rank { color: rgb(var(--gold)); }
.lb-avatar { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #2aabee, #7b6cff); font-weight: 800; }
.lb-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-weight: 800; color: rgb(var(--gold)); }
.lb-empty, .lb-note { padding: 16px; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.8; }

.lb-gap { padding: 4px 0; text-align: center; color: var(--muted); letter-spacing: 6px; border-bottom: 1px solid var(--line); }
.lb-info { flex: 1; min-width: 0; }
.lb-info .lb-name { display: block; }
.lb-user { display: block; margin-top: 1px; font-size: 10px; color: var(--muted); direction: ltr; text-align: right; }

/* ---------- MODE PAGE ---------- */
.mode-hero { display: flex; align-items: center; gap: 14px; padding: 20px 16px; border-radius: 20px; background: linear-gradient(135deg, #2ea6ff 0%, #6a6cff 70%, #9b5cff 100%); }
.mode-hero-icon { width: 58px; height: 58px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 29px; background: rgba(255, 255, 255, 0.2); }
.mode-hero span { display: block; font-size: 10px; font-weight: 800; color: rgba(255, 255, 255, 0.8); margin-bottom: 3px; }
.mode-hero h1 { font-size: 19px; }
.mode-hero p { margin-top: 5px; font-size: 11px; line-height: 1.8; color: rgba(255, 255, 255, 0.85); }

.multiplayer-panel { padding: 22px 16px; text-align: center; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.multiplayer-panel h3 { font-size: 17px; }
.multiplayer-panel > p { margin: 7px auto 16px; max-width: 300px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.matchmaking-icon { width: 66px; height: 66px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; font-size: 32px; background: rgba(var(--c), 0.18); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.matchmaking-timer { width: 74px; height: 74px; margin: 6px auto 14px; display: grid; place-items: center; border-radius: 50%; font-size: 26px; font-weight: 800; background: rgba(var(--c), 0.15); border: 2px solid rgb(var(--c)); }
.matchmaking-progress { height: 6px; margin-bottom: 14px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.matchmaking-progress-fill { width: 0; height: 100%; background: rgb(var(--c)); transition: width 1s linear; }

.friend-room-area { margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--panel2); }
.friend-room-area > span { display: block; font-size: 11px; color: var(--muted); }
.friend-room-area strong { display: block; margin: 8px 0 10px; font-size: 30px; letter-spacing: 6px; direction: ltr; }
.room-count { margin-top: 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.room-players { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.room-player { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--panel); text-align: right; }
.room-player.me { border: 1px solid rgba(var(--c), 0.5); }
.room-player span { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-player small { color: rgb(var(--gold)); font-size: 10px; }
.room-hint { margin: 12px 0 10px; font-size: 11px; line-height: 1.8; color: var(--muted); }
.group-score-box { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.group-chip { flex: 1 0 auto; min-width: 58px; padding: 6px 8px; text-align: center; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.group-chip.me { border-color: rgb(var(--c)); background: rgba(var(--c), 0.14); }
.group-chip span { display: block; max-width: 72px; margin: 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--muted); }
.group-chip strong { font-size: 15px; }
.divider { position: relative; margin: 20px 0 16px; text-align: center; }
.divider::before { content: ""; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--line); }
.divider span { position: relative; padding: 0 12px; background: var(--panel); color: var(--muted); font-size: 11px; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.room-input { flex: 1; min-width: 0; height: 54px; padding: 0 12px; text-align: center; direction: ltr; border-radius: 14px; color: #fff; background: var(--panel2); border: 1px solid var(--line); font-size: 18px; font-weight: 800; letter-spacing: 4px; text-transform: uppercase; -webkit-user-select: text; user-select: text; }
.room-input:focus { border-color: rgb(var(--c)); }
.join-btn { width: 90px; }
.game-mode-note { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border-radius: 14px; background: var(--panel); }
.game-mode-note p { font-size: 11px; line-height: 1.9; color: var(--muted); }

/* ---------- STAGES ---------- */
.stage-title-area { display: flex; align-items: center; gap: 11px; min-width: 0; }
.stage-category-emoji, .quiz-category > span { width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 23px; background: rgba(var(--c), 0.2); }
.stage-summary { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.stage-summary span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.stage-summary strong { font-size: 16px; }
.stage-summary-percent { --p: 0%; position: relative; z-index: 0; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 800; background: conic-gradient(rgb(var(--c)) var(--p), rgba(255, 255, 255, 0.1) 0); }
.stage-summary-percent::before { content: ""; position: absolute; inset: 5px; z-index: -1; border-radius: 50%; background: var(--panel); }
.stage-section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.stages-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stage-item { position: relative; min-height: 104px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); transition: transform 0.15s; }
.stage-item:active { transform: scale(0.96); }
.stage-number { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 20px; font-weight: 800; color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.stage-label { margin-top: 7px; font-size: 11px; font-weight: 700; color: var(--muted); }
.stage-mark { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 8px; font-size: 11px; background: rgba(255, 255, 255, 0.08); }
.stage-item.locked { opacity: 0.45; border-style: dashed; cursor: not-allowed; }
.stage-item.current { border-color: rgb(var(--c)); background: linear-gradient(145deg, rgba(var(--c), 0.22), var(--panel)); animation: ring 1.8s ease-in-out infinite; }
.stage-item.current .stage-number { color: #fff; background: rgb(var(--c)); }
.stage-item.current .stage-label { color: rgb(var(--c)); }
.stage-item.current .stage-mark { background: rgb(var(--c)); }
.stage-item.completed { border-color: rgba(var(--ok), 0.4); }
.stage-item.completed .stage-number { color: #04150d; background: rgb(var(--ok)); }
.stage-item.completed .stage-label { color: rgb(var(--ok)); }
.stage-item.completed .stage-mark { color: rgb(var(--ok)); background: rgba(var(--ok), 0.18); }
@keyframes ring { 50% { box-shadow: 0 0 0 5px rgba(var(--c), 0.15); } }

/* ---------- QUIZ ---------- */
.quiz-header { display: flex; align-items: center; gap: 10px; }
.quiz-category { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.quiz-category strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-category small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.timer-box { min-width: 64px; height: 42px; padding: 0 10px; display: flex; align-items: center; justify-content: center; gap: 5px; border-radius: 21px; background: rgba(var(--c), 0.15); border: 1px solid rgb(var(--c)); }
.timer-box strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.timer-box.danger { background: rgba(var(--bad), 0.2); border-color: rgb(var(--bad)); color: rgb(var(--bad)); animation: tpulse 0.5s infinite alternate; }
@keyframes tpulse { to { transform: scale(1.07); } }

.match-score-box { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.match-score-item { min-width: 70px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.match-score-item span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--muted); }
.match-score-item strong { font-size: 17px; }
.match-score-item.player strong { color: #7dd3fc; }
.match-score-item.opponent strong { color: #f9a8d4; }
.match-score-divider { font-size: 9px; font-weight: 800; color: var(--muted); }

.time-bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.time-bar-fill { width: 100%; height: 100%; border-radius: inherit; background: rgb(var(--c)); transition: width 1s linear, background 0.3s; }
.time-bar-fill.danger { background: rgb(var(--bad)); }
.quiz-progress-top { font-size: 11px; font-weight: 700; color: var(--muted); }
.question-dots { display: flex; gap: 5px; }
.dot { flex: 1; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); }
.dot.ok { background: rgb(var(--ok)); }
.dot.bad { background: rgb(var(--bad)); }
.dot.now { background: rgb(var(--c)); }

.question-card { padding: 20px 17px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); animation: pop 0.35s both; }
.question-label { display: inline-block; padding: 5px 9px; margin-bottom: 12px; border-radius: 9px; color: rgb(var(--c)); background: rgba(var(--c), 0.14); font-size: 11px; font-weight: 700; }
.question-text { font-size: 19px; line-height: 1.9; }

.answers-container { display: flex; flex-direction: column; gap: 10px; }
.answer-button { width: 100%; min-height: 60px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; text-align: right; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); animation: pop 0.35s both; transition: transform 0.12s; }
.answer-button:nth-child(2) { animation-delay: 0.05s; }
.answer-button:nth-child(3) { animation-delay: 0.1s; }
.answer-button:active { transform: scale(0.985); border-color: rgb(var(--c)); }
.answer-number { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 800; color: rgb(var(--c)); background: rgba(var(--c), 0.15); }
.answer-text { flex: 1; font-size: 15px; font-weight: 700; line-height: 1.6; }
.answer-button.correct { border-color: rgb(var(--ok)); background: linear-gradient(145deg, rgba(var(--ok), 0.3), rgba(var(--ok), 0.08)); }
.answer-button.correct .answer-number { color: #04150d; background: rgb(var(--ok)); }
.answer-button.wrong { border-color: rgb(var(--bad)); background: linear-gradient(145deg, rgba(var(--bad), 0.3), rgba(var(--bad), 0.08)); animation: shake 0.4s; }
.answer-button.wrong .answer-number { color: #fff; background: rgb(var(--bad)); }
.answer-button.disabled { pointer-events: none; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.answer-message { min-height: 26px; text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.answer-message.ok { color: rgb(var(--ok)); }
.answer-message.bad { color: rgb(var(--bad)); }

/* ---------- RESULT ---------- */
.result-page { min-height: calc(100vh - 60px); display: flex; flex-direction: column; gap: 13px; }
.result-top { text-align: center; padding-top: 8px; }
.result-icon { width: 82px; height: 82px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; font-size: 40px; background: rgba(var(--c), 0.18); border: 2px solid rgb(var(--c)); animation: pop 0.5s both; }
.result-label { display: block; color: var(--muted); font-size: 11px; }
.result-top h1 { margin-top: 4px; font-size: 25px; }
.result-title { margin-top: 6px; font-size: 16px; }
.result-message { margin-top: 6px; font-size: 13px; line-height: 1.8; color: #c9d1ee; }
.result-page.passed .result-title { color: rgb(var(--ok)); }
.result-page.failed .result-title { color: rgb(var(--bad)); }
.result-page.failed .result-icon { border-color: rgb(var(--bad)); background: rgba(var(--bad), 0.15); }

.result-score-card { padding: 18px; text-align: center; border-radius: 20px; background: var(--panel); border: 1px solid rgba(var(--gold), 0.35); }
.result-score-card span, .result-score-card small { display: block; color: var(--muted); font-size: 11px; }
.result-score-card strong { display: block; margin: 4px 0; font-size: 54px; line-height: 1.1; color: rgb(var(--gold)); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.result-stat { min-height: 88px; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.stat-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 4px; font-weight: 800; }
.result-stat strong { font-size: 20px; }
.result-stat span { color: var(--muted); font-size: 11px; }
.result-stat.correct .stat-icon { color: rgb(var(--ok)); background: rgba(var(--ok), 0.15); }
.result-stat.wrong .stat-icon { color: rgb(var(--bad)); background: rgba(var(--bad), 0.15); }
.result-stat.percent .stat-icon { color: rgb(var(--c)); background: rgba(var(--c), 0.15); }

.result-card { padding: 15px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.result-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.result-card-header span:first-child { display: block; color: var(--muted); font-size: 11px; }
.result-card-header strong { display: block; margin-top: 3px; font-size: 13px; }
.stage-badge { padding: 5px 10px; border-radius: 9px; font-size: 11px; font-weight: 800; background: rgba(255, 255, 255, 0.08); }
.stage-badge.good { color: rgb(var(--ok)); background: rgba(var(--ok), 0.14); }
.stage-badge.bad { color: rgb(var(--bad)); background: rgba(var(--bad), 0.14); }
.stage-track { height: 7px; border-radius: 7px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.stage-track-fill { width: 0; height: 100%; border-radius: inherit; background: rgb(var(--ok)); transition: width 0.4s; }
.stage-footer { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 10px; }
.pass-note { min-height: 22px; text-align: center; font-size: 13px; font-weight: 700; line-height: 1.8; color: #c9d1ee; }
.result-page.passed .pass-note { color: rgb(var(--ok)); }
.result-page.failed .pass-note { color: rgb(var(--bad)); }
.result-actions { margin-top: auto; }

/* ---------- TOAST / CONFETTI ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 200; max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px; background: var(--panel2); border: 1px solid rgba(var(--c), 0.5); font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: opacity 0.25s, transform 0.25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti-layer { position: fixed; inset: 0; z-index: 150; overflow: hidden; pointer-events: none; }
.confetti-layer i { position: absolute; top: -14px; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translate(var(--drift, 0), 110vh) rotate(var(--spin, 360deg)); } }

@media (max-width: 380px) {
    .app { padding-left: 11px; padding-right: 11px; }
    .game-modes-grid { grid-template-columns: 1fr; }
    .game-mode-card { min-height: 90px; flex-direction: row; align-items: center; gap: 10px; }
    .question-text { font-size: 17px; }
    .info-card strong { font-size: 16px; }
}

@media (min-width: 521px) {
    .app { border-inline: 1px solid rgba(255, 255, 255, 0.04); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* ---------- INVITE ---------- */
.invite-card { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 14px 16px; border-radius: 18px; background: var(--panel); border: 1px solid rgba(var(--c), 0.35); }
.invite-text { flex: 1; min-width: 0; }
.invite-text strong { display: block; font-size: 14px; }
.invite-text span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.invite-text small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.invite-btn { padding: 10px 18px; border-radius: 12px; background: linear-gradient(135deg, #2ea6ff, #6a6cff); color: #fff; font-size: 13px; font-weight: 800; }
.invite-btn:active { opacity: 0.85; }
/* ---------- WEEKLY TABS ---------- */
.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lb-tab { flex: 1; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.lb-tab.active { color: #fff; background: linear-gradient(135deg, #2ea6ff, #6a6cff); border-color: transparent; }
.lb-weekly-info { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; line-height: 1.9; text-align: center; }
.lb-weekly-info:empty { display: none; }

/* ---------- SOUND BUTTON ---------- */
.header-actions { display: flex; align-items: center; gap: 8px; }
.sound-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 18px; }
.sound-btn:active { opacity: 0.8; }
/* ---------- PROFILE ---------- */
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 18px 0 14px; padding: 18px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #2ea6ff, #6a6cff); }
.profile-card strong { font-size: 18px; }
.profile-card small { color: var(--muted); direction: ltr; }
.profile-edit { padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 14px; }
.profile-edit label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.profile-msg { min-height: 18px; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.profile-hint { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.profile-links { margin: 14px 0 4px; text-align: center; font-size: 12px; color: var(--muted); }
.profile-links a { color: inherit; text-decoration: underline; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.profile-stats div { padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.profile-stats span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.profile-stats strong { font-size: 17px; }