:root {
  --bg: #f6f8ff;
  --surface: #ffffff;
  --text: #1e2433;
  --muted: #5c657d;
  --border: #e4e9f5;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --pink: #db2777;
  --purple: #7c3aed;
  --teal: #0d9488;
  --orange: #ea580c;
  --blue: #2563eb;
  --cyan: #0891b2;
  --rose: #e11d48;
  --shadow: 0 10px 30px rgba(30, 36, 51, 0.07);
  --radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3, h4, h5, .brand-title { font-family: 'Fredoka', 'Nunito', sans-serif; }

.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

.bg-shapes { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.shape {
  position: absolute; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 5rem;
  color: rgba(79, 70, 229, 0.045); user-select: none; animation: floatSlow 14s ease-in-out infinite;
}
.s1 { top: 12%; left: 6%; animation-delay: 0s; }
.s2 { top: 24%; right: 8%; animation-delay: 2s; }
.s3 { bottom: 18%; left: 10%; animation-delay: 4s; }
.s4 { bottom: 12%; right: 12%; animation-delay: 6s; }
.s5 { top: 55%; left: 48%; animation-delay: 8s; }

@keyframes floatSlow { 0%, 100% { transform: translateY(0px) rotate(0deg); } 50% { transform: translateY(-18px) rotate(8deg); } }
.pulse-anim { animation: pulseSlow 2.6s ease-in-out infinite; }
@keyframes pulseSlow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

/* Header */
.topbar {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  position: relative; z-index: 25;
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: grid; place-items: center; font-size: 1.45rem;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.28);
}
.brand-title { font-size: 1.35rem; line-height: 1.1; color: var(--text); }
.brand-sub { font-size: 0.79rem; color: var(--muted); }
.topbar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stat-pill { background: var(--primary-soft); color: var(--primary); font-weight: 800; padding: 6px 13px; border-radius: 999px; font-size: 0.88rem; display: flex; align-items: center; gap: 5px; }
.streak-pill { background: #fff7ed; color: var(--orange); }
.pill-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: inherit; font-weight: 700; font-size: 0.85rem; padding: 6px 13px;
  border-radius: 999px; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pill-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06); }

/* Sticky Menu Bar */
.menubar {
  position: sticky; top: 0; z-index: 24;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); box-shadow: 0 4px 16px rgba(30, 36, 51, 0.04);
}
.menubar-inner {
  max-width: 1220px; margin: 0 auto; padding: 8px 18px;
  display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none;
}
.menubar-inner::-webkit-scrollbar { display: none; }
.menu-item {
  border: 1px solid transparent; background: #f8fafc; color: var(--text);
  font-family: inherit; font-weight: 800; font-size: 0.83rem; padding: 7px 13px;
  border-radius: 999px; cursor: pointer; white-space: nowrap; transition: all 0.16s ease;
}
.menu-item:hover { background: var(--primary-soft); color: var(--primary); }
.menu-item.active { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25); }

