/* ============================================================
   TRIVIA-IQ v2.0 — TECH-NOIR GLASSMORPHISM
   Mobile-First 9:16
   ============================================================ */

/* ── TOKENS ──────────────────────────────────────────────── */
:root {
  --c-bg:       #050510;
  --c-surface:  rgba(255,255,255,0.04);
  --c-glass:    rgba(255,255,255,0.07);
  --c-border:   rgba(255,255,255,0.10);
  --c-neon:     #00f5ff;
  --c-neon2:    #9d4edd;
  --c-neon3:    #39ff14;
  --c-danger:   #ff0055;
  --c-warn:     #ff9800;
  --c-text:     #e8eaf6;
  --c-muted:    rgba(232,234,246,0.45);
  --r-card:     20px;
  --r-btn:      14px;
  --blur:       blur(18px);
  --shadow:     0 8px 32px rgba(0,245,255,0.08);
  --glow:       0 0 20px rgba(0,245,255,0.25);
  --font:       'Inter', -apple-system, sans-serif;
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}

/* ── BACKGROUND GRADIENT ─────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(157,78,221,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(0,245,255,0.12) 0%, transparent 55%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(57,255,20,0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* ── SCREENS ─────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  padding: env(safe-area-inset-top,16px) 16px env(safe-area-inset-bottom,16px);
  opacity: 0; transform: translateY(12px);
  transition: opacity .28s ease, transform .28s ease;
  pointer-events: none;
}
.screen--hidden { display: none !important; }
.screen--active { opacity: 1; transform: translateY(0); pointer-events: all; }

/* ── GLASS CARD ──────────────────────────────────────────── */
.card {
  background: var(--c-glass);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px;
  border: none; border-radius: var(--r-btn);
  font-size: 15px; font-weight: 700; letter-spacing: .5px;
  cursor: pointer; user-select: none;
  transition: transform .12s, box-shadow .12s, opacity .12s;
  -webkit-font-smoothing: antialiased;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: .4; pointer-events: none; }

.btn--primary {
  background: linear-gradient(135deg, var(--c-neon2), var(--c-neon));
  color: #0a0a1a; box-shadow: 0 4px 20px rgba(0,245,255,0.30);
}
.btn--secondary {
  background: var(--c-glass); border: 1px solid var(--c-border); color: var(--c-text);
}
.btn--danger {
  background: linear-gradient(135deg, #ff0055, #9d4edd); color: #fff;
}
.btn--ghost {
  background: transparent; color: var(--c-muted); font-size: 13px;
}

/* ── INPUTS ──────────────────────────────────────────────── */
.input {
  width: 100%; padding: 14px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  color: var(--c-text); font-size: 15px; font-family: var(--font);
  outline: none; transition: border-color .2s;
}
.input:focus { border-color: var(--c-neon); }
.input::placeholder { color: var(--c-muted); }

/* ── AUTH SCREEN ─────────────────────────────────────────── */
#screen-auth {
  justify-content: center;
  gap: 12px;
}
.auth-logo {
  text-align: center; margin-bottom: 8px;
}
.auth-logo h1 {
  font-size: 36px; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--c-neon), var(--c-neon2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-logo p { color: var(--c-muted); font-size: 13px; margin-top: 4px; }
.auth-divider {
  text-align: center; color: var(--c-muted); font-size: 12px;
  margin: 4px 0; position: relative;
}

/* ── HOME SCREEN ─────────────────────────────────────────── */
#screen-home { gap: 14px; padding-top: 24px; }

.home-header {
  display: flex; align-items: center; gap: 14px;
}
.home-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; color: #0a0a1a;
  flex-shrink: 0;
}
.home-info h2 { font-size: 18px; font-weight: 800; }
.home-info p  { font-size: 13px; color: var(--c-muted); margin-top: 2px; }

.rating-block {
  text-align: center; padding: 16px 20px;
}
.rating-num {
  font-size: 56px; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--c-neon), var(--c-neon2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(0,245,255,0.4));
}
.rating-label { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.level-bar-wrap { margin-top: 12px; position: relative; }
.level-bar-track {
  height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.level-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--c-neon2), var(--c-neon));
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 0 8px rgba(0,245,255,0.5);
}
.level-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--c-muted); margin-top: 4px;
}

.stats-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px; padding: 14px 12px;
  text-align: center;
}
.stat-box .stat-val { font-size: 28px; font-weight: 900; color: var(--c-neon); }
.stat-box .stat-label { font-size: 11px; color: var(--c-muted); margin-top: 2px; }

.modes-grid { display: flex; flex-direction: column; gap: 10px; }

