:root {
  --bg: #0d0f0e;
  --bg-elevated: #151917;
  --bg-card: #1a1f1c;
  --accent: #2E6F40;
  --accent-light: #3a8a52;
  --accent-glow: rgba(46, 111, 64, 0.15);
  --accent-glow-strong: rgba(46, 111, 64, 0.3);
  --fg: #e8ece9;
  --fg-muted: #8a9b8f;
  --fg-dim: #5a6b5f;
  --border: rgba(46, 111, 64, 0.12);
  --border-hover: rgba(46, 111, 64, 0.3);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.section-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============ HERO ============ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 24px 80px;
  overflow: hidden;
}

.hero-bg-glow {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(ellipse, var(--accent-glow-strong) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 720px;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--accent-light);
  border: 1px solid var(--border-hover);
  padding: 8px 20px;
  border-radius: 100px;
  margin-bottom: 40px;
  background: var(--accent-glow);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 24px;
}

.hero h1 .accent {
  color: var(--accent-light);
  position: relative;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--fg-muted);
  max-width: 540px;
  margin: 0 auto 48px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: inline-flex;
}

.stat { text-align: center; }

.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* ============ MODES ============ */
.modes {
  padding: 120px 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 60px;
  letter-spacing: -0.5px;
}

.modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.mode-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 36px;
  transition: border-color 0.3s ease, transform 0.2s ease;
}

.mode-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.mode-card.ffa { border-top: 3px solid var(--accent); }
.mode-card.coop { border-top: 3px solid #c0392b; }

.mode-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}

.mode-card h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.mode-tagline {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  font-style: italic;
}

.mode-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-rules li {
  font-size: 0.9rem;
  color: var(--fg-muted);
  padding-left: 20px;
  position: relative;
}

.mode-rules li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.mode-card.coop .mode-rules li::before {
  background: #c0392b;
}

/* ============ FEATURES ============ */
.features {
  padding: 80px 0 120px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.feature {
  padding: 36px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.3s ease;
}

.feature:hover {
  border-color: var(--border-hover);
}

.feature-num {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.feature h4 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.feature p {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* ============ CLOSING ============ */
.closing {
  padding: 100px 0;
  text-align: center;
  position: relative;
}

.closing::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.closing-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}

.closing h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.closing p {
  font-size: 1.05rem;
  color: var(--fg-muted);
  line-height: 1.7;
}

/* ============ FOOTER ============ */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--fg-dim);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .hero { padding: 80px 20px 60px; min-height: auto; }
  .hero h1 { font-size: 2rem; }
  .hero-sub { font-size: 0.95rem; }

  .hero-stats {
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    width: 100%;
  }

  .stat-divider {
    width: 40px;
    height: 1px;
  }

  .modes { padding: 80px 0; }
  .modes-grid { grid-template-columns: 1fr; }
  .mode-card { padding: 32px 24px; }

  .features { padding: 60px 0 80px; }
  .features-grid { grid-template-columns: 1fr; }
  .feature { padding: 28px 24px; }

  .closing { padding: 60px 0; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }

  .section-title { margin-bottom: 40px; }
}

/* ============ CTA BUTTON ============ */
.btn-play {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 16px 40px;
  margin-bottom: 48px;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: -0.2px;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-play:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow-strong);
}

/* ============ LOBBY PAGE ============ */
.lobby-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  position: relative;
}

.lobby-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, var(--accent-glow-strong) 0%, transparent 70%);
  pointer-events: none;
}

.lobby-card {
  position: relative;
  z-index: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 480px;
}

.lobby-card h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.lobby-card .subtitle {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 32px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.field-group input, .field-group select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.field-group input:focus, .field-group select:focus {
  border-color: var(--accent);
}

.field-group input::placeholder {
  color: var(--fg-dim);
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  width: 100%;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--fg); }

.join-section {
  display: none;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.join-section.visible { display: block; }

.lobby-error {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-top: 12px;
  display: none;
}
.lobby-error.visible { display: block; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 32px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--fg); }

/* ============ GAME PAGE ============ */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  position: relative;
}

.game-page::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 720px;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
}

.game-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.game-code-badge {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--accent-light);
  border: 1px solid var(--border-hover);
  padding: 6px 16px;
  border-radius: 100px;
  background: var(--accent-glow);
}

.game-container {
  width: 100%;
  max-width: 720px;
  position: relative;
  z-index: 1;
}

/* Phases */
.phase { display: none; }
.phase.active { display: block; }

/* ── Waiting room ── */
.waiting-room {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
}

