/* ===== DESIGN TOKENS ===== */
:root {
  --color-bg: #0f0c29;
  --color-bg2: #1a1540;
  --color-primary: #7c3aed;
  --color-primary-light: #a78bfa;
  --color-secondary: #ec4899;
  --color-accent: #f59e0b;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-card: rgba(255,255,255,0.06);
  --color-card-border: rgba(255,255,255,0.12);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 40px;
  --shadow-glow: 0 0 40px rgba(124,58,237,0.35);
  --shadow-card: 0 8px 40px rgba(0,0,0,0.4);
  --transition: 0.28s cubic-bezier(.4,0,.2,1);
}

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

.hidden { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  min-height: 100vh;
  color: var(--color-text);
  overflow-x: hidden;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.screen.active { display: flex; flex-direction: column; }

/* ===== ANIMATED BUBBLES ===== */
.home-bg, .result-bg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0.18;
  animation: floatBubble 8s ease-in-out infinite;
}
.bubble.b1 { width: 340px; height: 340px; background: radial-gradient(circle, #7c3aed, transparent); top: -80px; left: -80px; animation-delay: 0s; }
.bubble.b2 { width: 220px; height: 220px; background: radial-gradient(circle, #ec4899, transparent); top: 30%; right: -60px; animation-delay: 2s; }
.bubble.b3 { width: 160px; height: 160px; background: radial-gradient(circle, #f59e0b, transparent); bottom: 15%; left: 10%; animation-delay: 4s; }
.bubble.b4 { width: 280px; height: 280px; background: radial-gradient(circle, #06b6d4, transparent); bottom: -60px; right: 5%; animation-delay: 1s; }

@keyframes floatBubble {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.06); }
}

/* ===== HOME SCREEN ===== */
.home-content {
  position: relative; z-index: 2;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px 40px;
  gap: 28px;
}

.logo-area { text-align: center; }
.logo-icon {
  font-size: 64px;
  display: inline-block;
  animation: bounceIn 0.8s cubic-bezier(.36,.07,.19,.97);
  filter: drop-shadow(0 8px 24px rgba(124,58,237,0.6));
}
.logo-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #f472b6, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-top: 8px;
}
.logo-sub {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.home-card {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 36px;
  max-width: 480px;
  width: 100%;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  animation: slideUp 0.6s ease both;
  animation-delay: 0.15s;
}

.home-emoji-row {
  display: flex; justify-content: center; gap: 12px;
  font-size: 1.6rem;
  margin-bottom: 16px;
}
.home-emoji-row .em {
  display: inline-block;
  animation: wiggle 2s ease-in-out infinite;
}
.home-emoji-row .em:nth-child(2) { animation-delay: 0.2s; }
.home-emoji-row .em:nth-child(3) { animation-delay: 0.4s; }
.home-emoji-row .em:nth-child(4) { animation-delay: 0.6s; }
.home-emoji-row .em:nth-child(5) { animation-delay: 0.8s; }

@keyframes wiggle {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-5px); }
}

.home-heading {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 10px;
}
.home-desc {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  text-align: center;
  margin-bottom: 18px;
}
.home-stats {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 22px;
}
.stat-pill {
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-primary-light);
}

/* Difficulty */
.difficulty-select { margin-bottom: 24px; }
.diff-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.diff-buttons { display: flex; gap: 10px; justify-content: center; }
.diff-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--color-text-muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.diff-btn:hover {
  border-color: var(--color-primary-light);
  color: var(--color-text);
  background: rgba(124,58,237,0.15);
}
.diff-btn.selected {
  border-color: var(--color-primary);
  background: rgba(124,58,237,0.25);
  color: var(--color-primary-light);
  box-shadow: 0 0 16px rgba(124,58,237,0.3);
}

/* Buttons */
.btn-primary {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 24px;
  background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(124,58,237,0.4);
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: var(--transition);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(124,58,237,0.5); }
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0); }

.btn-arrow {
  font-size: 1.2rem;
  transition: transform var(--transition);
}
.btn-primary:hover .btn-arrow { transform: translateX(4px); }

.btn-secondary {
  flex: 1;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover {
  border-color: var(--color-primary-light);
  background: rgba(124,58,237,0.15);
  transform: translateY(-1px);
}

/* ===== GAME HEADER ===== */
.game-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(15,12,41,0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-card-border);
}
.btn-back {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  color: var(--color-text-muted);
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-back:hover { color: var(--color-text); border-color: var(--color-primary-light); background: rgba(124,58,237,0.15); }

.game-header-center { flex: 1; padding: 0 16px; }
.progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.progress-label { font-size: 0.78rem; font-weight: 700; color: var(--color-text-muted); }
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #ec4899);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 10px rgba(236,72,153,0.5);
  width: 0%;
}
.score-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 0.95rem;
}
.score-icon { font-size: 1rem; }

