/* ==========================================================================
   Math Adventure — Stylesheet
   Colourful, cheerful, animated, responsive.
   No external resources — all graphics are CSS/SVG.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --c-primary: #4a90d9;
  --c-primary-dark: #2e6eb5;
  --c-secondary: #ff9f43;
  --c-accent: #e84393;
  --c-success: #00b894;
  --c-success-light: #55efc4;
  --c-warning: #fdcb6e;
  --c-error: #ff6b6b;
  --c-error-dark: #d63031;
  --c-gold: #ffd700;
  --c-purple: #6c5ce7;

  --c-sky-top: #74b9ff;
  --c-sky-mid: #a8d8ff;
  --c-sky-bot: #d6f0ff;

  --c-text: #2d3436;
  --c-text-light: #636e72;
  --c-text-white: #ffffff;
  --c-card: #ffffff;
  --c-card-shadow: rgba(0, 0, 0, 0.12);

  --c-forest: #55efc4;
  --c-desert: #ffeaa7;
  --c-mountain: #dfe6e9;
  --c-village: #fab1a0;

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.2);

  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--c-text);
  background: linear-gradient(180deg, var(--c-sky-top) 0%, var(--c-sky-mid) 40%, var(--c-sky-bot) 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  animation: screen-in 0.4s ease;
  z-index: 1;
}
.screen.hidden { display: none; }

@keyframes screen-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Animated background: clouds ---------- */
.sky-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-pill);
  filter: blur(2px);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
}
.cloud::before {
  width: 60%; height: 140%;
  top: -40%; left: 15%;
}
.cloud::after {
  width: 45%; height: 120%;
  top: -30%; right: 10%;
}
@keyframes drift {
  from { transform: translateX(-200px); }
  to { transform: translateX(calc(100vw + 200px)); }
}

/* Floating animals (CSS emoji) */
.floating-animal {
  position: absolute;
  font-size: 2rem;
  animation: float-up-down 4s ease-in-out infinite;
  z-index: 0;
  opacity: 0.7;
}
@keyframes float-up-down {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

/* ---------- Home screen ---------- */
.home-screen {
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.game-title {
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 3px 3px 0 var(--c-primary-dark), 6px 6px 0 rgba(0,0,0,0.1);
  letter-spacing: 1px;
  animation: title-bounce 2s ease-in-out infinite;
  line-height: 1.1;
}
@keyframes title-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.tagline {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
  margin-bottom: 8px;
}

/* Explorer character (CSS art) */
.explorer-char {
  width: 100px;
  height: 100px;
  margin: 8px auto;
  animation: char-idle 2s ease-in-out infinite;
}
@keyframes char-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s;
  color: #fff;
  background: var(--c-primary);
  box-shadow: 0 4px 0 var(--c-primary-dark), var(--shadow-sm);
  position: relative;
  overflow: hidden;
  line-height: 1.2;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--c-primary-dark), var(--shadow-md); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--c-primary-dark), var(--shadow-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--c-primary); box-shadow: 0 4px 0 var(--c-primary-dark), var(--shadow-sm); }
.btn--secondary { background: var(--c-secondary); box-shadow: 0 4px 0 #e08e2e, var(--shadow-sm); }
.btn--accent { background: var(--c-accent); box-shadow: 0 4px 0 #c3397a, var(--shadow-sm); }
.btn--success { background: var(--c-success); box-shadow: 0 4px 0 #009479, var(--shadow-sm); }
.btn--danger { background: var(--c-error); box-shadow: 0 4px 0 var(--c-error-dark), var(--shadow-sm); }
.btn--gold { background: var(--c-gold); color: #8a6d00; box-shadow: 0 4px 0 #c9a800, var(--shadow-sm); }
.btn--ghost { background: rgba(255,255,255,0.85); color: var(--c-text); box-shadow: 0 4px 0 rgba(0,0,0,0.1), var(--shadow-sm); }

.btn--lg { font-size: clamp(1.2rem, 4vw, 1.5rem); padding: 18px 40px; }
.btn--sm { font-size: 0.9rem; padding: 8px 18px; }
.btn--full { width: 100%; }

/* ---------- Home button grid ---------- */
.home-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 380px;
  width: 100%;
  margin-top: 8px;
}
.home-buttons .btn--full { width: 100%; }

/* ---------- Top bar (sound toggle) ---------- */
.top-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  gap: 10px;
}
.icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.6rem;
  font-weight: 900;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s;
}
.icon-btn:hover { transform: scale(1.1); }
.icon-btn:active { transform: scale(0.95); }

/* ---------- Year / difficulty selection ---------- */
.year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  max-width: 600px;
  width: 100%;
  margin: 16px 0;
}
.year-card {
  background: var(--c-card);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 3px solid transparent;
}
.year-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--c-primary); }
.year-card:active { transform: scale(0.97); }
.year-card__num {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--c-primary);
}
.year-card__desc {
  font-size: 0.85rem;
  color: var(--c-text-light);
  margin-top: 4px;
}

