@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Familjen+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  --bg:       #09090f;
  --surface:  #111118;
  --surface2: #18181f;
  --surface3: #1f1f28;
  --border:   #2a2a38;
  --border2:  #383848;
  --accent:   #f5a623;
  --accent2:  #3ecfcf;
  --accent3:  #e05c5c;
  --text:     #eeeef5;
  --muted:    #6b6b80;
  --muted2:   #9090a8;
  --success:  #3ecf8e;
  --error:    #e05c5c;
  --radius:   14px;
  --radius-sm: 8px;
  --font-display: 'Familjen Grotesk', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 999;
  opacity: 0.4;
}

/* Ambient glow */
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 60vh;
  background: radial-gradient(ellipse, rgba(245,166,35,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── LAYOUT ─────────────────────────────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}
.screen.active { display: flex; flex-direction: column; }

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ─── LANDING SCREEN ─────────────────────────────────────────── */
#screen-landing {
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.landing-inner { width: 100%; max-width: 420px; }

.logo-mark {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 24px;
  box-shadow: 0 0 40px rgba(245,166,35,0.3);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.landing-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.landing-title span {
  background: linear-gradient(120deg, var(--accent), #ffcc66);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-sub {
  color: var(--muted2);
  font-size: 15px;
  margin-bottom: 32px;
  font-weight: 400;
}

.disclaimer {
  background: rgba(245,166,35,0.07);
  border: 1px solid rgba(245,166,35,0.18);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.6;
  margin-bottom: 28px;
  text-align: left;
}

.disclaimer strong { color: var(--accent); font-weight: 600; }

.test-checks {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.check-btn {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}

.check-btn .icon { font-size: 22px; }
.check-btn:hover { background: var(--surface3); border-color: var(--border2); }
.check-btn:active { transform: scale(0.97); }
.check-btn.success { border-color: var(--success); color: var(--success); }
.check-btn.testing { border-color: var(--accent); color: var(--accent); animation: borderPulse 1s infinite; }

@keyframes borderPulse {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: rgba(245,166,35,0.3); }
}

.mode-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.mode-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.mode-btn {
  flex: 1;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  color: var(--muted2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn .mode-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.mode-btn:hover { border-color: var(--border2); color: var(--text); }
.mode-btn.selected { border-color: var(--accent); color: var(--accent); background: rgba(245,166,35,0.07); }

.start-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  color: #000;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.4;
  pointer-events: none;
}

.start-btn.ready { opacity: 1; pointer-events: all; }
.start-btn.ready:hover { background: #ffb93d; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(245,166,35,0.3); }
.start-btn.ready:active { transform: translateY(0); }

/* ─── SECTION INTRO SCREEN ───────────────────────────────────── */
#screen-intro {
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.intro-inner {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted2);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.section-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.intro-desc {
  color: var(--muted2);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 32px;
}

.intro-rules {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  margin-bottom: 28px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.5;
}

.rule-item:last-child { border-bottom: none; }

.rule-item .rule-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.next-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  color: #000;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.next-btn:hover { background: #ffb93d; transform: translateY(-1px); }
.next-btn:active { transform: translateY(0); }

/* ─── QUESTION SCREEN ────────────────────────────────────────── */
#screen-question {
  padding: 0;
}

.q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.q-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.q-counter {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted2);
}

.progress-track {
  height: 3px;
  background: var(--surface3);
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

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

/* Play button */
.play-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: all 0.2s;
  box-shadow: 0 0 0 0 rgba(245,166,35,0.4);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.play-btn:hover { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(245,166,35,0.15); }
.play-btn:active { transform: scale(0.97); }
.play-btn:disabled { cursor: not-allowed; opacity: 0.7; transform: none !important; box-shadow: none !important; }
.play-btn.playing { animation: playPulse 1.5s ease-in-out infinite; background: var(--surface3); border: 2px solid var(--accent); }
.play-btn.played { background: var(--surface3); border: 2px solid var(--border2); cursor: not-allowed; }

@keyframes playPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,166,35,0.4); }
  50% { box-shadow: 0 0 0 12px rgba(245,166,35,0.0); }
}

.play-hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.playing-label {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  display: none;
}

.playing-label.show { display: block; }

/* ─── TIMER BAR ──────────────────────────────────────────────── */
.timer-wrap {
  display: none;
}
.timer-wrap.show { display: block; }

.timer-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted2);
}

.timer-label .timer-num {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.timer-track {
  height: 5px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.timer-track::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transform-origin: left;
}

.timer-track.run-8::after {
  animation: drain 8s linear forwards;
}
.timer-track.run-10::after {
  animation: drain 10s linear forwards;
}
.timer-track.run-30::after {
  animation: drain 30s linear forwards;
}

@keyframes drain {
  from { width: 100%; }
  to { width: 0%; }
}

/* ─── MC CHOICES ─────────────────────────────────────────────── */
.choices-wrap {
  display: none;
  flex-direction: column;
  gap: 10px;
}
.choices-wrap.show { display: flex; }

.choice-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(245,166,35,0.06);
}

