/* EXAM QUEST — Pixel Art Quiz Game */

:root {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #252540;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #fbbf24;
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #fbbf24;
  --orange: #f59e0b;
  --purple: #a78bfa;
  --pink: #f472b6;
  --cyan: #06b6d4;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Press Start 2P', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  image-rendering: pixelated;
}

/* --- Screens --- */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  min-height: 100dvh;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.screen.active {
  display: flex;
}

/* --- Home Screen --- */
.home-header {
  text-align: center;
  margin: 30px 0 24px;
}
.game-title {
  font-size: 28px;
  letter-spacing: 4px;
  color: var(--text);
  text-shadow: 3px 3px 0 var(--bg3);
}
.title-accent {
  color: var(--accent);
}
.game-subtitle {
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 2px;
}

/* Subject Cards */
.subject-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}
.subject-card {
  background: var(--bg2);
  border: 2px solid var(--bg3);
  padding: 16px 12px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.subject-card:hover, .subject-card:active {
  transform: scale(1.03);
  border-color: var(--accent);
}
.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}
.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.card-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}
.card-title {
  font-size: 9px;
  color: var(--text);
}
.card-level {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 6px;
}
.card-stats {
  font-size: 7px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* XP Bar */
.xp-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  overflow: hidden;
}
.xp-bar-container.large {
  height: 10px;
  margin-top: 6px;
}
.xp-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.5s ease-out;
}

/* Overall Stats */
.overall-stats {
  display: flex;
  gap: 6px;
  font-size: 7px;
  color: var(--text-dim);
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 16px;
}
.stat-divider {
  color: var(--bg3);
}

/* Nav */
.home-nav {
  display: flex;
  gap: 12px;
}
.nav-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 10px 20px;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
}
.nav-btn:hover {
  border-color: var(--accent);
}

/* --- Mode Select --- */
.back-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  align-self: flex-start;
  margin-bottom: 16px;
}
.back-btn:hover {
  color: var(--text);
}
.mode-title {
  font-size: 18px;
  margin-bottom: 4px;
}
.mode-subtitle {
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.mode-card {
  font-family: inherit;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, border-color 0.2s;
  width: 100%;
}
.mode-card:hover, .mode-card:active {
  transform: scale(1.02);
  border-color: var(--accent);
}
.mode-card.boss {
  border-color: var(--red);
  background: linear-gradient(135deg, var(--bg2) 0%, #2e1a1a 100%);
}
.mode-card.boss:hover {
  border-color: #ff6b6b;
}
/* --- Topic Select --- */
.topic-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.topic-toggle-btn {
  font-family: inherit;
  font-size: 7px;
  padding: 6px 14px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
}
.topic-toggle-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}
.topic-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  max-height: 55vh;
  overflow-y: auto;
}
.topic-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  cursor: pointer;
  transition: border-color 0.2s;
  border: 2px solid var(--bg3);
  user-select: none;
}
.topic-item:hover {
  border-color: var(--accent);
}
.topic-item input[type="checkbox"] {
  display: none;
}
.topic-check {
  width: 16px;
  height: 16px;
  border: 2px solid var(--bg3);
  flex-shrink: 0;
  position: relative;
}
.topic-item input:checked ~ .topic-check {
  background: var(--accent);
  border-color: var(--accent);
}
.topic-item input:checked ~ .topic-check::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 8px;
  height: 8px;
  background: var(--bg);
}
.topic-name {
  font-size: 8px;
  color: var(--text);
  flex: 1;
}
.topic-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topic-acc {
  font-size: 7px;
  color: var(--text-dim);
}
.topic-acc.good { color: var(--green); }
.topic-acc.mid { color: var(--orange); }
.topic-acc.weak { color: var(--red); }
.topic-qty {
  font-size: 7px;
  color: var(--text-dim);
}
.topic-count {
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.topic-continue {
  width: 100%;
  max-width: 300px;
}
.topic-continue:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Topic pills on mode screen */
.mode-selected-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  justify-content: center;
}
.topic-pill {
  font-size: 6px;
  padding: 4px 8px;
  border: 1px solid var(--bg3);
  color: var(--text-dim);
}

