/* Myles.E's Maths – simple kid-friendly styles */

.hub-back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #6B46C1;
  text-decoration: none;
  margin: -0.75rem -0.75rem 0.6rem;
  padding: 0.55rem 0.75rem;
  background: linear-gradient(135deg, #ede9fe, #e0f2fe);
  border-bottom: 2px solid #c4b5fd;
  border-radius: 1rem 1rem 0 0;
}
.hub-back-link:hover {
  background: linear-gradient(135deg, #ddd6fe, #bae6fd);
}
.hub-back-link:hover span { text-decoration: underline; }
.hub-logo {
  height: 28px;
  width: auto;
  max-width: none;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

:root {
  --quest-purple: #6B46C1;
  --quest-blue: #3182CE;
  --quest-pink: #ED64A6;
  --quest-gold: #F6AD55;
  --quest-green: #38A169;
  --touch-min: 48px;
}

* { box-sizing: border-box; }

body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Touch targets */
.touch-target {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
}

/* Big simple navigation */
.nav-btn-big {
  padding: 0.75rem 0.5rem;
  border-radius: 1.25rem;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  background: #f3f4f6;
  color: #4b5563;
  text-align: center;
  min-height: 64px;
}
.nav-btn-big.active {
  background: var(--quest-purple);
  color: white;
}

/* Giant home action buttons */
.big-action-btn {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  padding: 1.5rem 1.75rem;
  border-radius: 1.5rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  transition: transform 0.15s;
  min-height: 80px;
}
.big-action-btn:active { transform: scale(0.98); }
.big-action-label { font-size: 1.5rem; }

/* Easy / hard pills */
.diff-pill {
  padding: 0.75rem 1.25rem;
  border-radius: 2rem;
  font-weight: 700;
  font-size: 1.1rem;
  background: white;
  border: 3px solid #e5e7eb;
  cursor: pointer;
}
.diff-pill.active {
  background: var(--quest-purple);
  color: white;
  border-color: var(--quest-purple);
}

/* Player card on map */
.player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  border-radius: 1.5rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.level-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  max-width: 140px;
}
.level-bar-fill {
  height: 100%;
  background: var(--quest-purple);
  border-radius: 999px;
  transition: width 0.4s;
}

/* World map */
.world-map {
  min-height: 280px;
  aspect-ratio: 4/3;
}
.world-map-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.world-map-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05), rgba(0,0,0,0.15));
}
.map-title {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
/* Learn / Test / Play — centred row */
.map-pin-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0.5rem;
  width: 88%;
  max-width: 340px;
  z-index: 2;
}

.map-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: white;
  border: 3px solid var(--quest-purple);
  border-radius: 1rem;
  padding: 0.6rem 0.5rem;
  flex: 1;
  min-width: 0;
  min-height: 76px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  cursor: pointer;
  animation: pinBounce 2s ease-in-out infinite;
}
.map-pin-center .map-pin:nth-child(2) { animation-delay: 0.25s; }
.map-pin-center .map-pin:nth-child(3) { animation-delay: 0.5s; }

/* My Stars — top right of map */
.map-pin-stars {
  position: absolute;
  top: 10%;
  right: 5%;
  border-color: var(--quest-gold);
  min-width: 72px;
  padding: 0.45rem 0.6rem;
  animation: pinBounce 2.5s ease-in-out infinite;
  z-index: 2;
}

.map-pin-learn { border-color: var(--quest-blue); }
.map-pin-test { border-color: var(--quest-purple); }
.map-pin-play { border-color: var(--quest-green); }
.map-pin-icon { font-size: 1.6rem; line-height: 1; }
.map-pin-label { font-weight: 700; font-size: 0.8rem; color: var(--quest-purple); }
.map-pin:active { transform: scale(0.95); }
@keyframes pinBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.map-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Character cards on map home */
.char-card-simple {
  background: white;
  border-radius: 1rem;
  padding: 0.5rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 2px solid transparent;
  width: 100%;
}
.char-card-tap { cursor: pointer; }
.char-card-tap:active { border-color: var(--quest-purple); background: #faf5ff; }
.char-card-simple img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
}
.char-card-simple .char-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--quest-purple);
  margin-top: 0.2rem;
}
.char-card-simple .char-role {
  font-size: 0.6rem;
  color: #6b7280;
  line-height: 1.2;
}

