/* ============================================
   StudyQuest - Design System
   Aesthetic: Dark game UI with neon accents
   Fonts: Syne (display) + DM Sans (body)
   ============================================ */

/* ===== CSS VARIABLES ===== */
:root {
  --bg-base:        #0d0f1a;
  --bg-card:        #13162a;
  --bg-card-hover:  #181c35;
  --bg-elevated:    #1e2340;

  --accent:         #7c3aed;
  --accent-bright:  #8b5cf6;
  --accent-glow:    rgba(124, 58, 237, 0.25);

  --green:          #22c55e;
  --green-glow:     rgba(34, 197, 94, 0.2);
  --red:            #ef4444;
  --red-glow:       rgba(239, 68, 68, 0.2);
  --yellow:         #f59e0b;
  --blue:           #3b82f6;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --border:         rgba(255,255,255,0.07);
  --border-bright:  rgba(255,255,255,0.15);

  --sidebar-w:      240px;
  --radius:         14px;
  --radius-sm:      8px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px var(--accent-glow);
}

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

html, body {
  height: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, .brand-name { font-family: 'Syne', sans-serif; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }

/* ============================================
   SCREENS
   ============================================ */
#app { height: 100vh; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.screen.active {
  display: flex;
  opacity: 1;
}

/* ============================================
   AUTH SCREEN
   ============================================ */
#screen-auth {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  position: relative;
}

.auth-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.1) 0%, transparent 50%);
  pointer-events: none;
}

.auth-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: float 8s ease-in-out infinite;
}

.orb-1 {
  width: 400px; height: 400px;
  background: var(--accent);
  top: -100px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 300px; height: 300px;
  background: var(--blue);
  bottom: -50px; right: -50px;
  animation-delay: -3s;
}
.orb-3 {
  width: 200px; height: 200px;
  background: var(--green);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -6s;
}

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

.auth-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-icon {
  font-size: 52px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(124,58,237,0.6));
}

.brand-name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 0%, var(--accent-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tagline {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 15px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.auth-tab.active {
  color: var(--text-primary);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent-bright);
  border-radius: 2px 2px 0 0;
}

.auth-form {
  padding: 28px;
  display: none;
  flex-direction: column;
  gap: 16px;
}
.auth-form.active { display: flex; }

/* ============================================
   FORM ELEMENTS
   ============================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.field input:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder { color: var(--text-muted); }

.form-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
  padding: 10px 14px;
  display: none;
}
.form-error.visible { display: block; }

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #5b21b6 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary.btn-full { width: 100%; }

.btn-primary.btn-large {
  padding: 16px 24px;
  font-size: 16px;
  border-radius: var(--radius);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-bright);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: none;
}
.btn-ghost:hover { color: var(--text-primary); }

.btn-back {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-back:hover { background: var(--bg-card-hover); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--red); }

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.2s;
  margin-left: auto;
}
.btn-logout:hover { color: var(--red); }

/* ============================================
   APP LAYOUT
   ============================================ */
#screen-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-icon-sm { font-size: 22px; }

.brand-name-sm {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--accent-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-bright);
}