.choice-btn:active:not(:disabled) { transform: scale(0.98); }

.choice-letter {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.18s;
  color: var(--muted2);
}

.choice-btn.correct { border-color: var(--success); background: rgba(62,207,142,0.08); }
.choice-btn.correct .choice-letter { background: var(--success); color: #000; }
.choice-btn.incorrect { border-color: var(--error); background: rgba(224,92,92,0.08); }
.choice-btn.incorrect .choice-letter { background: var(--error); color: #fff; }
.choice-btn.reveal-correct { border-color: var(--success); opacity: 0.6; }
.choice-btn.reveal-correct .choice-letter { background: var(--success); color: #000; }

/* ─── VISUALIZER ─────────────────────────────────────────────── */
.visualizer-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.visualizer-wrap.show { display: flex; }

.visualizer-label {
  font-size: 13px;
  color: var(--accent2);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rec-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  animation: recPulse 1s infinite;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#visualizer-canvas {
  width: 100%;
  max-width: 440px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--surface3);
}

/* ─── SENTENCE DONE BTN ──────────────────────────────────────── */
.done-btn {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--accent2);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
  -webkit-tap-highlight-color: transparent;
}
.done-btn.show { display: block; }
.done-btn:hover { background: rgba(62,207,207,0.1); }
.done-btn:active { transform: scale(0.98); }

/* ─── REVEAL SCREEN ──────────────────────────────────────────── */
.reveal-wrap {
  display: none;
  flex-direction: column;
  gap: 16px;
}
.reveal-wrap.show { display: flex; animation: fadeUp 0.35s ease; }

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

.reveal-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reveal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.reveal-card-header.original { color: var(--accent); }
.reveal-card-header.yours { color: var(--accent2); }
.reveal-card-header.result-correct { color: var(--success); }
.reveal-card-header.result-incorrect { color: var(--error); }

.replay-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--muted2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.replay-btn:hover { border-color: var(--border2); color: var(--text); }

.reveal-card-body {
  padding: 16px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.reveal-card-body.muted { color: var(--muted2); font-style: italic; }

/* Explanation */
.explanation-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.7;
}
.explanation-card.wrong { border-left-color: var(--error); }
.explanation-card strong { color: var(--text); font-weight: 600; }

/* Key points checklist */
.keypoints-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.keypoints-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.keypoint-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.keypoint-item:last-child { border-bottom: none; }
.keypoint-item:hover { background: var(--surface3); }

.kp-check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1.5px solid var(--border2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
  margin-top: 2px;
  background: var(--surface3);
}

.keypoint-item.checked .kp-check {
  background: var(--success);
  border-color: var(--success);
  color: #000;
}

.kp-text {
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.5;
}

.keypoint-item.checked .kp-text { color: var(--text); }

/* ─── NEXT QUESTION BTN ──────────────────────────────────────── */
.q-next-btn {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  color: #000;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
  -webkit-tap-highlight-color: transparent;
  margin-top: 4px;
}
.q-next-btn.show { display: block; }
.q-next-btn:hover { background: #ffb93d; }
.q-next-btn:active { transform: scale(0.99); }

/* ─── RESULTS SCREEN ─────────────────────────────────────────── */
#screen-results {
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.results-inner {
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.results-emoji {
  font-size: 52px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.results-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 700;
  margin-bottom: 8px;
}

.results-sub {
  color: var(--muted2);
  font-size: 14px;
  margin-bottom: 32px;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
}

.score-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
}

.score-card .sc-icon { font-size: 20px; margin-bottom: 8px; }
.score-card .sc-label { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.score-card .sc-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--accent); }
.score-card .sc-total { font-size: 11px; color: var(--muted); }

.results-note {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 13px;
  color: var(--muted2);
  line-height: 1.6;
  margin-bottom: 24px;
  text-align: left;
}

.retake-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.retake-btn {
  width: 100%;
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.retake-btn.primary { background: var(--accent); border: none; color: #000; }
.retake-btn.primary:hover { background: #ffb93d; }
.retake-btn.secondary { background: transparent; border: 1.5px solid var(--border2); color: var(--muted2); }
.retake-btn.secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ─── UTILITY ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── MOBILE TWEAKS ──────────────────────────────────────────── */
@media (max-width: 400px) {
  .test-checks { flex-direction: column; }
  .mode-btns { flex-direction: column; }
  .score-grid { grid-template-columns: 1fr; }
  .q-body { padding: 16px 14px; }
}

@media (hover: none) {
  .choice-btn:hover:not(:disabled) { transform: none; }
  .next-btn:hover { transform: none; }
  .start-btn.ready:hover { transform: none; }
}
