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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #dfe1e8;
  --text: #1e2333;
  --text-dim: #6b7085;
  --navy: #0f1d3d;
  --charcoal: #2b2d42;
  --accent: #0f1d3d;
  --accent-light: rgba(15, 29, 61, 0.07);
  --green: #16a34a;
  --green-bg: #ecfdf5;
  --green-border: #bbf7d0;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --blue: #2563eb;
  --purple: #7c3aed;
  --pink: #db2777;
  --orange: #ea580c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  animation: fadeIn 0.5s ease;
}

.screen.active { display: flex; }

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

/* ===== LANDING ===== */
.landing-container {
  margin: auto;
  text-align: center;
  padding: 2rem;
  max-width: 560px;
}

.landing-icon {
  font-size: 4.5rem;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.landing-title {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.landing-title .accent {
  color: var(--charcoal);
}

.landing-subtitle {
  color: var(--text-dim);
  font-size: 1.15rem;
  margin-bottom: 2rem;
}

.landing-tiers {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tier-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

.landing-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}

/* ===== BRANDING ===== */
.turnip-logo {
  height: 32px;
  width: auto;
  display: block;
}

.powered-by {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}

.powered-by a {
  display: flex;
  align-items: center;
  transition: opacity 0.2s ease;
}

.powered-by a:hover {
  opacity: 0.7;
}

.results-cta {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.cta-link {
  display: inline-block;
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
}

.cta-link:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  box-shadow: var(--shadow-md);
}

.results-logo {
  margin-top: 1.25rem;
}

.results-logo a {
  display: inline-flex;
  transition: opacity 0.2s ease;
}

.results-logo a:hover {
  opacity: 0.7;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--navy);
  color: #fff;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  padding: 1rem 2.8rem;
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(15, 29, 61, 0.25);
  letter-spacing: 0.3px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 29, 61, 0.3);
  background: #162a52;
}

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

/* ===== HUD ===== */
.quiz-hud {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.hud-question-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.hud-difficulty {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: #ecfdf5;
  color: var(--green);
  transition: all 0.4s ease;
}

.hud-difficulty[data-tier="intermediate"] {
  background: #eff6ff;
  color: var(--blue);
}
.hud-difficulty[data-tier="advanced"] {
  background: #f5f3ff;
  color: var(--purple);
}
.hud-difficulty[data-tier="expert"] {
  background: #fdf2f8;
  color: var(--pink);
}

.hud-center { flex: 1; min-width: 0; }

.progress-track {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: visible;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--purple), var(--pink));
  background-size: 400% 100%;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 14px;
  background: var(--border);
  transform: translateY(-50%);
  border-radius: 1px;
}

.hud-score {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--navy);
}

.hud-streak {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--orange);
  min-width: 40px;
  text-align: right;
  transition: all 0.3s ease;
}

/* ===== LEVEL UP BANNER ===== */
.level-up-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.level-up-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.level-up-text {
  padding: 0.75rem 2rem;
  border-radius: 60px;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--surface);
  border: 2px solid var(--navy);
  box-shadow: var(--shadow-lg);
  color: var(--navy);
}

/* ===== QUIZ BODY ===== */
.quiz-body {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateX(40px) scale(0.97); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.question-tier-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 20px;
  background: #ecfdf5;
  color: var(--green);
  margin-bottom: 1.25rem;
}

.question-tier-badge[data-tier="intermediate"] {
  background: #eff6ff;
  color: var(--blue);
}
.question-tier-badge[data-tier="advanced"] {
  background: #f5f3ff;
  color: var(--purple);
}
.question-tier-badge[data-tier="expert"] {
  background: #fdf2f8;
  color: var(--pink);
}

.question-text {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.55;
  margin-bottom: 1.75rem;
  color: var(--text);
}

/* ===== OPTIONS ===== */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

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

.option-label {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: all 0.2s ease;
}

.option-btn:hover:not(.disabled) .option-label {
  background: var(--navy);
  color: #fff;
}

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

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

.option-btn.disabled {
  cursor: default;
  opacity: 0.5;
}
.option-btn.correct.disabled,
.option-btn.wrong.disabled { opacity: 1; }

/* ===== FEEDBACK ===== */
.feedback-section {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  animation: fadeIn 0.4s ease;
  display: none;
}

.feedback-section.show {
  display: block;
}

.feedback-section.correct {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
}

.feedback-section.wrong {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
}

.feedback-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.feedback-message {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.feedback-message.correct { color: var(--green); }
.feedback-message.wrong { color: var(--red); }

.feedback-explanation {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.btn-next {
  background: var(--charcoal);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 2rem;
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-next:hover {
  background: var(--navy);
  box-shadow: var(--shadow-md);
}

/* ===== RESULTS ===== */
.results-container {
  margin: auto;
  text-align: center;
  padding: 2rem;
  max-width: 620px;
  animation: fadeIn 0.6s ease;
}

.results-badge {
  font-size: 5rem;
  margin-bottom: 0.5rem;
  animation: popIn 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes popIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.results-title {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
  color: var(--text);
}

.results-rank {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--navy);
}

.results-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 0.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
}

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

/* Breakdown */
.results-breakdown {
  text-align: left;
  margin-bottom: 2rem;
}

.breakdown-tier {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.breakdown-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.breakdown-name {
  font-weight: 600;
  font-size: 0.85rem;
  flex: 1;
  color: var(--text);
}

.breakdown-score {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .landing-title { font-size: 2.4rem; }
  .quiz-hud { flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1rem; }
  .hud-center { order: 3; flex-basis: 100%; }
  .results-stats { grid-template-columns: repeat(2, 1fr); }
  .question-text { font-size: 1.05rem; }
  .quiz-body { padding: 1.5rem 1rem 2rem; }
}

/* ===== UTILITY ANIMATIONS ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.shake { animation: shake 0.35s ease; }

@keyframes scoreFloat {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

.score-float {
  position: fixed;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--green);
  pointer-events: none;
  animation: scoreFloat 1s ease forwards;
  z-index: 200;
}
