/* ═════════════════════════════════════════════════════════════
   Rahe Roshan 1405 — Camp Live Quiz Theme
   Ported & Enhanced from Rahe Roshan Box Game v3.2
   Cosmic Dark + Daylight Theme + App Shell + TV Projector Stage
   ═════════════════════════════════════════════════════════════ */

@import url("https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css");

:root,
[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #141c38;
  --surface-2: #1e2a52;
  --surface-3: #2a3866;
  --ink: #f5f7ff;
  --ink-2: #c8d0ec;
  --muted: #98a3cc;
  --line: #2b3a6b;

  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-ink: #0b1020;
  --primary-soft: #232f66;

  --accent: #fbbf24;
  --accent-2: #fcd34d;
  --accent-ink: #1a1203;
  --accent-soft: #3d2f0a;

  --ok: #34d399;
  --ok-soft: #0f3a2e;
  --warn: #fbbf24;
  --warn-soft: #3d2f0a;
  --bad: #fca5a5;
  --bad-soft: #4a1d24;

  --gold: #fbbf24;
  --gold-grad: linear-gradient(135deg, #fef08a, #fbbf24 60%, #f59e0b);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --nav-h: 68px;

  --gem-emerald: #34d399;
  --gem-agate: #60a5fa;
  --gem-turquoise: #22d3ee;
  --gem-amber: #fbbf24;
  --gem-ruby: #f87171;

  --glass: rgba(20, 28, 56, 0.76);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-2: #eef2fa;
  --surface-3: #e2e8f5;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #dce3f2;

  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-ink: #ffffff;
  --primary-soft: #e0e7ff;

  --accent: #d97706;
  --accent-2: #f59e0b;
  --accent-ink: #ffffff;
  --accent-soft: #fef3c7;

  --ok: #047857;
  --ok-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;

  --gold: #d97706;
  --gold-grad: linear-gradient(135deg, #b45309, #d97706 55%, #78350f);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 10px 26px -8px rgba(15, 23, 42, 0.09);
  --radius: 18px;
  --nav-h: 68px;

  --gem-emerald: #059669;
  --gem-agate: #2563eb;
  --gem-turquoise: #0891b2;
  --gem-amber: #d97706;
  --gem-ruby: #dc2626;

  --glass: rgba(255, 255, 255, 0.9);
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 12% 6%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 42%),
    radial-gradient(circle at 92% 28%, color-mix(in srgb, var(--primary-2) 8%, transparent), transparent 40%);
  background-attachment: fixed;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(60% 45% at 85% 0%, rgba(124, 58, 237, 0.24), transparent 70%),
    radial-gradient(55% 40% at 0% 25%, rgba(56, 189, 248, 0.14), transparent 70%),
    radial-gradient(70% 50% at 50% 105%, rgba(244, 114, 182, 0.11), transparent 70%),
    radial-gradient(40% 30% at 100% 70%, rgba(251, 191, 36, 0.07), transparent 70%);
  background-attachment: fixed;
}

/* Twinkling starfield behind the app (dark mode only) */
html[data-theme="dark"] body::before,
html[data-theme="dark"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
}

html[data-theme="dark"] body::before {
  background-image:
    radial-gradient(1.2px 1.2px at 20px 30px, #fff, transparent 60%),
    radial-gradient(1px 1px at 110px 90px, #cbd5ff, transparent 60%),
    radial-gradient(1.4px 1.4px at 190px 40px, #fff, transparent 60%),
    radial-gradient(1px 1px at 70px 170px, #fde68a, transparent 60%),
    radial-gradient(1.2px 1.2px at 230px 150px, #fff, transparent 60%);
  background-size: 260px 210px;
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
}

html[data-theme="dark"] body::after {
  background-image:
    radial-gradient(1px 1px at 50px 70px, #fff, transparent 60%),
    radial-gradient(1.8px 1.8px at 160px 120px, #a5b4fc, transparent 60%),
    radial-gradient(1px 1px at 280px 30px, #fff, transparent 60%),
    radial-gradient(1.6px 1.6px at 320px 190px, #f9a8d4, transparent 60%);
  background-size: 360px 250px;
  opacity: 0.55;
  animation: twinkle 9s 2s ease-in-out infinite alternate-reverse;
}

html[data-theme="light"] body::before,
html[data-theme="light"] body::after {
  display: none;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

button, a, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
a { color: var(--primary); text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
}
[data-theme="dark"] :focus-visible {
  outline-color: var(--gold);
}

.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }

/* ───────── App Shell & Header ───────── */
.app-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

.app-header {
  flex: 0 0 auto;
  width: 100%;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

html[data-theme="dark"] .app-header {
  box-shadow: 0 8px 30px -14px rgba(124, 58, 237, 0.35);
}

.app-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-main {
  flex: 1 1 0%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 16px 16px calc(var(--nav-h) + 38px + env(safe-area-inset-bottom, 0px));
}

.app-main.no-bottom-nav {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

.app-main-inner {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.app-main-inner.wide {
  max-width: 1120px;
}

/* ───────── Telegram-Style Floating Pill Bottom Nav ───────── */
.bottom-nav-wrap {
  position: fixed;
  inset-inline: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: flex;
  justify-content: center;
  padding-inline: 12px;
  pointer-events: none;
}

.bottom-nav {
  pointer-events: auto;
  width: min(440px, 100%);
  height: var(--nav-h);
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(22px) saturate(1.8);
  -webkit-backdrop-filter: blur(22px) saturate(1.8);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 34px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
  user-select: none;
  touch-action: manipulation;
}

html[data-theme="dark"] .bottom-nav {
  background: rgba(18, 25, 52, 0.88);
  border-color: rgba(129, 140, 248, 0.28);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6), 0 0 28px -6px rgba(99, 102, 241, 0.32), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: #1e293b;
  font-size: 0.74rem;
  font-weight: 800;
  position: relative;
  transition: background-color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.2s ease, transform 0.15s ease;
}

html[data-theme="dark"] .bottom-nav button {
  color: #94a3b8;
}

.bottom-nav button:active {
  transform: scale(0.95);
}

.bottom-nav button[aria-current="page"] {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
}

html[data-theme="dark"] .bottom-nav button[aria-current="page"] {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(56, 189, 248, 0.22));
  color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28) inset;
}

.nav-pill {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
}

.nav-dot {
  position: absolute;
  top: -4px;
  inset-inline-start: 16px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1203;
  border: 2px solid var(--surface);
  font-size: 0.62rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  padding: 0 3px;
  line-height: 1;
}

/* ───────── Cards & Primitives ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

html[data-theme="dark"] .card {
  position: relative;
  background: linear-gradient(160deg, rgba(30, 42, 88, 0.9), rgba(18, 26, 56, 0.92));
  border-color: rgba(129, 140, 248, 0.24);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

html[data-theme="dark"] .card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 12%;
  right: 12%;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.8), rgba(167, 139, 250, 0.8), rgba(56, 189, 248, 0.8), transparent);
}

.card-flat {
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: 14px;
  padding: 12px;
}

.segmented {
  display: grid;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.segmented.cols-2 { grid-template-columns: repeat(2, 1fr); }
.segmented.cols-3 { grid-template-columns: repeat(3, 1fr); }

.segmented button {
  min-height: 38px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: transparent;
  transition: all 0.18s ease;
}

.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}

html[data-theme="dark"] .segmented button[aria-selected="true"] {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  box-shadow: 0 4px 14px rgba(129, 140, 248, 0.35);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 800;
  font-size: 0.92rem;
  user-select: none;
  transition: transform 0.15s ease, filter 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background-image: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 34%, transparent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn-accent {
  background-image: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.06); }

.btn-ok {
  background-image: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.3);
}
.btn-ok:hover:not(:disabled) { filter: brightness(1.07); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }

html[data-theme="dark"] .btn-ghost {
  border-color: rgba(129, 140, 248, 0.3);
}

.btn-danger {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}

.btn-lg { min-height: 54px; font-size: 1.02rem; border-radius: 16px; padding: 0 24px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.82rem; border-radius: 10px; }

.input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1.5px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea.input {
  min-height: 120px;
  padding: 12px 14px;
}

.input::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}

.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.badge-wrap { white-space: normal; max-width: 100%; line-height: 1.55; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--primary-soft); color: var(--primary); }

html[data-theme="dark"] .badge-info {
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.35) inset;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme="dark"] .progress > i {
  background: linear-gradient(90deg, #818cf8, #c084fc, #38bdf8);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.55);
}

.gold-text {
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ───────── Cosmic Islands: .sky, .neb, .cosmos ───────── */
.sky {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  border-radius: 22px;
  padding: 20px;
  background: radial-gradient(120% 140% at 85% 0%, #2b3b9c 0%, #0e1740 50%, #070b1c 100%);
  border: 1px solid rgba(251, 191, 36, 0.32);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset, 0 14px 40px -14px rgba(79, 70, 229, 0.55);
}

html[data-theme="dark"] .sky {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05) inset, 0 0 50px -8px rgba(251, 191, 36, 0.25), 0 18px 50px -14px rgba(124, 58, 237, 0.6);
}

.sky::before,
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
}

.sky::before {
  background-image:
    radial-gradient(1.2px 1.2px at 20px 30px, #fff, transparent 60%),
    radial-gradient(1px 1px at 90px 80px, #cbd5ff, transparent 60%),
    radial-gradient(1.4px 1.4px at 150px 20px, #fff, transparent 60%),
    radial-gradient(1px 1px at 60px 140px, #fde68a, transparent 60%),
    radial-gradient(1.2px 1.2px at 180px 120px, #fff, transparent 60%);
  background-size: 200px 170px;
  opacity: 0.85;
  animation: twinkle 5s ease-in-out infinite alternate;
}

.sky::after {
  background:
    radial-gradient(40% 40% at 18% 20%, rgba(168, 85, 247, 0.3), transparent 70%),
    radial-gradient(35% 35% at 85% 85%, rgba(56, 189, 248, 0.2), transparent 70%);
}

.sky .chip-w {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 8px 14px;
}

.sky .sub-stat {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px;
  color: #fff;
}

html[data-theme="light"] .sky {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 52%, #f3e8ff 100%);
  border: 1px solid #c7d2fe;
  color: #0f172a;
  box-shadow: 0 10px 28px -10px rgba(79, 70, 229, 0.16);
}
html[data-theme="light"] .sky::before { display: none; }
html[data-theme="light"] .sky .chip-w {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #c7d2fe;
  color: #1e1b4b;
}
html[data-theme="light"] .sky .sub-stat {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(199, 210, 254, 0.9);
  color: #1e293b;
}

/* Nebula gradient cards */
.neb {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  isolation: isolate;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow);
  padding: 18px;
}

.neb::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--neb-bg);
}

.neb::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.65;
  background-image:
    radial-gradient(1.2px 1.2px at 18% 24%, #fff, transparent 60%),
    radial-gradient(1px 1px at 72% 18%, #fff, transparent 60%),
    radial-gradient(1.4px 1.4px at 58% 68%, #fff, transparent 60%),
    radial-gradient(60% 60% at 90% 10%, rgba(255, 255, 255, 0.18), transparent 70%);
}

.neb-t1 { --neb-bg: linear-gradient(145deg, #3347b8, #14204f); }
.neb-t2 { --neb-bg: linear-gradient(145deg, #0e7490, #1e2a6b); }
.neb-t3 { --neb-bg: linear-gradient(145deg, #7e22ce, #1e1b4b); }
.neb-t4 { --neb-bg: linear-gradient(145deg, #c2410c, #8a1c3d 60%, #2a2170); }

html[data-theme="light"] .neb {
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
html[data-theme="light"] .neb::after { opacity: 0.2; }
html[data-theme="light"] .neb-t1 { --neb-bg: linear-gradient(145deg, #e0e7ff, #eef2ff); border-color: #a5b4fc; }
html[data-theme="light"] .neb-t2 { --neb-bg: linear-gradient(145deg, #cffafe, #ecfeff); border-color: #67e8f9; }
html[data-theme="light"] .neb-t3 { --neb-bg: linear-gradient(145deg, #f3e8ff, #faf5ff); border-color: #d8b4fe; }
html[data-theme="light"] .neb-t4 { --neb-bg: linear-gradient(145deg, #fef3c7, #ffe4e6); border-color: #fda4af; }

/* Full-page Cosmos (Login + TV) */
.cosmos {
  position: relative;
  isolation: isolate;
  background: #070a18;
  color: var(--ink);
  overflow-x: hidden;
}

.cosmos > canvas.galaxy {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
}

.cosmos .veil {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.veil-login {
  background: linear-gradient(180deg, transparent 15%, rgba(7, 10, 24, 0.72) 55%, #070a18 100%);
}

.veil-tv {
  background: radial-gradient(75% 75% at 50% 50%, rgba(7, 10, 24, 0.28), rgba(7, 10, 24, 0.82));
}

html[data-theme="light"] .cosmos:not([data-theme="dark"]) {
  background: #eef2ff;
}
html[data-theme="light"] .cosmos:not([data-theme="dark"]) > canvas.galaxy {
  opacity: 0.22;
  filter: invert(1) hue-rotate(180deg) saturate(1.2);
}
html[data-theme="light"] .cosmos:not([data-theme="dark"]) .veil-login {
  background: linear-gradient(180deg, rgba(238, 242, 255, 0.35) 0%, rgba(243, 246, 252, 0.86) 55%, #f3f6fc 100%);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  padding: 18px;
}

html[data-theme="light"] .cosmos:not([data-theme="dark"]) .glass {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #cbd5e1;
  box-shadow: var(--shadow);
}

/* ───────── TV Panels, Rows, Podium & Announcer ───────── */
.tv-panel {
  background: rgba(16, 23, 50, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
}

.tv-row {
  background: rgba(34, 47, 94, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
}

.tv-row.gold {
  background: linear-gradient(270deg, rgba(251, 191, 36, 0.28), rgba(34, 47, 94, 0.72));
  border-color: rgba(251, 191, 36, 0.55);
}

.podium {
  display: grid;
  grid-template-columns: 1fr 1.18fr 1fr;
  align-items: end;
  gap: 10px;
}

.podium .step {
  border-radius: 18px 18px 0 0;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 4px;
  padding: 14px 8px;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

.podium .p1 { height: 188px; background: linear-gradient(180deg, #f59e0b, #b45309); border: 1px solid rgba(254, 240, 138, 0.5); }
.podium .p2 { height: 148px; background: linear-gradient(180deg, #94a3b8, #475569); border: 1px solid rgba(226, 232, 240, 0.4); }
.podium .p3 { height: 120px; background: linear-gradient(180deg, #e08a2e, #8a4a14); border: 1px solid rgba(253, 186, 116, 0.4); }
.podium .rank-n { font-size: 2rem; font-weight: 900; line-height: 1; opacity: 0.95; }

.announce {
  position: fixed;
  inset-inline: 0;
  top: 16%;
  z-index: 90;
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: announceAnim 6s ease forwards;
}

.announce > div {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #fbbf24, #ef4444);
  color: #1a1203;
  border-radius: 26px;
  padding: 22px 46px;
  font-size: clamp(1.2rem, 2.5vw, 2.2rem);
  font-weight: 900;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 70px rgba(251, 191, 36, 0.45);
  text-align: center;
  max-width: 88vw;
}

/* ───────── Quiz Options & Interactive States ───────── */
.quiz-opt {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  text-align: start;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.14s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-2));
}

.quiz-opt:active:not(:disabled) {
  transform: scale(0.985);
}

.quiz-opt-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--gold);
  font-weight: 900;
  font-size: 0.88rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.quiz-opt.is-selected {
  background: color-mix(in srgb, var(--primary) 22%, var(--surface));
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 8px 22px color-mix(in srgb, var(--primary) 28%, transparent);
}
.quiz-opt.is-selected .quiz-opt-letter {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: transparent;
}

.quiz-opt.is-correct {
  background: color-mix(in srgb, var(--ok) 22%, var(--surface));
  border-color: var(--ok);
  box-shadow: 0 0 20px color-mix(in srgb, var(--ok) 28%, transparent);
}
.quiz-opt.is-correct .quiz-opt-letter {
  background: var(--ok);
  color: #06281e;
  border-color: transparent;
}

.quiz-opt.is-wrong {
  background: color-mix(in srgb, var(--bad) 20%, var(--surface));
  border-color: var(--bad);
}
.quiz-opt.is-wrong .quiz-opt-letter {
  background: var(--bad);
  color: #2c0b0e;
  border-color: transparent;
}

.quiz-opt.is-dim {
  opacity: 0.52;
}

/* ───────── Theme Toggle, Gems, Modals & Toasts ───────── */
.theme-toggle {
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { background: var(--primary-soft); }

.gem-svg {
  filter: drop-shadow(0 2px 6px color-mix(in srgb, currentColor 55%, transparent));
  display: inline-block;
  flex-shrink: 0;
}

.gem-fly {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  animation: gemFly 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.confetti-piece {
  position: fixed;
  z-index: 95;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiDrop 2.4s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 22, 0.68);
  backdrop-filter: blur(6px);
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade 0.2s ease;
}

.sheet {
  width: min(760px, 100%);
  max-height: 90dvh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  padding: 20px;
  animation: rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

html[data-theme="dark"] .sheet {
  background: linear-gradient(160deg, #1a2550, #121a38);
  border-color: rgba(129, 140, 248, 0.3);
}

@media (min-width: 768px) {
  .sheet-back { align-items: center; padding: 16px; }
  .sheet { border-radius: 26px; }
}

.toast {
  position: fixed;
  inset-inline: 12px;
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom, 0px));
  z-index: 95;
  margin-inline: auto;
  width: min(440px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  animation: rise 0.25s ease;
}
.toast-ok { background: #047857; color: #fff; }
.toast-bad { background: #b91c1c; color: #fff; }

/* Tables */
.table-wrap {
  overflow: auto;
  max-height: 520px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.84rem;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: color-mix(in srgb, var(--primary) 6%, transparent); }

/* Scrollable tabs */
.scroll-x {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* Simple Layout Helpers (Works 100% Offline without CDN) */
.grid { display: grid; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.shrink-0 { flex-shrink: 0; }
.flex-1 { flex: 1 1 0%; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 768px) {
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .md-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 600px) {
  .sm-col-1 { grid-template-columns: 1fr !important; }
}

/* Keyframes */
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.95; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.92); opacity: 0; } 60% { transform: scale(1.03); } 100% { transform: scale(1); opacity: 1; } }
@keyframes gemFly {
  0% { transform: translate(0, 30px) scale(0.4); opacity: 0; }
  20% { opacity: 1; transform: translate(0, 0) scale(1.25); }
  100% { transform: translate(var(--dx, 0), -190px) scale(0.5); opacity: 0; }
}
@keyframes confettiDrop {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(90vh) rotate(540deg); opacity: 0; }
}
@keyframes announceAnim {
  0% { opacity: 0; transform: scale(0.85); }
  8% { opacity: 1; transform: scale(1.04); }
  12% { transform: scale(1); }
  88% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20px); }
}

.pop { animation: pop 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
