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

:root {
  --font: 'Nunito', system-ui, sans-serif;
  --bg: #F0F4FF;
  --card-bg: #ffffff;
  --text: #2D3436;
  --text-light: #636e72;
  --green: #00B894;
  --red: #E17055;
  --blue: #0984E3;
  --purple: #6C5CE7;
  --yellow: #FDCB6E;
  --coral: #FF6B6B;
  --teal: #00CEC9;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);
}

html, body { height: 100%; }

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

#app {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ── Screens ── */
.screen {
  min-height: 100vh;
  padding: 20px;
  animation: fadeIn .25s ease;
}
.screen.hidden { display: none; }
.screen.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Top Nav ── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card-bg);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav.hidden { display: none; }

.btn-back {
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  transition: background .2s;
}
.btn-back:hover { background: #e0e6ff; }

.nav-center {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.nav-stars {
  background: #FFF9E6;
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 15px;
  font-weight: 700;
  color: #b8860b;
}

/* ── HOME SCREEN ── */
.home-header {
  text-align: center;
  padding: 32px 0 24px;
}

.mascot-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}
.mascot {
  font-size: 72px;
  display: block;
  animation: bounce 2s infinite;
}
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.bubble {
  position: absolute;
  top: -12px;
  right: -80px;
  background: white;
  border: 3px solid var(--purple);
  border-radius: 16px 16px 16px 4px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--purple);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(108,92,231,.2);
}

.app-title {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 8px;
}
.app-title em {
  font-style: normal;
  color: var(--purple);
}
.app-sub {
  color: var(--text-light);
  font-size: 16px;
  font-weight: 600;
}

/* Activity Grid */
.activity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 8px 0 24px;
}

.activity-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 18px;
  cursor: pointer;
  border: 3px solid transparent;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.activity-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--ac-color);
  border-radius: var(--radius) var(--radius) 0 0;
}
.activity-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--ac-color);
}
.activity-card:active { transform: scale(.97); }

.ac-icon { font-size: 42px; display: block; margin-bottom: 10px; }
.ac-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.ac-desc { font-size: 12px; color: var(--text-light); font-weight: 600; line-height: 1.3; }
.ac-stars {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 11px;
  background: #FFF9E6;
  border-radius: 8px;
  padding: 3px 7px;
}

.home-footer {
  text-align: center;
  padding: 16px 0 32px;
}
.total-stars {
  background: white;
  border-radius: 14px;
  padding: 10px 24px;
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-light);
  box-shadow: var(--shadow);
}
.total-stars strong { color: #b8860b; }

/* ── LEVEL SELECT SCREEN ── */
#screen-level { padding-top: 24px; }

.level-header {
  text-align: center;
  margin-bottom: 36px;
}
.level-icon {
  font-size: 64px;
  margin-bottom: 12px;
  display: block;
  animation: bounce 2s infinite;
}
.level-header h2 { font-size: 28px; font-weight: 900; margin-bottom: 6px; }
.level-header p { color: var(--text-light); font-size: 15px; font-weight: 600; }

.level-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.level-card {
  background: white;
  border: 3px solid #e0e6ff;
  border-radius: var(--radius);
  padding: 20px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.level-card:hover { transform: translateX(6px); box-shadow: var(--shadow-lg); }
.level-easy:hover { border-color: var(--green); }
.level-medium:hover { border-color: var(--yellow); }
.level-hard:hover { border-color: var(--coral); }

.lc-stars { font-size: 20px; min-width: 60px; }
.lc-name { font-size: 20px; font-weight: 900; flex: 1; text-align: left; }
.lc-label { font-size: 13px; color: var(--text-light); font-weight: 600; }
.lc-best { font-size: 12px; color: var(--yellow); font-weight: 700; margin-left: 8px; }

/* ── ACTIVITY SCREEN ── */
#screen-activity { padding: 0; }

.status-bar {
  background: white;
  padding: 12px 20px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}
.progress-track {
  height: 10px;
  background: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--teal));
  border-radius: 10px;
  transition: width .4s ease;
}
.status-row {
  display: flex;
  justify-content: space-between;
}
.q-counter { font-size: 14px; font-weight: 700; color: var(--text-light); }
.score-chip {
  background: #E8F8F1;
  color: var(--green);
  border-radius: 8px;
  padding: 2px 10px;
  font-size: 14px;
  font-weight: 800;
}

.activity-content {
  padding: 24px 20px 40px;
}

/* ── Feedback Overlay ── */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .15s;
}
.feedback-overlay.hidden { display: none; }