.waiting-room h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.waiting-room .waiting-sub {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.copy-code-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 10px 20px;
  color: var(--accent-light);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 4px;
  cursor: pointer;
  margin-bottom: 32px;
  transition: background 0.2s;
}
.copy-code-btn:hover { background: var(--accent-glow); }

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
  text-align: left;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--accent-light);
  flex-shrink: 0;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.player-badge {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.waiting-hint {
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-top: 16px;
}

/* ── Question ── */
.question-phase {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
}

.q-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.q-progress {
  font-size: 0.8rem;
  color: var(--fg-dim);
  font-family: var(--font-display);
  font-weight: 600;
}

.q-category {
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 100px;
  color: var(--fg-muted);
}

.timer-bar-container {
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear, background 0.5s;
  width: 100%;
}

.timer-bar.urgent { background: #e74c3c; }

.question-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 32px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  position: relative;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.option-btn:disabled { cursor: not-allowed; }

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.option-btn.correct {
  border-color: #27ae60;
  background: rgba(39, 174, 96, 0.15);
  color: #2ecc71;
}

.option-btn.wrong {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  opacity: 0.7;
}

.option-letter {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  text-align: center;
  line-height: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  margin-right: 10px;
  flex-shrink: 0;
}

.timer-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent-light);
}
.timer-display.urgent { color: #e74c3c; }

/* ── Answer result ── */
.result-banner {
  text-align: center;
  padding: 20px;
  border-radius: 12px;
  margin-top: 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.result-banner.correct { background: rgba(39, 174, 96, 0.15); color: #2ecc71; border: 1px solid rgba(39, 174, 96, 0.3); }
.result-banner.wrong   { background: rgba(231, 76, 60, 0.1); color: #e74c3c; border: 1px solid rgba(231, 76, 60, 0.25); }
.result-banner.unanswered { background: var(--bg-card); color: var(--fg-muted); border: 1px solid var(--border); }

.mini-leaderboard {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 0.85rem;
}

.mini-lb-rank {
  font-family: var(--font-display);
  font-weight: 700;
  width: 20px;
  color: var(--fg-dim);
}
.mini-lb-rank.gold   { color: #f1c40f; }
.mini-lb-rank.silver { color: #bdc3c7; }
.mini-lb-rank.bronze { color: #cd7f32; }

.mini-lb-pseudo { flex: 1; font-weight: 600; }
.mini-lb-score  { font-family: var(--font-display); font-weight: 700; color: var(--accent-light); }
.mini-lb-delta  { font-size: 0.75rem; color: #27ae60; margin-left: 4px; }

/* ── Game over ── */
.gameover-phase {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
}

.gameover-phase h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.gameover-phase .winner-line {
  color: var(--fg-muted);
  margin-bottom: 40px;
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.podium-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
}

.podium-score {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.podium-block {
  border-radius: 8px 8px 0 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
}

.podium-step.first .podium-block  { background: rgba(241, 196, 15, 0.2); border: 2px solid #f1c40f; height: 100px; color: #f1c40f; }
.podium-step.second .podium-block { background: rgba(189, 195, 199, 0.15); border: 2px solid #bdc3c7; height: 70px; color: #bdc3c7; }
.podium-step.third .podium-block  { background: rgba(205, 127, 50, 0.15); border: 2px solid #cd7f32; height: 50px; color: #cd7f32; }

.final-leaderboard {
  text-align: left;
  margin-bottom: 32px;
}

.final-lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.final-lb-rank {
  font-family: var(--font-display);
  font-weight: 700;
  width: 28px;
  color: var(--fg-dim);
  font-size: 0.9rem;
}
.final-lb-rank.gold   { color: #f1c40f; }
.final-lb-rank.silver { color: #bdc3c7; }
.final-lb-rank.bronze { color: #cd7f32; }

.final-lb-pseudo { flex: 1; font-weight: 600; }
.final-lb-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-light);
}

/* ── Connecting state ── */
.connecting-state {
  text-align: center;
  padding: 80px 40px;
}

.connecting-state .pulse {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 24px;
}

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

.connecting-state p {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

/* ── Score bar in question phase ── */
.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.score-bar .my-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-light);
}

/* ── Game responsive ── */
@media (max-width: 600px) {
  .options-grid { grid-template-columns: 1fr; }
  .lobby-card, .waiting-room, .question-phase, .gameover-phase { padding: 28px 20px; }
  .podium-block { width: 64px; }
  .game-page { padding: 24px 16px; }
}