:root {
  --bg: #07080D;
  --card: #12141C;
  --card-hi: #181B26;
  --text: #F4F6FF;
  --text-dim: #8A8FA3;
  --easy: #3DDC97;
  --normal: #4C8CFF;
  --hard: #FF8A3D;
  --insane: #FF3D6E;
  --purple: #A25DFF;
  --gold: #FFD23D;
  --daily: #00C2D1;
  --live: #FF3D6E;
  --wa: #25D366;
  --border: #23273A;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: "Heebo", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
html[dir="rtl"] body { direction: rtl; }
body { min-height: 100vh; min-height: 100dvh; }
button { font-family: inherit; cursor: pointer; border: none; color: var(--text); background: none; }
input, textarea { font-family: inherit; }
a { color: var(--normal); }
.ltr-force { direction: ltr; unicode-bidi: isolate; }
[hidden] { display: none !important; }

#app {
  max-width: 560px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* Topbar */
#topbar { padding-top: calc(10px + var(--safe-top)); padding-bottom: 8px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.app-title {
  font-size: 22px; font-weight: 900; letter-spacing: 0.3px; padding: 0; direction: ltr;
  background: linear-gradient(90deg, var(--normal), var(--insane));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.app-title span { font-weight: 900; }
.profile-tag-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  color: #05070E; font-weight: 900; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; direction: ltr;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn.is-muted { opacity: 0.5; }
.offline-bar { background: rgba(255,138,61,0.15); color: var(--hard); font-size: 13px; font-weight: 700; text-align: center; padding: 8px 16px; }

/* Screens */
.screen { display: none; flex: 1; flex-direction: column; padding: 12px 16px 20px; gap: 16px; }
.screen.active { display: flex; }
.mount { display: contents; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

/* Onboarding */
.onboarding-card { margin-top: 5vh; display: flex; flex-direction: column; gap: 20px; }
.hero-title { margin: 0; text-align: center; font-size: 38px; font-weight: 900; direction: ltr; }
.hero-title span { background: linear-gradient(90deg, var(--normal), var(--insane)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin: -10px 0 0; text-align: center; color: var(--text-dim); font-size: 15px; }
.field-block { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-size: 14px; color: var(--text-dim); font-weight: 700; }
.lang-row { display: flex; gap: 10px; }
.lang-btn { flex: 1; height: 52px; border-radius: 14px; background: var(--card-hi); border: 2px solid var(--border); font-size: 18px; font-weight: 700; color: var(--text); }
.lang-btn.selected { border-color: var(--normal); box-shadow: 0 0 0 3px rgba(76,140,255,0.25); }
.text-input { height: 56px; border-radius: 14px; border: 2px solid var(--border); background: var(--card-hi); color: var(--text); font-size: 18px; padding: 0 16px; width: 100%; }
.text-input:focus { outline: none; border-color: var(--normal); }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-weight: 900; font-size: 24px; text-align: center; font-family: "JetBrains Mono", ui-monospace, monospace; }
.copy-fallback-textarea { height: auto; min-height: 90px; padding: 12px 16px; font-size: 14px; line-height: 1.4; resize: none; white-space: pre-wrap; }
.avatar-row { display: flex; gap: 12px; flex-wrap: wrap; }
.avatar-swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.avatar-swatch.selected { border-color: var(--text); transform: scale(1.1); }
@media (prefers-reduced-motion: reduce) { .avatar-swatch.selected { transform: none; } }

.primary-btn, .secondary-btn, .ghost-btn { height: 56px; border-radius: 14px; font-size: 18px; font-weight: 800; width: 100%; }
.primary-btn { background: linear-gradient(90deg, var(--normal), #7aa9ff); color: #05070E; }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.primary-btn.btn-live { background: linear-gradient(90deg, var(--insane), #ff7a9c); }
.secondary-btn { background: var(--card-hi); border: 2px solid var(--border); color: var(--text); }
.secondary-btn.is-on { border-color: var(--easy); color: var(--easy); background: rgba(61,220,151,0.12); }
.ghost-btn { background: transparent; color: var(--text-dim); }

/* Home */
.profile-bar { display: flex; align-items: center; gap: 16px; }
.avatar-circle { width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.15); }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 18px; font-weight: 800; }
.profile-level { font-size: 13px; color: var(--text-dim); margin: 2px 0 6px; }
.xp-track { height: 8px; border-radius: 4px; background: var(--card-hi); overflow: hidden; }
.xp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--easy), var(--normal)); border-radius: 4px; transition: width 0.4s ease; }
.lobby-grid { display: flex; flex-direction: column; gap: 12px; }
.lobby-row { display: flex; gap: 12px; }
.lobby-row .lobby-card { flex: 1; min-width: 0; }
.lobby-card {
  position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; text-align: start; display: flex; flex-direction: column; gap: 4px; min-height: 56px; justify-content: center;
}
.lobby-card:active { background: var(--card-hi); }
.lobby-card--primary { background: linear-gradient(135deg, rgba(76,140,255,0.18), var(--card)); border-color: var(--normal); }
.lobby-card--live { background: linear-gradient(135deg, rgba(255,61,110,0.22), var(--card)); border-color: var(--live); padding: 22px 20px; }
.lobby-card--live .lobby-card-title { color: var(--live); }
.lobby-card--weekly { border-color: var(--purple); }
.lobby-card--weekly .lobby-card-title { color: var(--purple); }
.lobby-card--grade { border-color: var(--gold); }
.lobby-card--grade .lobby-card-title { color: var(--gold); }
.lobby-card--daily { border-color: var(--daily); }
.lobby-card--daily .lobby-card-title { color: var(--daily); }
.lobby-card--practice { border-color: var(--easy); }
.lobby-card--practice .lobby-card-title { color: var(--easy); }
.lobby-card-title { font-size: 19px; font-weight: 800; }
.lobby-card-title--big { font-size: 30px; letter-spacing: 0.5px; }
.lobby-card-sub { font-size: 13px; color: var(--text-dim); }
.live-pill {
  position: absolute; top: 14px; inset-inline-end: 14px;
  font-size: 11px; font-weight: 900; letter-spacing: 1px; color: #fff;
  background: var(--live); border-radius: 999px; padding: 4px 10px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.home-footer { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); padding: 0 4px; }