/* ===== GAME BODY ===== */
.game-body {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 20px 40px;
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Timer Ring */
.timer-container {
  position: relative;
  width: 64px; height: 64px;
  flex-shrink: 0;
}
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 4; }
.timer-progress {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 150.8;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}
.timer-text {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text);
}

/* Question Card */
.question-card {
  width: 100%;
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: slideUp 0.4s ease both;
}
.question-category {
  display: inline-block;
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-primary-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.question-emoji {
  font-size: 2.8rem;
  margin-bottom: 12px;
  display: block;
  animation: popIn 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
.question-text {
  font-size: clamp(1rem, 3vw, 1.15rem);
  font-weight: 700;
  line-height: 1.7;
  color: var(--color-text);
}

/* Answers */
.answers-section { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.answers-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
}
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choice-btn {
  padding: 14px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-card-border);
  background: var(--color-card);
  color: var(--color-text);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: popIn 0.3s ease both;
}
.choice-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.2), transparent);
  opacity: 0; transition: var(--transition);
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--color-primary-light);
  background: rgba(124,58,237,0.15);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124,58,237,0.3);
}
.choice-btn:hover:not(:disabled)::before { opacity: 1; }
.choice-btn.correct {
  border-color: var(--color-success) !important;
  background: rgba(16,185,129,0.2) !important;
  color: #6ee7b7;
  box-shadow: 0 0 20px rgba(16,185,129,0.35);
}
.choice-btn.wrong {
  border-color: var(--color-danger) !important;
  background: rgba(239,68,68,0.15) !important;
  color: #fca5a5;
  box-shadow: 0 0 20px rgba(239,68,68,0.25);
  animation: shake 0.4s ease;
}
.choice-btn.reveal {
  border-color: var(--color-success) !important;
  background: rgba(16,185,129,0.12) !important;
  color: #6ee7b7;
}
.choice-btn:disabled { cursor: default; }

/* Manual input */
.manual-input-wrap {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  backdrop-filter: blur(10px);
}
.manual-input-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.pen-icon { font-size: 1rem; }
.manual-input-row { display: flex; gap: 10px; }
.manual-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-card-border);
  background: rgba(255,255,255,0.06);
  color: var(--color-text);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  transition: var(--transition);
  -moz-appearance: textfield;
}
.manual-input::-webkit-inner-spin-button,
.manual-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.manual-input::placeholder { color: var(--color-text-muted); font-weight: 600; }
.manual-input:focus {
  border-color: var(--color-primary-light);
  background: rgba(124,58,237,0.12);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}
