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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #a78bfa;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font-main: 'Outfit', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth
}

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

/* ═══════════ PARTICLES ═══════════ */
#particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none
}

/* ═══════════ GLASS CARD ═══════════ */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px)
}

/* ═══════════ GRADIENT TEXT ═══════════ */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text
}

/* ═══════════ BUTTONS ═══════════ */
.btn-primary,
.btn-secondary,
.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .3s ease
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 20px rgba(99, 102, 241, .35)
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(99, 102, 241, .5)
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border)
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary)
}

.btn-retry {
  background: linear-gradient(135deg, var(--accent-amber), #f97316);
  color: #fff;
  box-shadow: 0 4px 20px rgba(245, 158, 11, .35)
}

.btn-retry:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(245, 158, 11, .5)
}

/* ═══════════ HUD ═══════════ */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border)
}

.hud-left,
.hud-right {
  display: flex;
  gap: 16px
}

.hud-center {
  text-align: center
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em
}

.game-subtitle {
  font-size: .7rem;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs)
}

.hud-icon {
  font-size: 1.1rem
}

.hud-label {
  font-size: .7rem;
  color: var(--text-muted);
  display: none
}

.hud-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem
}

/* ═══════════ PROGRESS BAR ═══════════ */
#progress-bar-container {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  z-index: 100
}

#progress-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3));
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px var(--accent-1)
}

/* ═══════════ SCREENS ═══════════ */
.screen {
  display: none;
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: 80px 20px 40px;
  align-items: center;
  justify-content: center
}

.screen.active {
  display: flex;
  animation: fadeIn .5s ease
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ═══════════ WELCOME ═══════════ */
.welcome-card {
  max-width: 560px;
  width: 100%;
  padding: 48px 40px;
  text-align: center
}

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

@keyframes float {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-12px)
  }
}

.welcome-card h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: 16px;
  line-height: 1.2
}

.welcome-card>p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px
}

.feature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-xs);
  font-size: .9rem;
  color: var(--text-secondary)
}

.feature span {
  font-size: 1.2rem
}

/* ═══════════ MAP ═══════════ */
.map-container {
  max-width: 700px;
  width: 100%;
  text-align: center
}

.map-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px
}

.map-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  max-width: 500px;
  margin: 0 auto
}

.question-tile {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  cursor: pointer;
  transition: all .3s ease;
  overflow: hidden
}

.question-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(139, 92, 246, .1));
  opacity: 0;
  transition: opacity .3s ease
}

.question-tile:hover::before {
  opacity: 1
}

.question-tile:hover {
  transform: translateY(-4px) scale(1.05);
  border-color: var(--accent-1);
  box-shadow: 0 8px 30px rgba(99, 102, 241, .25)
}

.tile-number {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  position: relative;
  z-index: 1;
  color: #ffffff
}

.question-tile.completed {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  cursor: default;
  pointer-events: none
}

.question-tile.completed:hover {
  transform: none;
  box-shadow: none
}

.tile-check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: .8rem;
  color: var(--accent-green)
}

.question-tile.completed .tile-number {
  color: var(--accent-green);
  font-size: 1.3rem
}

/* ═══════════ QUESTION CARD ═══════════ */
.question-card {
  max-width: 680px;
  width: 100%;
  padding: 36px 32px
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px
}

.question-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-3)
}

.question-points {
  font-size: .85rem;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(245, 158, 11, 0.2)
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 28px
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--glass-bg);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .3s ease;
  text-align: left;
  font-family: var(--font-main);
  font-size: .95rem;
  color: var(--text-primary)
}

.option-btn:hover {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.08);
  transform: translateX(6px)
}

.option-letter {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
  color: var(--accent-3);
  flex-shrink: 0;
  transition: all .3s ease
}

.option-btn:hover .option-letter {
  background: var(--accent-1);
  color: #fff
}

.option-text {
  flex: 1
}

.option-btn.option-correct {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.12);
  animation: correctPulse .5s ease
}

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

.option-btn.option-wrong {
  border-color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
  animation: wrongShake .5s ease
}

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

@keyframes correctPulse {

  0%,
  100% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.02)
  }
}

@keyframes wrongShake {

  0%,
  100% {
    transform: translateX(0)
  }

  20% {
    transform: translateX(-8px)
  }

  40% {
    transform: translateX(8px)
  }

  60% {
    transform: translateX(-4px)
  }

  80% {
    transform: translateX(4px)
  }
}

/* ═══════════ OVERLAYS ═══════════ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px)
}

.overlay.active {
  display: flex;
  animation: fadeIn .3s ease
}

.overlay-content {
  max-width: 520px;
  width: 100%;
  padding: 40px 32px;
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto
}

/* Correct */
.correct-emoji,
.wrong-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: float 2s ease-in-out infinite
}

.correct-title,
.wrong-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px
}

.correct-title {
  color: var(--accent-green)
}

.wrong-title {
  color: var(--accent-red)
}

.correct-subtitle,
.wrong-subtitle {
  color: var(--text-secondary);
  margin-bottom: 20px
}

.points-earned {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-amber);
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(245, 158, 11, .4)
}

.explanation-box {
  text-align: left;
  padding: 16px 20px;
  border-radius: var(--radius-xs);
  margin-bottom: 24px;
  line-height: 1.6;
  font-size: .9rem;
  color: var(--text-secondary)
}

.explanation-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: .85rem
}

.correct-explanation {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2)
}

.wrong-explanation {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2)
}

/* ═══════════ CONFETTI ═══════════ */
.confetti-burst {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  overflow: hidden
}