.install-hint { font-size: 12px; }

/* Screen header */
.screen-header { display: flex; align-items: center; gap: 12px; }
.screen-header h2 { margin: 0; font-size: 22px; }
.back-btn { width: 44px; height: 44px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); font-size: 20px; flex-shrink: 0; }
html[dir="rtl"] .back-btn { transform: scaleX(-1); }

/* Difficulty */
.difficulty-list { display: flex; flex-direction: column; gap: 14px; }
.diff-btn { min-height: 88px; border-radius: var(--radius); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 12px 22px; gap: 4px; background: var(--card); border: 2px solid var(--border); text-align: start; }
.diff-name { font-size: 24px; font-weight: 900; }
.diff-example { font-size: 14px; color: var(--text-dim); direction: ltr; unicode-bidi: isolate; }
.diff-easy { border-color: var(--easy); } .diff-easy .diff-name { color: var(--easy); }
.diff-normal { border-color: var(--normal); } .diff-normal .diff-name { color: var(--normal); }
.diff-hard { border-color: var(--hard); } .diff-hard .diff-name { color: var(--hard); }
.diff-insane { border-color: var(--insane); } .diff-insane .diff-name { color: var(--insane); }

/* Mode buttons */
.mode-list { display: flex; flex-direction: column; gap: 12px; }
.mode-btn { min-height: 80px; border-radius: var(--radius); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 12px 22px; gap: 4px; background: var(--card); border: 2px solid var(--border); text-align: start; }
.mode-btn:active { background: var(--card-hi); }
.mode-btn.selected { border-color: var(--normal); box-shadow: 0 0 0 3px rgba(76,140,255,0.25); }
.mode-btn--accent { border-color: var(--live); background: linear-gradient(135deg, rgba(255,61,110,0.18), var(--card)); }
.mode-name { font-size: 20px; font-weight: 900; }
.mode-sub { font-size: 13px; color: var(--text-dim); }