.mode-name {
  font-size: 11px;
  color: var(--text);
  margin-bottom: 4px;
}
.mode-desc {
  font-size: 8px;
  color: var(--text-dim);
}

/* --- Game Screen --- */
#game-screen {
  padding: 12px 12px;
  justify-content: flex-start;
  gap: 0;
  position: relative;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 8px;
  min-height: 48px;
}
.hud-left {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heart {
  font-size: 16px;
  margin: 0 1px;
  transition: transform 0.2s;
}
.heart.alive { color: var(--red); }
.heart.dead { color: var(--bg3); }

#character-canvas {
  width: 48px;
  height: 48px;
}

.q-number {
  font-size: 9px;
  color: var(--text-dim);
}
.q-topic {
  font-size: 7px;
  color: var(--accent);
}

.streak {
  font-size: 11px;
  color: var(--text-dim);
  transition: color 0.2s;
}
.streak.on-fire {
  color: var(--orange);
  animation: pulse 0.5s ease-in-out infinite;
}
.score {
  font-size: 14px;
  color: var(--accent);
}

/* Timer */
.timer-container {
  width: 100%;
  height: 8px;
  background: var(--bg3);
  margin-bottom: 16px;
  position: relative;
}
.timer-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.05s linear;
}
.timer-bar.urgent {
  background: var(--red);
  animation: pulse 0.3s ease-in-out infinite;
}
.timer-text {
  position: absolute;
  right: 4px;
  top: 10px;
  font-size: 8px;
  color: var(--text-dim);
}

/* Question */
.question-area {
  width: 100%;
  text-align: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.question-difficulty {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 10px;
}
.diff-pip {
  width: 8px;
  height: 8px;
  background: var(--bg3);
}
.diff-pip.active {
  background: var(--accent);
}
.question-text {
  font-size: 11px;
  line-height: 1.8;
  color: var(--text);
  padding: 0 4px;
}

/* Answer Options */
.answer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
}
.answer-btn {
  font-family: inherit;
  font-size: 8px;
  line-height: 1.5;
  padding: 14px 10px;
  border: 3px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, filter 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 70px;
  position: relative;
}
.answer-btn:hover:not(:disabled) {
  transform: scale(1.03);
  filter: brightness(1.1);
}
.answer-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.answer-label {
  font-size: 10px;
  font-weight: bold;
  opacity: 0.7;
}
.answer-text {
  font-size: 8px;
  line-height: 1.5;
}

/* Answer Colors */
.answer-red { background: #dc2626; color: #fff; }
.answer-blue { background: #2563eb; color: #fff; }
.answer-green { background: #16a34a; color: #fff; }
.answer-yellow { background: #ca8a04; color: #fff; }

/* Numeric input questions */
.input-answer-area {
  grid-column: 1 / -1;
  padding: 16px;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  text-align: center;
}
.input-label {
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.input-prefix, .input-suffix {
  font-size: 12px;
  color: var(--accent);
}
.numeric-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 2px solid var(--accent);
  color: var(--text);
  text-align: center;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}
.numeric-input:focus {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.3);
}
.numeric-input:disabled {
  opacity: 0.5;
  border-color: var(--bg3);
}
.input-hint {
  font-size: 7px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.6;
}
.input-result {
  font-size: 9px;
  margin-top: 12px;
  padding: 8px;
  line-height: 1.6;
}
.input-result.correct {
  color: var(--green);
  border-top: 1px solid rgba(34, 197, 94, 0.3);
}
.input-result.wrong {
  color: var(--red);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
}
.timer-bar.paused {
  background: var(--bg3);
  opacity: 0.5;
}

/* Multi-select */
.answer-btn.selected {
  border-color: #fff;
  filter: brightness(1.2);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}
.multi-submit-btn {
  font-family: inherit;
  font-size: 10px;
  padding: 12px 24px;
  margin-top: 8px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s, filter 0.1s;
}
.multi-submit-btn:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* Answer States */
.answer-btn:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none !important;
}
.answer-btn.correct {
  opacity: 1 !important;
  border-color: #fff;
  animation: correctPulse 0.5s ease-out;
}
.answer-btn.wrong {
  opacity: 1 !important;
  border-color: var(--red);
  animation: wrongShake 0.3s ease-out;
}

/* Feedback */
.feedback-area {
  width: 100%;
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.3s;
}
.feedback-area.correct, .feedback-area.wrong {
  min-height: 60px;
  padding: 12px;
  margin-top: 4px;
}
.feedback-area.correct {
  background: rgba(34, 197, 94, 0.15);
  border-left: 3px solid var(--green);
}
.feedback-area.wrong {
  background: rgba(239, 68, 68, 0.15);
  border-left: 3px solid var(--red);
}
.feedback-header {
  font-size: 10px;
  margin-bottom: 6px;
}
.feedback-area.correct .feedback-header { color: var(--green); }
.feedback-area.wrong .feedback-header { color: var(--red); }
.feedback-explain {
  font-size: 7px;
  line-height: 1.7;
  color: var(--text-dim);
}
.next-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 10px 24px;
  margin-top: 10px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  display: inline-block;
}
.next-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}
.next-btn:active {
  transform: scale(0.97);
}

