/* ===================================================================
   Metro ABC Adventure — Core Stylesheet
   Mobile-first, rounded, high-contrast, child-friendly (ages 3-8)
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;800&display=swap');

:root {
  /* Palette — bright, saturated, high-contrast for young readers */
  --sky-top: #4FC3F7;
  --sky-bottom: #B3E5FC;
  --line-red: #FF5A5F;
  --line-yellow: #FFC93C;
  --line-green: #3DDC97;
  --line-blue: #4A6CF7;
  --line-purple: #A66CFF;

  --ink: #1B2A4A;
  --ink-soft: #4B5A7A;
  --paper: #FFFFFF;
  --paper-soft: #F4F8FF;

  --gold: #FFC93C;
  --star: #FFD54F;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--sky-bottom);
  touch-action: manipulation;
}

button {
  font-family: var(--font-display);
  border: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------- Canvas ---------- */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ---------- Generic screen ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

/* ===================================================================
   BOOT / LOADING SCREEN
   =================================================================== */
.boot-screen {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  gap: 18px;
}

.boot-track {
  width: min(280px, 70vw);
  height: 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 8px;
  position: relative;
  margin-bottom: 8px;
}

.boot-train {
  position: absolute;
  top: -22px;
  left: 0;
  font-size: 40px;
  animation: boot-chug 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

@keyframes boot-chug {
  0% { left: 0; transform: scaleX(1); }
  48% { left: calc(100% - 40px); transform: scaleX(1); }
  50% { transform: scaleX(-1); }
  98% { left: 0; transform: scaleX(-1); }
  100% { transform: scaleX(-1); }
}

.boot-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 7vw, 42px);
  color: var(--ink);
  text-align: center;
  margin: 0;
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
}

.boot-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  margin: -10px 0 10px;
  font-weight: 600;
}

.boot-bar-track {
  width: min(260px, 65vw);
  height: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--line-green), var(--gold));
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.boot-status {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ===================================================================
   MAIN MENU
   =================================================================== */
.menu-screen {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 55%, #E8F5E9 100%);
  justify-content: flex-start;
  overflow-y: auto;
  gap: 4px;
}

.menu-clouds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(60px 34px at 15% 12%, rgba(255,255,255,0.9), transparent 70%),
    radial-gradient(80px 40px at 80% 8%, rgba(255,255,255,0.8), transparent 70%),
    radial-gradient(50px 28px at 55% 18%, rgba(255,255,255,0.7), transparent 70%);
}

.menu-header { text-align: center; margin-top: 6px; }

.menu-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 8vw, 38px);
  margin: 0;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255,255,255,0.7);
}
.menu-logo span { color: var(--line-red); }

.menu-tag {
  margin: 2px 0 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--ink-soft);
}

.menu-mascot {
  font-size: 64px;
  margin: 6px 0 4px;
  animation: mascot-bob 2.6s ease-in-out infinite;
}
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.menu-buttons {
  width: 100%;
  max-width: 380px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.menu-btn {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  padding: 16px 10px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 rgba(0,0,0,0.12), 0 6px 14px rgba(0,0,0,0.08);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  min-height: 56px;
}
.menu-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
}

.menu-btn-primary {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--line-green), #2FBF8F);
  color: white;
  font-size: 18px;
  padding: 18px;
}
#btn-continue.hidden { display: none !important; }

.menu-footer { margin-top: 14px; margin-bottom: 4px; }
.menu-currency { display: flex; gap: 10px; }

/* Pills (coins / stars / xp) shared between HUD + menu */
.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}
.hud-icon { font-size: 16px; }

/* ===================================================================
   HUD (during ride)
   =================================================================== */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 8;
  padding: calc(12px + var(--safe-top)) 14px 0;
  pointer-events: none;
}
.hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  font-size: 18px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
}
.hud-xp { flex: 1; padding-right: 10px; }
.hud-xp-track {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.hud-xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--line-purple), var(--line-blue));
  border-radius: 999px;
  transition: width 0.3s ease;
}
.hud-station-banner {
  margin-top: 10px;
  align-self: center;
  width: fit-content;
  background: rgba(27,42,74,0.85);
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  margin-left: auto;
  margin-right: auto;
}

.hud-bottom {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  padding: 0 20px;
}
.hud-bottom > * { pointer-events: auto; }

.hud-round-btn {
  width: 60px; height: 60px;
  font-size: 26px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
}
.hud-round-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

.hud-horn-btn { background: linear-gradient(135deg, var(--gold), #FFB300); }

.hud-depart-btn {
  grid-column: unset;
  width: auto;
  padding: 16px 26px;
  font-size: 17px;
  border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 10px 20px rgba(0,0,0,0.2);
  animation: depart-pulse 1.6s ease-in-out infinite;
}
@keyframes depart-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ===================================================================
   MODAL
   =================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-panel {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius-lg);
  width: min(420px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 20px 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--paper-soft);
  font-size: 16px;
  color: var(--ink-soft);
}
.modal-content h2 {
  font-family: var(--font-display);
  margin-top: 0;
}

/* ===================================================================
   LEARNING SCREEN (Module 4)
   =================================================================== */
.learning-screen {
  background: linear-gradient(180deg, #FFF9E6 0%, #FFF3D0 100%);
  z-index: 15;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  justify-content: flex-start;
  gap: 10px;
}

.learning-close {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 2;
}

.learning-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.learning-progress .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  transition: background 0.2s ease, transform 0.2s ease;
}
.learning-progress .dot.active { background: var(--line-blue); transform: scale(1.3); }
.learning-progress .dot.done { background: var(--line-green); }

.learning-body {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
}

.learn-letter-pair {
  display: flex;
  gap: 18px;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(72px, 22vw, 120px);
  color: var(--line-blue);
  text-shadow: 0 4px 0 rgba(255,255,255,0.8);
}
.learn-letter-pair .lower { color: var(--line-purple); }

.learn-emoji-big { font-size: clamp(56px, 16vw, 90px); }
.learn-word { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); }