.btn-submit-manual {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-submit-manual:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,58,237,0.4); }
.btn-submit-manual:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Feedback Overlay */
.feedback-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  padding: 24px;
  transition: opacity var(--transition);
}
.feedback-overlay.hidden { display: none; }
.feedback-card {
  background: linear-gradient(135deg, rgba(26,21,64,0.95), rgba(48,43,99,0.95));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 36px 28px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card), 0 0 60px rgba(124,58,237,0.3);
  animation: popIn 0.35s cubic-bezier(.36,.07,.19,.97) both;
}
.feedback-emoji { font-size: 3.5rem; margin-bottom: 12px; display: block; }
.feedback-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.feedback-title.correct-title { color: #6ee7b7; }
.feedback-title.wrong-title { color: #fca5a5; }
.feedback-title.timeout-title { color: #fbbf24; }
.feedback-detail {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.feedback-explanation {
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: left;
  border-left: 3px solid var(--color-primary-light);
}
.feedback-explanation:empty { display: none; }
.btn-next {
  margin-top: 0;
  background: linear-gradient(135deg, #7c3aed, #ec4899) !important;
}

/* ===== RESULT SCREEN ===== */
.result-content {
  position: relative; z-index: 2;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  gap: 20px;
}
.result-trophy {
  font-size: 5rem;
  animation: bounceIn 0.7s cubic-bezier(.36,.07,.19,.97) both, pulse 2s ease-in-out 1s infinite;
  filter: drop-shadow(0 8px 32px rgba(245,158,11,0.6));
}
.result-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #f472b6, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}
.result-sub {
  font-size: 1rem;
  color: var(--color-text-muted);
  text-align: center;
}
.result-score-card {
  background: rgba(245,158,11,0.12);
  border: 2px solid rgba(245,158,11,0.35);
  border-radius: var(--radius-lg);
  padding: 24px 48px;
  text-align: center;
  box-shadow: 0 0 40px rgba(245,158,11,0.2);
}
.result-score-big {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1;
}
.result-score-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: rgba(245,158,11,0.7);
  letter-spacing: 0.2em;
  margin-top: 4px;
}
.result-breakdown {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}
.result-stat {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 80px;
}
.rst-icon { font-size: 1.4rem; }
.rst-val {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text);
}
.rst-key { font-size: 0.75rem; font-weight: 700; color: var(--color-text-muted); }

.result-badge {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  padding: 10px 24px;
  border-radius: 999px;
  animation: popIn 0.5s ease both;
  animation-delay: 0.3s;
}
.result-actions {
  display: flex; gap: 12px; width: 100%; max-width: 380px;
}
.result-actions .btn-primary { flex: 1; width: auto; }

/* ===== CONFETTI ===== */
.confetti-container { position: absolute; inset: 0; pointer-events: none; }
.confetti-piece {
  position: absolute;
  width: 10px; height: 14px;
  border-radius: 2px;
  animation: confettiFall linear both;
  top: -20px;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== KEYFRAME ANIMATIONS ===== */
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.1); }
  80% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes slideUp {
  0% { transform: translateY(30px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(26,21,64,0.95);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== AUTH BAR & MODAL ===== */
.auth-bar {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-card-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}
.user-profile-badge.hidden { display: none; }

.user-avatar { font-size: 1rem; }
.user-display-name { color: var(--color-text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 999px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.4); color: #fff; }

.btn-auth-open {
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: var(--color-primary-light);
  border-radius: 999px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}
.btn-auth-open:hover {
  background: rgba(124, 58, 237, 0.4);
  color: #fff;
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.4);
}

/* AUTH MODAL */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  padding: 20px;
  transition: opacity var(--transition);
}
.auth-modal.hidden { display: none; }

.auth-modal-card {
  position: relative;
  background: linear-gradient(135deg, rgba(26, 21, 64, 0.95), rgba(48, 43, 99, 0.95));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-card), 0 0 60px rgba(124, 58, 237, 0.3);
  animation: popIn 0.35s cubic-bezier(.36,.07,.19,.97) both;
}

.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-close-modal:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.auth-header { text-align: center; margin-bottom: 22px; }
.auth-icon { font-size: 2.5rem; display: block; margin-bottom: 6px; }
.auth-title { font-family: 'Poppins', sans-serif; font-size: 1.4rem; font-weight: 800; }
.auth-sub { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 4px; }

.auth-field { margin-bottom: 16px; text-align: left; }
.auth-field label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--color-text-muted); margin-bottom: 6px; }
.auth-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}
.auth-field input:focus {
  border-color: var(--color-primary-light);
  background: rgba(124, 58, 237, 0.12);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.auth-btn { margin-top: 8px; }

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; border-bottom: 1px solid rgba(255,255,255,0.12);
}
.auth-divider span { padding: 0 10px; }