/* Particles */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  animation: particleFly 0.8s ease-out forwards;
}

/* Screen Shake */
.shake {
  animation: shake 0.4s ease-out;
}

/* --- Result Screen --- */
#result-screen {
  padding-top: 30px;
  gap: 16px;
}
.result-header {
  text-align: center;
}
.result-header h2 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
}
.result-subject {
  font-size: 10px;
}
.result-grade-container {
  text-align: center;
  margin: 8px 0;
}
.result-grade {
  font-size: 48px;
  line-height: 1;
}
.grade-s { color: #fbbf24; text-shadow: 0 0 20px rgba(251, 191, 36, 0.5); }
.grade-a { color: #22c55e; }
.grade-b { color: #3b82f6; }
.grade-c { color: #a78bfa; }
.grade-d { color: #f59e0b; }
.grade-f { color: #ef4444; }
.result-grade-label {
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 4px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}
.result-stat {
  text-align: center;
  padding: 10px 4px;
  background: var(--bg2);
}
.result-stat-value {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 4px;
}
.result-stat-label {
  font-size: 6px;
  color: var(--text-dim);
}

.result-xp-area {
  width: 100%;
  background: var(--bg2);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#result-xp {
  font-size: 12px;
  color: var(--green);
}
#result-level {
  font-size: 9px;
  color: var(--accent);
  margin-left: auto;
}

/* Achievements in results */
.result-achievements {
  width: 100%;
}
.achievement-unlock {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, var(--bg2) 100%);
  border: 2px solid var(--accent);
  margin-bottom: 6px;
  animation: achieveSlide 0.5s ease-out;
}
.achievement-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}
.achievement-name {
  font-size: 9px;
  color: var(--accent);
  margin-bottom: 2px;
}
.achievement-desc {
  font-size: 7px;
  color: var(--text-dim);
}

/* Weak Topics */
.result-weak-topics {
  width: 100%;
  background: var(--bg2);
  padding: 12px;
}
.weak-title {
  font-size: 8px;
  color: var(--orange);
  margin-bottom: 8px;
}
.weak-topic {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: var(--text-dim);
  padding: 4px 0;
  border-bottom: 1px solid var(--bg3);
}

/* Review Mistakes */
.result-review {
  width: 100%;
}
.review-title {
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.review-item {
  background: var(--bg2);
  padding: 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--red);
}
.review-q {
  font-size: 8px;
  line-height: 1.6;
  margin-bottom: 6px;
}
.review-correct {
  font-size: 7px;
  color: var(--green);
  margin-bottom: 4px;
}
.review-explain {
  font-size: 7px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Result Actions */
.result-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding-bottom: 30px;
}
.action-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 14px 20px;
  border: 2px solid var(--bg3);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
  flex: 1;
  transition: transform 0.1s, border-color 0.2s;
}
.action-btn:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}
.action-btn.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.action-btn.primary:hover {
  filter: brightness(1.1);
}

/* --- Achievements Screen --- */
.screen-title {
  font-size: 16px;
  margin-bottom: 20px;
  color: var(--text);
}
.badge-count {
  font-size: 10px;
  color: var(--text-dim);
}
.achievements-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 30px;
}
.achievement-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg2);
  border: 2px solid var(--bg3);
}
.achievement-card.earned {
  border-color: var(--accent);
}
.achievement-card.locked {
  opacity: 0.4;
}
.achievement-card .achievement-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.achievement-card.earned .achievement-icon { color: var(--accent); }
.achievement-card.locked .achievement-icon { color: var(--text-dim); }

