/* ===================== VARIABLES ===================== */
:root {
  --bg:       #060912;
  --surface:  #121a30;
  --card:     #182440;
  --card2:    #18254a;
  --border:   rgba(255,255,255,0.14);
  --yellow:   #ffe600;
  --pink:     #ff2d78;
  --cyan:     #00e5ff;
  --purple:   #b14aed;
  --green:    #39d98a;
  --red:      #ff4d6d;
  --orange:   #ff8c42;
  --text:     #eef0ff;
  --muted:    #9ba8d4;
  --radius:   18px;
  --shadow:   0 8px 32px rgba(0,0,0,0.5);
}

/* ===================== RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; font-size: clamp(17px, 4.2vw, 22px); }
body {
  height: 100%; overflow: hidden;
  font-family: 'Nunito', sans-serif;
  font-size: 17px;
  letter-spacing: 0.01em;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button { cursor: pointer; font-family: inherit; border: none; }
input  { font-family: inherit; }
a      { color: inherit; text-decoration: none; }

/* ===================== CANVAS ===================== */
#particle-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ===================== SCREEN SYSTEM ===================== */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center;
  overflow-y: auto; overflow-x: hidden;
  z-index: 10;
  opacity: 0; pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  -webkit-overflow-scrolling: touch;
}
.screen.active {
  opacity: 1; pointer-events: all;
  transform: translateY(0);
}
.screen-inner {
  width: 100%; max-width: 600px;
  padding: 16px 16px 100px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ===================== BOTTOM NAV ===================== */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(14,17,30,0.98);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.12);
  display: none;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
#bottom-nav.visible { display: flex; }
.nav-items {
  display: flex; width: 100%; max-width: 600px;
  margin: 0 auto;
  padding: 6px 8px 2px;
  gap: 4px;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 0 10px;
  min-height: 48px;
  font-family: 'Fredoka One', cursive;
  font-size: 13px; font-weight: 400;
  letter-spacing: 0.3px;
  color: rgba(255,255,255,0.55);
  background: none; border: none;
  border-radius: 12px;
  transition: all 0.2s;
  gap: 4px;
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.06);
}
.nav-item .nav-icon {
  font-size: 26px;
  line-height: 1;
  transition: transform 0.2s;
}
.nav-item.active {
  color: var(--yellow);
  background: rgba(255,230,0,0.08);
}
.nav-item.active .nav-icon {
  transform: scale(1.15);
}
/* Active indicator dot */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(255,230,0,0.5);
}

/* Nav tap bounce */
@keyframes navBounce { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.nav-item .nav-icon.bounce { animation: navBounce 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.nav-signout {
  flex: 0.7 !important;
  color: rgba(255,107,107,0.55) !important;
  font-size: 12px !important;
}
.nav-signout:hover {
  color: rgba(255,107,107,0.8) !important;
  background: rgba(255,107,107,0.08) !important;
}

.nav-pause {
  flex: 0.7 !important;
  color: rgba(255, 200, 60, 0.85) !important;
  font-size: 12px !important;
}
.nav-pause:hover {
  color: #ffc83c !important;
  background: rgba(255, 200, 60, 0.1) !important;
}

/* ===================== TOASTS ===================== */
#xp-toast {
  position: fixed; top: 80px; right: 16px;
  font-family: 'Fredoka One', cursive;
  font-size: 28px; color: var(--yellow);
  text-shadow: 0 0 20px rgba(255,230,0,0.8);
  pointer-events: none; z-index: 500;
  opacity: 0; transform: translateY(0);
  transition: opacity 0.15s, transform 0.6s cubic-bezier(0.175,0.885,0.32,1.275);
}
#xp-toast.show {
  opacity: 1; transform: translateY(-40px);
}

#achievement-toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 2px solid var(--yellow);
  border-radius: 20px;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  z-index: 600;
  transition: transform 0.45s cubic-bezier(0.175,0.885,0.32,1.275);
  min-width: 280px;
  box-shadow: 0 0 40px rgba(255,230,0,0.3);
  white-space: nowrap;
}
#achievement-toast.show { transform: translateX(-50%) translateY(0); }
.ach-toast-icon { font-size: 32px; }
.ach-toast-label { font-size: 13px; font-weight: 700; color: var(--yellow); text-transform: uppercase; letter-spacing: 1px; }
.ach-toast-name { font-size: 17px; font-weight: 800; }

/* ===================== LEVEL UP OVERLAY ===================== */
#levelup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 700;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#levelup-overlay.show { opacity: 1; pointer-events: all; }
#levelup-card {
  background: var(--card);
  border: 3px solid var(--yellow);
  border-radius: 28px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 0 80px rgba(255,230,0,0.4);
  transform: scale(0.8);
  transition: transform 0.45s cubic-bezier(0.175,0.885,0.32,1.275);
}
#levelup-overlay.show #levelup-card { transform: scale(1); }
#levelup-burst { font-size: 64px; animation: spinPop 0.6s ease; display: block; margin-bottom: 8px; }
@keyframes spinPop {
  from { transform: rotate(-180deg) scale(0); }
  to   { transform: rotate(0deg) scale(1); }
}
#levelup-title {
  font-family: 'Fredoka One', cursive;
  font-size: 48px;
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 8px;
}
#levelup-num { font-family: 'Fredoka One', cursive; font-size: 80px; color: var(--yellow); line-height: 1; }
#levelup-name { font-size: 18px; font-weight: 800; color: var(--muted); margin: 4px 0 24px; }
#levelup-close {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  border-radius: 16px;
  padding: 14px 36px;
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
  color: #060912;
}

/* ===================== BREAK TIME OVERLAY ===================== */
#break-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 650;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#break-overlay.show { opacity: 1; pointer-events: all; }
#break-card {
  width: 88%; max-width: 380px;
  background: var(--card);
  border: 3px solid var(--cyan);
  border-radius: 28px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0,229,255,0.25);
  transform: scale(0.8);
  transition: transform 0.45s cubic-bezier(0.175,0.885,0.32,1.275);
}
#break-overlay.show #break-card { transform: scale(1); }
#break-emoji {
  font-size: 72px;
  display: block;
  margin-bottom: 8px;
  animation: breakBounce 1s ease infinite;
}
@keyframes breakBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
#break-title {
  font-family: 'Fredoka One', cursive;
  font-size: 40px;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 12px;
}
#break-message {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 20px;
}
#break-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.break-stat {
  background: var(--card2);
  border-radius: 14px;
  padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.break-stat-num {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: var(--cyan);
}
.break-stat-lbl {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#break-continue {
  width: 100%;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  border-radius: 16px;
  padding: 16px 24px;
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
  color: #060912;
  margin-top: 4px;
}

/* ===================== SHARED COMPONENTS ===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.section-label {
  font-size: 14px; font-weight: 800;
  color: var(--muted); text-transform: uppercase; letter-spacing: 2px;
  margin-bottom: 2px;
}
.btn {
  border-radius: 14px;
  padding: 14px 24px;
  font-weight: 800; font-size: 18px;
  transition: all 0.18s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary:active, .btn-cyan:active { animation: btnPulse 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes btnPulse { 0% { transform: scale(0.95); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
.btn-primary {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #060912;
  box-shadow: 0 6px 24px rgba(255,230,0,0.3);
}
.btn-secondary {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: linear-gradient(135deg, var(--pink), var(--red));
  color: white;
}
.btn-cyan {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #060912;
}
.btn-accent {
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #060912;
  box-shadow: 0 6px 24px rgba(57,217,138,0.3);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ===================== SPLASH SCREEN ===================== */
#screen-splash {
  background: var(--bg);
  justify-content: center;
  align-items: center;
  text-align: center;
}
.splash-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 0;
  padding: 20px;
  z-index: 1;
}
.splash-mascot-wrap {
  position: relative;
  width: 130px; height: 130px;
  display: flex; align-items: center; justify-content: center;
}
.splash-mascot {
  font-size: 80px;
  animation: mascotBob 2s ease-in-out infinite;
  display: block; line-height: 1.1;
  filter: drop-shadow(0 0 30px rgba(255,230,0,0.5));
}
.splash-sparkle {
  position: absolute;
  pointer-events: none;
  animation: sparkleFloat 3s ease-in-out infinite;
}
.splash-sparkle.s1 { top: 2px; right: 2px; font-size: 22px; animation-delay: 0s; }
.splash-sparkle.s2 { top: 15px; left: -2px; font-size: 16px; animation-delay: 1s; }
.splash-sparkle.s3 { bottom: 10px; right: -6px; font-size: 18px; animation-delay: 2s; }
@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { transform: translateY(-10px) scale(1.3); opacity: 1; }
}
@keyframes mascotBob {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-12px) rotate(5deg); }
}
.splash-logo {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(56px, 16vw, 88px);
  line-height: 1;
  margin: 12px 0 4px;
  display: flex;
  gap: 2px;
}
.logo-letter {
  display: inline-block;
  animation: letterBounce 2.5s ease-in-out infinite;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
}
.logo-letter.l1 { background-image: linear-gradient(180deg, #ffe600, #ff8c42); animation-delay: 0s; }
.logo-letter.l2 { background-image: linear-gradient(180deg, #ff2d78, #ff8c42); animation-delay: 0.12s; }
.logo-letter.l3 { background-image: linear-gradient(180deg, #00e5ff, #b14aed); animation-delay: 0.24s; }
.logo-letter.l4 { background-image: linear-gradient(180deg, #39d98a, #00e5ff); animation-delay: 0.36s; }
.logo-letter.l5 { background-image: linear-gradient(180deg, #b14aed, #ff2d78); animation-delay: 0.48s; }
@keyframes letterBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-10px) rotate(-4deg); }
  40% { transform: translateY(0) rotate(0deg); }
  60% { transform: translateY(-5px) rotate(3deg); }
  80% { transform: translateY(0) rotate(0deg); }
}
.splash-sub {
  font-size: 18px; font-weight: 700; color: var(--muted);
  margin-bottom: 48px;
}
.splash-tap {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--yellow);
  padding: 18px 48px;
  background: rgba(255,230,0,0.1);
  border: 2px solid var(--yellow);
  border-radius: 18px;
  animation: pulseGlow 1.8s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(255,230,0,0.2);
  width: 100%;
  max-width: 300px;
}
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 20px rgba(255,230,0,0.2); }
  50%      { box-shadow: 0 0 50px rgba(255,230,0,0.5); }
}
/* Role selection on splash */
.splash-role-pick { width: 100%; max-width: 320px; }
.splash-role-label {
  font-family: 'Fredoka One', cursive;
  font-size: 18px; color: var(--muted);
  margin-bottom: 14px; text-align: center;
}
.splash-role-btns { display: flex; gap: 16px; }
.splash-role-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 10px;
  background: rgba(255,255,255,0.05);
  border: 2px solid var(--border);
  border-radius: 18px;
  font-family: 'Fredoka One', cursive;
  font-size: 18px; color: var(--text);
  transition: all 0.2s;
}
.splash-role-btn:hover, .splash-role-btn:active {
  border-color: var(--yellow);
  background: rgba(255,230,0,0.08);
  transform: scale(1.04);
  box-shadow: 0 0 24px rgba(255,230,0,0.15);
}
.splash-role-icon { font-size: 36px; }
.splash-role-text { font-size: 18px; }

.splash-badges {
  display: flex; gap: 12px; margin-top: 40px; flex-wrap: wrap; justify-content: center;
}
.splash-badge {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px; font-weight: 600; color: var(--muted);
  opacity: 0.6;
  letter-spacing: 0.3px;
}
.splash-links {
  margin-top: 32px;
  display: flex; align-items: center; gap: 12px;
  justify-content: center;
}
.splash-links a {
  color: var(--cyan); font-size: 14px; font-weight: 700;
  text-decoration: none; opacity: 0.8;
  transition: opacity 0.2s;
}
.splash-links a:hover { opacity: 1; text-decoration: underline; }
.splash-links-dot { color: var(--muted); opacity: 0.4; }

/* ===================== SETUP WIZARD ===================== */
.setup-wizard {
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 80vh;
  position: relative;
}
.setup-progress {
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
}
.setup-progress-track {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}
.setup-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  width: 25%;
}
.setup-progress-dots {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.setup-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  transition: all 0.3s;
}
.setup-dot.active {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,229,255,0.4);
}
.setup-dot.done {
  background: var(--green);
  border-color: var(--green);
}
.setup-viewport {
  width: 100%;
  position: relative;
}
.setup-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
}
.setup-step.active {
  display: flex;
  animation: setupSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.setup-step.slide-out {
  animation: setupSlideOut 0.2s ease forwards;
}
@keyframes setupSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes setupSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-40px); }
}
@keyframes setupSlideInReverse {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.setup-step.active.from-left {
  animation-name: setupSlideInReverse;
}
.setup-step-emoji {
  font-size: 56px;
  margin-bottom: 8px;
  animation: setupEmojiBounce 0.5s 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes setupEmojiBounce {
  from { transform: scale(0) rotate(-15deg); }
  to   { transform: scale(1) rotate(0deg); }
}
.setup-step-title {
  font-family: 'Fredoka One', cursive;
  font-size: 26px; margin-bottom: 4px;
}
.setup-step-sub {
  color: var(--muted);
  font-size: 15px; font-weight: 600;
  margin-bottom: 20px;
}
.setup-next {
  margin-top: 20px;
  width: 100%;
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  padding: 16px;
}
.setup-back-btn {
  position: absolute;
  top: 24px; left: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px; font-weight: 700;
  border-radius: 12px;
  padding: 6px 14px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s;
}
.setup-back-btn:hover { background: var(--card2); }

/* Name input */
.name-input {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 18px; font-weight: 800;
  color: var(--text); outline: none;
  text-align: center;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--yellow); }
.name-input::placeholder { color: var(--muted); font-weight: 600; }

/* Avatar grid */
.avatar-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  width: 100%;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
}
.avatar-btn {
  aspect-ratio: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  font-size: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.avatar-btn:hover { border-color: var(--yellow); transform: scale(1.05); }
.avatar-btn.selected {
  border-color: var(--yellow);
  background: rgba(255,230,0,0.1);
  box-shadow: 0 0 20px rgba(255,230,0,0.25);
  transform: scale(1.08);
}

/* Interest grid */
.interest-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%;
}
.interest-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px 12px;
  display: flex; align-items: center; gap: 12px;
  font-size: 17px; font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s; text-align: left;
}
.interest-btn .i-emoji { font-size: 30px; }
.interest-btn:hover { border-color: var(--cyan); transform: translateY(-2px); }
.interest-btn.selected {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.08);
  box-shadow: 0 0 20px rgba(0,229,255,0.2);
}