.btn-supabase-placeholder {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(62, 207, 142, 0.4);
  background: rgba(62, 207, 142, 0.1);
  color: #3ECF8E;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-supabase-placeholder:hover {
  background: rgba(62, 207, 142, 0.2);
  transform: translateY(-1px);
}

.btn-google-login {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-google-login:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.supabase-config-link {
  margin-top: 14px;
  text-align: center;
  font-size: 0.78rem;
}
.supabase-config-link a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.supabase-config-link a:hover {
  color: var(--color-primary-light);
}

.supabase-config-box {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: left;
}
.supabase-config-box.hidden { display: none; }
.config-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary-light);
  margin-bottom: 10px;
}
.btn-save-config {
  width: 100%;
  padding: 8px;
  font-size: 0.82rem;
  margin-top: 6px;
}

.auth-switch {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}
.auth-switch a { color: var(--color-primary-light); font-weight: 700; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ===== SIDEBAR NAVIGATION ===== */
.btn-toggle-sidebar {
  position: fixed;
  top: 16px;
  left: 20px;
  z-index: 250;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(26, 21, 64, 0.8);
  border: 1px solid var(--color-card-border);
  backdrop-filter: blur(12px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.btn-toggle-sidebar span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: var(--transition);
}
.btn-toggle-sidebar:hover {
  background: rgba(124, 58, 237, 0.3);
  border-color: var(--color-primary-light);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 280;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  z-index: 290;
  background: linear-gradient(180deg, #151138 0%, #0f0c29 100%);
  border-right: 1px solid var(--color-card-border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
}
.app-sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-emoji { font-size: 1.8rem; }
.sidebar-logo .logo-text {
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-close-sidebar {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-close-sidebar:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.user-avatar-large {
  font-size: 1.8rem;
  background: rgba(124, 58, 237, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-info { flex: 1; overflow: hidden; }
.user-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  transition: var(--transition);
}
.nav-item .nav-icon { font-size: 1.2rem; }
.nav-item:hover {
  background: rgba(124, 58, 237, 0.15);
  color: var(--color-text);
}
.nav-item.active {
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--color-primary-light);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.2);
}

.sidebar-footer { margin-top: auto; }
.btn-sidebar-auth {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-card-border);
  background: rgba(124, 58, 237, 0.2);
  color: var(--color-primary-light);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-sidebar-auth:hover {
  background: rgba(124, 58, 237, 0.35);
  color: #fff;
}
.btn-logout-sidebar {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.btn-logout-sidebar:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

/* ===== DASHBOARD SCREEN & HISTORY ===== */
.dashboard-header {
  padding: 30px 24px 10px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}
.dash-title {
  font-family: 'Poppins', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.dash-sub {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.dashboard-body {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.dash-stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.dash-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-primary-light);
}
.dash-stat-icon { font-size: 2rem; margin-bottom: 6px; }
.dash-stat-val {
  font-family: 'Poppins', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-text);
}
.dash-stat-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.history-card-wrap {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}
.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.history-card-header h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}
.btn-refresh-history {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-refresh-history:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--color-primary-light);
}

.history-loading, .history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
.history-empty .empty-icon { font-size: 3rem; display: block; margin-bottom: 10px; }

.history-table-container {
  overflow-x: auto;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.history-table th {
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--color-card-border);
}
.history-table td {
  padding: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.badge-diff {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}
.badge-diff.easy { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-diff.medium { background: rgba(245, 158, 11, 0.2); color: #fde68a; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-diff.hard { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .home-card { padding: 24px 18px 28px; }
  .game-body { padding: 16px 14px 32px; }
  .choices-grid { grid-template-columns: 1fr; }
  .diff-buttons { flex-direction: column; }
}