.section-title {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  margin: 16px 0 8px;
  text-align: center;
}

/* ---------- Game screen ---------- */
.game-screen { justify-content: flex-start; }

.hud {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.hud__group { display: flex; align-items: center; gap: 6px; }
.hud__label { font-size: 0.75rem; font-weight: 700; color: var(--c-text-light); }
.hud__value { font-size: 1rem; font-weight: 900; color: var(--c-text); }
.hud__icon { font-size: 1.2rem; }

.hearts { display: flex; gap: 2px; }
.heart { font-size: 1.3rem; transition: transform 0.3s; }
.heart.lost { opacity: 0.25; filter: grayscale(1); transform: scale(0.8); }
.heart.beat { animation: heart-beat 0.6s ease; }
@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.4); }
  60% { transform: scale(0.9); }
}

/* Progress bar */
.progress-wrap {
  width: 100%;
  max-width: 600px;
  background: rgba(255,255,255,0.6);
  border-radius: var(--radius-pill);
  height: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--c-success), var(--c-success-light));
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
  width: 0%;
}

/* World banner */
.world-banner {
  width: 100%;
  max-width: 600px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
  margin-bottom: 8px;
}

/* Question card */
.question-card {
  width: 100%;
  max-width: 600px;
  background: var(--c-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
  text-align: center;
  margin-bottom: 16px;
  position: relative;
}
.question-card.shake { animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.question-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  background: var(--c-accent);
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}
.question-text {
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  font-weight: 900;
  color: var(--c-text);
  line-height: 1.3;
  word-break: break-word;
}

/* Answer buttons grid */
.answers {
  width: 100%;
  max-width: 600px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.answer-btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 22px 16px;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  line-height: 1.2;
  min-height: 72px;
}
.answer-btn:nth-child(1) { background: #ff6b6b; box-shadow: 0 4px 0 #c0392b; }
.answer-btn:nth-child(2) { background: #4a90d9; box-shadow: 0 4px 0 #2e6eb5; }
.answer-btn:nth-child(3) { background: #00b894; box-shadow: 0 4px 0 #009479; }
.answer-btn:nth-child(4) { background: #ff9f43; box-shadow: 0 4px 0 #e08e2e; }
.answer-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.answer-btn:active { transform: translateY(2px); }
.answer-btn.correct { animation: correct-flash 0.6s ease; }
.answer-btn.wrong { animation: wrong-flash 0.6s ease; }
.answer-btn.disabled { pointer-events: none; opacity: 0.6; }

@keyframes correct-flash {
  0%, 100% { background: #00b894; }
  50% { background: #55efc4; transform: scale(1.08); box-shadow: 0 0 30px rgba(0,184,148,0.6); }
}
@keyframes wrong-flash {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.5) saturate(2); }
}

.answer-label {
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: 0.7rem;
  font-weight: 800;
  opacity: 0.7;
  text-transform: uppercase;
}

/* ---------- Combo / feedback overlay ---------- */
.feedback-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}
.feedback-text {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  animation: feedback-pop 1s ease forwards;
}
@keyframes feedback-pop {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  30% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  70% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(1.5) rotate(0); opacity: 0; }
}

/* Celebration particles */
.particle {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 99;
}

/* ---------- Star burst ---------- */
.star-burst {
  position: fixed;
  font-size: 2rem;
  pointer-events: none;
  z-index: 99;
  animation: star-fly 1s ease-out forwards;
}
@keyframes star-fly {
  0% { transform: scale(0) rotate(0); opacity: 1; }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.5) rotate(360deg) translateY(-80px); opacity: 0; }
}

/* ---------- Coin pop ---------- */
.coin-pop {
  position: fixed;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--c-gold);
  text-shadow: 2px 2px 0 #c9a800;
  pointer-events: none;
  z-index: 99;
  animation: coin-fly 1s ease-out forwards;
}
@keyframes coin-fly {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.3s ease;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--c-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modal-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes modal-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal__title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--c-text);
  margin-bottom: 12px;
}
.modal__body {
  font-size: 1rem;
  color: var(--c-text-light);
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Leaderboard ---------- */
.leaderboard-list {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.lb-row__rank {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1rem;
  flex-shrink: 0;
}
.lb-row__rank--1 { background: #ffd700; color: #8a6d00; }
.lb-row__rank--2 { background: #c0c0c0; color: #555; }
.lb-row__rank--3 { background: #cd7f32; color: #fff; }
.lb-row__rank--other { background: var(--c-sky-mid); color: var(--c-text); }
.lb-row__name { font-weight: 800; flex: 1; }
.lb-row__score { font-weight: 900; color: var(--c-primary); }
.lb-row__year { font-size: 0.75rem; color: var(--c-text-light); }

/* ---------- Settings ---------- */
.settings-group {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.setting-row:last-child { border-bottom: none; }
.setting-row__label { font-weight: 700; font-size: 1rem; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 56px; height: 30px;
  border-radius: var(--radius-pill);
  background: #ccc;
  border: none;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s;
}
.toggle.on { background: var(--c-success); }
.toggle.on::after { transform: translateX(26px); }

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: #ddd;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--c-primary);
  cursor: pointer;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  gap: 6px;
}
.lang-btn {
  border: 2px solid transparent;
  background: #eee;
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}
.lang-btn.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary-dark); }

/* ---------- Achievements ---------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 500px;
  margin-top: 12px;
}
.badge {
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
.badge:hover { transform: scale(1.05); }
.badge__icon { font-size: 2.5rem; margin-bottom: 6px; }
.badge__name { font-weight: 800; font-size: 0.85rem; }
.badge__desc { font-size: 0.7rem; color: var(--c-text-light); margin-top: 2px; }
.badge--locked { opacity: 0.4; filter: grayscale(1); }

/* ---------- Lucky wheel ---------- */
.wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}
.wheel-wrap {
  position: relative;
  width: min(300px, 80vw);
  height: min(300px, 80vw);
}
.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 8px solid #fff;
  box-shadow: var(--shadow-lg);
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
  position: relative;
}
.wheel-pointer {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 28px solid var(--c-error);
  z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* ---------- Daily reward ---------- */
.daily-calendar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 400px;
  width: 100%;
  margin: 16px 0;
}
.daily-cell {
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.daily-cell__day { font-size: 0.7rem; font-weight: 700; color: var(--c-text-light); }
.daily-cell__reward { font-size: 1.5rem; margin: 4px 0; }
.daily-cell__coins { font-size: 0.8rem; font-weight: 800; color: var(--c-gold); }
.daily-cell--claimed { background: var(--c-success-light); }
.daily-cell--claimed::after {
  content: '✓';
  position: absolute;
  top: 4px; right: 6px;
  font-size: 1rem;
  color: var(--c-success);
  font-weight: 900;
}
.daily-cell--today {
  border: 3px solid var(--c-accent);
  animation: pulse-border 1.5s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,67,147,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(232,67,147,0); }
}

/* ---------- Boss level ---------- */
.boss-banner {
  width: 100%;
  max-width: 600px;
  background: linear-gradient(135deg, var(--c-error-dark), var(--c-accent));
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  margin-bottom: 12px;
  animation: boss-pulse 1s ease-in-out infinite;
  box-shadow: var(--shadow-md);
}
@keyframes boss-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.boss-char {
  font-size: 4rem;
  animation: boss-shake 0.5s ease-in-out infinite;
}
@keyframes boss-shake {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

/* ---------- Game over ---------- */
.game-over-screen { justify-content: center; text-align: center; gap: 12px; }
.game-over-title {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}
.score-display {
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  width: 100%;
}
.score-display__num {
  font-size: 3rem;
  font-weight: 900;
  color: var(--c-primary);
}
.score-display__stats {
  display: flex;
  justify-content: space-around;
  margin-top: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.stat-pill {
  background: var(--c-sky-mid);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ---------- Name input ---------- */
.name-input {
  width: 100%;
  max-width: 300px;
  padding: 12px 18px;
  border: 3px solid var(--c-primary);
  border-radius: var(--radius-pill);
  font-size: 1.1rem;
  font-family: var(--font-body);
  text-align: center;
  outline: none;
  margin: 8px 0;
}

/* ---------- Back button ---------- */
.back-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  font-weight: 900;
}

/* ---------- Pause overlay ---------- */
.pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 150;
}
.pause-overlay.hidden { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .answers { gap: 8px; }
  .answer-btn { padding: 18px 12px; min-height: 64px; }
  .home-buttons { gap: 10px; }
  .btn { padding: 12px 22px; }
  .question-card { padding: 18px 14px; }
  .hud { padding: 8px 10px; gap: 4px; }
  .hud__label { font-size: 0.65rem; }
  .hud__value { font-size: 0.9rem; }
}

@media (min-width: 768px) {
  .screen { padding: 24px; }
  .year-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gap-1 { gap: 8px; }

/* ---------- Treasure chest ---------- */
.treasure-chest {
  font-size: 4rem;
  animation: chest-bounce 0.8s ease-in-out infinite;
  cursor: pointer;
}
@keyframes chest-bounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-10px) rotate(-5deg); }
}
.treasure-chest.opening { animation: chest-open 0.6s ease forwards; }
@keyframes chest-open {
  0% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1.1) rotate(0); }
}

/* ---------- Credit footer ---------- */
.credit-footer {
  position: fixed;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 50;
  pointer-events: auto;
}
.credit-footer a {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--c-primary-dark);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.credit-footer a:hover {
  opacity: 1;
  text-decoration: underline;
}