/* ===================== HOME SCREEN ===================== */
#screen-home { padding-top: 12px; }

/* Greeting bar */
/* Hero card — groups greeting + XP bar */
.home-hero-card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px 18px;
}
.home-greeting {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home-avatar {
  width: 48px; height: 48px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.home-greeting-text { flex: 1; }
.home-hi {
  font-family: 'Fredoka One', cursive;
  font-size: 22px; line-height: 1.1;
}
.home-level {
  font-size: 15px; font-weight: 700; color: var(--muted);
}
.home-level-row {
  display: flex; align-items: center; gap: 8px; margin-top: 2px;
}
.home-streak-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(255,152,0,0.15); color: var(--orange);
  padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 800;
  font-family: 'Fredoka One', cursive;
}
/* XP progress bar */
.home-xp-bar {
  margin: 10px 0 0;
}
.home-xp-labels {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--muted);
  margin-bottom: 4px;
}
.home-xp-amount {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: var(--yellow);
}
.home-xp-track {
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}
.home-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Subject indicator */
.home-subject-indicator {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 0;
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.home-subject-indicator span {
  font-family: 'Fredoka One', cursive;
  color: var(--cyan);
}

/* Pikoo speech bubble */
.pikoo-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px 20px;
  margin: 12px 0;
  background: rgba(177,74,237,0.10);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.pikoo-bubble:active { opacity: 0.7; }
.pikoo-bubble.pop { animation: msgPop 0.4s cubic-bezier(0.175,0.885,0.32,1.275); }
.pikoo-avatar {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
}
.pikoo-text {
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.55;
  color: #c8d0ec;
}

/* Pikoo bounce */
.pikoo-bounce {
  display: inline-block;
  animation: pikooBounce 2s ease-in-out infinite;
}
@keyframes pikooBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
  50% { transform: translateY(0); }
  65% { transform: translateY(-2px); }
  80% { transform: translateY(0); }
}

/* Stats card — groups recap + quests */
.home-stats-card {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 16px;
}
.home-stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.home-stats-item {
  display: flex; align-items: center; gap: 8px;
}
.home-stats-divider {
  width: 1px; height: 22px; background: var(--border); flex-shrink: 0;
}

/* XP teaser */
.home-xp-teaser {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  margin-top: 6px;
  opacity: 0.85;
}
.home-xp-teaser.hot {
  font-size: 14px;
  color: var(--yellow);
  opacity: 1;
  animation: xpPulse 1.5s ease-in-out infinite alternate;
}
@keyframes xpPulse {
  0% { opacity: 0.8; }
  100% { opacity: 1; text-shadow: 0 0 8px rgba(255,230,0,0.4); }
}

/* Session recap (inline inside stats card) */
.home-recap {
  font-size: 14px;
  font-weight: 700;
  color: #a8b4d8;
  white-space: nowrap;
}

/* Prompt */
.home-prompt {
  font-family: 'Fredoka One', cursive;
  font-size: 26px;
  text-align: center;
  padding: 20px 0 16px;
}

/* Big mode cards */
.mode-card-big {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  transition: all 0.18s;
  cursor: pointer;
}
.mode-card-big:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.mode-card-big:active {
  transform: scale(0.98);
}

.mode-story {
  background: rgba(0,229,255,0.06);
  border-color: rgba(0,229,255,0.2);
}
.mode-story:hover { border-color: var(--cyan); }
.mode-speed {
  background: rgba(255,230,0,0.06);
  border-color: rgba(255,230,0,0.2);
}
.mode-speed:hover { border-color: var(--yellow); }
.mode-boss {
  background: rgba(255,45,120,0.06);
  border-color: rgba(255,45,120,0.2);
}
.mode-boss:hover { border-color: var(--pink); }
.mode-prep {
  background: rgba(177,74,237,0.06);
  border-color: rgba(177,74,237,0.2);
}
.mode-prep:hover { border-color: var(--purple); }

.mode-big-icon {
  width: 80px; min-height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; flex-shrink: 0;
}
.mode-big-text { flex: 1; padding: 16px 0; }
.mode-big-title {
  font-family: 'Fredoka One', cursive;
  font-size: 22px; line-height: 1.1;
}
.mode-big-desc {
  font-size: 15px; font-weight: 600; color: var(--muted); margin-top: 4px;
}
.mode-big-xp {
  margin-right: 18px;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 800;
  white-space: nowrap;
}
.mode-story .mode-big-xp { background: rgba(0,229,255,0.12); color: var(--cyan); }
.mode-speed .mode-big-xp { background: rgba(255,230,0,0.12); color: var(--yellow); }
.mode-boss .mode-big-xp  { background: rgba(255,45,120,0.12); color: var(--pink); }
.mode-prep .mode-big-xp  { background: rgba(177,74,237,0.12); color: var(--purple); }

.mode-create {
  background: rgba(255,152,0,0.06);
  border-color: rgba(255,152,0,0.2);
}
.mode-create:hover { border-color: #ff9800; }
.mode-create .mode-big-xp { background: rgba(255,152,0,0.12); color: #ff9800; }

/* Home subject cards */
.home-subjects {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0 0;
}
.home-subject-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
}
.home-subject-card:not([disabled]):hover { border-color: var(--cyan); }
.home-subject-card.selected {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.08);
  box-shadow: 0 0 12px rgba(0,229,255,0.15);
}
.home-subject-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.home-subject-emoji { font-size: 28px; }
.home-subject-label {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: var(--text);
}
.home-subject-soon {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 10px;
  background: var(--surface);
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 6px;
  font-weight: 600;
}

/* Home Start button */
.home-start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 22px 24px;
  margin: 14px 0 8px;
  border-radius: 20px;
  border: none;
  background: linear-gradient(135deg, #00e5ff, #b14aed);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: 26px;
  cursor: pointer;
  transition: all 0.18s;
  animation: startBtnPulse 2.5s ease-in-out infinite;
  box-shadow: 0 6px 24px rgba(0,229,255,0.25);
}
.home-start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,229,255,0.35);
}
.home-start-btn:active {
  transform: scale(0.97);
}
.home-start-btn .start-icon {
  font-size: 32px;
}
@keyframes startBtnPulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(0,229,255,0.25); }
  50% { box-shadow: 0 6px 32px rgba(0,229,255,0.45); }
}

/* Mode selector cards (inside picker, Phase 2) */
.mode-selector-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-selector-card {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  transition: all 0.15s;
  cursor: pointer;
}
.mode-selector-card:hover {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.04);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.mode-selector-card:active {
  transform: translateY(0) scale(0.98);
}
.mode-selector-card.selected {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.08);
  box-shadow: 0 0 0 1px var(--cyan);
}
.mode-sel-icon {
  width: 56px; min-height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; flex-shrink: 0;
}
.mode-sel-info { flex: 1; padding: 12px 0; }
.mode-sel-title {
  font-family: 'Fredoka One', cursive;
  font-size: 17px; line-height: 1.1;
}
.mode-sel-desc {
  font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 2px;
}
.mode-sel-xp {
  margin-right: 14px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px; font-weight: 800;
  white-space: nowrap;
  background: rgba(0,229,255,0.1);
  color: var(--cyan);
}

/* Mode card color strips */
.mode-selector-card[data-mode="story"]  { border-left: 4px solid var(--cyan); }
.mode-selector-card[data-mode="speed"]  { border-left: 4px solid var(--pink); }
.mode-selector-card[data-mode="boss"]   { border-left: 4px solid var(--red); }
.mode-selector-card[data-mode="prep"]   { border-left: 4px solid var(--purple); }
.mode-selector-card[data-mode="create"] { border-left: 4px solid var(--orange); }

/* Creative Mode project picker */
.creative-project-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}
.creative-project-card:hover {
  border-color: #ff9800;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.creative-project-card:active {
  transform: translateY(0) scale(0.98);
}
.creative-project-card.selected {
  border-color: #ff9800;
  background: rgba(255,152,0,0.08);
  box-shadow: 0 0 16px rgba(255,152,0,0.2);
}
.creative-project-icon {
  font-size: 32px;
  flex-shrink: 0;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,152,0,0.1);
  border-radius: 12px;
}
.creative-project-info { flex: 1; }
.creative-project-name {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  line-height: 1.2;
}
.creative-project-math {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 3px;
}
.creative-surprise {
  border-style: dashed;
  opacity: 0.8;
}
.creative-surprise:hover { opacity: 1; }

/* Creative mode focus class */
#screen-story.creative-focus .story-title {
  color: #ff9800;
}

/* Creative inline choices & replies (same pattern as prep) */
.creative-inline-choices {
  gap: 8px;
  padding: 8px 0;
}
.creative-inline-replies {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}

/* Prep subject tabs */
.prep-subject-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 8px;
}
.prep-subject-tab {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  padding: 6px 16px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.prep-subject-tab:hover:not([disabled]) {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
}
.prep-subject-active {
  border-color: var(--purple);
  background: rgba(177,74,237,0.12);
  color: var(--text);
}
.prep-subject-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.prep-subject-soon {
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 4px;
  vertical-align: middle;
}
.prep-subject-grade {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* Prep lesson progress badges */
.prep-lesson-badge { font-size: 14px; font-weight: 800; min-width: 20px; text-align: center; }
.prep-lesson-badge.completed { color: var(--green); }
.prep-lesson-badge.partial { color: var(--yellow); font-size: 12px; }

/* Chapter progress count in prep picker */
.pregame-ch-progress {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: var(--green);
  background: rgba(57,217,138,0.1);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: auto;
}

/* Chapter progress bar in lesson picker */
.pregame-ch-bar { width: 100%; height: 4px; background: var(--surface); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.pregame-ch-bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); border-radius: 4px; transition: width 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* Last-played resume badge */
.pregame-resume-badge { font-size: 11px; font-weight: 800; color: var(--cyan); background: rgba(0,229,255,0.12); padding: 2px 8px; border-radius: 6px; animation: resumePulse 2s ease-in-out infinite; }
@keyframes resumePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Resume prompt overlay */
.resume-prompt-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; transition: opacity 0.2s ease; }
.resume-prompt-overlay.show { opacity: 1; }
.resume-prompt { background: var(--card); border-radius: 18px; padding: 28px 24px; text-align: center; max-width: 320px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.4); transform: scale(0.9); transition: transform 0.2s ease; }
.resume-prompt-overlay.show .resume-prompt { transform: scale(1); }
.resume-prompt-title { font-family: 'Fredoka One', cursive; font-size: 18px; color: #fff; margin-bottom: 8px; }
.resume-prompt-info { font-size: 14px; color: var(--muted); margin-bottom: 20px; }
.resume-prompt-btns { display: flex; flex-direction: column; gap: 10px; }
.resume-btn-continue { font-size: 16px !important; padding: 12px !important; }
.resume-btn-restart { font-size: 14px !important; padding: 10px !important; }

/* Lesson mini-progress */
.pregame-ls-progress { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.pregame-ls-progress .ls-acc { color: var(--green); }

/* ---- Prep Focus Mode ---- */

/* Breadcrumb navigation in story/prep header */
.breadcrumb-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
}
.breadcrumb-nav:hover .breadcrumb-line { color: var(--cyan); }
.breadcrumb-nav:active .breadcrumb-line { opacity: 0.7; }
.breadcrumb-line {
  transition: color 0.15s ease, opacity 0.15s ease;
  line-height: 1.3;
}
.breadcrumb-line-top {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.breadcrumb-line-top .breadcrumb-label {
  text-transform: uppercase;
  font-size: 10px;
  opacity: 0.6;
}
.breadcrumb-sep { opacity: 0.4; }
.breadcrumb-line-bottom {
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Legacy class (keep for any other usage) */
.prep-breadcrumb {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.3px;
  display: block;
}
.prep-subtitle {
  display: block;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--purple);
  margin-top: 2px;
  letter-spacing: 0.2px;
}

/* Hide input row in prep mode — quick replies only */
.prep-focus .story-input-row {
  display: none;
}

/* Prep mode: spacious paragraphs for young readers */
.prep-focus .chat-bubble {
  line-height: 2.1;
  letter-spacing: 0.2px;
}
.chat-para {
  margin-bottom: 14px;
  line-height: 2.0;
}
.chat-para:last-child {
  margin-bottom: 0;
}
.prep-focus .chat-step {
  margin: 16px 0;
  padding: 16px 18px;
}
.prep-focus .chat-callout {
  margin: 18px 0;
}

/* Inline quick replies inside chat area for prep mode */
.prep-inline-replies {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 16px 8px 24px;
}
.prep-inline-replies .qr-btn {
  font-size: 17px;
  padding: 11px 20px;
  background: transparent;
  border: 2px solid rgba(177,74,237,0.5);
  color: var(--purple);
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.18s;
}
.prep-inline-replies .qr-btn:hover {
  background: rgba(177,74,237,0.12);
  border-color: var(--purple);
  color: #d4a5f5;
}
.prep-inline-replies .qr-btn:first-child {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  box-shadow: 0 2px 12px rgba(177,74,237,0.3);
}
.prep-inline-replies .qr-btn:first-child:hover {
  background: #c65cf7;
  border-color: #c65cf7;
  transform: translateY(-2px);
}

/* Inline answer choices inside chat area for prep mode */
.prep-inline-choices {
  gap: 10px;
  max-width: 400px;
  margin: 12px auto 24px;
  padding: 0 8px;
}

/* Variant tabs on teach bubbles (Original / Simpler / Different) */
.prep-variant-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
}
.prep-variant-tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.prep-variant-tab:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.08);
}
.prep-variant-tab.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 2px 8px rgba(177,74,237,0.3);
}