/* Character profile page */
.char-profile-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: white;
  border-radius: 1.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 6px solid var(--quest-purple);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.char-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--quest-gold);
  flex-shrink: 0;
}

/* Intro cinema ("video") */
.char-cinema {
  background: #1a1a2e;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.char-cinema-screen {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #000;
}
.cinema-scene-img,
.cinema-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 8s ease-out;
}
.cinema-video.hidden,
.cinema-scene-img.hidden { display: none; }
.cinema-playing .cinema-scene-img {
  animation: cinemaPan 12s ease-in-out infinite alternate;
}
@keyframes cinemaPan {
  from { transform: scale(1) translateX(0); }
  to { transform: scale(1.08) translateX(-2%); }
}
.cinema-subtitle {
  position: absolute;
  bottom: 8%;
  left: 5%;
  right: 5%;
  background: rgba(0,0,0,0.65);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
}
.cinema-subtitle.hidden { display: none; }
.cinema-subtitle-idle { opacity: 1; }
.cinema-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255,255,255,0.2);
}
.cinema-progress-bar {
  height: 100%;
  background: var(--quest-gold);
  width: 0%;
  transition: width 0.5s linear;
}
.char-cinema-controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #16213e;
}
.char-lesson-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f5f3ff;
  border-radius: 0.75rem;
  font-weight: 600;
  color: var(--quest-purple);
  border: 2px solid #e9d5ff;
  cursor: pointer;
}
.char-lesson-link:active { background: #ede9fe; }

/* Profile switcher */
.profile-switch-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  font-weight: 600;
  background: white;
}
.profile-switch-btn.active {
  border-color: var(--quest-purple);
  background: #f5f3ff;
}