/* --- Stats Screen --- */
.stats-details {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-subject {
  background: var(--bg2);
  padding: 14px;
  border-left: 3px solid var(--accent);
}
.stat-subject-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 10px;
}
.stat-subject-header span:first-child {
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.stat-level {
  margin-left: auto;
  color: var(--accent);
  font-size: 10px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: var(--text-dim);
  padding: 3px 0;
}
.stat-overall {
  background: var(--bg2);
  padding: 14px;
  border-left: 3px solid var(--text-dim);
}
.danger-btn {
  font-family: inherit;
  font-size: 7px;
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  cursor: pointer;
  opacity: 0.5;
  margin-bottom: 30px;
}
.danger-btn:hover {
  opacity: 1;
}

/* --- Pixel Icon --- */
.pixel-icon {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Mode Section Labels --- */
.mode-section-label {
  font-size: 7px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin: 12px 0 6px;
  width: 100%;
  text-align: left;
}
.mode-card.study-mode {
  border-color: var(--purple);
  background: linear-gradient(135deg, var(--bg2) 0%, #1e1a2e 100%);
}
.mode-card.study-mode:hover {
  border-color: var(--pink);
}

/* --- Flashcard Screen --- */
.flash-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 16px;
}
.flash-progress {
  font-size: 9px;
  color: var(--text-dim);
}
.flash-piles {
  font-size: 9px;
}
.flash-card {
  width: 100%;
  max-width: 500px;
  min-height: 300px;
  perspective: 800px;
  cursor: pointer;
  margin-bottom: 16px;
}
.flash-card-inner {
  width: 100%;
  min-height: 300px;
  position: relative;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flash-card-inner.flipped {
  transform: rotateY(180deg);
}
.flash-front, .flash-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.flash-back {
  transform: rotateY(180deg);
  overflow-y: auto;
}
.flash-topic {
  font-size: 7px;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.flash-question {
  font-size: 11px;
  line-height: 1.8;
  text-align: center;
  color: var(--text);
}
.flash-tap-hint {
  font-size: 7px;
  color: var(--text-dim);
  margin-top: 20px;
  opacity: 0.5;
}
.flash-answer {
  font-size: 12px;
  color: var(--green);
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.6;
}
.flash-explanation {
  font-size: 8px;
  color: var(--text-dim);
  line-height: 1.8;
  text-align: center;
}
.flash-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 500px;
}
.flash-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 14px 12px;
  border: 2px solid var(--bg3);
  cursor: pointer;
  flex: 1;
  transition: transform 0.1s;
}
.flash-btn:hover { transform: scale(1.03); }
.flash-btn.learning {
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange);
  border-color: var(--orange);
}
.flash-btn.know {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border-color: var(--green);
}
.flash-done {
  text-align: center;
  padding: 24px;
}
.flash-done-title {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
}
.flash-done-stat {
  font-size: 9px;
  color: var(--text-dim);
  margin: 4px 0;
}

/* --- Learn Screen --- */
.learn-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 16px;
}
.learn-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  padding: 20px 16px;
}
.learn-question {
  font-size: 11px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}
.learn-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.learn-input-area {
  margin-bottom: 8px;
}
.learn-feedback {
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.3s;
}
.learn-feedback.correct, .learn-feedback.wrong {
  padding: 12px;
  margin-top: 8px;
}
.learn-feedback.correct {
  background: rgba(34, 197, 94, 0.1);
  border-left: 3px solid var(--green);
}
.learn-feedback.wrong {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--red);
}