/* ---- Scratch Pad ---- */
.scratchpad-fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.15);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 110;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.scratchpad-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.scratchpad-panel {
  position: fixed;
  top: 0; right: -320px;
  width: 300px; height: 100%;
  background: rgba(18,22,40,0.98);
  border-left: 1px solid rgba(255,255,255,0.12);
  z-index: 200;
  display: flex; flex-direction: column;
  transition: right 0.3s ease;
}
.scratchpad-panel.open {
  right: 0;
}

.sp-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-wrap: wrap;
}
.sp-colors {
  display: flex; gap: 5px;
}
.sp-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
}
.sp-swatch:hover { transform: scale(1.15); }
.sp-swatch.active {
  border-color: #fff;
  transform: scale(1.15);
}

.sp-eraser {
  padding: 6px 14px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  margin-left: 8px;
}
.sp-eraser:hover { background: rgba(255,255,255,0.16); }
.sp-eraser.active {
  border-color: var(--red);
  background: rgba(255,45,85,0.2);
  color: var(--red);
}
.sp-widths {
  display: flex; gap: 4px; margin-left: 4px;
}
.sp-width {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: border-color 0.15s;
}
.sp-width span {
  display: block;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
}
.sp-width.active {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
}

.sp-clear {
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 12px; font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
}
.sp-clear:hover { background: rgba(255,255,255,0.14); color: #fff; }

.sp-close {
  background: none; border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.sp-close:hover { color: #fff; }

.sp-canvas-wrap {
  flex: 1;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}
.sp-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* On mobile, make panel wider */
@media (max-width: 600px) {
  .scratchpad-panel {
    width: 75vw;
    right: -75vw;
  }
}

/* ---- Quick Tip ---- */
.tip-fab {
  position: fixed;
  bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid rgba(255,200,60,0.3);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 110;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.tip-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(255,200,60,0.3);
}
.tip-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.tip-backdrop.show { opacity: 1; pointer-events: all; }
.tip-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-height: 70vh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  z-index: 200;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.175,0.885,0.32,1.275);
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
}
.tip-panel.open { transform: translateY(0); }
.tip-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.tip-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
}
.tip-panel-title {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  color: var(--yellow);
}
.tip-close {
  background: none; border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.tip-close:hover { color: #fff; }
.tip-content {
  padding: 0 16px 24px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.tip-section-title {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  margin-top: 16px;
}
.tip-section-title:first-child { margin-top: 0; }
.tip-item {
  font-size: 15px;
  color: var(--text);
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  border-left: 3px solid var(--cyan);
  line-height: 1.4;
}
.tip-item.formula {
  border-left-color: var(--yellow);
  font-weight: 700;
}
.tip-columns { display: flex; flex-direction: column; gap: 4px; }
@media (min-width: 600px) {
  .tip-columns { flex-direction: row; gap: 20px; }
  .tip-col { flex: 1; min-width: 0; }
  .tip-panel { max-width: 700px; left: 50%; right: auto; transform: translateX(-50%) translateY(100%); }
  .tip-panel.open { transform: translateX(-50%) translateY(0); }
}

/* ---- Revisit Dialog (completed mission) ---- */
.revisit-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 0 4px;
}
.revisit-badge {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: var(--green);
  background: rgba(57,217,138,0.12);
  border: 1.5px solid rgba(57,217,138,0.3);
  padding: 6px 20px;
  border-radius: 50px;
  letter-spacing: 0.5px;
}
.revisit-desc {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}
.revisit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--card2);
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
}
.revisit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.revisit-btn-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.revisit-btn-title {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: var(--text);
  display: block;
}
.revisit-btn-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}
.revisit-btn-text {
  flex: 1;
}
.revisit-fresh {
  border-color: rgba(0,149,255,0.3);
  background: rgba(0,149,255,0.06);
}
.revisit-fresh:hover {
  border-color: var(--blue);
  background: rgba(0,149,255,0.12);
}
.revisit-fresh .revisit-btn-icon {
  background: rgba(0,149,255,0.15);
}
.revisit-deep {
  border-color: rgba(177,74,237,0.3);
  background: rgba(177,74,237,0.06);
}
.revisit-deep:hover {
  border-color: var(--purple);
  background: rgba(177,74,237,0.12);
}
.revisit-deep .revisit-btn-icon {
  background: rgba(177,74,237,0.15);
}

/* Mini quests bar */
.quests-mini-label {
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.quests-mini-dots {
  display: flex; gap: 6px;
}
.quest-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
}
.quest-dot.done {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(57,217,138,0.4);
}
.quests-mini-count {
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  color: var(--green);
}