.mode-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  background: var(--c-glass);
  border: 1px solid var(--c-border);
  border-radius: 18px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  cursor: pointer; transition: transform .12s, border-color .2s;
  width: 100%; text-align: left; color: var(--c-text);
}
.mode-btn:active { transform: scale(0.97); }
.mode-btn--solo:hover, .mode-btn--solo:focus { border-color: var(--c-neon); box-shadow: var(--glow); }
.mode-btn--iq:hover, .mode-btn--iq:focus { border-color: var(--c-neon2); box-shadow: 0 0 20px rgba(157,78,221,0.3); }
.mode-btn__icon { font-size: 32px; flex-shrink: 0; }
.mode-btn__label { font-size: 16px; font-weight: 800; }
.mode-btn__sub { font-size: 12px; color: var(--c-muted); margin-top: 2px; }
.mode-btn__arrow { margin-left: auto; color: var(--c-muted); font-size: 18px; }

/* ── GAME HUD ────────────────────────────────────────────── */
.game-hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; gap: 8px;
}
.hud-rating {
  font-size: 22px; font-weight: 900;
  background: linear-gradient(135deg, var(--c-neon), var(--c-neon2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hud-level { font-size: 12px; color: var(--c-muted); }
.hud-streak {
  display: flex; flex-direction: column; align-items: center;
  font-size: 11px; color: var(--c-muted);
}
.hud-streak span { font-size: 18px; font-weight: 900; color: var(--c-warn); }
.hud-combo {
  font-size: 12px; font-weight: 800; color: var(--c-neon3);
  min-width: 30px; text-align: center;
}

/* ── TIMER ───────────────────────────────────────────────── */
.timer-wrap { position: relative; display: flex; justify-content: center; margin: 8px 0; }
.timer {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900;
  background: conic-gradient(var(--c-neon) var(--pct, 100%), rgba(255,255,255,0.08) 0);
  position: relative; transition: color .3s;
  --pct: 100%;
}
.timer::after {
  content: ''; position: absolute; inset: 6px;
  border-radius: 50%; background: var(--c-bg);
}
.timer span { position: relative; z-index: 1; }
.timer--warn  { color: var(--c-warn); }
.timer--danger { color: var(--c-danger); animation: pulse .5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* ── QUESTION CARD ───────────────────────────────────────── */
.question-card {
  background: var(--c-glass);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  padding: 22px; min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 17px; font-weight: 600; line-height: 1.55;
  position: relative;
}
.q-diff-badge {
  position: absolute; top: 10px; right: 12px;
  font-size: 10px; color: var(--c-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: 99px;
}

/* ── OPTIONS ─────────────────────────────────────────────── */
.options { display: flex; flex-direction: column; gap: 10px; }

.option-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: 16px;
  color: var(--c-text); font-size: 15px; font-weight: 600;
  text-align: left; cursor: pointer; width: 100%;
  transition: transform .1s, border-color .18s, background .18s;
}
.option-btn:active:not(:disabled) { transform: scale(0.975); }
.option-btn:hover:not(:disabled) { border-color: var(--c-neon); background: rgba(0,245,255,0.06); }
.opt-letter {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; flex-shrink: 0;
}
.option-btn--correct {
  border-color: var(--c-neon3) !important;
  background: rgba(57,255,20,0.10) !important;
  animation: correctPop .3s ease;
}
.option-btn--correct .opt-letter { background: var(--c-neon3); color: #0a0a1a; }
.option-btn--wrong {
  border-color: var(--c-danger) !important;
  background: rgba(255,0,85,0.10) !important;
  animation: wrongShake .3s ease;
}
.option-btn--wrong .opt-letter { background: var(--c-danger); color: #fff; }
@keyframes correctPop { 0%{transform:scale(1)} 40%{transform:scale(1.03)} 100%{transform:scale(1)} }
@keyframes wrongShake { 0%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} 100%{transform:translateX(0)} }

/* ── DELTA POPUP ────────────────────────────────────────── */
.delta-popup {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%,-50%) scale(.6);
  font-size: 32px; font-weight: 900; pointer-events: none; z-index: 99;
  opacity: 0; transition: all .35s cubic-bezier(.34,1.56,.64,1);
}
.delta-popup--visible { opacity: 1; transform: translate(-50%,-80%) scale(1); }
.delta-popup--up   { color: var(--c-neon3); text-shadow: 0 0 20px var(--c-neon3); }
.delta-popup--down { color: var(--c-danger); text-shadow: 0 0 20px var(--c-danger); }

/* ── SHAKE ───────────────────────────────────────────────── */
.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-8px)}
  40%{transform:translateX(8px)}
  60%{transform:translateX(-5px)}
  80%{transform:translateX(5px)}
}

/* ── CONFETTI ────────────────────────────────────────────── */
.confetti-particle {
  position: fixed; width: 6px; height: 6px;
  border-radius: 2px; pointer-events: none; z-index: 999;
  top: 40%; animation: confettiFall .9s ease-in forwards;
}
@keyframes confettiFall {
  0%   { opacity:1; transform: translateY(0) rotate(0deg); }
  100% { opacity:0; transform: translateY(140px) rotate(720deg); }
}

/* ── RESULT SCREEN ───────────────────────────────────────── */
.result-center { text-align: center; }
.result-rating {
  font-size: 72px; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--c-neon), var(--c-neon2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(0,245,255,0.5));
}
.result-label { font-size: 13px; color: var(--c-muted); margin-top: 6px; }
.result-stats { display: flex; gap: 10px; margin: 20px 0; }
.result-stat { flex: 1; text-align: center; }
.result-stat .val { font-size: 26px; font-weight: 900; color: var(--c-neon); }
.result-stat .lbl { font-size: 11px; color: var(--c-muted); margin-top: 2px; }