.learn-sound-btn {
  background: linear-gradient(135deg, var(--gold), #FFB300);
  color: var(--ink);
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
}
.learn-sound-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

.learn-next-btn {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(135deg, var(--line-green), #2FBF8F);
  color: white;
  font-size: 18px;
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 5px 0 rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.15);
  margin-top: 6px;
}
.learn-next-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

.learn-trace-canvas {
  touch-action: none;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  max-width: 100%;
}
.learn-trace-hint { color: var(--ink-soft); font-weight: 600; font-size: 14px; }

.learn-quiz-prompt { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--ink); }
.learn-quiz-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}
.learn-quiz-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 18px 6px;
  font-size: 48px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.1), 0 6px 14px rgba(0,0,0,0.08);
  transition: transform 0.1s ease;
}
.learn-quiz-card:active { transform: scale(0.94); }
.learn-quiz-card.correct { background: #E8F9F0; box-shadow: 0 0 0 3px var(--line-green); }
.learn-quiz-card.wrong { background: #FFEDEE; box-shadow: 0 0 0 3px var(--line-red); }

.learn-reward-burst {
  font-size: 64px;
  animation: reward-pop 0.5s ease;
}
@keyframes reward-pop {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* ===================================================================
   TOASTS (Module 6 — Reward Juice)
   =================================================================== */
.reward-toast {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 50;
  background: white;
  border-radius: 999px;
  padding: 10px 20px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  transition: transform 0.4s cubic-bezier(.2,.8,.3,1);
  max-width: 90vw;
}
.reward-toast.visible { transform: translateX(-50%) translateY(0); }
.reward-toast .toast-emoji { font-size: 26px; }
.reward-toast .toast-sub { font-weight: 600; color: var(--ink-soft); font-size: 12px; display: block; }

/* ===================================================================
   MINI-GAMES (Module 5)
   =================================================================== */
.game-area {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.game-title { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--ink); }
.game-score { font-weight: 700; color: var(--ink-soft); }

.game-stage {
  position: relative;
  width: 100%;
  height: 300px;
  background: linear-gradient(180deg, #E3F2FD 0%, #FFFFFF 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
}
.game-stage-rising { background: linear-gradient(180deg, #FFF9E6 0%, #FFFFFF 100%); }

.game-falling-item, .game-balloon {
  position: absolute;
  top: -10px;
  font-size: 44px;
  transition: transform 2.2s linear;
  cursor: pointer;
  user-select: none;
}
.game-balloon {
  top: auto;
  bottom: -60px;
  width: 54px;
  height: 64px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  transition: transform 2.4s linear;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.game-item-caught { transform: scale(1.6) !important; opacity: 0; transition: all 0.2s ease !important; }

.game-cat { font-size: 72px; margin: 4px 0; }

.game-memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}
.game-memory-card {
  aspect-ratio: 1;
  font-size: 30px;
  background: var(--line-blue);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
  transition: transform 0.15s ease, background 0.15s ease;
}
.game-memory-card.flipped, .game-memory-card.matched { background: white; box-shadow: 0 0 0 3px var(--line-blue); }
.game-memory-card.matched { box-shadow: 0 0 0 3px var(--line-green); opacity: 0.75; }

.game-color-target {
  width: 90px; height: 90px;
  border-radius: 50%;
  margin: 6px 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15), inset 0 0 0 4px white;
}
.game-color-card { font-size: 0; min-height: 64px; }

/* ===================================================================
   RESPONSIVE — tablet / desktop
   =================================================================== */
@media (min-width: 560px) {
  .menu-buttons { max-width: 460px; gap: 14px; }
  .menu-btn { font-size: 16px; }
}

@media (min-width: 900px) {
  .menu-screen { justify-content: center; }
  .menu-buttons { max-width: 520px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .boot-train, .menu-mascot, .hud-depart-btn { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Focus visibility (accessibility) ---------- */
button:focus-visible {
  outline: 3px solid var(--line-blue);
  outline-offset: 3px;
}

/* ---------- Accessibility toggles (Settings) ---------- */
body.large-text .menu-btn,
body.large-text .modal-content p,
body.large-text .hud-pill {
  font-size: 120%;
}

body.high-contrast {
  --ink: #000000;
  --ink-soft: #1a1a1a;
  --paper: #FFFFFF;
}
body.high-contrast .menu-btn {
  border: 2px solid #000;
}
body.high-contrast .hud-station-banner {
  background: #000;
}