.home-profile-nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(255,180,70,0.12), rgba(255,120,200,0.10));
  border: 1.5px solid rgba(255,180,70,0.3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.home-profile-nudge:active { transform: scale(0.98); }
.nudge-icon { font-size: 28px; }
.nudge-text { flex: 1; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.nudge-title { font-family: 'Fredoka One', cursive; font-size: 16px; color: var(--text); }
.nudge-sub { font-size: 14px; color: var(--muted); font-weight: 600; }
.nudge-arrow { font-size: 24px; color: var(--muted); font-weight: 700; }

/* ===================== PROFILE SCREEN ===================== */
#screen-profile { padding-top: 8px; }

/* Profile tabs */
.ptab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 16px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.ptab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.ptab-emoji { font-size: 20px; line-height: 1; }
.ptab-label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.ptab.active {
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.ptab.active .ptab-label { color: var(--cyan); }
.ptab:active { transform: scale(0.93); }
.ptab-panel { display: none; }
.ptab-panel.active { display: block; animation: ptabFadeIn 0.2s ease; }
@keyframes ptabFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Inline avatar/name editing */
.profile-avatar-btn {
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.profile-avatar-btn:hover {
  border-color: var(--purple);
  box-shadow: 0 0 16px rgba(177,74,237,0.4);
}
.profile-avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.profile-av-opt {
  aspect-ratio: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
  cursor: pointer;
}
.profile-av-opt:hover { border-color: var(--yellow); transform: scale(1.08); }
.profile-av-opt.selected {
  border-color: var(--yellow);
  background: rgba(255,230,0,0.1);
  box-shadow: 0 0 12px rgba(255,230,0,0.25);
}
.profile-av-opt.locked {
  opacity: 0.3;
  filter: grayscale(0.8);
  cursor: not-allowed;
  position: relative;
}
.profile-av-opt.locked:hover { border-color: var(--border); transform: none; }
.av-lock {
  position: absolute;
  bottom: 1px;
  left: 0; right: 0;
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
  line-height: 1;
}

.profile-name-btn {
  background: none; border: none; color: var(--text);
  font-family: 'Fredoka One', cursive;
  font-size: 24px; line-height: 1.1;
  cursor: pointer; padding: 0;
  transition: color 0.18s;
}
.profile-name-btn:hover { color: var(--yellow); }
.profile-name-edit {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.profile-name-edit .name-input { flex: 1; font-size: 16px; padding: 10px 14px; }

/* About Me preference grid */
.pref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pref-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pref-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.pref-card.empty {
  border-style: dashed;
  opacity: 0.7;
}
.pref-card.empty:hover { opacity: 1; }
.pref-emoji { font-size: 22px; }
.pref-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pref-value {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  line-height: 1.2;
}
.pref-card.empty .pref-value {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

/* Preference picker */
.pref-picker-card {
  padding: 16px;
  margin-top: 10px;
  border: 1.5px solid var(--cyan);
  background: var(--card2);
}
.pref-picker-title {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  margin-bottom: 12px;
}
.pref-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pref-option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.pref-option:hover {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.08);
  transform: scale(1.03);
}
.pref-option.selected {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.12);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0,229,255,0.2);
}
.pref-number-wrap,
.pref-text-wrap {
  display: flex; gap: 8px; align-items: center;
}
.pref-number-wrap .name-input,
.pref-text-wrap .name-input {
  flex: 1; font-size: 16px; padding: 10px 14px;
}
.pref-picker-close {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.pref-picker-close:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Grade selection in setup */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.grade-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 8px;
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
}
.grade-btn:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.grade-btn.selected {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.12);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,229,255,0.25);
}

/* My Math settings in profile */
.math-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.math-setting-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.math-setting-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.math-setting-card .pref-label {
  flex: 1;
}
.math-setting-card .pref-value {
  font-size: 16px;
  color: var(--cyan);
}
.math-setting-card.chapter-card .pref-value {
  font-size: 15px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mathcurriculum-hint {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}
.grade-picker-grid {
  grid-template-columns: repeat(4, 1fr) !important;
}

/* Chapter list in picker */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.chapter-option {
  text-align: left !important;
  padding: 10px 14px !important;
  font-size: 15px !important;
  border-radius: 10px !important;
}

/* ===== Stats Screen ===== */
.stats-loading, .stats-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 300px; text-align: center; padding: 40px 20px; color: var(--muted);
}
.stats-overview {
  text-align: center; padding: 24px 16px;
  background: linear-gradient(135deg, var(--card) 0%, var(--card2) 100%);
  border: 1px solid var(--border);
}
.stats-overview-title {
  font-family: 'Fredoka One', cursive; font-size: 18px; margin-bottom: 8px;
}
.stats-big-num {
  font-family: 'Fredoka One', cursive; font-size: 56px; line-height: 1;
}
.stats-overview-label {
  font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 16px;
}
.stats-overview-row {
  display: flex; justify-content: center; gap: 24px; margin-bottom: 12px;
}
.stats-overview-stat { display: flex; flex-direction: column; align-items: center; }
.stats-ov-num { font-family: 'Fredoka One', cursive; font-size: 22px; }
.stats-ov-lbl { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.stats-avg-time { font-size: 15px; font-weight: 700; color: var(--muted); }
.stats-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stats-bar-label { font-weight: 700; font-size: 15px; width: 90px; color: var(--text); }
.stats-bar-track {
  flex: 1; height: 14px; border-radius: 7px;
  background: var(--card2); overflow: hidden;
}
.stats-bar-fill {
  height: 100%; border-radius: 7px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stats-bar-fill.strong { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.stats-bar-fill.ok { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.stats-bar-fill.weak { background: linear-gradient(90deg, var(--red), var(--pink)); }
.stats-bar-pct { font-weight: 800; font-size: 16px; width: 45px; text-align: right; }
.stats-weak-badge {
  background: var(--red); color: white; font-size: 12px;
  padding: 2px 8px; border-radius: 6px; font-weight: 700; white-space: nowrap;
}
.stats-mode-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stats-mode-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 8px;
  text-align: center; border: 1px solid var(--border);
}
.stats-trend-bars {
  display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-bottom: 4px;
}
.stats-trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stats-trend-bar {
  width: 100%; border-radius: 4px 4px 0 0; min-height: 4px;
  transition: height 0.6s ease;
}
.stats-trend-bar.strong { background: linear-gradient(180deg, var(--green), var(--cyan)); }
.stats-trend-bar.ok { background: linear-gradient(180deg, var(--yellow), var(--orange)); }
.stats-trend-bar.weak { background: linear-gradient(180deg, var(--red), var(--pink)); }
.stats-trend-day { font-size: 12px; font-weight: 700; color: var(--muted); }
.stats-trend-text {
  text-align: center; font-size: 15px; font-weight: 700; color: var(--cyan); margin-top: 10px;
}
.stats-help-grid { display: flex; justify-content: space-around; margin-bottom: 12px; }
.stats-help-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stats-help-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.stats-help-num { font-family: 'Fredoka One', cursive; font-size: 20px; }
.stats-help-compare {
  display: flex; justify-content: space-around;
  font-size: 15px; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 10px;
}
.stats-help-compare strong { color: var(--text); }
.stats-session-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.stats-session-item:last-child { border-bottom: none; }
.stats-session-icon { font-size: 24px; }
.stats-session-info { flex: 1; }
.stats-session-mode { font-weight: 800; font-size: 16px; }
.stats-session-date { font-size: 14px; color: var(--muted); }
.stats-session-result { text-align: right; }
.stats-session-score { font-family: 'Fredoka One', cursive; font-size: 18px; }
.stats-session-xp { font-size: 14px; color: var(--cyan); font-weight: 700; }
.stats-session-item.clickable { cursor: pointer; }
.stats-session-item.clickable:active { background: var(--card2); }
.stats-session-chevron { font-size: 20px; color: var(--muted); font-weight: 700; margin-left: 4px; }

/* Session Detail Overlay */
#session-detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#session-detail-overlay.show { opacity: 1; pointer-events: all; }
.session-detail-card {
  position: relative;
  width: 92%; max-width: 440px; max-height: 88vh;
  background: var(--card);
  border-radius: 20px;
  border: 2px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px 24px;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#session-detail-overlay.show .session-detail-card { transform: scale(1); }
.sd-close-btn {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 28px; cursor: pointer; line-height: 1;
  z-index: 2;
}
.sd-close-btn:hover { color: var(--text); }

.sd-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.sd-header-icon { font-size: 36px; }
.sd-header-mode { font-family: 'Fredoka One', cursive; font-size: 20px; }
.sd-header-date { font-size: 15px; color: var(--muted); }
.sd-header-chapter { font-size: 14px; color: var(--cyan); margin-top: 2px; }

.sd-summary {
  display: flex; justify-content: space-around;
  background: var(--card2); border-radius: 12px;
  padding: 14px 8px; margin-bottom: 18px;
}
.sd-summary-stat { display: flex; flex-direction: column; align-items: center; }
.sd-summary-num { font-family: 'Fredoka One', cursive; font-size: 20px; }
.sd-summary-lbl { font-size: 13px; color: var(--muted); text-transform: uppercase; }

.sd-questions-label {
  font-family: 'Fredoka One', cursive; font-size: 16px;
  color: var(--muted); margin-bottom: 10px;
}

.sd-question-card {
  background: var(--card2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-left: 4px solid var(--muted);
}
.sd-question-card.sd-correct { border-left-color: var(--green); }
.sd-question-card.sd-wrong { border-left-color: var(--red); }

.sd-q-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sd-q-num { font-family: 'Fredoka One', cursive; font-size: 15px; color: var(--muted); }
.sd-q-status { font-size: 16px; }

.sd-q-text { font-size: 16px; line-height: 1.4; margin-bottom: 8px; }

.sd-q-answer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.sd-q-student {
  font-family: 'Fredoka One', cursive; font-size: 15px;
  padding: 2px 10px; border-radius: 8px;
}
.sd-q-student.correct { background: rgba(76,175,80,0.15); color: var(--green); }
.sd-q-student.wrong { background: rgba(244,67,54,0.15); color: var(--red); text-decoration: line-through; }
.sd-q-correct-label { font-size: 15px; color: var(--green); }

.sd-q-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sd-q-time { font-size: 14px; color: var(--muted); }
.sd-q-type { font-size: 13px; color: var(--muted); background: var(--card); padding: 2px 8px; border-radius: 6px; }
.sd-help-badge {
  font-size: 13px; padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.sd-help-badge.tier1 { background: rgba(0,188,212,0.15); color: var(--cyan); }
.sd-help-badge.tier2 { background: rgba(255,193,7,0.15); color: var(--yellow); }
.sd-help-badge.tier3 { background: rgba(244,67,54,0.15); color: var(--red); }

.player-card {
  padding: 20px;
  background: linear-gradient(135deg, var(--card) 0%, var(--card2) 100%);
  border: 1px solid var(--border);
}
.player-top {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.player-avatar {
  width: 64px; height: 64px;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
}
/* ---- Avatar Frame Progression ---- */
.avatar-frame-1 {
  background: var(--surface);
  border: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.avatar-frame-2 {
  background: linear-gradient(135deg, #132a13, #0d1f0d);
  border: 2px solid #39d98a;
  box-shadow: 0 0 14px rgba(57,217,138,0.35);
}
.avatar-frame-3 {
  background: linear-gradient(135deg, #0d1b3e, #0a1230);
  border: 2px solid #60a5fa;
  box-shadow: 0 0 18px rgba(96,165,250,0.4);
  animation: avatar-pulse 2.5s ease-in-out infinite;
}
.avatar-frame-4 {
  background: linear-gradient(135deg, #1f0a3e, #150730);
  border: 2px solid #b14aed;
  box-shadow: 0 0 22px rgba(177,74,237,0.5);
  animation: avatar-glow 2s ease-in-out infinite;
}
.avatar-frame-5 {
  background: linear-gradient(135deg, #3e2a0d, #2f1a00);
  border: 3px solid #f59e0b;
  box-shadow: 0 0 26px rgba(245,158,11,0.5);
  animation: avatar-sparkle 1.8s ease-in-out infinite;
}
.avatar-frame-6 {
  background: linear-gradient(135deg, #1a0a2e, #0d0520);
  border: 3px solid #ff2d78;
  box-shadow: 0 0 20px rgba(255,45,120,0.4), 0 0 40px rgba(177,74,237,0.2);
  animation: avatar-rainbow-border 3s linear infinite, avatar-sparkle 1.8s ease-in-out infinite;
}
@keyframes avatar-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes avatar-glow {
  0%, 100% { box-shadow: 0 0 18px rgba(177,74,237,0.4); }
  50% { box-shadow: 0 0 28px rgba(177,74,237,0.7); }
}
@keyframes avatar-sparkle {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.05); filter: brightness(1.15); }
}
@keyframes avatar-rainbow-border {
  0%   { border-color: #ff2d78; box-shadow: 0 0 20px rgba(255,45,120,0.5); }
  20%  { border-color: #f59e0b; box-shadow: 0 0 20px rgba(245,158,11,0.5); }
  40%  { border-color: #39d98a; box-shadow: 0 0 20px rgba(57,217,138,0.5); }
  60%  { border-color: #60a5fa; box-shadow: 0 0 20px rgba(96,165,250,0.5); }
  80%  { border-color: #b14aed; box-shadow: 0 0 20px rgba(177,74,237,0.5); }
  100% { border-color: #ff2d78; box-shadow: 0 0 20px rgba(255,45,120,0.5); }
}
/* ---- end avatar frames ---- */

.player-info { flex: 1; }
.player-name {
  font-family: 'Fredoka One', cursive;
  font-size: 24px; line-height: 1.1;
}
.player-level-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 14px; font-weight: 800;
  margin-top: 3px;
}
.player-stats {
  display: flex; gap: 8px;
}
.stat-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 14px; font-weight: 800;
  display: flex; align-items: center; gap: 5px;
}
.stat-chip .sv { font-family: 'Fredoka One', cursive; font-size: 16px; }

.xp-bar-wrap { margin-top: 14px; }
.xp-bar-labels {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 5px;
}
.xp-bar-track {
  height: 10px; background: var(--surface); border-radius: 10px; overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  border-radius: 10px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(255,230,0,0.5);
}

/* Daily Missions */
.missions-list { display: flex; flex-direction: column; gap: 8px; }
.mission-item {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: opacity 0.3s;
}
.mission-item.done { opacity: 0.5; }
.mission-check {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  background: var(--surface);
}
.mission-item.done .mission-check {
  background: var(--green);
  border-color: var(--green);
}
.mission-text { flex: 1; }
.mission-name { font-weight: 800; font-size: 16px; }
.mission-prog { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.mission-xp {
  font-family: 'Fredoka One', cursive;
  font-size: 14px; color: var(--yellow);
}

/* Mode Cards */
.mode-cards { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  padding: 0;
  overflow: hidden;
  transition: all 0.2s;
  border: 1px solid var(--border);
}
.mode-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.mode-card-inner {
  display: flex; align-items: center; gap: 0;
  background: none; border: none;
  width: 100%; padding: 0; text-align: left; color: var(--text);
}
.mode-icon-wrap {
  width: 80px; min-height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; flex-shrink: 0;
}
.mode-text { flex: 1; padding: 14px 0; }
.mode-title {
  font-family: 'Fredoka One', cursive;
  font-size: 20px; line-height: 1.1;
}
.mode-desc { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 3px; }
.mode-badge {
  margin-right: 16px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px; font-weight: 800;
}
.mode-arrow { font-size: 20px; margin-right: 16px; color: var(--muted); }

/* Achievements preview */
.ach-preview-grid {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.ach-preview-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.ach-preview-chip.locked { opacity: 0.4; filter: grayscale(1); }

/* ===================== STORY MODE ===================== */
#screen-story {
  padding-top: 0;
  background: var(--bg);
}
.story-header {
  width: 100%; max-width: 600px;
  padding: 16px 16px 0;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0;
  background: rgba(6,9,18,0.9);
  backdrop-filter: blur(16px);
  z-index: 50;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.story-title-wrap {
  flex: 1;
  min-width: 0;
}
.story-title {
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
}
.story-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--purple);
  margin-top: 2px;
  letter-spacing: 0.2px;
}
.story-speaker-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.story-speaker-btn:hover {
  background: rgba(255,255,255,0.06);
}
.story-stats {
  display: flex; gap: 8px;
}
.story-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 14px; font-weight: 800;
  display: flex; align-items: center; gap: 4px;
}
.question-marker { height: 0; overflow: hidden; clear: both; }
.exercise-progress-nav { gap: 0 !important; padding: 0 4px !important; }
.ep-arrow { background: none; border: none; color: var(--green); font-size: 18px; font-weight: 900; cursor: pointer; padding: 4px 6px; line-height: 1; opacity: 0.7; transition: opacity 0.15s; }
.ep-arrow:hover:not([disabled]) { opacity: 1; }
.ep-arrow[disabled] { opacity: 0.25; cursor: default; }
.ep-label { padding: 4px 2px; white-space: nowrap; }

#story-exercise-progress {
  background: rgba(57,217,138,0.15);
  border: 1px solid var(--green);
  color: var(--green);
}

/* Exercise tag above chat bubbles */

.chat-area {
  flex: 1;
  width: 100%; max-width: 600px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-msg {
  display: flex; gap: 10px; align-items: flex-end;
  margin-bottom: 6px;
  animation: msgPop 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes msgPop {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.chat-msg.ai .chat-avatar { background: linear-gradient(135deg, var(--purple), var(--cyan)); }
.chat-msg.user .chat-avatar { background: linear-gradient(135deg, var(--pink), var(--yellow)); }
.chat-bubble {
  padding: 18px 22px;
  border-radius: 20px;
  max-width: 88%;
  font-size: 17.5px; line-height: 1.85; font-weight: 600;
  letter-spacing: 0.15px;
  word-spacing: 0.5px;
}
.chat-msg.ai .chat-bubble {
  background: rgba(16, 20, 34, 0.9);
  border: 1.5px solid rgba(0,229,255,0.15);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, rgba(255,230,0,0.12), rgba(255,45,120,0.12));
  border: 1.5px solid rgba(255,230,0,0.22);
  border-bottom-right-radius: 4px;
}
.typing-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
}
.typing-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.typing-dots {
  display: flex; gap: 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  background: var(--muted); border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-6px); }
}

/* Rich chat content */
.chat-bubble strong {
  color: var(--yellow);
  font-weight: 800;
}
.chat-greeting {
  color: var(--cyan);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 10px;
}
.chat-context {
  color: #c8d0ec;
  margin-bottom: 8px;
  line-height: 1.7;
}
.chat-ask {
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  margin-top: 10px;
  line-height: 1.7;
}
.chat-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0;
  padding: 14px 18px;
  background: rgba(0,229,255,0.10);
  border-radius: 16px;
  border-left: 3px solid var(--cyan);
}
.chat-step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--cyan);
  color: #060912;
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-step-text {
  flex: 1;
  padding-top: 2px;
  line-height: 1.75;
  font-size: 17px;
}
.chat-bullet {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0;
  padding: 6px 0;
}
.chat-bullet-dot {
  color: var(--pink);
  font-size: 18px;
  line-height: 1.5;
  flex-shrink: 0;
}
.chat-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 14px 0;
  padding: 16px 18px;
  background: rgba(255,230,0,0.14);
  border: 1.5px solid rgba(255,230,0,0.28);
  border-radius: 16px;
}
.chat-callout-icon {
  font-size: 22px;
  flex-shrink: 0;
}

/* ---- Visual Aids (tables, charts, etc.) ---- */
.chat-visual { margin-top: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chat-diagram { display: flex; justify-content: center; padding: 8px 0; margin-top: 0; }
.chat-diagram svg { max-width: 220px; max-height: 180px; width: 100%; height: auto; }
.visual-table { width:100%; border-collapse:collapse; font-size:15px; }
.visual-table th {
  background:rgba(0,229,255,0.15); color:var(--cyan);
  padding:10px 14px; text-align:center;
  border-bottom:2px solid rgba(0,229,255,0.3);
  font-family:'Fredoka One',cursive; font-weight:400;
}
.visual-table td {
  padding:10px 14px; text-align:center;
  border-bottom:1px solid rgba(255,255,255,0.08); color:var(--text);
}
.visual-table tr:last-child td { border-bottom:none; }
.visual-table td.highlight {
  background:rgba(255,230,0,0.18); color:var(--yellow); font-weight:800;
}
.visual-table caption {
  caption-side:top; color:var(--muted); font-size:13px;
  margin-bottom:8px; text-align:left;
}

.story-input-wrap {
  width: 100%; max-width: 600px;
  padding: 10px 16px 14px;
  background: rgba(6,9,18,0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; bottom: 0;
}
.quick-replies {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.qr-btn {
  background: transparent;
  border: 2px solid rgba(0,229,255,0.4);
  border-radius: 50px;
  padding: 10px 18px;
  font-size: 16px; font-weight: 800; color: var(--cyan);
  transition: all 0.18s;
  cursor: pointer;
}
.qr-btn:hover {
  background: rgba(0,229,255,0.1);
  border-color: var(--cyan);
  transform: translateY(-1px);
}
/* Primary action — first button stands out */
.qr-btn:first-child {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #060912;
  box-shadow: 0 2px 10px rgba(0,229,255,0.25);
}
.qr-btn:first-child:hover {
  background: #33e0ff;
  border-color: #33e0ff;
  color: #060912;
  box-shadow: 0 4px 16px rgba(0,229,255,0.35);
  transform: translateY(-2px);
}

/* Prep nudge (struggle detection) */
.prep-nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: rgba(177,74,237,0.1);
  border: 1.5px solid rgba(177,74,237,0.3);
  border-radius: 14px;
  margin-bottom: 4px;
  animation: msgPop 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
.prep-nudge-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.prep-nudge-title {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: var(--purple);
}
.prep-nudge-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

/* Prep completion nudge (Prep → Story) */
.prep-complete-nudge {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  width: 100%;
  padding: 20px 16px 14px;
  background: rgba(78,205,196,0.1);
  border: 1.5px solid rgba(78,205,196,0.3);
  border-radius: 16px;
  margin: 12px 0;
  animation: msgPop 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
.prep-complete-icon {
  font-size: 36px;
}
.prep-complete-title {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: #4ECDC4;
}
.prep-complete-sub {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}
.prep-complete-stats {
  font-size: 13px;
  color: var(--purple);
  font-weight: 700;
  margin-top: 2px;
}
.prep-complete-btn {
  width: 100%;
  margin-top: 4px;
}

.story-input-row {
  display: flex; gap: 10px;
}
.story-input {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 18px; font-weight: 700; color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.story-input:focus { border-color: var(--cyan); }
.story-input::placeholder { color: var(--muted); font-weight: 600; font-size: 16px; }
.story-send {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 14px;
  width: 50px; height: 50px;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s; color: #060912; font-weight: 800;
}
.story-send:hover { transform: scale(1.08); box-shadow: 0 4px 16px rgba(0,229,255,0.4); }
.story-send:disabled { opacity: 0.45; transform: none; }

/* ===================== SPEED ROUND ===================== */
#screen-speed { background: var(--bg); }
.speed-header {
  width: 100%; max-width: 600px;
  padding: 60px 16px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.speed-score-display {
  text-align: center;
}
.speed-score-num {
  font-family: 'Fredoka One', cursive; font-size: 48px;
  color: var(--yellow); line-height: 1;
  text-shadow: 0 0 30px rgba(255,230,0,0.5);
}
.speed-score-label { font-size: 14px; font-weight: 800; color: var(--muted); }
.timer-circle-wrap { position: relative; }
.timer-svg { transform: rotate(-90deg); }
.timer-track { fill: none; stroke: var(--card2); stroke-width: 6; }
.timer-fill  { fill: none; stroke: var(--cyan); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.5s; }
.timer-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka One', cursive; font-size: 24px; color: var(--cyan);
}

.speed-timer-bar-wrap { width: 100%; max-width: 600px; padding: 12px 16px 0; }
.speed-timer-bar-track {
  height: 8px; background: var(--card2); border-radius: 8px; overflow: hidden;
}
.speed-timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  border-radius: 8px;
  transition: width 1s linear, background 0.5s;
}

.speed-body {
  flex: 1; width: 100%; max-width: 600px;
  padding: 20px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
}
.speed-context {
  font-size: 17px; font-weight: 700; color: var(--muted);
  text-align: center; min-height: 40px;
}
.speed-problem {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(40px, 12vw, 68px);
  text-align: center; line-height: 1.1;
  color: var(--text);
  text-shadow: 0 0 40px rgba(255,255,255,0.1);
}
.speed-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%;
}
.choice-btn {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 28px; color: var(--text);
  transition: all 0.15s;
  text-align: center;
}
.choice-btn:hover { border-color: var(--yellow); background: rgba(255,230,0,0.08); transform: scale(1.03); }
.choice-btn.correct { border-color: var(--green) !important; background: rgba(57,217,138,0.15) !important; color: var(--green) !important; animation: correctBounce 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; }
.choice-btn.wrong   { border-color: #ffb74d !important; background: rgba(255,183,77,0.15) !important; color: #ffb74d !important; }
.choice-btn:disabled { cursor: default; }

/* Speed results overlay */
#speed-results {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#speed-results.show { opacity: 1; pointer-events: all; }
.results-card {
  background: var(--card);
  border: 2px solid var(--yellow);
  border-radius: 28px;
  padding: 36px 40px;
  text-align: center;
  width: min(90vw, 380px);
  box-shadow: 0 0 60px rgba(255,230,0,0.3);
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#speed-results.show .results-card { transform: scale(1); }
.results-emoji { font-size: 64px; display: block; margin-bottom: 8px; }
.results-title {
  font-family: 'Fredoka One', cursive; font-size: 36px;
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 6px;
}
.results-score {
  font-family: 'Fredoka One', cursive; font-size: 72px;
  color: var(--yellow);
  text-shadow: 0 0 40px rgba(255,230,0,0.5);
  line-height: 1;
}
.results-label { font-size: 16px; font-weight: 700; color: var(--muted); margin-bottom: 24px; }
.results-xp {
  font-family: 'Fredoka One', cursive; font-size: 24px; color: var(--cyan);
  margin-bottom: 20px;
}
.results-btns { display: flex; flex-direction: column; gap: 10px; }

/* ===================== SPEED COUNTDOWN ===================== */
.speed-countdown { position: fixed; inset: 0; background: rgba(6,9,18,0.92); display: flex; align-items: center; justify-content: center; z-index: 310; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.speed-countdown.show { opacity: 1; pointer-events: all; }
.countdown-num { font-family: 'Fredoka One', cursive; font-size: clamp(100px, 30vw, 180px); color: var(--yellow); text-shadow: 0 0 60px rgba(255,230,0,0.5); animation: countdownPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.countdown-num.go { background: linear-gradient(135deg, var(--green), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-shadow: none; filter: drop-shadow(0 0 40px rgba(57,217,138,0.6)); }
@keyframes countdownPop { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* Speed timer urgency */
.timer-num.urgent { animation: urgentPulse 0.5s ease-in-out infinite alternate; color: var(--red) !important; }
@keyframes urgentPulse { from { transform: scale(1); } to { transform: scale(1.15); } }
body.speed-urgency { box-shadow: inset 0 0 60px 15px rgba(255,77,109,0.3); transition: box-shadow 0.4s ease; }

/* ===================== BOSS BATTLE ===================== */
#screen-boss { background: var(--bg); }
.boss-header {
  width: 100%; max-width: 600px;
  padding: 56px 16px 0;
}
.boss-hp-wrap { margin-bottom: 6px; }
.boss-hp-label {
  display: flex; justify-content: space-between;
  font-size: 14px; font-weight: 800; color: var(--red);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px;
}
.boss-hp-track {
  height: 16px; background: var(--card2); border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255,77,109,0.2);
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--pink));
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 16px rgba(255,77,109,0.5);
}
.boss-problems-dots {
  display: flex; justify-content: center; gap: 8px; margin-top: 10px;
}
.boss-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--card2); border: 2px solid var(--border);
  transition: all 0.3s;
}
.boss-dot.done { background: var(--green); border-color: var(--green); box-shadow: 0 0 10px rgba(57,217,138,0.5); }
.boss-dot.current { background: var(--yellow); border-color: var(--yellow); box-shadow: 0 0 10px rgba(255,230,0,0.5); }

.boss-body {
  flex: 1; width: 100%; max-width: 600px;
  padding: 0 16px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  overflow-y: auto;
}
.boss-character {
  font-size: 90px;
  animation: bossShake 0.3s ease infinite alternate;
  filter: drop-shadow(0 0 30px rgba(255,77,109,0.6));
  text-align: center; line-height: 1;
}
.boss-character.hurt { animation: bossHurt 0.4s ease; }
@keyframes bossShake {
  from { transform: rotate(-3deg) scale(1); }
  to   { transform: rotate(3deg) scale(1.03); }
}
@keyframes bossHurt {
  0%,100% { transform: translateX(0) scale(1); filter: drop-shadow(0 0 30px rgba(255,77,109,0.6)); }
  25%     { transform: translateX(-10px) scale(1.1); filter: drop-shadow(0 0 50px rgba(255,77,109,1)); }
  75%     { transform: translateX(10px) scale(0.9); }
}
.boss-name {
  font-family: 'Fredoka One', cursive; font-size: 22px; color: var(--red);
  text-align: center;
}
.boss-says {
  background: var(--card); border: 1px solid rgba(255,77,109,0.3);
  border-radius: 16px; padding: 14px 18px;
  font-size: 17px; font-weight: 700; line-height: 1.5;
  text-align: center; width: 100%; min-height: 60px;
  color: var(--text);
}
.boss-problem-display {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(36px, 10vw, 56px);
  text-align: center; color: var(--text);
}
.boss-problem-display.long-text {
  font-family: 'Inter', sans-serif;
  font-size: 17px; font-weight: 700; line-height: 1.5;
}
.boss-input-wrap {
  display: flex; gap: 10px; width: 100%;
}
.boss-input {
  flex: 1;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 20px; font-weight: 800; color: var(--text);
  outline: none; transition: border-color 0.2s;
  text-align: center;
}
.boss-input:focus { border-color: var(--red); }
.boss-submit {
  background: linear-gradient(135deg, var(--red), var(--pink));
  border-radius: 14px; padding: 14px 24px;
  font-family: 'Fredoka One', cursive; font-size: 18px; color: white;
  transition: all 0.18s;
}
.boss-submit:hover { transform: scale(1.05); }

/* Boss results */
#boss-results {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#boss-results.show { opacity: 1; pointer-events: all; }
.boss-result-card {
  background: var(--card); border-radius: 28px; padding: 36px 40px;
  text-align: center; width: min(90vw, 380px);
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#boss-results.show .boss-result-card { transform: scale(1); }

/* Boss entrance animation */
.boss-character.entering { animation: bossEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes bossEntrance { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 60% { transform: scale(1.2) rotate(5deg); opacity: 1; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }

/* Boss defeat animation */
.boss-character.defeated { animation: bossDefeat 0.8s cubic-bezier(0.6, -0.28, 0.74, 0.05) forwards; }
@keyframes bossDefeat { 0% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.3) rotate(180deg); opacity: 0.8; } 100% { transform: scale(0) rotate(720deg); opacity: 0; } }

/* Pre-game picker overlay */
/* Pause Overlay */
#pause-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#pause-overlay.show { opacity: 1; pointer-events: all; }
.pause-card {
  width: 88%; max-width: 360px;
  background: var(--card);
  border-radius: 24px;
  border: 2px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#pause-overlay.show .pause-card { transform: scale(1); }
.pause-title {
  font-family: 'Fredoka One', cursive;
  font-size: 32px;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
}
.pause-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.pause-stat {
  background: var(--card2);
  border-radius: 14px;
  padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.pause-stat-num {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--cyan);
}
.pause-stat-lbl {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pause-actions {
  display: flex; flex-direction: column; gap: 10px;
}
.btn-danger {
  background: transparent;
  border: 2px solid var(--red);
  color: var(--red);
  padding: 14px 24px;
  border-radius: 14px;
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-danger:hover, .btn-danger:active {
  background: var(--red);
  color: #fff;
}

/* ---- Sign-Out Overlay ---- */
#signout-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#signout-overlay.show { opacity: 1; pointer-events: all; }
.signout-card {
  width: 88%; max-width: 340px;
  background: var(--card);
  border-radius: 24px;
  border: 2px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#signout-overlay.show .signout-card { transform: scale(1); }
.signout-title {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
  color: var(--text);
  margin-bottom: 12px;
}
.signout-msg {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.5;
}
.signout-actions {
  display: flex; flex-direction: column; gap: 10px;
}

/* Games History */
.history-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.history-back-btn {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text); font-size: 20px;
  width: 40px; height: 40px; border-radius: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.history-back-btn:active { background: var(--border); }
.history-title {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
}
.history-filters {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 16px;
}
.filter-row {
  display: flex; gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-chip.active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #000;
}
.filter-chip:not(.active):hover {
  border-color: var(--cyan);
  color: var(--text);
}
.history-date-label {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 4px;
}
.history-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 15px;
}

/* ---- Mistake Journal ---- */
.mj-link {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s; margin-top: 12px;
}
.mj-link:active { border-color: var(--yellow); }
.mj-link-icon { font-size: 32px; }
.mj-link-info { flex: 1; }
.mj-link-title { font-family: 'Fredoka One', cursive; font-size: 17px; color: var(--yellow); }
.mj-link-sub { font-size: 13px; color: #c5cdeb; margin-top: 2px; }
.mj-link-arrow { font-size: 24px; color: var(--yellow); font-weight: 700; }
.mj-count {
  font-family: 'Fredoka One', cursive; font-size: 16px;
  color: var(--yellow); padding: 16px 0 8px;
}
.mj-empty { text-align: center; padding: 60px 16px; }
.mj-card {
  padding: 16px; margin-bottom: 12px;
  border-left: 4px solid var(--red);
}
.mj-card.mj-reviewed { opacity: 0.6; border-left-color: var(--green); }
.mj-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.mj-card-q { font-size: 18px; }
.mj-card-type {
  font-size: 11px; font-weight: 700; color: var(--cyan);
  background: rgba(0,229,255,0.1); padding: 2px 8px; border-radius: 6px;
}
.mj-card-chapter {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--card2); padding: 2px 8px; border-radius: 6px;
}
.mj-times {
  font-size: 11px; font-weight: 800; color: var(--red);
  background: rgba(255,77,109,0.12); padding: 2px 8px; border-radius: 6px;
}
.mj-card-question {
  font-size: 15px; font-weight: 600; margin-bottom: 12px; line-height: 1.4;
}
.mj-card-answers { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mj-answer {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  padding: 8px 12px; border-radius: 8px;
}
.mj-answer.wrong { background: rgba(255,77,109,0.08); }
.mj-answer.correct { background: rgba(57,217,138,0.08); }
.mj-answer-label { font-size: 12px; color: var(--muted); font-weight: 700; min-width: 70px; }
.mj-answer-text { font-weight: 700; }
.mj-answer.wrong .mj-answer-text { color: var(--red); text-decoration: line-through; }
.mj-answer.correct .mj-answer-text { color: var(--green); }
.mj-card-actions { display: flex; gap: 8px; }
.mj-card-actions .btn { flex: 1; padding: 10px; font-size: 13px; }
.mj-reviewed-header { padding: 16px 0 8px; }
.mj-reviewed-toggle {
  background: none; border: none; color: var(--muted); font-size: 14px;
  font-weight: 700; cursor: pointer; padding: 8px 0;
}

/* Help Screen */
.help-section { margin-bottom: 20px; }
.help-section-title {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  margin-bottom: 8px;
}
.help-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.help-card p {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 8px;
}
.help-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.help-card-icon { font-size: 28px; }
.help-card-name {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
}
.help-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.help-detail {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  padding: 6px 10px;
  background: var(--card2);
  border-radius: 8px;
}
.help-detail strong { color: var(--cyan); }

#pregame-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
#pregame-overlay.show { opacity: 1; pointer-events: all; }
.pregame-card {
  background: var(--card); border-radius: 28px; padding: 28px 24px;
  width: 92%; max-width: 500px; max-height: 85vh;
  display: flex; flex-direction: column; gap: 16px;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}
#pregame-overlay.show .pregame-card { transform: scale(1); }
.pregame-card { position: relative; }
.pregame-back {
  position: absolute; top: 16px; left: 16px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 15px; font-weight: 700;
  border-radius: 12px; padding: 6px 14px; cursor: pointer;
  display: none; align-items: center; gap: 4px;
  z-index: 2; transition: background 0.15s;
}
.pregame-back:hover { background: var(--card2); }
.pregame-header { text-align: center; }
.pregame-title {
  font-family: 'Fredoka One', cursive; font-size: 22px;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.pregame-subtitle { font-size: 15px; color: var(--muted); margin-top: 4px; }
.pregame-section-label {
  font-family: 'Fredoka One', cursive; font-size: 16px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 1px;
}
.pregame-chapter-list {
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; max-height: 45vh; padding-right: 4px;
}
.pregame-chapter-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
  color: #fff; font-size: 16px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}
.pregame-chapter-btn:hover { border-color: var(--cyan); }
.pregame-chapter-btn.selected {
  border-color: var(--cyan); background: rgba(0,229,255,0.08);
}
.pregame-ch-num {
  font-family: 'Fredoka One', cursive; font-size: 14px;
  color: var(--cyan); min-width: 36px;
}
.pregame-ch-name { flex: 1; }
.pregame-ch-arrow {
  font-size: 12px; color: var(--muted); margin-left: 4px;
  transition: transform 0.2s;
}
.pregame-lesson-list {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 0 8px 20px;
  animation: lessonSlide 0.25s ease-out;
}
@keyframes lessonSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.pregame-lesson-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--card2); border: 2px solid transparent;
  border-radius: 10px; padding: 10px 12px;
  color: #fff; font-size: 15px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}
.pregame-lesson-btn:hover { border-color: var(--green); }
.pregame-lesson-btn.selected {
  border-color: var(--green); background: rgba(57,217,138,0.1);
}
.pregame-ls-num {
  font-family: 'Fredoka One', cursive; font-size: 13px;
  color: var(--green); min-width: 32px;
}
.pregame-ls-name { flex: 1; }
.pregame-assessment-divider {
  font-family: 'Fredoka One', cursive; font-size: 11px; text-transform: uppercase;
  color: var(--muted); letter-spacing: 1.5px;
  margin: 10px 0 4px; padding: 0 4px;
}
.pregame-lesson-practice {
  border-color: rgba(0,199,255,0.2); background: rgba(0,199,255,0.05);
}
.pregame-lesson-practice:hover { border-color: var(--cyan); }
.pregame-lesson-practice.selected { border-color: var(--cyan); background: rgba(0,199,255,0.12); }
.pregame-lesson-assessment {
  border-color: rgba(255,204,0,0.2); background: rgba(255,204,0,0.05);
}
.pregame-lesson-assessment:hover { border-color: var(--yellow); }
.pregame-lesson-assessment.selected { border-color: var(--yellow); background: rgba(255,204,0,0.12); }
.pregame-actions {
  display: flex; gap: 10px;
}
.pregame-actions .btn { flex: 1; padding: 14px; font-size: 16px; }
.pregame-cancel {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  border-radius: 14px; cursor: pointer;
}
.pregame-cancel:hover { background: var(--card2); }

/* Subject grid (profile) */
.subject-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.subject-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: 2px solid var(--border);
  border-radius: 16px; padding: 16px 8px;
  color: #fff; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.subject-card.enabled {
  border-color: var(--cyan); background: rgba(0,229,255,0.06);
}
.subject-card.coming-soon {
  opacity: 0.45; cursor: default; pointer-events: none;
}
.subject-emoji { font-size: 28px; }
.subject-name {
  font-family: 'Fredoka One', cursive; font-size: 15px;
}
.default-badge {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  background: var(--cyan); color: var(--bg); padding: 2px 8px;
  border-radius: 8px; letter-spacing: 0.5px;
}
.coming-soon-badge {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.subject-curriculum {
  font-size: 13px; font-weight: 700; color: var(--cyan);
  text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.85;
}
.subject-grade-card {
  width: 100%; margin-bottom: 10px;
}

/* ===================== ACHIEVEMENTS SCREEN ===================== */
#screen-achievements { padding-top: 0; }
.ach-screen-header {
  width: 100%; max-width: 600px;
  padding: 60px 16px 0;
  font-family: 'Fredoka One', cursive; font-size: 28px;
  display: flex; align-items: center; gap: 10px;
}
.ach-count {
  background: var(--yellow);
  color: #060912;
  border-radius: 50px; padding: 2px 10px;
  font-size: 14px; margin-left: auto;
}
.ach-grid {
  width: 100%; max-width: 600px;
  padding: 12px 16px 100px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.ach-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  transition: all 0.2s;
}
.ach-card.unlocked {
  border-color: rgba(255,230,0,0.3);
  box-shadow: 0 0 20px rgba(255,230,0,0.1);
}
.ach-card.locked { opacity: 0.35; filter: grayscale(0.7); }
.ach-card-icon { font-size: 34px; }
.ach-card-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.ach-card-desc { font-size: 13px; font-weight: 600; color: var(--muted); }
.ach-card-xp  {
  font-family: 'Fredoka One', cursive; font-size: 15px;
  color: var(--yellow); margin-top: 2px;
}

/* ===================== STORY ANSWER CHOICES ===================== */
.answer-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 0 4px;
}
.answer-choice-btn {
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,230,0,0.25);
  border-radius: 16px;
  padding: 18px 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--text);
  text-align: center;
  transition: all 0.18s;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.answer-choice-btn:hover {
  border-color: var(--yellow);
  background: rgba(255,230,0,0.1);
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(255,230,0,0.15);
}
.answer-choice-btn.correct {
  border-color: var(--green) !important;
  background: rgba(57,217,138,0.18) !important;
  color: var(--green) !important;
  box-shadow: 0 0 16px rgba(57,217,138,0.25) !important;
  animation: correctBounce 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}
.answer-choice-btn.wrong {
  border-color: #ffb74d !important;
  background: rgba(255,183,77,0.14) !important;
  color: #ffb74d !important;
  box-shadow: 0 0 12px rgba(255,183,77,0.15) !important;
}
.answer-choice-btn:disabled { cursor: default; transform: none; }

/* ===================== HELP BUTTON (progressive help) ===================== */
.help-btn {
  grid-column: 1 / -1;
  background: rgba(177, 74, 237, 0.1);
  border: 1.5px dashed rgba(177, 74, 237, 0.4);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  text-align: center;
  transition: all 0.18s;
  cursor: pointer;
  margin-top: 2px;
}
.help-btn:hover {
  background: rgba(177, 74, 237, 0.18);
  border-color: var(--purple);
  transform: translateY(-1px);
  color: #d4a5f5;
}
.help-btn:active {
  transform: translateY(0) scale(0.98);
}
.help-btn-prominent {
  background: rgba(57,217,138,0.12);
  border: 1.5px dashed rgba(57,217,138,0.5);
  color: var(--green);
  animation: helpPulse 2s ease-in-out infinite;
}
.help-btn-prominent:hover {
  background: rgba(57,217,138,0.2);
  border-color: var(--green);
  color: #7aedb8;
}
@keyframes helpPulse {
  0%, 100% { border-color: rgba(57,217,138,0.3); }
  50% { border-color: rgba(57,217,138,0.7); }
}

/* ===================== MISC ===================== */
.divider {
  height: 1px; background: var(--border); margin: 4px 0;
}
.loading-dots {
  display: flex; gap: 5px; justify-content: center; align-items: center; padding: 20px;
}
.loading-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--purple); animation: typingBounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Feedback flash */
#feedback-flash {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0);
  font-family: 'Fredoka One', cursive; font-size: 52px;
  padding: 16px 36px; border-radius: 20px;
  pointer-events: none; z-index: 400;
  transition: transform 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
  white-space: nowrap;
}
#feedback-flash.show { transform: translate(-50%,-50%) scale(1); }
#feedback-flash.correct { background: var(--green); color: #060912; }
#feedback-flash.wrong   { background: #ffb74d; color: #060912; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
.shake { animation: shake 0.4s ease !important; }

/* ===================== CORRECT BOUNCE ===================== */
@keyframes correctBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ===================== CONFETTI BURST ===================== */
.confetti-particle {
  position: fixed;
  z-index: 410;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: confettiBurst 0.85s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
  }
  20% {
    opacity: 1;
    transform: translate(
      calc(-50% + var(--tx) * 0.3),
      calc(-50% + var(--ty) * 0.3)
    ) scale(1.2) rotate(calc(var(--rot) * 0.3));
  }
  100% {
    opacity: 0;
    transform: translate(
      calc(-50% + var(--tx)),
      calc(-50% + var(--ty) + 20px)
    ) scale(0.3) rotate(var(--rot));
  }
}

/* ===================== STREAK MILESTONE BANNER ===================== */
.streak-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 420;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 24px;
  font-family: 'Fredoka One', cursive;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
}
.streak-banner.show {
  transform: translateY(0);
  opacity: 1;
}
.streak-banner.streak-3 {
  background: linear-gradient(135deg, rgba(255, 140, 66, 0.95), rgba(255, 45, 120, 0.9));
}
.streak-banner.streak-5 {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.95), rgba(177, 74, 237, 0.9));
}
.streak-banner.streak-10 {
  background: linear-gradient(135deg, rgba(255, 230, 0, 0.95), rgba(255, 140, 66, 0.9));
}
.streak-banner-emoji {
  font-size: 36px;
  animation: streakEmojiBounce 0.6s ease;
}
.streak-banner-text {
  font-size: 32px;
  color: #060912;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.streak-banner-count {
  font-size: 16px;
  font-weight: 700;
  color: rgba(6, 9, 18, 0.7);
}
@keyframes streakEmojiBounce {
  0%   { transform: scale(0) rotate(-20deg); }
  50%  { transform: scale(1.3) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}
body.streak-glow {
  box-shadow: inset 0 0 80px 20px var(--streak-glow-color, rgba(255, 140, 66, 0.5));
  transition: box-shadow 0.4s ease;
}

/* ===================== GENTLE WRONG FLASH ===================== */
#feedback-flash.gentle {
  font-size: 38px;
  padding: 12px 28px;
}
#feedback-flash .flash-main {
  display: block;
}
#feedback-flash .flash-micro {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  opacity: 0.85;
  margin-top: 2px;
}

/* ===================== MINI FLASH (Speed mode) ===================== */
#feedback-flash.mini {
  font-size: 40px;
  padding: 10px 24px;
  border-radius: 50%;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===================== SPEAKER BUTTON (TTS) ===================== */
.speaker-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,229,255,0.1);
  border: 1px solid rgba(0,229,255,0.25);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
  float: right;
}
.speaker-btn:hover {
  background: rgba(0,229,255,0.2);
  border-color: var(--cyan);
  transform: scale(1.1);
}
.speaker-btn.speaking {
  background: rgba(0,229,255,0.25);
  border-color: var(--cyan);
  animation: speakerPulse 1s ease infinite;
}
@keyframes speakerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ===================== IDLE NUDGE ===================== */
.idle-nudge {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(20px) scale(0.9);
  border-radius: 20px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 450;
  width: 90%;
  max-width: 420px;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
  cursor: pointer;
}
.idle-nudge.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.idle-nudge .idle-nudge-icon {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}
.idle-nudge-text {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.45;
}

/* ---- Tier 1: Gentle (30s) — warm cyan banner ---- */
.idle-nudge-gentle {
  bottom: 130px;
  background: linear-gradient(135deg, rgba(0,180,220,0.92), rgba(0,140,200,0.92));
  box-shadow: 0 8px 32px rgba(0,180,220,0.35);
}

/* ---- Tier 2: Re-read (60s) — bigger purple card with problem ---- */
.idle-nudge-reread {
  bottom: 100px;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  background: linear-gradient(135deg, rgba(130,60,200,0.94), rgba(100,40,180,0.94));
  box-shadow: 0 12px 40px rgba(130,60,200,0.4);
}
.idle-nudge-reread .idle-nudge-icon { align-self: center; font-size: 40px; }
.idle-nudge-reread .idle-nudge-text { text-align: center; }
.idle-nudge-problem {
  display: none;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
  text-align: center;
}
.idle-nudge-reread .idle-nudge-problem,
.idle-nudge-mascot .idle-nudge-problem { display: block; }
.idle-nudge-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
}
.idle-nudge-action {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.idle-nudge-action:hover { background: rgba(255,255,255,0.28); }

/* ---- Tier 3: Mascot (90s) — big Pikoo overlay, impossible to miss ---- */
.idle-nudge-mascot.idle-nudge {
  bottom: 80px;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, rgba(200,160,20,0.95), rgba(220,140,0,0.95));
  box-shadow: 0 14px 50px rgba(220,160,0,0.45);
  animation: nudgeBounce 2s ease-in-out infinite;
}
.idle-nudge-mascot .idle-nudge-icon { font-size: 52px; animation: nudgeWiggle 1.5s ease-in-out infinite; }
@keyframes nudgeBounce {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  50% { transform: translateX(-50%) translateY(-6px) scale(1.02); }
}
@keyframes nudgeWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

/* ===================== TOGGLE SWITCH ===================== */
.settings-toggle-card {
  padding: 16px;
  margin-bottom: 12px;
}
.settings-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-toggle-icon { font-size: 24px; }
.settings-toggle-label {
  flex: 1;
  font-weight: 800;
  font-size: 15px;
}
.settings-toggle-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}
.voice-select {
  flex: 1;
  max-width: 180px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}
.voice-select:focus {
  outline: none;
  border-color: var(--cyan);
}
.voice-preview-btn {
  display: block;
  margin-top: 10px;
  padding: 6px 16px;
  border: none;
  border-radius: 10px;
  background: var(--cyan);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.voice-preview-btn:active {
  transform: scale(0.96);
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: 28px;
  transition: all 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: all 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(0,229,255,0.2);
  border-color: var(--cyan);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--cyan);
}

/* ─── Curriculum View ──────────────────────────────────────────────── */
.curr-header {
  text-align: center;
  margin-bottom: 16px;
}
.curr-title {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  background: linear-gradient(135deg, var(--cyan), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.curr-selectors {
  display: flex; gap: 16px; justify-content: center;
  margin-bottom: 14px; flex-wrap: wrap;
}
.curr-selector-group {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.curr-selector-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.curr-selector-value {
  font-size: 14px; font-weight: 700; color: var(--text);
  padding: 6px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px;
}
.curr-select {
  font-family: 'Nunito', sans-serif;
  font-size: 14px; font-weight: 700; color: var(--text);
  padding: 6px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px;
  outline: none; cursor: pointer;
}
.curr-select:focus { border-color: var(--cyan); }

.curr-grade-chips {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.curr-grade-chip {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.curr-grade-chip.active {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.12);
  color: var(--cyan);
}
.curr-grade-chip:hover { border-color: var(--cyan); }

.curr-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.curr-chapter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}
.curr-chapter-row:hover { border-color: var(--cyan); }
.curr-chapter-row.expanded { border-color: var(--cyan); border-radius: 12px 12px 0 0; }

.curr-expand-icon {
  background: none; border: none;
  color: var(--cyan);
  font-size: 12px;
  cursor: pointer;
  width: 20px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.curr-ch-num {
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  color: var(--cyan);
  min-width: 36px;
  flex-shrink: 0;
}

.curr-item-name {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.curr-accuracy-badge {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.curr-accuracy-badge.strong { background: rgba(57,217,138,0.15); color: var(--green); }
.curr-accuracy-badge.ok { background: rgba(255,230,0,0.15); color: var(--yellow); }
.curr-accuracy-badge.weak { background: rgba(255,77,109,0.15); color: var(--red); }

.curr-menu-btn {
  background: none; border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
  line-height: 1;
}
.curr-menu-btn:hover { color: var(--text); }

.curr-menu-popup {
  display: none;
  position: absolute;
  right: 12px;
  top: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 0;
  z-index: 50;
  min-width: 100px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.curr-menu-popup.show { display: block; }
.curr-menu-item {
  display: block; width: 100%;
  padding: 8px 16px;
  background: none; border: none;
  color: var(--text);
  font-size: 15px; font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.curr-menu-item:hover { background: var(--card); }
.curr-menu-danger { color: var(--red); }
.curr-menu-danger:hover { background: rgba(255,77,109,0.1); }

.curr-lessons-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 4px 8px 8px;
  margin-bottom: 4px;
}

.curr-lesson-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-left: 12px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}
.curr-lesson-row:hover { background: var(--card2); }

.curr-ls-num {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: var(--muted);
  min-width: 28px;
  flex-shrink: 0;
}

.curr-exercises-wrap {
  margin-left: 36px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
}

.curr-exercise-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 8px;
  position: relative;
  transition: background 0.2s;
}
.curr-exercise-row:hover { background: var(--card2); }
.curr-ex-content {
  flex: 1;
  min-width: 0;
}
.curr-ex-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.curr-ex-badge {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}
.curr-ex-badge-practice {
  background: rgba(57,217,138,0.15);
  color: var(--green);
}
.curr-ex-badge-quiz {
  background: rgba(177,74,237,0.15);
  color: var(--purple);
}
.curr-ls-type-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px;
}
.curr-ls-type-practice { background: rgba(0,199,255,0.15); color: var(--cyan); }
.curr-ls-type-checkpoint { background: rgba(255,204,0,0.15); color: var(--yellow); }
.curr-ls-type-test { background: rgba(255,106,60,0.15); color: var(--orange); }
.curr-ex-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.curr-add-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--cyan);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.curr-add-btn:hover { border-color: var(--cyan); background: rgba(0,229,255,0.05); }

.curr-add-inline {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  background: none;
  border: none;
  color: var(--cyan);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}
.curr-add-inline:hover { background: rgba(0,229,255,0.05); }

.curr-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
}
.curr-inline-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--cyan);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}
.curr-edit-input {
  border-width: 1px;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 6px;
}
.curr-inline-save {
  padding: 8px 14px;
  background: var(--cyan);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.curr-inline-save:active { transform: scale(0.96); }
.curr-inline-cancel {
  background: none; border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.curr-loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-weight: 700;
}
.curr-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.curr-empty-hint {
  padding: 8px 12px;
  margin-left: 12px;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

/* ─── Auth Screens ─────────────────────────────────────────── */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 32px 20px;
  position: relative;
}
.auth-back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--text);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.auth-back-btn:hover { background: rgba(255,255,255,0.14); }
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}
.auth-title {
  font-family: 'Fredoka One', cursive;
  font-size: 26px;
  color: var(--text);
}
.auth-subtitle {
  color: var(--muted);
  font-size: 16px;
  margin-top: 6px;
}
.auth-form {
  width: 100%;
  max-width: 360px;
}
.auth-field {
  margin-bottom: 16px;
}
.auth-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 18px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
}
.auth-input:focus {
  border-color: var(--purple);
  background: rgba(177,74,237,0.06);
}
.auth-input::placeholder {
  color: rgba(255,255,255,0.25);
}
select.auth-input {
  appearance: none;
  cursor: pointer;
}
.auth-error {
  color: #ff6b6b;
  font-size: 15px;
  font-weight: 700;
  min-height: 20px;
  margin-bottom: 8px;
  text-align: center;
}
.auth-submit {
  width: 100%;
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  padding: 16px;
}
.auth-switch {
  text-align: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}
.auth-switch-btn {
  background: none;
  border: none;
  color: var(--cyan);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: 'Nunito', sans-serif;
}
.auth-switch-btn:hover { text-decoration: underline; }
.auth-forgot {
  text-align: center;
  margin-top: 8px;
}
.auth-skip-btn {
  width: 100%;
  margin-top: 12px;
  background: transparent;
  color: var(--muted);
  border: 2px solid rgba(255,255,255,0.1);
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.auth-skip-btn:hover {
  border-color: rgba(255,255,255,0.25);
  color: var(--text);
}

/* ─── Student Roster ──────────────────────────────────────── */
.roster-new-btn {
  width: 100%;
  max-width: 360px;
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  padding: 16px;
}

/* ─── PIN Entry ──────────────────────────────────────────── */
.pin-avatar {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
}
.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0 24px;
}
.pin-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: transparent;
  transition: all 0.15s;
}
.pin-dot.filled {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,229,255,0.4);
}
.pin-dots.shake {
  animation: pinShake 0.4s ease;
}
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}
.pin-key {
  width: 100%; aspect-ratio: 1.4;
  font-family: 'Fredoka One', cursive;
  font-size: 32px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
}
.pin-key:active {
  background: rgba(0,229,255,0.15);
  border-color: var(--cyan);
  transform: scale(0.95);
}
.pin-key-empty { visibility: hidden; }
.pin-key-delete { font-size: 22px; color: var(--muted); }