.nav-item svg { flex-shrink: 0; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.user-avatar-sm {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.user-info-sm { flex: 1; min-width: 0; }

.user-name-sm {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-level-sm {
  font-size: 11px;
  color: var(--accent-bright);
  font-weight: 500;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.page { display: none; animation: fadePage 0.25s ease; }
.page.active { display: block; }

@keyframes fadePage {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 14px;
}

/* ============================================
   DASHBOARD
   ============================================ */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hero-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.hero-card-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

.hero-stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.hero-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* XP Progress */
.xp-progress-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.xp-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
}

.xp-progress-header span:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

.xp-progress-header span:last-child { color: var(--accent-bright); }

.progress-bar-container {
  background: var(--bg-elevated);
  border-radius: 100px;
  height: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  border-radius: 100px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

/* Sections grid */
.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Session items */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.session-item:last-child { border-bottom: none; }

.session-deck { color: var(--text-primary); font-weight: 500; }
.session-meta { color: var(--text-muted); margin-top: 2px; font-size: 11px; }

.session-score {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
}

.score-pass { color: var(--green); }
.score-fail { color: var(--red); }

/* Achievement items */
.achievement-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.achievement-item:last-child { border-bottom: none; }

.achievement-icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
}

.achievement-name {
  font-weight: 600;
  color: var(--text-primary);
}

.achievement-desc {
  color: var(--text-muted);
  font-size: 11px;
}

/* Empty states */
.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.empty-state-large {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-large h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-large p { margin-bottom: 20px; font-size: 14px; }

/* ============================================
   DECKS GRID
   ============================================ */
.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.deck-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.deck-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.deck-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.deck-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.deck-status-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-ready {
  background: rgba(34,197,94,0.15);
  color: var(--green);
}

.status-processing {
  background: rgba(245,158,11,0.15);
  color: var(--yellow);
}

.status-error {
  background: rgba(239,68,68,0.15);
  color: var(--red);
}

.deck-title {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.deck-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.deck-levels-preview {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.level-dot.completed {
  background: var(--green);
  border-color: var(--green);
}

.level-dot.unlocked {
  background: var(--accent);
  border-color: var(--accent);
}

/* ============================================
   UPLOAD PAGE
   ============================================ */
.upload-container {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drop-zone {
  background: var(--bg-card);
  border: 2px dashed var(--border-bright);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone.drag-over {
  border-color: var(--accent-bright);
  background: var(--accent-glow);
}

.drop-zone:hover {
  border-color: var(--accent);
}

.drop-icon { font-size: 48px; margin-bottom: 12px; }

.drop-zone h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.file-preview {
  background: var(--bg-card);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-preview.hidden { display: none; }

.file-icon { font-size: 24px; }

.file-details { flex: 1; }
.file-name { font-weight: 500; font-size: 14px; }
.file-size { color: var(--text-muted); font-size: 12px; }

/* Upload progress */
.upload-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.upload-progress.hidden { display: none; }

.progress-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  position: relative;
}

.progress-steps::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  height: 2px;
  background: var(--bg-elevated);
  z-index: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.step-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 2px solid var(--border);
  transition: all 0.3s;
}

.step.active .step-icon {
  border-color: var(--accent);
  background: var(--accent-glow);
  animation: pulse-step 1s ease infinite;
}

.step.done .step-icon {
  border-color: var(--green);
  background: rgba(34,197,94,0.15);
}

.step.active { color: var(--text-primary); }
.step.done { color: var(--green); }

@keyframes pulse-step {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

#upload-status-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-form .field input {
  width: 100%;
}

/* ============================================
   LEVELS SCREEN
   ============================================ */
#screen-levels {
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 20px;
}

.levels-container {
  width: 100%;
  max-width: 480px;
}

.levels-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}

.levels-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.levels-header p {
  color: var(--text-muted);
  font-size: 13px;
}

.levels-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.level-node-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.level-connector {
  width: 3px;
  height: 40px;
  background: var(--border);
  transition: background 0.3s;
}

.level-connector.active { background: var(--green); }

.level-node {
  width: 240px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}

.level-node.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-node.unlocked {
  border-color: var(--accent);
}

.level-node.completed {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--bg-card), rgba(34,197,94,0.05));
}

.level-node:not(.locked):hover {
  transform: scale(1.03);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.level-node-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.level-node-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}

.level-node-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.level-node-stars {
  margin-top: 10px;
  font-size: 18px;
}

.level-node-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--green);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* ============================================
   QUIZ SCREEN
   ============================================ */
#screen-quiz {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-base);
}

.quiz-container {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 40px;
}

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-meta { flex: 1; }

.quiz-level-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  background: var(--accent-glow);
  color: var(--accent-bright);
  border-radius: 100px;
  margin-bottom: 4px;
}

.quiz-deck-name {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.quiz-score-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--yellow);
}

.quiz-progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-lives { font-size: 16px; letter-spacing: 2px; }

.quiz-bar-wrapper {
  flex: 1;
  background: var(--bg-elevated);
  border-radius: 100px;
  height: 10px;
  overflow: hidden;
}

.quiz-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #4ade80);
  border-radius: 100px;
  transition: width 0.4s ease;
}

.quiz-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

/* Question area */
.question-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.question-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.question-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

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

.option-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-bright);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.option-label {
  width: 28px;
  height: 28px;
  background: var(--bg-elevated);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s;
}

.option-btn.correct {
  border-color: var(--green);
  background: var(--green-glow);
}

.option-btn.correct .option-label {
  background: var(--green);
  color: #fff;
}

.option-btn.wrong {
  border-color: var(--red);
  background: var(--red-glow);
}

.option-btn.wrong .option-label {
  background: var(--red);
  color: #fff;
}

.option-btn.disabled:not(.correct):not(.wrong) {
  opacity: 0.4;
}

/* Feedback */
.feedback-area {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feedback-area.hidden { display: none; }

.feedback-content {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.feedback-icon { font-size: 28px; flex-shrink: 0; }

.feedback-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.feedback-area.correct-feedback { border: 1px solid var(--green); }
.feedback-area.wrong-feedback   { border: 1px solid var(--red); }
.feedback-area.correct-feedback .feedback-title { color: var(--green); }
.feedback-area.wrong-feedback   .feedback-title { color: var(--red); }

.feedback-explanation {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================
   RESULT SCREEN
   ============================================ */
#screen-result {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}

.result-container {
  width: 100%;
  max-width: 440px;
  text-align: center;
  padding: 20px 0;
}

.result-animation {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounce-in 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounce-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 28px;
}

.result-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 24px;
}

.result-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  flex: 1;
}

.result-stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.result-stat-xp .result-stat-value {
  color: var(--yellow);
}

.levelup-banner {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(59,130,246,0.2));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 15px;
}

.levelup-banner.hidden { display: none; }

.levelup-icon { font-size: 24px; }

.levelup-banner strong {
  display: block;
  font-family: 'Syne', sans-serif;
  color: var(--accent-bright);
}

.achievements-earned {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.achievement-badge {
  background: rgba(245,158,11,0.15);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--yellow);
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================
   RANKING PAGE
   ============================================ */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
}

.ranking-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
}

.ranking-item.is-me {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-card), rgba(124,58,237,0.05));
}

.ranking-rank {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 800;
  min-width: 36px;
  text-align: center;
}

.rank-1 { color: var(--yellow); }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #92400e; }

.ranking-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ranking-info { flex: 1; }
.ranking-username { font-weight: 600; font-size: 15px; }
.ranking-level { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.ranking-xp {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--yellow);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--accent); }

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .sidebar { display: none; }

  .main-content { padding: 20px; }

  .hero-stats { grid-template-columns: repeat(2, 1fr); }

  .quiz-container { padding: 0 0 40px; }
}