.confetti-piece {
  position: absolute;
  top: -10px;
  animation: confettiFall linear forwards
}

.confetti-square {
  width: 10px;
  height: 10px;
  border-radius: 2px
}

.confetti-circle {
  width: 8px;
  height: 8px;
  border-radius: 50%
}

.confetti-strip {
  width: 4px;
  height: 14px;
  border-radius: 2px
}

@keyframes confettiFall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1
  }

  100% {
    transform: translateY(500px) rotate(720deg);
    opacity: 0
  }
}

/* ═══════════ MINI-GAMES ═══════════ */
.minigame-content {
  max-width: 580px
}

.minigame-header {
  margin-bottom: 24px
}

.minigame-emoji {
  font-size: 3rem;
  margin-bottom: 8px
}

.minigame-header h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px
}

.minigame-header p {
  color: var(--text-secondary);
  font-size: .9rem
}

.minigame-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
  font-size: .85rem;
  color: var(--accent-3)
}

.minigame-complete {
  padding: 20px 0
}

.minigame-complete h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 12px 0 8px
}

.minigame-complete p {
  color: var(--text-secondary);
  margin-bottom: 16px
}

/* Memory Match */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 360px;
  margin: 0 auto
}

.memory-card {
  aspect-ratio: 1;
  perspective: 600px;
  cursor: pointer
}

.memory-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .4s ease
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg)
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  backface-visibility: hidden;
  font-size: 1.8rem
}

.memory-card-front {
  background: linear-gradient(135deg, rgba(99, 102, 241, .2), rgba(139, 92, 246, .15));
  border: 1.5px solid var(--glass-border);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-3)
}

.memory-card-back {
  background: linear-gradient(135deg, rgba(99, 102, 241, .3), rgba(139, 92, 246, .2));
  border: 1.5px solid var(--accent-1);
  transform: rotateY(180deg)
}

.memory-card.matched .memory-card-front,
.memory-card.matched .memory-card-back {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.15)
}

/* Quick Tap */
.quicktap-arena {
  position: relative;
  width: 100%;
  height: 280px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  margin-bottom: 16px;
  overflow: hidden
}

.qt-target {
  position: absolute;
  font-size: 2rem;
  cursor: pointer;
  animation: qtPop .3s ease;
  transition: transform .1s;
  user-select: none
}

.qt-target:hover {
  transform: scale(1.2)
}

.qt-target.qt-popped {
  animation: qtBurst .2s ease forwards
}

@keyframes qtPop {
  from {
    transform: scale(0)
  }

  to {
    transform: scale(1)
  }
}

@keyframes qtBurst {
  to {
    transform: scale(2);
    opacity: 0
  }
}

/* Word Scramble */
.scramble-area {
  max-width: 400px;
  margin: 0 auto
}

.scramble-hint {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-xs)
}

.scramble-letters {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 12px;
  color: var(--accent-3);
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite
}

.scramble-input {
  width: 100%;
  padding: 14px 20px;
  background: var(--glass-bg);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .3s
}

.scramble-input:focus {
  border-color: var(--accent-1)
}

.scramble-feedback {
  height: 28px;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 12px
}

.scramble-correct {
  color: var(--accent-green)
}

.scramble-wrong {
  color: var(--accent-red)
}

/* ═══════════ RESULTS ═══════════ */
.results-card {
  max-width: 520px;
  width: 100%;
  padding: 48px 36px;
  text-align: center
}

.results-emoji {
  font-size: 4rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: float 3s ease-in-out infinite
}

.results-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 6px
}

.results-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px
}

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

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  min-width: 100px
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-amber)
}

.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px
}

.results-grade {
  margin-bottom: 28px
}

.grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  border-radius: 50%;
  border: 3px solid
}

.grade-s {
  color: #FFD700;
  border-color: #FFD700;
  background: rgba(255, 215, 0, 0.1);
  text-shadow: 0 0 20px rgba(255, 215, 0, .5)
}

.grade-a {
  color: var(--accent-green);
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1)
}

.grade-b {
  color: var(--accent-1);
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.1)
}

.grade-c {
  color: var(--accent-amber);
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.1)
}

.grade-d {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1)
}

/* ═══════════ SCORE POP ═══════════ */
.score-pop {
  animation: scorePop .3s ease
}

@keyframes scorePop {
  0% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.3);
    color: var(--accent-amber)
  }

  100% {
    transform: scale(1)
  }
}

/* ═══════════ RESPONSIVE ═══════════ */
@media(max-width:640px) {
  #hud {
    padding: 10px 12px
  }

  .hud-item {
    padding: 4px 10px;
    gap: 4px
  }

  .hud-value {
    font-size: .8rem
  }

  .game-title {
    font-size: .9rem
  }

  .game-subtitle {
    font-size: .6rem
  }

  .welcome-card {
    padding: 32px 24px
  }

  .welcome-card h2 {
    font-size: 1.5rem
  }

  .question-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px
  }

  .question-card {
    padding: 24px 20px
  }

  .question-text {
    font-size: .95rem
  }

  .overlay-content {
    padding: 28px 20px
  }

  .results-stats {
    flex-wrap: wrap;
    gap: 12px
  }

  .stat-item {
    min-width: 80px;
    padding: 12px 14px
  }

  .memory-grid {
    grid-template-columns: repeat(3, 1fr)
  }

  .scramble-letters {
    font-size: 1.8rem;
    letter-spacing: 8px
  }
}

@media(min-width:641px) {
  .hud-label {
    display: inline
  }
}