/* ─── Setup PIN Step ─────────────────────────────────────── */
.setup-pin-desc {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 16px;
}
.setup-pin-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Teacher Dashboard ───────────────────────────────────── */

.teacher-logout-btn {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: background 0.2s, color 0.2s;
}
.teacher-logout-btn:hover {
  background: rgba(255,107,107,0.15);
  color: #ff6b6b;
}
.teacher-loading {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-weight: 700;
}
.teacher-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 2px dashed rgba(255,255,255,0.08);
}
.teacher-class-card {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  transition: border-color 0.2s, background 0.2s;
}
.teacher-class-card:hover {
  border-color: var(--purple);
  background: rgba(177,74,237,0.06);
}
.tcc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.tcc-name {
  font-weight: 800;
  font-size: 17px;
}
.tcc-code {
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  background: rgba(177,74,237,0.2);
  color: var(--purple);
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 1.5px;
}
.tcc-meta {
  display: flex;
  gap: 16px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}
.teacher-form-card {
  padding: 20px;
}
.teacher-form-btns {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.teacher-form-btns .btn {
  flex: 1;
  padding: 12px;
  font-size: 15px;
}
.teacher-create-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 17px;
}

/* Teacher detail */
.teacher-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.teacher-detail-header .auth-back-btn {
  position: static;
}
.teacher-detail-name {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
}
.teacher-detail-code {
  color: var(--muted);
  font-size: 14px;
}
.teacher-detail-code strong {
  color: var(--purple);
  letter-spacing: 1px;
  font-family: 'Fredoka One', cursive;
}
.teacher-student-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  margin-bottom: 8px;
}
.tsc-avatar {
  font-size: 28px;
}
.tsc-info { flex: 1; }
.tsc-name {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 3px;
}
.tsc-stats {
  display: flex;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

/* Sign Out button (profile / teacher) */
.signout-btn {
  width: 100%;
  margin-top: 24px;
  margin-bottom: 32px;
  background: rgba(255,107,107,0.08);
  color: #ff8a8a;
  border: 2px solid rgba(255,107,107,0.25);
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.signout-btn:hover {
  border-color: rgba(255,107,107,0.45);
  color: #ff6b6b;
  background: rgba(255,107,107,0.12);
}

/* Class code banner (after creation) */
.class-code-banner {
  text-align: center;
  padding: 20px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: rgba(76,209,55,0.08);
  border: 2px solid rgba(76,209,55,0.25);
}
.ccb-title {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  color: #4cd137;
  margin-bottom: 4px;
}
.ccb-instruction {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}
.ccb-code {
  font-family: 'Fredoka One', cursive;
  font-size: 32px;
  letter-spacing: 4px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  padding: 12px 24px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 10px;
}
.ccb-how {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.ccb-how strong { color: var(--text); }
.ccb-dismiss {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--muted);
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
}
.ccb-dismiss:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }

/* Class share card (in detail view) */
.class-share-card {
  text-align: center;
  padding: 18px;
  margin: 12px 0;
  border-radius: 14px;
  background: rgba(177,74,237,0.06);
  border: 1.5px solid rgba(177,74,237,0.2);
}
.csc-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.csc-code {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
  letter-spacing: 4px;
  color: var(--purple);
  margin-bottom: 8px;
}
.csc-how {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.csc-how strong { color: var(--text); }

/* ---- Teacher: Try as Student (muted) ---- */
.teacher-try-section {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.teacher-try-label {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-align: center;
}
.teacher-try-btns {
  display: flex;
  gap: 8px;
}
.teacher-try-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  padding: 10px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}
.teacher-try-btn:hover {
  border-color: var(--purple);
  color: var(--text);
}

/* ---- Teacher: Student card chevron ---- */
.tsc-chevron {
  font-size: 20px;
  color: var(--muted);
  margin-left: auto;
  flex-shrink: 0;
}
.teacher-student-card {
  cursor: pointer;
  transition: transform 0.15s;
}
.teacher-student-card:hover {
  transform: translateX(3px);
}

/* ---- Teacher: Student Detail ---- */
.sd-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.sd-stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
}
.sd-stat-value {
  font-family: 'Fredoka One', cursive;
  font-size: 20px;
  color: var(--text);
}
.sd-stat-label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.sd-weak-areas {
  background: rgba(244,67,54,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sd-weak-label {
  font-size: 14px;
  color: var(--muted);
}
.sd-weak-tag {
  font-size: 14px;
  background: rgba(244,67,54,0.15);
  color: var(--red);
  padding: 3px 8px;
  border-radius: 6px;
}

/* ---- Teacher: Session cards in student detail ---- */
.sd-session-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--card);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform 0.15s;
  text-align: left;
  color: var(--text);
}
.sd-session-card:hover { transform: translateX(3px); }
.sd-session-icon { font-size: 22px; flex-shrink: 0; }
.sd-session-info { flex: 1; min-width: 0; }
.sd-session-mode {
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
}
.sd-session-stats {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---- Teacher: Session Detail (answers) ---- */
.sess-summary {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.sess-summary-top {
  font-size: 16px;
  text-transform: capitalize;
  margin-bottom: 6px;
}
.sess-summary-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 15px;
  color: var(--muted);
}
.sess-answer-card {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-left: 3px solid var(--muted);
}
.sess-answer-card.correct { border-left-color: var(--green); }
.sess-answer-card.wrong { border-left-color: var(--red); }
.sess-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sess-q-num {
  font-family: 'Fredoka One', cursive;
  font-size: 14px;
  color: var(--muted);
}
.sess-q-icon { font-size: 16px; }
.sess-q-text {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 6px;
}
.sess-q-answer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
}
.sess-correct-ans {
  color: var(--green);
  font-weight: 600;
}
.sess-wrong-ans {
  color: var(--red);
  text-decoration: line-through;
}
.sess-right-ans {
  color: var(--green);
  font-size: 14px;
}
.sess-time {
  font-size: 14px;
  color: var(--muted);
}
.sess-hint {
  display: inline-block;
  font-size: 14px;
  color: var(--cyan);
  margin-top: 4px;
}

/* ---- Teacher: Profile ---- */
.teacher-profile {
  text-align: center;
  padding: 32px 0 24px;
}
.tp-avatar {
  font-size: 56px;
  margin-bottom: 12px;
}
.tp-name {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--text);
}
.tp-email {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* ===================== TOUCH TARGETS ===================== */
.answer-choice-btn { min-height: 48px; }
.mode-card-big { min-height: 80px; }
.prep-option { min-height: 48px; }
.choice-btn { min-height: 48px; }

/* ===================== RESPONSIVE ===================== */

/* Small phones */
@media (max-width: 380px) {
  .screen-inner { padding: 12px 12px 90px; }
  .mode-card-big { border-radius: 16px; }
  .home-subjects { grid-template-columns: repeat(3, 1fr); }
  .nav-item { font-size: 11px; }
  .nav-item .nav-icon { font-size: 22px; }
  .profile-av-opt { font-size: 24px; }
  .pin-key { font-size: 26px; }
  .pin-pad { max-width: 240px; gap: 8px; }
  .chat-bubble { font-size: 16px; padding: 14px 16px; }
  .speed-choices { gap: 8px; }
  .choice-btn { padding: 14px 8px; font-size: 24px; }
  .results-card { padding: 28px 24px; }
  .boss-input { font-size: 18px; }
}

/* Tablets */
@media (min-width: 768px) {
  .screen-inner { max-width: 720px; padding: 24px 24px 100px; }
  .home-modes { gap: 14px; }
  .home-subjects { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .subject-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .chat-bubble { font-size: 19px; }
  .answer-choice-btn { font-size: 24px; padding: 20px 14px; }
  .choice-btn { font-size: 32px; padding: 22px 14px; }
  .speed-choices { gap: 14px; }
  .boss-input { font-size: 22px; }
  .ach-grid { grid-template-columns: repeat(3, 1fr); }
  .pref-grid { gap: 12px; }
  .pregame-card { max-width: 560px; padding: 32px 28px; }
  .pregame-title { font-size: 24px; }
  .pregame-chapter-btn { padding: 14px 16px; font-size: 17px; }
  .pregame-lesson-btn { padding: 12px 14px; font-size: 16px; }
  .pause-card { max-width: 420px; }
  .results-card { width: min(85vw, 420px); }
  .pin-pad { max-width: 320px; gap: 14px; }
  .pin-key { font-size: 34px; }
}

/* Large screens */
@media (min-width: 1024px) {
  .screen-inner { max-width: 860px; }
  .pregame-card { max-width: 640px; padding: 36px 32px; }
  .pregame-chapter-list { max-height: 50vh; }
  .home-subjects { gap: 16px; }
  .chat-bubble { font-size: 20px; }
  .ach-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

/* ===================== LOADING SKELETON ===================== */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--card2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-block { height: 20px; margin-bottom: 10px; }
.skeleton-block.lg { height: 80px; }
.skeleton-block.md { height: 40px; }
.skeleton-block.sm { width: 60%; }

/* ===================== PROGRESS MAP ===================== */
.map-loading { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 15px; }

.map-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; margin-bottom: 8px;
}
.map-title { font-family: 'Fredoka One', cursive; font-size: 22px; color: var(--cyan); }
.map-grade { color: var(--muted); font-size: 13px; margin-top: 2px; }
.map-overall-pct { font-family: 'Fredoka One', cursive; font-size: 28px; color: var(--green); }

.map-zones { padding: 0 12px 80px; }

.map-zone {
  background: var(--card); border-radius: 14px; margin-bottom: 10px;
  border: 2px solid transparent; overflow: hidden; transition: border-color 0.2s;
}
.map-zone.current { border-color: var(--cyan); }

.map-zone-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.map-zone-num {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka One', cursive; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--cyan), #3b82f6); flex-shrink: 0;
}
.map-zone-info { flex: 1; min-width: 0; }
.map-zone-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-zone-meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.map-zone-pct { font-family: 'Fredoka One', cursive; font-size: 15px; color: var(--green); flex-shrink: 0; }
.map-zone-arrow { color: var(--muted); font-size: 12px; flex-shrink: 0; transition: transform 0.2s; }
.map-zone.expanded .map-zone-arrow { transform: rotate(0deg); }

.map-zone-bar {
  height: 4px; background: rgba(255,255,255,0.06); margin: 0 16px 12px;
  border-radius: 2px; overflow: hidden;
}
.map-zone-bar-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.4s; }

/* Lessons inside expanded zone */
.map-lessons { padding: 4px 16px 16px; }

.map-lesson-node {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: none;
  background: rgba(255,255,255,0.04); color: #fff; font-size: 13px;
  text-align: left; cursor: pointer; transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.map-lesson-node:active { background: rgba(255,255,255,0.1); }
.map-lesson-status { font-size: 16px; flex-shrink: 0; }
.map-lesson-num { color: var(--muted); font-size: 12px; flex-shrink: 0; min-width: 28px; }
.map-lesson-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-lesson-stats { color: var(--muted); font-size: 11px; flex-shrink: 0; }

/* Status variants */
.map-lesson-completed { opacity: 0.85; }
.map-lesson-not-started { opacity: 0.5; }
.map-lesson-in-progress .map-lesson-status { animation: mapPulse 1.5s ease-in-out infinite; }

/* Current lesson highlight */
.map-lesson-node.map-current {
  border: 2px solid var(--cyan); background: rgba(0,229,255,0.08);
}

/* Connector line between lessons */
.map-connector { width: 2px; height: 12px; background: rgba(255,255,255,0.1); margin: 0 0 0 28px; }

/* Special lessons (practice/assessments) */
.map-special-label {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px;
  margin: 14px 0 6px 12px; font-weight: 700;
}
.map-lesson-special { opacity: 0.65; }
.map-lesson-special:active { opacity: 0.85; }

@keyframes mapPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── WhatsApp / Family ─── */

/* Message Parents button */
.btn-wa-send {
  display: block; width: 100%; margin: 16px 0;
  background: #25d366; color: #fff;
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px; padding: 14px; border: none; border-radius: 14px;
  cursor: pointer; text-align: center;
  transition: background .15s;
}
.btn-wa-send:hover { background: #1ebe5d; }
.btn-wa-send:active { transform: scale(.97); }

/* Compose overlay */
#wa-compose-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
#wa-compose-overlay.show { opacity: 1; pointer-events: auto; }

.wa-compose-card {
  background: var(--card); border-radius: 18px;
  padding: 24px; width: 92%; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.wa-compose-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px; color: #fff; margin-bottom: 4px;
}
.wa-compose-subtitle {
  font-size: 14px; color: var(--muted); margin-bottom: 14px;
}
.wa-compose-textarea {
  width: 100%; min-height: 120px; border-radius: 12px;
  background: rgba(255,255,255,.07); color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  padding: 12px; font-size: 15px; font-family: 'Inter', sans-serif;
  resize: vertical;
}
.wa-compose-textarea:focus {
  outline: none; border-color: #25d366;
}
.wa-compose-hint {
  font-size: 12px; color: var(--muted); margin-top: 6px;
}
.wa-compose-count {
  font-size: 12px; color: var(--muted); text-align: right; margin-top: 2px;
}
.wa-compose-error {
  font-size: 13px; color: var(--red); font-weight: 700;
  min-height: 18px; margin-top: 6px;
}
.wa-compose-actions {
  display: flex; gap: 10px; margin-top: 14px;
}
.wa-compose-actions .btn { flex: 1; }

/* Family tab contacts */
.family-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.family-emoji { font-size: 22px; }
.family-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 17px; color: #fff;
}

.family-contact-card {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
}
.fcc-info { flex: 1; min-width: 0; }
.fcc-name {
  font-weight: 700; font-size: 15px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fcc-phone { font-size: 13px; color: var(--cyan); margin-top: 2px; }
.fcc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fcc-remove {
  background: none; border: none; color: var(--red);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  opacity: .7; transition: opacity .15s;
}
.fcc-remove:hover { opacity: 1; }

/* WhatsApp consent checkbox label */
.wa-consent-label {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: #c5cdeb; margin-top: 8px;
  cursor: pointer;
}
.wa-consent-label input[type="checkbox"] {
  margin-top: 2px; accent-color: #25d366;
}

/* Setup parent step tweaks */
#setup-parent-step .auth-field { margin-bottom: 8px; }