/* Chips / segments */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 40px; padding: 0 14px; border-radius: 999px; background: var(--card-hi); border: 2px solid var(--border); color: var(--text-dim); font-weight: 700; font-size: 14px; }
.chip.selected { border-color: var(--easy); color: var(--easy); background: rgba(61,220,151,0.12); }
.chip.chip--blue.selected { border-color: var(--normal); color: var(--normal); background: rgba(76,140,255,0.15); }
.seg-row { display: flex; gap: 6px; }
.seg-btn { flex: 1; height: 44px; border-radius: 12px; background: var(--card-hi); border: 2px solid var(--border); color: var(--text-dim); font-weight: 800; font-size: 14px; padding: 0; }
.seg-btn.selected { border-color: var(--normal); color: var(--text); background: rgba(76,140,255,0.15); }
.practice-card { display: flex; flex-direction: column; gap: 12px; }

/* Live config */
.clash-setup-card { display: flex; flex-direction: column; gap: 14px; }
.clash-diff-row { display: flex; gap: 8px; }
.clash-diff-btn { flex: 1; height: 48px; border-radius: 12px; background: var(--card-hi); border: 2px solid var(--border); color: var(--text-dim); font-weight: 800; font-size: 14px; padding: 0; }
.clash-diff-btn[data-diff="easy"].selected { border-color: var(--easy); color: var(--easy); background: rgba(61,220,151,0.15); }
.clash-diff-btn[data-diff="normal"].selected { border-color: var(--normal); color: var(--normal); background: rgba(76,140,255,0.15); }
.clash-diff-btn[data-diff="hard"].selected { border-color: var(--hard); color: var(--hard); background: rgba(255,138,61,0.15); }
.clash-diff-btn[data-diff="insane"].selected { border-color: var(--insane); color: var(--insane); background: rgba(255,61,110,0.15); }
.clash-room-name { font-size: 20px; font-weight: 800; color: var(--text); }
.live-join-card { display: flex; flex-direction: column; gap: 10px; }
.join-row { display: flex; gap: 8px; }
.join-row .text-input { flex: 1; min-width: 0; }
.join-row .primary-btn { width: auto; padding: 0 20px; flex-shrink: 0; }