/* --- Sync Screen --- */
.sync-desc {
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.6;
  text-align: center;
}
.sync-section {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  padding: 16px;
  margin-bottom: 12px;
}
.sync-label {
  font-size: 8px;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.sync-code-area {
  display: flex;
  gap: 8px;
}
.sync-code-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 2px solid var(--accent);
  color: var(--text);
  flex: 1;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  outline: none;
}
.sync-code-input:focus {
  border-color: #fff;
}
.sync-status {
  font-size: 8px;
  color: var(--text-dim);
  margin: 12px 0;
  text-align: center;
  min-height: 20px;
  line-height: 1.6;
}
.sync-hint {
  font-size: 7px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
  opacity: 0.6;
  max-width: 350px;
}

/* --- Glossary --- */
.glossary-search {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 12px 14px;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  color: var(--text);
  width: 100%;
  max-width: 600px;
  margin-bottom: 16px;
  outline: none;
}
.glossary-search:focus { border-color: var(--accent); }
.glossary-search::placeholder { color: var(--text-dim); }
.glossary-list {
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  overflow-y: auto;
}
.glossary-item {
  padding: 12px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--bg3);
  cursor: pointer;
  transition: background 0.2s;
}
.glossary-item:hover { background: var(--bg3); }
.glossary-term {
  font-size: 8px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.glossary-def {
  font-size: 8px;
  color: var(--text-dim);
  line-height: 1.7;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.glossary-empty {
  font-size: 8px;
  color: var(--text-dim);
  padding: 20px;
  text-align: center;
}
/* Glossary popup */
.glossary-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.glossary-popup-inner {
  background: var(--bg2);
  border: 2px solid var(--accent);
  padding: 24px 20px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.glossary-popup-term {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.glossary-popup-def {
  font-size: 9px;
  line-height: 2;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin-bottom: 16px;
}
.glossary-popup-close {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  width: 100%;
}
.glossary-popup-close:hover { opacity: 0.9; }
/* Inline glossary highlights in Read mode */
.glossary-highlight {
  color: var(--cyan);
  border-bottom: 1px dotted var(--cyan);
  cursor: pointer;
  transition: color 0.2s;
}
.glossary-highlight:hover {
  color: #fff;
}

/* --- Read Mode --- */
.read-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
}
.read-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  width: 100%;
}
.read-nav-pill {
  font-family: inherit;
  font-size: 6px;
  padding: 5px 8px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.read-nav-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}
.read-nav-pill.active {
  background: var(--bg3);
}
.read-content {
  width: 100%;
  max-width: 700px;
  margin-bottom: 20px;
}
.read-title {
  font-size: 14px;
  margin-bottom: 20px;
  letter-spacing: 2px;
}
.read-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg2);
  border-left: 3px solid var(--bg3);
}
.read-heading {
  font-size: 9px;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.read-body {
  font-size: 9px;
  line-height: 2;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.read-fun-fact {
  width: 100%;
  max-width: 700px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.08) 100%);
  border: 1px solid rgba(139, 92, 246, 0.25);
  font-size: 8px;
  line-height: 1.8;
  color: var(--text-dim);
  margin-bottom: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.fun-fact-label {
  color: var(--purple);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 6px;
}
.read-nav-btns {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 700px;
  margin-bottom: 40px;
}
.read-nav-btns .action-btn {
  flex: 1;
}
.mode-card.read-mode {
  border-color: var(--cyan, #06b6d4);
  background: linear-gradient(135deg, var(--bg2) 0%, #0e1e2e 100%);
}
.mode-card.read-mode:hover {
  border-color: var(--accent);
}

/* --- Animations --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}

@keyframes particleFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) scale(0); opacity: 0; }
}

@keyframes achieveSlide {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 400px) {
  .game-title { font-size: 22px; }
  .question-text { font-size: 10px; }
  .answer-btn { padding: 10px 8px; min-height: 60px; }
  .answer-text { font-size: 7px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 601px) {
  .game-title { font-size: 42px; letter-spacing: 6px; }
  .game-subtitle { font-size: 11px; }
  .subject-cards { max-width: 750px; gap: 16px; }
  .subject-card { padding: 24px 20px; }
  .card-title { font-size: 12px; }
  .card-level { font-size: 20px; }
  .card-stats { font-size: 9px; }
  .card-icon { width: 24px; height: 24px; }
  .xp-bar-container { height: 8px; }
  .overall-stats { font-size: 9px; gap: 10px; margin-bottom: 24px; }
  .nav-btn { font-size: 11px; padding: 12px 28px; }
  .mode-cards { max-width: 750px; }
  .mode-card { padding: 20px; }
  .mode-name { font-size: 14px; }
  .mode-desc { font-size: 10px; }
  .mode-title { font-size: 24px; }
  .mode-subtitle { font-size: 11px; }
  .mode-section-label { font-size: 9px; }
  .answer-options { max-width: 750px; }
  .answer-btn { padding: 18px 14px; min-height: 80px; }
  .answer-label { font-size: 13px; }
  .answer-text { font-size: 10px; }
  .question-text { font-size: 15px; }
  .q-number { font-size: 11px; }
  .q-topic { font-size: 9px; }
  .score { font-size: 18px; }
  .streak { font-size: 14px; }
  .timer-text { font-size: 10px; }
  .feedback-header { font-size: 13px; }
  .feedback-explain { font-size: 9px; }
  .next-btn { font-size: 11px; padding: 12px 30px; }
  .topic-list { max-height: 60vh; }
  .topic-item { padding: 12px 16px; }
  .topic-name { font-size: 10px; }
  .topic-acc, .topic-qty { font-size: 9px; }
  .topic-count { font-size: 10px; }
  .back-btn { font-size: 11px; }
  .screen-title { font-size: 20px; }
  .result-grade { font-size: 64px; }
  .result-stat-value { font-size: 18px; }
  .result-stat-label { font-size: 8px; }
  .result-stat { padding: 14px 8px; }
  #result-xp { font-size: 14px; }
  #result-level { font-size: 11px; }
  .action-btn { font-size: 11px; padding: 16px 24px; }
  .flash-card { max-width: 700px; min-height: 380px; }
  .flash-card-inner { min-height: 380px; }
  .flash-question { font-size: 14px; }
  .flash-answer { font-size: 15px; }
  .flash-explanation { font-size: 10px; }
  .flash-btn { font-size: 11px; padding: 16px; }
  .flash-actions { max-width: 700px; }
  .learn-card { max-width: 700px; padding: 28px 24px; }
  .learn-question { font-size: 14px; }
  .numeric-input { font-size: 20px; width: 260px; padding: 14px 20px; }
  .multi-submit-btn { font-size: 12px; padding: 14px 28px; }
  .sync-code-input { font-size: 18px; }
  .sync-desc { font-size: 10px; }
  .sync-section { max-width: 500px; }
  .stat-subject-header { font-size: 12px; }
  .stat-row { font-size: 9px; }
  .achievement-card { padding: 14px; }
  .achievement-name { font-size: 11px; }
  .achievement-desc { font-size: 9px; }
  .home-header { margin: 50px 0 36px; }
  .read-title { font-size: 20px; }
  .read-heading { font-size: 11px; }
  .read-body { font-size: 11px; }
  .read-content { max-width: 800px; }
  .read-fun-fact { max-width: 800px; font-size: 10px; }
  .read-nav-btns { max-width: 800px; }
  .read-nav-pill { font-size: 8px; padding: 6px 10px; }
  .read-section { padding: 20px; }
  .fun-fact-label { font-size: 8px; }
  .glossary-search { font-size: 11px; max-width: 700px; }
  .glossary-list { max-width: 700px; }
  .glossary-term { font-size: 10px; }
  .glossary-def { font-size: 10px; }
  .glossary-popup-term { font-size: 16px; }
  .glossary-popup-def { font-size: 11px; }
  .glossary-popup-inner { max-width: 600px; padding: 30px 28px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); }

/* Safe area for mobile */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .result-actions, .achievements-list, .stats-details {
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
  }
}