/* Simple game cards */
.game-card-simple {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  background: white;
  border-radius: 1.5rem;
  padding: 1.25rem;
  border: 3px solid #e5e7eb;
  text-align: left;
  cursor: pointer;
  min-height: 80px;
}
.game-card-simple:active { background: #f0fdf4; border-color: var(--quest-green); }

/* Zones */
.zone { animation: fadeIn 0.4s ease; }
.zone.hidden { display: none !important; }
.zone.active { display: block; }

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

.animate-fade-in { animation: fadeIn 0.8s ease; }

/* Topic buttons */
.topic-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1.25rem;
  background: white;
  border-radius: 1.5rem;
  border: 3px solid #e9d5ff;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--quest-purple);
  transition: all 0.25s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  cursor: pointer;
  min-height: 120px;
  justify-content: center;
}
.topic-btn small { font-size: 0.75rem; color: #6b7280; font-weight: 400; }
.topic-btn:hover, .topic-btn:active {
  transform: scale(1.03);
  border-color: var(--quest-purple);
  box-shadow: 0 8px 25px rgba(107, 70, 193, 0.25);
}

/* Character cards */
.char-card {
  background: white;
  border-radius: 1.25rem;
  padding: 0.75rem;
  text-align: center;
  border: 2px solid #e5e7eb;
  transition: transform 0.2s;
  cursor: pointer;
}
.char-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.char-card img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  border: 3px solid var(--quest-gold);
}
.char-card.locked { opacity: 0.5; filter: grayscale(0.8); }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--quest-purple), var(--quest-pink));
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.85rem 1.75rem;
  border-radius: 1.25rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(107, 70, 193, 0.35);
  transition: transform 0.15s;
}
.btn-primary:hover { transform: scale(1.05); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: white;
  color: var(--quest-purple);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 1.25rem;
  border: 3px solid var(--quest-purple);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: #f5f3ff; }

/* Working notebook */
.working-notebook {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border: 3px dashed var(--quest-gold);
  position: relative;
}
.working-notebook::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fca5a5;
  opacity: 0.5;
}
.working-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.working-step-num {
  background: var(--quest-purple);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.working-step input {
  flex: 1;
  border: 2px solid #d1d5db;
  border-radius: 0.75rem;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: white;
}
.working-step input:focus {
  outline: none;
  border-color: var(--quest-blue);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

/* Lesson styles */
.lesson-step {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: 1rem;
  align-items: flex-start;
}
.lesson-step:nth-child(odd) { background: #eff6ff; }
.lesson-step:nth-child(even) { background: #fdf4ff; }
.step-number {
  background: var(--quest-blue);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.lesson-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  background: white;
  border-radius: 1.5rem;
  padding: 1rem 1.25rem;
  border: 3px solid #e9d5ff;
  cursor: pointer;
  text-align: left;
  min-height: 72px;
}
.lesson-card:active {
  border-color: var(--quest-purple);
  background: #faf5ff;
}

/* Practice */
.practice-filter {
  background: white;
  cursor: pointer;
}
.practice-input {
  border: 3px solid var(--quest-purple);
  border-radius: 1rem;
  padding: 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
  max-width: 100%;
}
.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  border-radius: 1rem;
  border: 3px solid #e5e7eb;
  background: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.choice-btn:hover { border-color: var(--quest-blue); background: #eff6ff; }
.choice-btn.selected { border-color: var(--quest-purple); background: #f5f3ff; }
.choice-btn.correct { border-color: var(--quest-green); background: #d1fae5; }
.choice-btn.wrong { border-color: #ef4444; background: #fee2e2; }

.feedback-correct {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border: 3px solid var(--quest-green);
  color: #065f46;
}
.feedback-wrong {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border: 3px solid #ef4444;
  color: #991b1b;
}

/* Games */
.game-card {
  background: white;
  border-radius: 1.5rem;
  padding: 1.5rem;
  border: 3px solid #bbf7d0;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.game-card:hover {
  transform: scale(1.03);
  border-color: var(--quest-green);
  box-shadow: 0 8px 25px rgba(56, 161, 105, 0.2);
}
.game-timer {
  font-size: 2rem;
  font-weight: 700;
  color: var(--quest-purple);
}
.game-score-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--quest-gold);
}
.fraction-tile, .shape-tile {
  padding: 1rem;
  border-radius: 1rem;
  border: 3px solid #e5e7eb;
  background: white;
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fraction-tile:hover, .shape-tile:hover { border-color: var(--quest-pink); }
.fraction-tile.matched, .shape-tile.correct {
  background: #d1fae5;
  border-color: var(--quest-green);
  pointer-events: none;
}
.fraction-tile.selected, .shape-tile.selected {
  border-color: var(--quest-purple);
  background: #f5f3ff;
}
.ninja-monster {
  font-size: 3rem;
  animation: monsterPulse 1s infinite;
}
@keyframes monsterPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.outfit-badge {
  background: #f5f3ff;
  border: 2px solid var(--quest-purple);
  border-radius: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
}
.outfit-badge.locked { opacity: 0.4; }

/* Progress */
.badge-item {
  text-align: center;
  padding: 0.75rem;
  border-radius: 1rem;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
}
.badge-item.earned {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: var(--quest-gold);
}
.badge-item .badge-icon { font-size: 2rem; }

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #f9fafb;
}
.leaderboard-row.today { background: #dbeafe; font-weight: 700; }

/* Certificate */
.certificate { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.modal-content { position: relative; z-index: 1; width: 100%; }

/* Animations */
.character-float { animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.spark-bounce { animation: sparkBounce 2s ease-in-out infinite; }
@keyframes sparkBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.quest-dot {
  font-size: 1.5rem;
  color: #d1d5db;
}
.quest-dot.done { color: var(--quest-gold); }

/* Scrollbar hide */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Responsive */
@media (max-width: 640px) {
  .topic-btn { min-height: 100px; font-size: 1rem; }
  .practice-input { font-size: 1.25rem; }
}

/* Print */
@media print {
  body * { visibility: hidden; }
  #certificate, #certificate * { visibility: visible; }
  #certificate { position: absolute; left: 0; top: 0; width: 100%; }
}

/* Visual fraction bar (CSS-built) */
.frac-bar {
  display: flex;
  height: 24px;
  width: 120px;
  border: 2px solid #333;
  border-radius: 4px;
  overflow: hidden;
}
.frac-bar-fill { background: var(--quest-pink); height: 100%; }

/* Place value chart */
.place-value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 4px;
  text-align: center;
}
.pv-cell {
  border: 2px solid var(--quest-blue);
  border-radius: 8px;
  padding: 8px 4px;
  background: #eff6ff;
}
.pv-cell .label { font-size: 0.65rem; color: #6b7280; }
.pv-cell .digit { font-size: 1.5rem; font-weight: 700; color: var(--quest-purple); }