/* Lobby */
.lobby-code-card { display: flex; flex-direction: column; gap: 10px; text-align: center; align-items: center; }
.clash-code-label { font-size: 13px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.clash-code { font-size: 56px; font-weight: 900; letter-spacing: 10px; color: var(--normal); font-family: "JetBrains Mono", ui-monospace, monospace; direction: ltr; line-height: 1; padding-inline-start: 10px; }
.lobby-summary { font-size: 14px; color: var(--text-dim); font-weight: 700; }
.share-row { display: flex; gap: 8px; width: 100%; margin-top: 6px; }
.share-btn { flex: 1; height: 44px; border-radius: 12px; background: var(--card-hi); border: 2px solid var(--border); color: var(--text); font-weight: 700; font-size: 13px; padding: 0 6px; }
.share-btn--wa { border-color: var(--wa); color: var(--wa); }
.lobby-players-card { display: flex; flex-direction: column; gap: 10px; }
.lobby-players-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.lobby-players { display: flex; flex-direction: column; gap: 8px; }
.lobby-player { display: flex; align-items: center; gap: 10px; background: var(--card-hi); border-radius: 12px; padding: 10px 12px; border: 1px solid transparent; }
.lobby-player.is-you { border-color: var(--border); }
.lobby-player-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #05070E; flex-shrink: 0; direction: ltr; position: relative; }
.lobby-player-name { flex: 1; font-weight: 800; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player-tag { font-size: 11px; font-weight: 700; color: var(--text-dim); background: var(--card); border-radius: 999px; padding: 3px 8px; }
.lobby-player-ready { unicode-bidi: isolate; font-size: 13px; font-weight: 800; color: var(--text-dim); }
.lobby-player-ready.on { color: var(--easy); }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.online-dot.online { background: var(--easy); box-shadow: 0 0 6px var(--easy); }
.lobby-hint { font-size: 13px; color: var(--text-dim); text-align: center; line-height: 1.4; padding: 4px 0; }

/* ===== Shared play area ===== */
#play-area { display: contents; }
.game-top { display: flex; flex-direction: column; gap: 10px; }
.game-top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.game-mode-label { font-size: 13px; font-weight: 800; color: var(--text-dim); flex: 1; text-align: center; }
.q-progress { font-size: 13px; font-weight: 800; color: var(--text-dim); letter-spacing: 0.3px; min-width: 44px; text-align: end; }
.timer-row { display: flex; align-items: center; gap: 10px; }
.timer-track { flex: 1; height: 14px; border-radius: 7px; background: var(--card-hi); overflow: hidden; border: 1px solid var(--border); }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--easy), var(--normal)); border-radius: 7px; transition: width 0.1s linear; }
.timer-fill.low { background: linear-gradient(90deg, var(--hard), var(--insane)); }
.timer-text { font-variant-numeric: tabular-nums; font-weight: 800; width: 46px; text-align: end; direction: ltr; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.score-block { display: flex; align-items: baseline; gap: 8px; }
.score-label { font-size: 13px; color: var(--text-dim); }
.score-value { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; display: inline-block; }
.score-value.punch { animation: scorePunch 0.28s ease; }
.race-progress { font-size: 18px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.combo-badge { direction: ltr; unicode-bidi: isolate; font-size: 15px; font-weight: 800; background: var(--card-hi); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; color: var(--text-dim); }
.combo-badge.hot { color: var(--bg); background: linear-gradient(90deg, var(--hard), var(--insane)); border-color: transparent; }
.combo-badge.hot::before { content: "🔥 "; }
@keyframes scorePunch { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

.ghost-bars { display: flex; flex-direction: column; gap: 6px; }
.ghost-row { display: flex; align-items: center; gap: 8px; }
.ghost-label { font-size: 11px; font-weight: 800; color: var(--text-dim); width: 40px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-track { flex: 1; height: 10px; border-radius: 5px; background: var(--card-hi); overflow: hidden; }
.ghost-fill { height: 100%; width: 0%; border-radius: 5px; transition: width 0.25s ease; }
.ghost-fill--ai { background: var(--text-dim); }
.ghost-fill--you { background: linear-gradient(90deg, var(--normal), var(--easy)); }
.ghost-score { font-size: 12px; font-weight: 800; color: var(--text-dim); width: 40px; text-align: end; font-variant-numeric: tabular-nums; }

/* Live bars: every player in the room */
.live-bars { display: flex; flex-direction: column; gap: 5px; }
.live-bar { display: flex; align-items: center; gap: 8px; }
.live-bar-name { font-size: 12px; font-weight: 800; color: var(--text-dim); width: 64px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-bar.is-you .live-bar-name { color: var(--text); }
.live-bar-track { flex: 1; height: 10px; border-radius: 5px; background: var(--card-hi); overflow: hidden; }
.live-bar-fill { height: 100%; width: 0%; border-radius: 5px; transition: width 0.25s ease; }
.live-bar-score { font-size: 12px; font-weight: 800; color: var(--text-dim); width: 44px; text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
.live-bar.is-done .live-bar-score::after { content: " ✓"; color: var(--easy); }

.question-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-height: 20vh; text-align: center; transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.question-card.flash-correct { background-color: rgba(61,220,151,0.18); box-shadow: inset 0 0 0 2px var(--easy); }
.question-card.flash-wrong { background-color: rgba(255,61,110,0.14); box-shadow: inset 0 0 0 2px var(--insane); }
@media (prefers-reduced-motion: no-preference) { .question-card.flash-wrong { animation: shake 0.28s ease; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }
.question-text { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 900; line-height: 1.2; }
.question-line { white-space: nowrap; font-size: 44px; }
.answer-display { min-height: 40px; font-size: 30px; font-weight: 700; color: var(--normal); letter-spacing: 1px; }
.answer-reveal { font-size: 16px; font-weight: 800; color: var(--insane); }
@media (min-width: 460px) { .question-text .question-line { font-size: 50px; } .hero-title { font-size: 44px; } }

.numpad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pad-key { height: 60px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); font-size: 26px; font-weight: 800; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; }
.pad-key:active { background: var(--card-hi); }
.pad-key--fn { color: var(--text-dim); font-size: 22px; }
.pad-key--enter { grid-column: span 2; background: linear-gradient(90deg, var(--easy), var(--normal)); color: #05070E; font-size: 20px; }
@media (max-height: 700px) { .pad-key { height: 52px; font-size: 22px; } .question-line { font-size: 38px; } }

/* Countdown overlay */
.countdown-overlay { position: fixed; inset: 0; background: rgba(2,3,8,0.86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 90; }
.countdown-num { font-size: 120px; font-weight: 900; color: var(--text); line-height: 1; animation: countPop 0.9s ease infinite; font-variant-numeric: tabular-nums; }
.countdown-num.go { color: var(--easy); font-size: 80px; }
.countdown-sub { font-size: 18px; color: var(--text-dim); font-weight: 700; }
@keyframes countPop { 0% { transform: scale(1.25); opacity: 0.6; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* Weekly feedback */
.weekly-feedback { display: flex; flex-direction: column; gap: 12px; }
.weekly-feedback-banner { font-size: 22px; font-weight: 900; text-align: center; }
.weekly-explain-text { background: var(--card-hi); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 15px; color: var(--text-dim); }

/* Results */
.results-card { display: flex; flex-direction: column; gap: 18px; margin-top: 2vh; }
.results-title { margin: 0; text-align: center; font-size: 28px; }
@media (prefers-reduced-motion: no-preference) {
  .results-title { animation: slamIn 0.32s cubic-bezier(.2,1.4,.4,1); }
  .results-score-big, .results-side-score { animation: slamIn 0.4s 0.08s cubic-bezier(.2,1.4,.4,1) backwards; }
  .results-stats { animation: fadeUp 0.35s 0.22s ease backwards; }
  .results-actions { animation: fadeUp 0.35s 0.32s ease backwards; }
}
@keyframes slamIn { 0% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { 0% { transform: translateY(10px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
.results-compare { display: flex; align-items: center; justify-content: center; gap: 18px; }
.results-side { text-align: center; flex: 1; }
.results-side-label { font-size: 13px; color: var(--text-dim); font-weight: 700; }
.results-side-score { font-size: 36px; font-weight: 900; font-variant-numeric: tabular-nums; }
.results-score-big { font-size: 56px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.results-vs { color: var(--text-dim); font-weight: 700; }
.results-stats { display: flex; flex-direction: column; gap: 8px; }
.results-stat { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-dim); background: var(--card-hi); border-radius: 10px; padding: 10px 14px; }
.results-stat span:last-child { color: var(--text); font-weight: 800; direction: ltr; unicode-bidi: isolate; }
.results-actions { display: flex; flex-direction: column; gap: 10px; }

/* Live results */
.duel-rows { display: flex; flex-direction: column; gap: 8px; }
.duel-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--card-hi); border: 2px solid var(--border); }
.duel-row--winner { border-color: var(--gold); background: linear-gradient(135deg, rgba(255,210,61,0.14), var(--card-hi)); }
.duel-row--you { border-color: var(--normal); }
.duel-row-rank { width: 26px; font-weight: 900; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.duel-row-name { flex: 1; font-size: 16px; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-row-meta { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.duel-row-score { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; direction: ltr; }
.clash-podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; padding: 6px 0; }
.podium-spot { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; max-width: 120px; }
.podium-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #05070E; font-size: 14px; direction: ltr; border: 3px solid transparent; }
.podium-spot--1 .podium-avatar { width: 58px; height: 58px; border-color: var(--gold); font-size: 18px; }
.podium-medal { font-size: 26px; line-height: 1; }
.podium-name { font-size: 13px; font-weight: 700; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.podium-block { width: 100%; border-radius: 10px 10px 0 0; background: var(--card-hi); border: 1px solid var(--border); border-bottom: none; }
.podium-spot--1 .podium-block { height: 44px; background: linear-gradient(180deg, rgba(255,210,61,0.35), var(--card-hi)); }
.podium-spot--2 .podium-block { height: 30px; }
.podium-spot--3 .podium-block { height: 20px; }

/* Boards */
.boards-tabs { display: flex; gap: 10px; }
.board-tab { flex: 1; height: 44px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--border); color: var(--text-dim); font-weight: 700; font-size: 14px; }
.board-tab.selected { border-color: var(--normal); color: var(--text); }
.board-panel { display: flex; flex-direction: column; gap: 10px; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); }
.board-row.is-you { border-color: var(--normal); background: linear-gradient(135deg, rgba(76,140,255,0.12), var(--card)); }
.board-row-rank { width: 28px; font-weight: 900; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.board-row-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.board-row-label { flex: 1; font-weight: 800; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row-score { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; direction: ltr; }
.board-empty { color: var(--text-dim); text-align: center; padding: 30px 16px; font-size: 15px; line-height: 1.5; }
.board-friend-row { padding: 12px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.board-friend-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
.board-friend-line { font-size: 15px; font-weight: 600; color: var(--text-dim); display: flex; justify-content: space-between; }
.board-friend-line--winner { color: var(--text); font-weight: 800; }
.diff-color-easy { color: var(--easy); }
.diff-color-normal { color: var(--normal); }
.diff-color-hard { color: var(--hard); }
.diff-color-insane { color: var(--insane); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; direction: ltr; }
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.stats-topics { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.topic-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topic-row-name { width: 90px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.topic-row-track { flex: 1; height: 8px; border-radius: 4px; background: var(--card-hi); overflow: hidden; }
.topic-row-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--hard), var(--easy)); }
.topic-row-pct { width: 44px; text-align: end; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; }
.achievements-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.ach.locked { opacity: 0.4; filter: grayscale(1); }
.ach-icon { font-size: 28px; line-height: 1; }
.ach-name { font-size: 12px; font-weight: 800; }
.ach-desc { font-size: 11px; color: var(--text-dim); line-height: 1.3; }

/* Intro cards */
.weekly-intro-card, .grade-locked-card { display: flex; flex-direction: column; gap: 16px; text-align: center; margin-top: 2vh; }
.weekly-intro-week { font-size: 15px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.weekly-intro-desc { font-size: 16px; color: var(--text-dim); line-height: 1.4; }
.grade-locked-icon { font-size: 40px; }
.grade-locked-text { font-size: 16px; color: var(--text-dim); line-height: 1.4; }
.grade-countdown { font-size: 28px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,3,8,0.72); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.modal-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto; }
.modal-label { font-size: 16px; font-weight: 700; text-align: center; }
.field-error { color: var(--insane); font-size: 13px; font-weight: 700; }
.profile-menu-box { display: flex; flex-direction: column; gap: 10px; }
.menu-row { height: 52px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--border); color: var(--text); font-weight: 700; font-size: 16px; text-align: start; padding: 0 16px; }
.menu-row--danger { color: var(--insane); }
.sub-modal-body { display: flex; flex-direction: column; gap: 12px; }
.settings-note { font-size: 13px; color: var(--text-dim); line-height: 1.5; background: var(--card-hi); border-radius: 10px; padding: 12px 14px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; height: 52px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--border); padding: 0 16px; font-weight: 700; width: 100%; }
.toggle-row .knob { width: 44px; height: 26px; border-radius: 13px; background: var(--border); position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle-row .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform 0.2s; }
.toggle-row.on .knob { background: var(--easy); }
.toggle-row.on .knob::after { transform: translateX(18px); }
.how-to-play-text { font-size: 15px; color: var(--text-dim); line-height: 1.6; white-space: pre-line; }

/* Toast + confetti */
.toast {
  position: fixed; bottom: calc(24px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--card-hi); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; z-index: 200;
  max-width: 90vw; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: fadeUp 0.25s ease;
}
.toast.gold { border-color: var(--gold); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 150; }