/* ── IQ SCREEN ───────────────────────────────────────────── */
.iq-progress-wrap { margin: 6px 0; }
.iq-progress-track {
  height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
.iq-progress-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--c-neon2), var(--c-neon));
  transition: width .4s ease;
}
.iq-counter { font-size: 12px; color: var(--c-muted); text-align: right; margin-top: 4px; }
.iq-type-badge {
  display: inline-flex; align-items: center;
  background: rgba(157,78,221,0.15); border: 1px solid rgba(157,78,221,0.3);
  border-radius: 99px; padding: 3px 12px; font-size: 12px; color: var(--c-neon2);
  margin-bottom: 10px;
}
.iq-img-wrap { min-height: 80px; display: flex; align-items: center; justify-content: center; }

/* ── IQ RESULT ───────────────────────────────────────────── */
.iq-score-big {
  font-size: 96px; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--c-neon2), var(--c-neon));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px rgba(157,78,221,0.5));
}
.iq-label { font-size: 20px; font-weight: 700; color: var(--c-neon); margin-top: 6px; }

.breakdown-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; margin-bottom: 8px;
}
.breakdown-row > span:first-child { width: 90px; color: var(--c-muted); }
.breakdown-row > span:last-child  { width: 36px; text-align: right; color: var(--c-text); font-weight: 700; }
.breakdown-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
.breakdown-bar div {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--c-neon2), var(--c-neon));
  transition: width .8s ease;
}

/* ── LEADERBOARD ─────────────────────────────────────────── */
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  font-size: 14px;
}
.lb-row--me { background: rgba(0,245,255,0.06); border-radius: 10px; border-color: var(--c-neon); }
.lb-rank  { width: 28px; font-weight: 700; }
.lb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #0a0a1a;
  flex-shrink: 0;
}
.lb-name  { flex: 1; font-weight: 600; }
.lb-level { font-size: 16px; }
.lb-rating { font-weight: 900; color: var(--c-neon); min-width: 50px; text-align: right; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: env(safe-area-inset-top, 16px); left: 50%;
  transform: translateX(-50%); z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - 32px); max-width: 360px; pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  opacity: 0; transform: translateY(-8px);
  transition: all .25s ease;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--c-border);
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: rgba(57,255,20,0.15); border-color: var(--c-neon3); color: var(--c-neon3); }
.toast--error   { background: rgba(255,0,85,0.15);  border-color: var(--c-danger); color: var(--c-danger); }
.toast--info    { background: rgba(0,245,255,0.10);  border-color: var(--c-neon); color: var(--c-neon); }

/* ── PAGE TITLE ─────────────────────────────────────────── */
.page-title {
  font-size: 22px; font-weight: 900; letter-spacing: -.5px;
  padding: 8px 0 4px;
}
.page-subtitle { font-size: 13px; color: var(--c-muted); }

/* ── NAV BACK ────────────────────────────────────────────── */
.nav-back {
  display: flex; align-items: center; gap: 6px;
  color: var(--c-muted); font-size: 14px; font-weight: 600;
  background: none; border: none; cursor: pointer; padding: 4px 0;
}
.nav-back:active { opacity: .6; }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,245,255,0.2); border-radius: 2px; }

/* ── SECTION TITLE ───────────────────────────────────────── */
.section-title {
  font-size: 12px; font-weight: 800; letter-spacing: 1.5px;
  color: var(--c-muted); text-transform: uppercase; margin-bottom: 10px;
}
