/* ===========================================================
   Maiah's Math World — shared design system
   Dark space theme, kid-friendly, mobile-first.
   =========================================================== */

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

:root {
  /* Path colours */
  --c-numbers:     #378ADD;
  --c-addition:    #639922;
  --c-timestables: #EF9F27;
  --c-fractions:   #D85A30;
  --c-measurement: #1D9E75;
  --c-shapes:      #D4537E;

  /* Space theme */
  --bg-top:    #1a1a2e;
  --bg-bottom: #16213e;
  --accent:    #00ff88;          /* glowing green */
  --ink:       #ffffff;
  --ink-soft:  #b8c2e0;
  --card:      rgba(255,255,255,0.07);
  --card-edge: rgba(255,255,255,0.15);
  --gold:      #ffd84d;

  /* The 5 bubble gradient colours (reused everywhere) */
  --bub-blue:   linear-gradient(135deg,#4facfe,#2575fc);
  --bub-pink:   linear-gradient(135deg,#ff6ec4,#d4537e);
  --bub-green:  linear-gradient(135deg,#5ee7a0,#1d9e75);
  --bub-yellow: linear-gradient(135deg,#ffe259,#ef9f27);
  --bub-purple: linear-gradient(135deg,#a18cd1,#8e44ad);

  /* This page's accent — overridden per path via inline style */
  --path: var(--accent);
}

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

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: 'Nunito', 'Comic Sans MS', system-ui, sans-serif;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
  overflow-x: hidden;
}

/* Star particle background canvas */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

/* ---------- Typography ---------- */
h1 { font-size: 34px; font-weight: 900; margin: 0; }
h2 { font-size: 28px; font-weight: 800; margin: 0 0 8px; }
h3 { font-size: 22px; font-weight: 800; margin: 0; }
p  { font-size: 18px; }
.small { font-size: 16px; color: var(--ink-soft); }

/* ---------- Header bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.topbar .title { display: flex; align-items: center; gap: 10px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 20px;
  color: #08101f;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  min-height: 52px;
  min-width: 52px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.btn:hover  { transform: translateY(-2px) scale(1.03); filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn.path  { background: var(--path); color: #fff; }
.btn.ghost {
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--card-edge);
  box-shadow: none;
}
.btn.big { font-size: 24px; padding: 18px 40px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.backbtn {
  position: relative;
  z-index: 2;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 16px;
  padding: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

/* Path card */
.path-card {
  border-radius: 16px;
  padding: 18px;
  color: #fff;
  cursor: pointer;
  border: none;
  text-align: left;
  font-family: inherit;
  background: var(--pc, #444);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: transform .14s ease, box-shadow .14s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.path-card:hover { transform: translateY(-4px) scale(1.02); }
.path-card:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.path-card .pc-emoji { font-size: 40px; }
.path-card .pc-name { font-size: 22px; font-weight: 900; }
.path-card .pc-stars { font-weight: 800; font-size: 18px; }

/* Hero / daily challenge */
.hero {
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 18px;
  background: linear-gradient(120deg, #ff9a3c, #ff6ec4 70%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  cursor: pointer;
  border: none;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: transform .14s ease;
}
.hero:hover { transform: scale(1.015); }
.hero .hero-emoji { font-size: 54px; }

/* ---------- Progress bar ---------- */
.progress {
  height: 14px;
  background: rgba(0,0,0,.3);
  border-radius: 999px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width .5s ease;
}

/* ---------- Star rating ---------- */
.stars { display: inline-flex; gap: 4px; font-size: 22px; line-height: 1; }
.stars .s { filter: grayscale(1) brightness(.6); transition: transform .3s ease, filter .3s ease; }
.stars .s.on { filter: none; }
.stars.big { font-size: 44px; }
@keyframes pop { 0%{transform:scale(0)} 60%{transform:scale(1.35)} 100%{transform:scale(1)} }
.stars .s.pop { animation: pop .45s ease both; }

/* ---------- Topic list (path page) ---------- */
.path-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
@media (max-width: 760px) { .path-layout { grid-template-columns: 1fr; } }

.topic {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--ink);
  transition: transform .12s ease, border-color .12s ease;
}
.topic:hover:not(:disabled) { transform: translateX(4px); }
.topic.active { border-color: var(--path); box-shadow: 0 0 0 2px var(--path); }
.topic:disabled { opacity: .5; cursor: not-allowed; }
.topic .t-num {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%;
  background: var(--path);
  color: #fff; font-weight: 900;
  display: grid; place-items: center;
  font-size: 20px;
}
.topic .t-body { flex: 1; min-width: 0; }
.topic .t-name { font-weight: 800; font-size: 18px; }

/* ---------- Game shell (used by every game) ---------- */
.game-shell {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hud .chip { background: var(--card); }
.hud .path-name { font-weight: 900; color: var(--path); font-size: 20px; }

/* Centered overlay screens (start / game over) */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 20px;
}
.screen .panel {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 22px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.screen .big-emoji { font-size: 64px; }

/* Generic play area */
.play-area {
  flex: 1;
  position: relative;
}

/* Option buttons (multiple choice) */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.option {
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--card-edge);
  border-radius: 16px;
  padding: 20px;
  min-height: 64px;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.option:hover { transform: translateY(-2px); border-color: var(--path); }
.option:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
.option.correct { background: #1d9e75; border-color: #2fe6a8; color:#fff; }
.option.wrong   { background: #c0392b; border-color: #ff7a6b; color:#fff; }
.option:disabled { cursor: default; }

/* Feedback toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(40px);
  background: #08101f;
  border: 2px solid var(--accent);
  color: #fff;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  z-index: 50;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Big question display */
.question {
  font-size: 44px;
  font-weight: 900;
  text-align: center;
  margin: 10px 0 20px;
}
@media (max-width: 480px) { .question { font-size: 34px; } }

/* Text input for typed answers */
.answer-input {
  font-family: inherit;
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  width: 180px;
  max-width: 70vw;
  padding: 12px;
  border-radius: 14px;
  border: 3px solid var(--card-edge);
  background: rgba(0,0,0,.25);
  color: #fff;
}
.answer-input:focus { outline: none; border-color: var(--path); }

/* Round dots progress (e.g. q 3/10) */
.dots { display: flex; gap: 6px; justify-content: center; margin: 6px 0 14px; }
.dots .d { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.2); }
.dots .d.done { background: var(--path); }
.dots .d.wrong { background: #c0392b; }

.center { text-align: center; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* Badge animation (path champion / streak) */
@keyframes badgePop { 0%{transform:scale(0) rotate(-20deg);opacity:0} 60%{transform:scale(1.2) rotate(8deg)} 100%{transform:scale(1) rotate(0);opacity:1} }
.badge-pop { animation: badgePop .6s ease both; }