/* Container & Views */
.container { position: relative; z-index: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 22px 20px 44px; flex: 1; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-banner { background: linear-gradient(135deg, #ffffff, #eef2ff); border: 1px solid var(--border); border-radius: 22px; padding: 20px 24px; margin-bottom: 18px; }
.page-banner h2 { font-size: 1.45rem; margin-bottom: 4px; }
.page-banner p { color: var(--muted); font-size: 0.94rem; }

/* Quick Hubs Row */
.quick-hubs-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 26px; }
.hub-tile { border: 1.5px solid var(--border); background: #fff; border-radius: 18px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left; font-family: inherit; transition: transform 0.16s ease, box-shadow 0.16s ease; }
.hub-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(30, 36, 51, 0.08); }
.hub-emoji { font-size: 2rem; line-height: 1; }
.hub-tile strong { display: block; font-size: 0.98rem; color: var(--text); }
.hub-tile small { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.hub-purple:hover { border-color: var(--purple); }
.hub-blue:hover { border-color: var(--blue); }
.hub-green:hover { border-color: var(--success); }
.hub-orange:hover { border-color: var(--orange); }

/* Hero */
.hero-card { background: linear-gradient(135deg, #ffffff 0%, #eef2ff 100%); border: 1px solid var(--border); border-radius: 26px; padding: 24px 28px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.hero-text { flex: 1; }
.hero-badge { display: inline-block; background: var(--success-soft); color: var(--success); font-weight: 800; font-size: 0.8rem; padding: 5px 12px; border-radius: 999px; margin-bottom: 10px; }
.hero-text h2 { font-size: clamp(1.35rem, 2.4vw, 1.9rem); margin-bottom: 8px; line-height: 1.25; }
.hero-text p { color: var(--muted); font-size: 0.95rem; line-height: 1.5; max-width: 720px; margin-bottom: 14px; }

.class-picker-box { background: rgba(255, 255, 255, 0.92); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.class-picker-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.syllabus-pill { background: var(--primary-soft); color: var(--primary); font-size: 0.78rem; font-weight: 800; padding: 5px 12px; border-radius: 999px; }
.class-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.class-btn { border: 1.5px solid var(--border); background: #fff; color: var(--text); font-family: inherit; font-weight: 800; font-size: 0.82rem; padding: 6px 11px; border-radius: 11px; cursor: pointer; transition: all 0.16s ease; }
.class-btn.senior-btn { border-color: #c7d2fe; background: #f5f3ff; }
.class-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.class-btn.active { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25); }

.difficulty-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.diff-label { font-weight: 800; font-size: 0.88rem; color: var(--text); }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.seg-btn { border: none; background: transparent; font-family: inherit; font-weight: 700; font-size: 0.84rem; padding: 6px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); transition: all 0.18s ease; }
.seg-btn.active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25); }

.hero-mascot { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 215px; }
.mascot-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 12px 14px; font-size: 0.84rem; font-weight: 700; text-align: center; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05); }
.mascot-avatar { font-size: 3.7rem; line-height: 1; }

/* Chapters */
.chapters-section { margin-bottom: 28px; }
.section-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-heading { font-size: 1.26rem; }
.chapters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.chapter-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; padding: 16px; cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; display: flex; flex-direction: column; gap: 6px; }
.chapter-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 12px 24px rgba(79, 70, 229, 0.1); }
.chapter-top { display: flex; align-items: center; justify-content: space-between; }
.chapter-num { font-size: 0.72rem; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 3px 8px; border-radius: 999px; }
.chapter-icon { font-size: 1.5rem; }
.chapter-card h4 { font-size: 1.02rem; line-height: 1.25; }
.chapter-card p { font-size: 0.82rem; color: var(--muted); line-height: 1.4; flex: 1; }
.chapter-types { font-size: 0.74rem; font-weight: 800; color: var(--teal); margin-top: 4px; }
.chapter-progress-bar { height: 6px; background: #f1f5f9; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.chapter-progress-fill { height: 100%; background: linear-gradient(90deg, #4f46e5, #10b981); transition: width 0.35s ease; }

/* Arcade Toolbar & Games Grid */
.arcade-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 28px; }
.game-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.game-card:hover { transform: translateY(-4px); box-shadow: 0 14px 28px rgba(30, 36, 51, 0.1); border-color: var(--primary); }
.featured-card { background: linear-gradient(145deg, #ffffff 0%, #eef2ff 100%); border-color: #c7d2fe; }
.new-ribbon { position: absolute; top: 10px; right: 10px; background: linear-gradient(135deg, #4f46e5, #db2777); color: #fff; font-size: 0.65rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.game-icon { font-size: 2rem; line-height: 1; }
.game-tag { align-self: flex-start; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.game-card h4 { font-size: 1.06rem; }
.game-card p { font-size: 0.84rem; color: var(--muted); line-height: 1.4; flex: 1; }
.play-cta { margin-top: 4px; font-weight: 800; font-size: 0.84rem; color: var(--primary); }

/* Formula Vault & About */
.formulas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin-bottom: 26px; }
.formula-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 4px 12px rgba(30,36,51,0.03); }
.formula-card h4 { font-size: 1.06rem; color: var(--text); }
.formula-math-box { background: #0f172a; color: #38bdf8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.94rem; font-weight: 700; padding: 10px 12px; border-radius: 12px; word-break: break-word; }
.formula-example { background: #f8fafc; border-left: 3px solid var(--success); padding: 8px 10px; border-radius: 8px; font-size: 0.84rem; color: var(--muted); }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }

/* Progress Banner */
.progress-banner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.progress-info h4 { font-size: 1.05rem; margin-bottom: 4px; }
.progress-info p { color: var(--muted); font-size: 0.9rem; }
.badges-row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-chip { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; font-weight: 800; font-size: 0.8rem; padding: 5px 11px; border-radius: 999px; }
.badge-chip.locked { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }

/* Dedicated Game Page Breadcrumbs & Meta Bar */
.game-page-breadcrumbs {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.84rem; font-weight: 700; color: var(--muted); margin-bottom: 10px;
}
.crumb-link { border: none; background: transparent; font-family: inherit; font-weight: 800; color: var(--primary); cursor: pointer; font-size: 0.84rem; }
.crumb-link:hover { text-decoration: underline; }
.route-pill { margin-left: auto; background: #e2e8f0; color: #334155; padding: 2px 10px; border-radius: 999px; font-family: ui-monospace, monospace; font-size: 0.76rem; }

.game-page-meta-bar {
  background: linear-gradient(90deg, #eef2ff, #fefce8);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.meta-desc { font-size: 0.86rem; font-weight: 700; color: var(--text); }
.meta-progress { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; font-weight: 800; color: var(--primary); }
.mini-lv-track { width: 110px; height: 9px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.mini-lv-fill { height: 100%; background: linear-gradient(90deg, #4f46e5, #f59e0b); transition: width 0.35s ease; }

/* Stage View */
.stage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.back-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: inherit; font-weight: 800; padding: 8px 15px; border-radius: 12px; cursor: pointer; }
.back-btn:hover { background: #f1f5f9; }
.stage-title-wrap { display: flex; align-items: center; gap: 10px; }
.stage-icon { font-size: 1.85rem; }
.stage-badges-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.stage-class-tag { font-size: 0.75rem; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 2px 9px; border-radius: 999px; }
.stage-level-tag { font-size: 0.75rem; font-weight: 800; color: #b45309; background: #fef3c7; padding: 2px 9px; border-radius: 999px; }
.stage-type-tag { font-size: 0.75rem; font-weight: 800; color: #0f766e; background: #ccfbf1; padding: 2px 9px; border-radius: 999px; }
.stage-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.type-stepper, .level-stepper { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); padding: 4px 8px; border-radius: 12px; font-size: 0.8rem; font-weight: 800; }
.step-mini-btn { border: none; background: #eef2ff; color: var(--primary); width: 25px; height: 25px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.step-mini-btn:hover { background: var(--primary); color: #fff; }
.zen-toggle { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.83rem; background: var(--surface); border: 1px solid var(--border); padding: 6px 11px; border-radius: 12px; cursor: pointer; }
.timer-pill { background: #fee2e2; color: #b91c1c; font-weight: 800; padding: 6px 13px; border-radius: 999px; }
.hidden { display: none !important; }

.game-stage { background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 24px; box-shadow: var(--shadow); min-height: 460px; }

/* FRUIT CUTTER DOJO ARENA */
.fruit-hud {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  background: linear-gradient(90deg, #1e293b, #334155); color: #fff;
  padding: 12px 18px; border-radius: 16px; margin-bottom: 14px;
}
.fruit-target-pill { background: #f59e0b; color: #1e293b; font-family: 'Fredoka', sans-serif; font-size: 1.25rem; font-weight: 700; padding: 6px 16px; border-radius: 999px; }
.fruit-canvas-wrap {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: 22px;
  overflow: hidden;
  border: 3px solid #92400e;
  background: radial-gradient(circle at center, #78350f 0%, #451a03 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.45);
  touch-action: none;
  cursor: crosshair;
}
.fruit-canvas { width: 100%; height: 100%; display: block; }
.fc-board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 6;
  animation: fadeIn 0.2s ease;
}
.fc-overlay-card {
  background: #ffffff;
  color: var(--text);
  border-radius: 22px;
  padding: 22px 26px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.35);
}
.fc-hud-restart {
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.fc-hud-restart:hover { background: rgba(255,255,255,0.26); }

/* PROGRESSIVE MEMORY PHOTO & STRIP GRID */
.memory-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.memory-grid {
  display: grid;
  gap: 11px;
  max-width: 820px;
  margin: 14px auto;
}
.memory-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.memory-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.memory-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 680px) {
  .memory-grid.cols-4, .memory-grid.cols-5, .memory-grid.cols-6 { grid-template-columns: repeat(3, 1fr); }
}

.mem-card {
  min-height: 92px;
  padding: 8px;
  border-radius: 16px;
  border: 2.5px solid #c7d2fe;
  background: linear-gradient(145deg, #4f46e5, #6366f1);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.mem-card:hover:not(.matched) { transform: translateY(-2px); }
.mem-card.open { background: #ffffff; color: var(--text); border-color: var(--primary); box-shadow: 0 8px 18px rgba(79,70,229,0.14); }
.mem-card.matched { background: var(--success-soft); color: #14532d; border-color: var(--success); cursor: default; }
.mem-card.wrong-flash { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.mem-photo-wrap { width: 54px; height: 54px; display: grid; place-items: center; }
.mem-photo-label { font-size: 0.76rem; font-weight: 800; color: var(--muted); }

/* Animated Chapter Quest Banner */
.chapter-quest-bar { background: linear-gradient(90deg, #eef2ff, #f0fdf4); border: 1px solid var(--border); border-radius: 16px; padding: 12px 16px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quest-runner-track { flex: 1; min-width: 180px; height: 14px; background: #e2e8f0; border-radius: 999px; position: relative; }
.quest-runner-fill { height: 100%; background: linear-gradient(90deg, #4f46e5, #10b981); border-radius: 999px; transition: width 0.4s ease; }
.quest-runner-avatar { position: absolute; top: -11px; font-size: 1.4rem; transform: translateX(-50%); transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Race, Tower, Monkey, Sheru, Rocket, Wheel */
.race-stadium { background: linear-gradient(180deg, #dbeafe 0%, #93c5fd 35%, #334155 35%, #1e293b 100%); border: 2px solid #475569; border-radius: 22px; padding: 16px; margin-bottom: 18px; position: relative; overflow: hidden; }
.race-hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 800; font-size: 0.88rem; }
.race-badge { background: rgba(255,255,255,0.92); padding: 4px 12px; border-radius: 999px; color: var(--text); }
.race-lane { position: relative; height: 54px; border-bottom: 2px dashed rgba(255,255,255,0.4); display: flex; align-items: center; }
.race-lane:last-child { border-bottom: none; }
.race-car { position: absolute; font-size: 2.35rem; transform: scaleX(-1); transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1); z-index: 3; }
.race-car.nitro { filter: drop-shadow(-8px 0 10px #f97316); }
.race-finish { position: absolute; right: 10px; font-size: 1.75rem; z-index: 2; }

.tower-stage { background: linear-gradient(180deg, #1e1b4b, #312e81); color: #fff; border-radius: 22px; padding: 18px 22px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hp-bar { width: 160px; height: 14px; background: rgba(255,255,255,0.2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.hp-fill { height: 100%; background: #22c55e; transition: width 0.35s ease; }
.hp-fill.boss { background: #ef4444; }

.jungle-stage { position: relative; height: 220px; border-radius: 22px; background: linear-gradient(180deg, #bae6fd 0%, #dcfce7 68%, #86efac 100%); border: 2px solid #86efac; overflow: hidden; margin-bottom: 18px; display: flex; align-items: flex-end; justify-content: space-around; padding: 16px; }
.jungle-sun { position: absolute; top: 14px; right: 20px; font-size: 2.3rem; animation: spinSlow 16s linear infinite; }
@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.tree-trunk { position: absolute; left: 26px; bottom: 0; width: 22px; height: 100%; background: #92400e; border-radius: 8px 8px 0 0; }
.monkey-sprite { position: absolute; bottom: 24px; left: 60px; font-size: 3.1rem; z-index: 4; transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); filter: drop-shadow(0 6px 8px rgba(0,0,0,0.18)); }
.monkey-sprite.leap { animation: monkeyArc 0.65s ease; }
@keyframes monkeyArc { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-68px) scale(1.15) rotate(-14deg); } 100% { transform: translateY(0) scale(1); } }
.branch-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; width: 100%; z-index: 3; }
.branch-btn { background: linear-gradient(135deg, #fef08a, #fde047); border: 3px solid #a16207; border-radius: 18px; padding: 12px 18px; min-width: 118px; font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 700; color: #713f12; cursor: pointer; box-shadow: 0 6px 0 #a16207; transition: transform 0.14s ease; }
.branch-btn:hover:not(:disabled) { transform: translateY(-4px); }
.branch-btn.correct { background: #86efac; border-color: #15803d; box-shadow: 0 6px 0 #15803d; }
.branch-btn.wrong { background: #fecaca; border-color: #b91c1c; animation: shake 0.35s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.sheru-track { position: relative; height: 185px; border-radius: 22px; background: linear-gradient(180deg, #fef3c7 0%, #fde68a 60%, #a16207 60%, #78350f 100%); border: 2px solid #f59e0b; overflow: hidden; margin-bottom: 18px; }
.sheru-sprite { position: absolute; bottom: 52px; left: 34px; font-size: 3.3rem; transition: left 0.55s ease; z-index: 4; }
.sheru-sprite.pounce { animation: lionLeap 0.6s ease; }
@keyframes lionLeap { 0% { transform: translateY(0) scale(1); } 50% { transform: translateY(-60px) scale(1.16); } 100% { transform: translateY(0) scale(1); } }
.sheru-obstacle { position: absolute; bottom: 52px; right: 110px; font-size: 2.5rem; transition: opacity 0.3s ease, transform 0.3s ease; }
.sheru-goal { position: absolute; bottom: 54px; right: 22px; font-size: 2.6rem; }

.space-stage { position: relative; height: 195px; border-radius: 22px; background: radial-gradient(circle at 80% 25%, #312e81, #0f172a); color: #fff; overflow: hidden; margin-bottom: 18px; padding: 16px; }
.rocket-sprite { position: absolute; left: 36px; bottom: 24px; font-size: 3rem; transition: left 0.6s ease, bottom 0.6s ease; }
.rocket-sprite.boost { animation: rocketThrust 0.65s ease; }
@keyframes rocketThrust { 0% { transform: rotate(25deg) scale(1); } 50% { transform: rotate(25deg) translate(16px, -28px) scale(1.2); } 100% { transform: rotate(25deg) scale(1); } }
.planet-goal { position: absolute; right: 26px; top: 22px; font-size: 3rem; }

.wheel-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 18px; }
.wheel-pointer { font-size: 1.8rem; line-height: 1; margin-bottom: -10px; z-index: 3; }
.spin-wheel { width: 210px; height: 210px; border-radius: 50%; border: 6px solid #fff; box-shadow: 0 10px 26px rgba(30,36,51,0.18); background: conic-gradient(#4f46e5 0deg 60deg, #ec4899 60deg 120deg, #f59e0b 120deg 180deg, #10b981 180deg 240deg, #06b6d4 240deg 300deg, #8b5cf6 300deg 360deg); transition: transform 2.4s cubic-bezier(0.17, 0.89, 0.24, 1); display: grid; place-items: center; }
.wheel-center { width: 54px; height: 54px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 1.5rem; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }

/* Shared Game UI Components */
.question-box { text-align: center; margin-bottom: 18px; }
.qtype-badge { display: inline-block; background: #e0f2fe; color: #0369a1; font-weight: 800; font-size: 0.74rem; padding: 4px 11px; border-radius: 999px; margin-bottom: 8px; text-transform: uppercase; }
.question-prompt { font-size: 0.96rem; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.question-main { font-family: 'Fredoka', sans-serif; font-size: clamp(1.45rem, 3.2vw, 2.25rem); font-weight: 700; color: var(--text); line-height: 1.3; }

.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 13px; max-width: 700px; margin: 0 auto 18px; }
.option-btn { border: 2px solid var(--border); background: #f8fafc; color: var(--text); font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 600; padding: 14px 12px; border-radius: 16px; cursor: pointer; transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease; }
.option-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--primary); background: var(--primary-soft); }
.option-btn.correct { background: var(--success-soft); border-color: var(--success); color: #14532d; }
.option-btn.wrong { background: #fef2f2; border-color: #f87171; color: #7f1d1d; }

.fill-answer-row { display: flex; justify-content: center; gap: 10px; max-width: 440px; margin: 0 auto 18px; flex-wrap: wrap; }
.bubble-arena { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin: 18px auto 22px; max-width: 720px; }
.bubble-btn { width: 108px; height: 108px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.85); font-family: 'Fredoka', sans-serif; font-size: 1.3rem; font-weight: 700; color: #fff; cursor: pointer; box-shadow: inset -6px -10px 18px rgba(0,0,0,0.14), 0 10px 20px rgba(37, 99, 235, 0.22); transition: transform 0.18s ease; animation: bob 3.2s ease-in-out infinite; }
.bubble-btn:nth-child(2n) { animation-delay: 0.6s; }
.bubble-btn:nth-child(3n) { animation-delay: 1.2s; }
.bubble-btn:hover:not(:disabled) { transform: scale(1.08); }
.bubble-btn.popped { transform: scale(1.2); opacity: 0; transition: all 0.25s ease; }
@keyframes bob { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-8px); } }

.visual-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 12px auto; padding: 12px; background: #f8fafc; border-radius: 14px; max-width: 520px; }
.dot-group { display: flex; flex-wrap: wrap; gap: 4px; max-width: 150px; padding: 6px 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; justify-content: center; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); }
.dot.alt { background: var(--orange); }

.action-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.btn-secondary { border: 1.5px solid #fde68a; background: #fffbeb; color: #92400e; font-family: inherit; font-weight: 800; padding: 10px 18px; border-radius: 12px; cursor: pointer; }
.btn-primary { border: none; background: var(--primary); color: #fff; font-family: inherit; font-weight: 800; padding: 10px 22px; border-radius: 12px; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.07); }

.hint-box, .feedback-box { max-width: 740px; margin: 16px auto 0; padding: 16px 20px; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; text-align: left; }
.hint-box { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.feedback-box.ok { background: var(--success-soft); border: 1.5px solid #86efac; color: #14532d; }
.feedback-box.try { background: #fff7ed; border: 1.5px solid #fdba74; color: #7c2d12; }
.feedback-box.error-alert {
  background: #fef2f2;
  border: 2px solid #ef4444;
  color: #991b1b;
  animation: errorShake 0.42s ease;
}
.stage-error-flash {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25) !important;
  animation: errorShake 0.42s ease;
}
@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.step-solution-card { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.step-line { background: rgba(255, 255, 255, 0.88); border-left: 4px solid var(--primary); padding: 7px 11px; border-radius: 8px; font-size: 0.92rem; color: var(--text); }
.auto-next-pill { font-size: 0.82rem; font-weight: 800; color: #15803d; background: #bbf7d0; padding: 5px 12px; border-radius: 999px; }
.auto-next-pill.warn-pill { color: #991b1b; background: #fecaca; }

.heart-lifeline-box { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.heart-bar-track { width: 104px; height: 8px; background: rgba(255,255,255,0.22); border-radius: 999px; overflow: hidden; }
.heart-bar-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #f43f5e); transition: width 0.3s ease; }

/* Scale, Pizza, Pattern, Magic Square, Tug, Factor */
.scale-visual { max-width: 580px; margin: 0 auto 22px; display: flex; flex-direction: column; align-items: center; }
.scale-beam { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f8fafc; border: 2px solid var(--border); border-radius: 18px; padding: 16px 20px; }
.scale-pan { flex: 1; background: #fff; border: 2px dashed #cbd5e1; border-radius: 14px; padding: 14px; text-align: center; font-family: 'Fredoka', sans-serif; font-size: 1.35rem; font-weight: 700; }
.scale-equals { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.scale-base { width: 0; height: 0; border-left: 22px solid transparent; border-right: 22px solid transparent; border-bottom: 24px solid var(--primary); margin-top: 4px; }

.pizza-layout { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 28px; margin: 18px 0; }
.pizza-svg { width: 220px; height: 220px; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.08)); }
.slice { cursor: pointer; transition: transform 0.15s ease, fill 0.15s ease; }
.fraction-readout { font-family: 'Fredoka', sans-serif; font-size: 2rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); padding: 14px 24px; border-radius: 18px; text-align: center; }

.pattern-row { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 24px; }
.pattern-tile { min-width: 68px; height: 68px; padding: 0 14px; border-radius: 16px; background: #f1f5f9; border: 2px solid var(--border); display: grid; place-items: center; font-family: 'Fredoka', sans-serif; font-size: 1.4rem; font-weight: 700; }
.pattern-tile.mystery { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.ms-header-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.ms-target-pill { background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff; font-family: 'Fredoka', sans-serif; font-size: 1.15rem; font-weight: 700; padding: 8px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgba(234, 88, 12, 0.25); }
.ms-board-wrap { display: flex; flex-direction: column; align-items: center; overflow-x: auto; padding: 8px 4px; }
.ms-grid { display: grid; gap: 6px; align-items: center; justify-items: center; }
.ms-cell { width: 54px; height: 54px; border-radius: 12px; border: 2px solid var(--border); background: #fff; font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 700; text-align: center; color: var(--primary); }
.ms-cell.fixed { background: #eef2ff; color: var(--text); border-color: #c7d2fe; }
.ms-cell:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.18); }
.ms-cell.bad { border-color: #ef4444; background: #fef2f2; }
.ms-cell.good { border-color: var(--success); background: var(--success-soft); }
.ms-sum-chip { min-width: 48px; height: 36px; padding: 0 8px; border-radius: 10px; background: #f1f5f9; color: var(--muted); font-size: 0.78rem; font-weight: 800; display: grid; place-items: center; }
.ms-sum-chip.match { background: var(--success-soft); color: #15803d; }
.ms-sum-chip.over { background: #fee2e2; color: #b91c1c; }
.ms-diag-bar { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
@media (max-width: 560px) { .ms-cell { width: 42px; height: 42px; font-size: 1rem; } .ms-sum-chip { min-width: 38px; font-size: 0.7rem; } }

.tug-arena { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 18px auto 22px; max-width: 680px; }
.tug-card { flex: 1; min-width: 180px; background: #f8fafc; border: 2px solid var(--border); border-radius: 18px; padding: 20px; text-align: center; font-family: 'Fredoka', sans-serif; font-size: 1.45rem; font-weight: 700; }
.tug-vs { font-weight: 800; font-size: 1.3rem; color: var(--primary); }
.compare-btns { display: flex; justify-content: center; gap: 14px; margin-bottom: 18px; }
.cmp-btn { min-width: 82px; font-size: 1.6rem; }

.sorter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 12px; max-width: 640px; margin: 16px auto 20px; }
.sort-tile { padding: 16px 10px; border-radius: 16px; border: 2px solid var(--border); background: #f8fafc; font-family: 'Fredoka', sans-serif; font-size: 1.35rem; font-weight: 700; cursor: pointer; transition: all 0.15s ease; }
.sort-tile.selected { background: var(--primary); color: #fff; border-color: var(--primary); transform: scale(1.04); }
.sort-tile.correct { background: var(--success-soft); color: #14532d; border-color: var(--success); }
.sort-tile.wrong { background: #fee2e2; color: #991b1b; border-color: #f87171; }

/* Labs & Tabs */
.lab-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.lab-tab { border: 1px solid var(--border); background: #f8fafc; padding: 8px 14px; border-radius: 12px; font-family: inherit; font-weight: 800; font-size: 0.85rem; cursor: pointer; }
.lab-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lab-panel { max-width: 760px; margin: 0 auto; background: #f8fafc; border: 1px solid var(--border); border-radius: 20px; padding: 22px; }
.lab-input-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lab-input { flex: 1; min-width: 140px; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 12px; font-family: inherit; font-size: 0.98rem; font-weight: 700; background: #fff; }
.steps-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.step-item { background: #fff; border-left: 4px solid var(--primary); padding: 10px 14px; border-radius: 8px; font-size: 0.94rem; }

.cipher-terminal { background: #0f172a; color: #e2e8f0; border-radius: 16px; padding: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 14px 0; }
.cipher-code-box { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.14em; color: #38bdf8; word-break: break-word; margin-top: 6px; }
.cipher-map-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cipher-chip { background: #1e293b; border: 1px solid #334155; color: #cbd5e1; padding: 5px 8px; border-radius: 8px; font-size: 0.78rem; }
.cipher-chip strong { color: #fbbf24; }

.table-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.table-num-btn { width: 42px; height: 42px; border-radius: 10px; border: 1.5px solid var(--border); background: #fff; font-family: 'Fredoka', sans-serif; font-weight: 700; cursor: pointer; }
.table-num-btn.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.table-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.table-fact { background: #fff; border: 1.5px solid var(--border); border-radius: 14px; padding: 12px; text-align: center; font-family: 'Fredoka', sans-serif; font-size: 1.15rem; }
.table-fact span { color: var(--primary); font-weight: 700; }

.geo-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 24px; margin: 14px 0; }
.geo-canvas-box { width: 260px; height: 220px; background: #fff; border: 2px dashed #cbd5e1; border-radius: 18px; display: grid; place-items: center; padding: 12px; }
.geo-sliders { flex: 1; min-width: 240px; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.geo-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.metric-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; text-align: center; }
.metric-val { font-family: 'Fredoka', sans-serif; font-size: 1.35rem; color: var(--primary); font-weight: 700; }

.magic-card { max-width: 580px; margin: 0 auto; text-align: center; background: linear-gradient(145deg, #fff1f2, #eef2ff); border: 2px solid #fbcfe8; border-radius: 22px; padding: 26px; }
.magic-step-badge { display: inline-block; background: var(--rose); color: #fff; font-weight: 800; font-size: 0.8rem; padding: 4px 12px; border-radius: 999px; margin-bottom: 12px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 24px; max-width: 560px; width: 100%; padding: 24px; position: relative; box-shadow: 0 24px 48px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 14px; right: 14px; border: none; background: #f1f5f9; width: 34px; height: 34px; border-radius: 50%; font-weight: 800; cursor: pointer; }
.cert-frame { border: 4px double #6366f1; border-radius: 18px; padding: 24px 20px; text-align: center; background: linear-gradient(180deg, #ffffff, #f8faff); }
.cert-top { font-size: 0.85rem; font-weight: 800; letter-spacing: 0.08em; color: var(--primary); margin-bottom: 8px; }
.cert-frame h3 { font-size: 1.7rem; margin-bottom: 8px; }
.cert-name-row { max-width: 320px; margin: 14px auto; }
.cert-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
.cert-footer { font-size: 0.86rem; color: var(--muted); margin-top: 10px; }

/* Rich Multi-Column Site Footer */
.site-footer { background: #0f172a; color: #cbd5e1; padding: 36px 24px 20px; position: relative; z-index: 2; margin-top: 24px; }
.footer-grid { max-width: 1200px; margin: 0 auto 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.footer-brand { font-family: 'Fredoka', sans-serif; font-size: 1.45rem; color: #fff; margin-bottom: 8px; }
.footer-col p { font-size: 0.86rem; line-height: 1.55; color: #94a3b8; }
.footer-col h5 { color: #fff; font-size: 1rem; margin-bottom: 10px; }
.footer-link { display: block; background: none; border: none; color: #cbd5e1; font-family: inherit; font-size: 0.86rem; font-weight: 700; padding: 4px 0; cursor: pointer; text-align: left; transition: color 0.15s ease, transform 0.15s ease; }
.footer-link:hover { color: #38bdf8; transform: translateX(3px); }
.footer-bottom { max-width: 1200px; margin: 0 auto; padding-top: 16px; border-top: 1px solid #1e293b; text-align: center; font-size: 0.84rem; color: #94a3b8; }

@media (max-width: 720px) {
  .hero-card { flex-direction: column; padding: 20px; }
  .game-stage { padding: 16px; }
}