.feedback-card {
  background: white;
  border-radius: 24px;
  padding: 36px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 90%;
}
.feedback-icon {
  font-size: 56px;
  margin-bottom: 12px;
  animation: popIn .3s cubic-bezier(.36,.07,.19,.97);
}
@keyframes popIn { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

.feedback-msg { font-size: 24px; font-weight: 900; margin-bottom: 6px; }
.feedback-detail { font-size: 15px; color: var(--text-light); margin-bottom: 20px; font-weight: 600; }

.btn-next {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 12px 32px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-next:hover { background: #5a4bd1; }
.btn-next:active { transform: scale(.96); }

/* ── RESULTS SCREEN ── */
#screen-results {
  display: flex;
  align-items: center;
  justify-content: center;
}
.results-wrap {
  text-align: center;
  padding: 20px;
}
.results-mascot { font-size: 80px; margin-bottom: 16px; animation: bounce 2s infinite; }
.results-title { font-size: 36px; font-weight: 900; margin-bottom: 12px; }
.results-stars { font-size: 48px; margin-bottom: 16px; letter-spacing: 4px; }
.results-score {
  font-size: 22px;
  font-weight: 700;
  background: white;
  border-radius: 16px;
  padding: 14px 28px;
  display: inline-block;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.results-score span { font-size: 32px; font-weight: 900; color: var(--purple); }
.results-msg { color: var(--text-light); font-size: 16px; font-weight: 600; margin-bottom: 28px; }
.results-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn-primary {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s, transform .1s;
  box-shadow: 0 4px 14px rgba(108,92,231,.4);
}
.btn-primary:hover { background: #5a4bd1; transform: translateY(-2px); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 3px solid #e0e6ff;
  border-radius: 14px;
  padding: 14px 28px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .2s, transform .1s;
}
.btn-secondary:hover { border-color: var(--purple); transform: translateY(-2px); }

/* ════════════════════════════════════════════
   ACTIVITY-SPECIFIC STYLES
   ════════════════════════════════════════════ */

/* Shared question elements */
.q-instruction {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 28px;
  line-height: 1.5;
}
.q-instruction strong { color: var(--text); font-weight: 900; }

.answer-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.num-input {
  width: 100px;
  height: 56px;
  border: 3px solid #e0e6ff;
  border-radius: 14px;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.num-input:focus { border-color: var(--purple); }
.num-input.wide { width: 130px; }

.btn-check {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s, transform .1s;
  box-shadow: 0 4px 14px rgba(0,184,148,.35);
}
.btn-check:hover { background: #00a381; transform: translateY(-1px); }
.btn-check:active { transform: scale(.96); }

/* ── NUMBER BONDS ── */
.bond-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 10px 0 4px;
}

.bond-whole {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 4px solid var(--purple);
  background: #F5F0FF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 900;
  color: var(--purple);
  position: relative;
  z-index: 1;
}

.bond-branches {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  margin-top: -2px;
}

.bond-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.bond-line {
  width: 3px;
  height: 50px;
  background: var(--purple);
  opacity: .5;
}
.bond-line-left { transform: rotate(-25deg); transform-origin: top center; }
.bond-line-right { transform: rotate(25deg); transform-origin: top center; }

.bond-parts-row {
  display: flex;
  gap: 60px;
  margin-top: -4px;
}

.bond-part {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--blue);
  background: #EFF8FF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
  color: var(--blue);
}

.bond-svg-wrap { text-align: center; }

/* Alternative: SVG-based bond diagram */
.bond-container {
  position: relative;
  width: 260px;
  height: 200px;
  margin: 0 auto;
}
.bond-node {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  position: absolute;
  border: 4px solid;
}
.bond-node.whole {
  top: 0; left: 50%; transform: translateX(-50%);
  border-color: var(--purple);
  background: #F5F0FF;
  color: var(--purple);
}
.bond-node.part-left {
  bottom: 0; left: 10%;
  border-color: var(--blue);
  background: #EFF8FF;
  color: var(--blue);
}
.bond-node.part-right {
  bottom: 0; right: 10%;
  border-color: var(--teal);
  background: #E8FFFE;
  color: var(--teal);
}
.bond-node.is-blank {
  border-style: dashed;
  background: #fafafa;
  color: #ccc;
}
.bond-node.is-blank .num-input {
  width: 68px;
  height: 48px;
  border: none;
  background: transparent;
  font-size: 24px;
  padding: 0;
}

.bond-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── PLACE VALUE ── */
.place-value-wrap {
  text-align: center;
}

.blocks-display {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  padding: 20px 0;
  flex-wrap: wrap;
  min-height: 140px;
}

.blocks-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.blocks-group-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.blocks-row { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; max-width: 180px; }

.block-one {
  width: 22px;
  height: 22px;
  background: #FF6B6B;
  border-radius: 4px;
  border: 2px solid #e55555;
}
.block-ten {
  width: 22px;
  height: 80px;
  background: #00B894;
  border-radius: 4px;
  border: 2px solid #009b79;
  position: relative;
}
.block-ten::after {
  content: '';
  position: absolute;
  inset: 3px 3px;
  border-top: 2px solid rgba(255,255,255,.4);
  border-bottom: 2px solid rgba(255,255,255,.4);
}
.block-hundred {
  width: 80px;
  height: 80px;
  background: #0984E3;
  border-radius: 4px;
  border: 2px solid #076dba;
  position: relative;
}
.block-thousand {
  width: 80px;
  height: 80px;
  background: var(--purple);
  border-radius: 4px;
  border: 2px solid #5a4bd1;
  opacity: .8;
}

.pv-question {
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0 20px;
}
.pv-number {
  font-size: 52px;
  font-weight: 900;
  color: var(--purple);
  margin: 0 0 8px;
  letter-spacing: 4px;
}
.pv-digit-highlight {
  background: #FFE066;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.place-labels {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 0 auto 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
}
.place-label {
  padding: 4px 12px;
  border-bottom: 2px solid #e0e6ff;
  text-align: center;
  width: 60px;
}

/* ── BAR MODEL ── */
.word-problem {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  border-left: 5px solid var(--blue);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.bar-model {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.bar-row:last-child { margin-bottom: 0; }

.bar-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-light);
  min-width: 56px;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.bar-track {
  flex: 1;
  display: flex;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #e0e6ff;
  position: relative;
}

.bar-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
  overflow: hidden;
  min-width: 24px;
  transition: width .3s;
}
.bar-seg.blue { background: var(--blue); }
.bar-seg.green { background: var(--green); }
.bar-seg.orange { background: var(--coral); }
.bar-seg.yellow { background: var(--yellow); color: #8B6914; }
.bar-seg.dashed {
  background: repeating-linear-gradient(
    90deg, #e0e6ff 0, #e0e6ff 8px, #fff 8px, #fff 14px
  );
  color: var(--purple);
  border: none;
}

/* ── MENTAL MATH ── */
.mental-math-box {
  background: white;
  border-radius: 24px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.math-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
}
.math-num {
  font-size: 52px;
  font-weight: 900;
  color: var(--text);
}
.math-op {
  font-size: 48px;
  font-weight: 900;
  color: var(--purple);
}
.math-eq {
  font-size: 44px;
  font-weight: 700;
  color: var(--text-light);
}
.math-blank {
  font-size: 52px;
  font-weight: 900;
  color: #ccc;
  width: 80px;
  border-bottom: 4px solid #ccc;
  text-align: center;
}

.math-timer-ring {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
}
.timer-bar {
  background: #e9ecef;
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  border-radius: 20px;
  transition: width .1s linear;
}

/* ── SKIP COUNTING ── */
.skip-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 10px 0 20px;
}

.seq-num {
  width: 72px;
  height: 72px;
  background: var(--purple);
  color: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(108,92,231,.3);
}

.seq-blank {
  width: 72px;
  height: 72px;
  border: 3px dashed var(--purple);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seq-blank input {
  width: 60px;
  height: 60px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  color: var(--purple);
  outline: none;
}

.seq-arrow {
  display: flex;
  align-items: center;
  color: #b2bec3;
  font-size: 20px;
  font-weight: 900;
  align-self: center;
}

.skip-hint {
  text-align: center;
  background: #F5F0FF;
  border-radius: 14px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 20px;
  display: inline-block;
}

/* ── COMPARE NUMBERS ── */
.compare-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.cmp-num {
  font-size: 48px;
  font-weight: 900;
  color: var(--text);
  background: white;
  border-radius: 18px;
  padding: 14px 24px;
  box-shadow: var(--shadow);
  min-width: 110px;
  text-align: center;
}

.symbol-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.symbol-btn {
  width: 70px;
  height: 58px;
  border: 3px solid #e0e6ff;
  border-radius: 14px;
  background: white;
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
  color: var(--text);
}
.symbol-btn:hover {
  border-color: var(--purple);
  background: #F5F0FF;
  color: var(--purple);
  transform: scale(1.05);
}
.symbol-btn.selected {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(108,92,231,.4);
}

/* ── Utility ── */
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ── Correct/Wrong feedback colors ── */
.feedback-card.correct { border-top: 6px solid var(--green); }
.feedback-card.wrong { border-top: 6px solid var(--red); }

/* ── CHOICE BUTTONS (Easy mode) ── */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}

.choice-btn {
  background: white;
  border: 3px solid #e0e6ff;
  border-radius: 20px;
  padding: 20px 12px;
  font-family: var(--font);
  font-size: 30px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s, box-shadow .15s;
  box-shadow: var(--shadow);
  line-height: 1;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--purple);
  background: #F5F0FF;
  color: var(--purple);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.choice-btn:active:not(:disabled) { transform: scale(.96); }
.choice-btn:disabled { cursor: default; }

.choice-btn.choice-correct {
  background: #E8FFF8;
  border-color: var(--green);
  color: var(--green);
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(0,184,148,.3);
}
.choice-btn.choice-wrong {
  background: #FFF0EE;
  border-color: var(--red);
  color: var(--red);
}

/* ── Responsive ── */
@media (max-width: 420px) {
  .app-title { font-size: 28px; }
  .activity-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ac-icon { font-size: 34px; }
  .math-num { font-size: 40px; }
  .math-op { font-size: 36px; }
  .cmp-num { font-size: 36px; padding: 12px 18px; }
}
