/* ============ Ethan's Math Quest ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, "Comic Sans MS", sans-serif;
  background: linear-gradient(160deg, #38bdf8 0%, #3b82f6 45%, #7c3aed 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* comic-book sunburst rays behind everything */
body::before {
  content: '';
  position: fixed;
  inset: -60%;
  background: repeating-conic-gradient(rgba(255,255,255,0.07) 0deg 8deg, transparent 8deg 16deg);
  pointer-events: none;
  z-index: 0;
}
.screen { z-index: 1; }

.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }
/* Safari's floating bottom toolbar overlaps the layout viewport; dvh tracks
 * the visible area so answer buttons never hide behind it */
@supports (height: 100dvh) {
  .screen { bottom: auto; height: 100dvh; }
}

/* ---------- buttons ---------- */
.btn-big {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 10px auto;
  padding: 20px 24px;
  font-size: 1.5rem;
  font-weight: 800;
  border: none;
  border-radius: 24px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.25);
  transition: transform 0.1s;
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.25); }
.btn-green { background: linear-gradient(180deg, #f87171, #dc2626); }
.btn-blue  { background: linear-gradient(180deg, #60a5fa, #2563eb); }

.btn-icon {
  font-size: 1.6rem;
  background: rgba(255,255,255,0.85);
  border: none;
  border-radius: 16px;
  width: 52px;
  height: 52px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.btn-icon:active { transform: translateY(2px); }

.btn-tiny {
  background: rgba(255,255,255,0.5);
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #334155;
  cursor: pointer;
}

/* ---------- login ---------- */
#screen-login { justify-content: flex-start; align-items: center; }
.login-inner { text-align: center; padding: 24px; width: 100%; max-width: 440px; margin: auto; }

/* ---------- profiles ---------- */
.profile-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 14px 0 4px;
}
.profile-list:empty { display: none; }
.profile-card {
  position: relative;
  background: rgba(255,255,255,0.94);
  border: none;
  border-radius: 22px;
  padding: 16px 10px 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15);
  transition: transform 0.1s;
}
.profile-card:active { transform: translateY(3px); }
.profile-avatar { font-size: 3rem; line-height: 1.1; }
.profile-name { font-size: 1.15rem; font-weight: 900; color: #1e293b; margin-top: 4px; }
.profile-stars { font-size: 0.9rem; font-weight: 800; color: #b45309; }
.profile-del {
  position: absolute;
  top: 8px; right: 10px;
  font-size: 0.9rem;
  font-weight: 900;
  color: #94a3b8;
  padding: 4px 7px;
  border-radius: 10px;
  background: #f1f5f9;
}
.profile-del:active { background: #fecaca; color: #b91c1c; }

.new-profile {
  background: rgba(255,255,255,0.35);
  border-radius: 22px;
  padding: 14px 16px 6px;
  margin-top: 14px;
}
.new-profile-title {
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
  margin-bottom: 8px;
}
.avatar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}
.avatar-btn {
  font-size: 1.8rem;
  background: rgba(255,255,255,0.85);
  border: 3px solid transparent;
  border-radius: 14px;
  width: 52px; height: 52px;
  cursor: pointer;
}
.avatar-btn.sel { border-color: #facc15; background: #fff; transform: scale(1.1); }
.name-input {
  display: block;
  width: 100%;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  color: #1e293b;
  border: none;
  border-radius: 16px;
  padding: 12px;
  margin: 0 auto;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.name-input:focus { outline: 3px solid #facc15; }

/* ---------- teaching mode ---------- */
body.teaching #stage, body.teaching #choices { pointer-events: none; }
body.teaching .choice-btn { opacity: 0.45; }
.tf-cell.hl { background: #fef9c3; border-color: #f59e0b; transform: scale(1.06); }
.tf-cell.hl2 { background: #fce7f3; border-color: #db2777; transform: scale(1.06); }
.obj.ghost { opacity: 0.55; animation: ghostIn 0.4s; }
@keyframes ghostIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
.obj-group.win { border: 5px solid #16a34a; background: #dcfce7; }
.seq-num.hl-num { background: #fef9c3; box-shadow: 0 0 0 4px #f59e0b; }
.streak {
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.endless-card { background: linear-gradient(120deg, #fef08a, #fdba74); }

/* ---------- tracks, quizzes, reading ---------- */
.track-header {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
  margin-top: 6px;
  text-align: left;
}
.quiz-card {
  background: linear-gradient(135deg, #fde047, #f59e0b);
  grid-column: 1 / -1;
}
.quiz-card .level-name { color: #713f12; font-size: 1rem; }
.quiz-card .level-star-row { color: #713f12; font-weight: 800; font-size: 0.9rem; }
.pdot.small { width: 10px; height: 10px; }
.choice-btn.word { font-size: 1.7rem; text-transform: none; letter-spacing: 1px; }
.choice-sub {
  display: block;
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0;
  margin-top: 2px;
}
.choice-btn.hl-btn { outline: 5px solid #f59e0b; }
.word-tiles { display: flex; gap: 10px; }
.word-tile {
  background: #fff;
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 3rem;
  font-weight: 900;
  color: #1e293b;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
}
.word-tile.hl { background: #fef9c3; box-shadow: 0 0 0 4px #f59e0b; transform: scale(1.1); }
.rhyme-base { text-align: center; }
.rhyme-emoji { font-size: 5rem; line-height: 1.1; }
.rhyme-word {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.2);
}
.login-dino { font-size: 6rem; line-height: 1; }
.login-title {
  font-size: 2.6rem;
  margin: 12px 0 4px;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,0.2);
  line-height: 1.1;
}
.login-stars { font-size: 1.8rem; margin-bottom: 24px; }
.login-hint { color: rgba(255,255,255,0.9); font-weight: 600; }

.bounce { animation: bounce 1.6s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 12px calc(14px + env(safe-area-inset-left));
  flex-shrink: 0;
}
.topbar-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
  text-align: center;
  flex: 1;
}
.star-bank {
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #b45309;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
  white-space: nowrap;
}

/* ---------- world map ---------- */
.world-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 18px 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.world-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 24px;
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
  transition: transform 0.1s;
}
.world-card:active { transform: translateY(3px); }
.world-card.locked { opacity: 0.55; filter: grayscale(0.6); }
.world-emoji { font-size: 3rem; line-height: 1; }
.world-info { flex: 1; }
.world-name { font-size: 1.2rem; font-weight: 800; color: #1e293b; }
.world-desc { font-size: 0.85rem; color: #64748b; font-weight: 600; }
.world-stars { font-size: 0.95rem; font-weight: 800; color: #b45309; margin-top: 3px; }
.world-lock { font-size: 1.7rem; }
.map-footer { text-align: center; padding: 10px 0 24px; }

/* ---------- level select ---------- */
.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  padding: 10px 18px 26px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.level-card {
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 22px;
  padding: 18px 10px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.level-card:active { transform: translateY(3px); }
.level-card.locked { opacity: 0.5; filter: grayscale(0.7); }
.level-num { font-size: 2rem; font-weight: 900; color: #4f46e5; }
.level-name { font-size: 0.82rem; font-weight: 700; color: #64748b; margin: 4px 0; }
.level-star-row { font-size: 1.05rem; letter-spacing: 2px; }

/* ---------- game ---------- */
#screen-game { display: none; }
#screen-game.active { display: flex; }

.progress-dots { display: flex; gap: 7px; flex: 1; justify-content: center; }
.pdot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
}
.pdot.done { background: #fbbf24; box-shadow: 0 0 6px #fbbf24; }
.pdot.now { background: #fff; transform: scale(1.25); }

.prompt-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.94);
  margin: 4px 14px;
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.btn-speak {
  font-size: 1.5rem;
  background: #eef2ff;
  border: none;
  border-radius: 14px;
  width: 50px; height: 50px;
  cursor: pointer;
  flex-shrink: 0;
}
.prompt-text { font-size: 1.15rem; font-weight: 800; color: #1e293b; line-height: 1.3; }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-height: 160px;
}

/* object groups on stage */
.obj-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  width: 100%;
}
.obj-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 6px;
  background: rgba(255,255,255,0.55);
  border-radius: 22px;
  padding: 14px;
  max-width: 320px;
  min-width: 110px;
  min-height: 80px;
}
.obj-group.pickable { cursor: pointer; border: 4px dashed rgba(79,70,229,0.45); }
.obj-group.pickable:active { transform: scale(0.97); }

.obj {
  font-size: 2.4rem;
  line-height: 1;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s;
  padding: 2px;
}
.obj.small { font-size: 1.8rem; }
.obj.counted { transform: scale(1.15); }
.obj.gone { animation: flyaway 0.7s forwards; }
@keyframes flyaway {
  to { transform: translateY(-90px) rotate(30deg) scale(0.4); opacity: 0; }
}
.obj .count-badge {
  position: absolute;
  top: -10px; right: -10px;
  background: #4f46e5;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 900;
  border-radius: 999px;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

.op-symbol {
  font-size: 3rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.2);
}

.big-numeral {
  font-size: 6.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 0 rgba(0,0,0,0.22);
  line-height: 1;
}
.medium-numeral {
  font-size: 3.2rem;
  font-weight: 900;
  color: #4f46e5;
  line-height: 1;
}

/* ten frame */
.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.tf-cell {
  width: 46px; height: 46px;
  border: 3px solid #cbd5e1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
}
@media (max-width: 380px) {
  .tf-cell { width: 38px; height: 38px; font-size: 1.4rem; }
}

/* sequence display */
.seq-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.seq-num {
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  min-width: 70px;
  padding: 14px 8px;
  text-align: center;
  font-size: 2.4rem;
  font-weight: 900;
  color: #1e293b;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.seq-num.mystery { color: #db2777; background: #fce7f3; }

/* ---------- choices ---------- */
.choices {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: stretch;
  padding: 10px 14px calc(22px + env(safe-area-inset-bottom));
  flex-wrap: wrap;
  flex-shrink: 0;
}
.choice-btn {
  flex: 1;
  min-width: 86px;
  max-width: 150px;
  font-size: 2.6rem;
  font-weight: 900;
  color: #4f46e5;
  background: #fff;
  border: none;
  border-radius: 22px;
  padding: 18px 8px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
  transition: transform 0.1s;
}
.choice-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }
.choice-btn.correct { background: #4ade80; color: #fff; animation: pop 0.4s; }
.choice-btn.wrong { background: #fda4af; color: #fff; animation: shake 0.4s; }
.choice-btn:disabled { pointer-events: none; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ---------- level complete ---------- */
#screen-complete { justify-content: center; align-items: center; text-align: center; }
.complete-inner { padding: 24px; width: 100%; max-width: 400px; }
.complete-emoji { font-size: 5.5rem; animation: bounce 1.2s infinite; }
#complete-title {
  color: #fff;
  font-size: 2.2rem;
  margin: 8px 0;
  text-shadow: 0 3px 0 rgba(0,0,0,0.2);
}
.complete-stars { font-size: 3.4rem; letter-spacing: 6px; min-height: 70px; }
.complete-stars .cstar { display: inline-block; opacity: 0; transform: scale(0); }
.complete-stars .cstar.show { animation: starIn 0.5s forwards; }
@keyframes starIn {
  0% { opacity: 0; transform: scale(0) rotate(-90deg); }
  70% { transform: scale(1.4) rotate(10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.complete-earned {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
  margin-bottom: 16px;
}

/* ---------- prizes ---------- */
.prizes-hint {
  text-align: center;
  color: #fff;
  font-weight: 700;
  margin: 0 20px 10px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.prize-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  padding: 4px 18px 30px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.prize-card {
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 22px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.prize-card:active { transform: translateY(3px); }
.prize-emoji { font-size: 3.2rem; line-height: 1.1; }
.prize-card.mystery .prize-emoji { filter: brightness(0) opacity(0.35); }
.prize-name { font-weight: 800; color: #1e293b; margin: 6px 0 2px; }
.prize-cost { font-weight: 800; color: #b45309; font-size: 0.95rem; }
.prize-card.owned { border: 4px solid #4ade80; }
.prize-card.owned .prize-cost { color: #16a34a; }

/* ---------- feedback + confetti ---------- */
.feedback-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.feedback-pop {
  font-size: 4.5rem;
  animation: fbPop 0.9s forwards;
}
.feedback-pop.burst {
  font-size: 4rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  color: #facc15;
  -webkit-text-stroke: 2px #b91c1c;
  text-shadow: 4px 4px 0 #7f1d1d, 0 0 24px rgba(250,204,21,0.7);
  animation: burstPop 0.9s forwards;
}
@keyframes burstPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  40% { transform: scale(1.35) rotate(-8deg); opacity: 1; }
  80% { transform: scale(1) rotate(-8deg); opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); opacity: 0; }
}
@keyframes fbPop {
  0% { transform: scale(0); opacity: 0; }
  40% { transform: scale(1.3); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}
.confetti-bit {
  position: absolute;
  top: -30px;
  font-size: 1.6rem;
  animation: confFall linear forwards;
}
@keyframes confFall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- hero rig: avatar wearing owned gear ---------- */
.hero-rig {
  position: relative;
  display: inline-block;
  width: 74px; height: 74px;
  font-size: 3rem;
  line-height: 74px;
}
.hero-rig.big { width: 96px; height: 96px; font-size: 4rem; line-height: 96px; }
.rig-avatar { position: relative; z-index: 1; }
.rig-gear {
  position: absolute;
  font-size: 1.05rem;
  z-index: 2;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}
.hero-rig.big .rig-gear { font-size: 1.35rem; }
.rig-gear.g0 { top: -4px; left: -6px; }
.rig-gear.g1 { top: -4px; right: -6px; }
.rig-gear.g2 { bottom: -2px; left: -8px; }
.rig-gear.g3 { bottom: -2px; right: -8px; }
.rig-gear.g4 { top: 40%; left: -14px; }
.rig-gear.g5 { top: 40%; right: -14px; }
.rig-gear.g6 { top: -14px; left: 40%; }
.rig-gear.g7 { bottom: -14px; left: 40%; }
.map-hero { text-align: center; padding: 2px 0 4px; flex-shrink: 0; }
.map-hero:empty { display: none; }
.map-hero-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

/* ---------- subitizing flash ---------- */
.flash-wrap { position: relative; display: inline-block; }
.dot-pattern {
  position: relative;
  width: 190px; height: 190px;
  background: rgba(255,255,255,0.92);
  border-radius: 24px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.sub-dot {
  position: absolute;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #60a5fa, #1d4ed8);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}
.sub-dot.hl-dot { background: radial-gradient(circle at 35% 30%, #fde047, #d97706); transform: translate(-50%, -50%) scale(1.15); }
.flash-cover {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.flash-wrap.hidden-flash .flash-cover { display: flex; }
.choices.waiting .choice-btn { opacity: 0.35; pointer-events: none; }

/* staggered ten-frame fill ('backwards' releases the transform after, so
 * teach highlights can still scale cells) */
.tf-cell.pop-in { animation: cellIn 0.25s backwards; }
/* stacked equation (teen numbers): frame, plus, extras in a centered column */
.eq-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.eq-stack .op-symbol { font-size: 2.1rem; line-height: 1; }
@keyframes cellIn {
  from { transform: scale(0.2); }
  to { transform: scale(1); }
}

/* ---------- number line ---------- */
.numline {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.9);
  border-radius: 18px;
  padding: 30px 10px 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  max-width: 100%;
}
.nl-tick {
  position: relative;
  width: 34px;
  text-align: center;
  cursor: pointer;
  padding-top: 4px;
  border-top: 4px solid #cbd5e1;
}
.nl-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; margin: 2px auto; }
.nl-num { font-size: 1.05rem; font-weight: 900; color: #334155; }
.nl-hero {
  position: absolute;
  top: -30px; left: 50%;
  transform: translateX(-50%) scale(0);
  font-size: 1.7rem;
  transition: transform 0.25s;
}
.nl-tick.here .nl-hero { transform: translateX(-50%) scale(1); }
.nl-tick.here { border-top-color: #f59e0b; }
.nl-tick.here .nl-num { color: #b45309; }
.nl-tick.land { background: #fef9c3; border-radius: 8px; }
@media (max-width: 420px) {
  .numline { padding: 26px 6px 8px; gap: 1px; }
  .nl-tick { width: 26px; }
  .nl-num { font-size: 0.82rem; }
  .nl-hero { font-size: 1.4rem; top: -26px; }
}

/* ---------- shapes ---------- */
.shape-pick {
  background: rgba(255,255,255,0.92);
  border: 4px dashed rgba(79,70,229,0.45);
  border-radius: 22px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.shape-pick:active { transform: scale(0.96); }
.shape-pick.win { border: 5px solid #16a34a; background: #dcfce7; }
.shape-pick.wrong-pick { border: 5px solid #f87171; background: #fee2e2; animation: shake 0.4s; }
.shape-pick.hl-pick { border: 5px solid #f59e0b; background: #fef9c3; }
.shape-box svg { width: 100%; height: 100%; display: block; }
.corner-wrap { display: inline-block; background: rgba(255,255,255,0.92); border-radius: 22px; padding: 18px; box-shadow: 0 4px 0 rgba(0,0,0,0.12); }
.corner-inner { position: relative; }
.corner-spot {
  position: absolute;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  cursor: pointer;
}
.corner-spot.counted { background: rgba(250,204,21,0.5); }

/* ---------- longer / shorter ---------- */
.bars {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  width: min(92%, 420px);
  padding: 16px;
  background: rgba(255,255,255,0.5);
  border-radius: 22px;
}
.bars.lined { border-left: 6px dashed #f59e0b; }
.len-bar {
  position: relative;
  height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18);
  min-width: 60px;
}
.len-bar .len-nose {
  position: absolute;
  right: -12px; top: 50%;
  transform: translateY(-50%);
  font-size: 1.9rem;
}
.len-bar.win { outline: 5px solid #16a34a; }
.len-bar.wrong-pick { outline: 5px solid #f87171; animation: shake 0.4s; }
.len-bar.hl-pick { outline: 5px solid #f59e0b; }

/* ---------- sorting ---------- */
.sort-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.sort-card {
  font-size: 3.4rem;
  background: rgba(255,255,255,0.92);
  border: 4px dashed rgba(79,70,229,0.45);
  border-radius: 22px;
  padding: 16px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.sort-card:active { transform: scale(0.96); }
.sort-card.win { border: 5px solid #16a34a; background: #dcfce7; }
.sort-card.wrong-pick { border: 5px solid #f87171; background: #fee2e2; animation: shake 0.4s; }
.sort-card.hl-pick { border: 5px solid #f59e0b; background: #fef9c3; }

/* ---------- sentence reading ---------- */
.sentence-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  background: rgba(255,255,255,0.94);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
  max-width: 92%;
}
.sent-word {
  font-size: 2rem;
  font-weight: 900;
  color: #1e293b;
  padding: 2px 6px;
  border-radius: 10px;
}
.sent-word.hl-word { background: #fef9c3; box-shadow: 0 0 0 3px #f59e0b; }

/* word slot tiles (build-a-word, missing vowel) */
.word-tile.slot { background: #fce7f3; color: #db2777; border: 3px dashed #db2777; min-width: 62px; }

/* ---------- finger tracing ---------- */
.trace-wrap {
  position: relative;
  background: rgba(255,255,255,0.94);
  border-radius: 24px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
  overflow: hidden;
}
.trace-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: rgba(99, 102, 241, 0.28);
  pointer-events: none;
}
.trace-glyph.traced { color: #16a34a; transition: color 0.4s; }
.trace-glyph.demo { animation: glyphGlow 1.2s infinite; }
@keyframes glyphGlow {
  0%, 100% { color: rgba(99, 102, 241, 0.28); }
  50% { color: #f59e0b; }
}
.trace-wrap canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.trace-clear { align-self: center; }

/* ---------- modal (native confirm is blocked in webviews) ---------- */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 20px;
}
.modal-layer[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: 26px;
  padding: 22px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(0,0,0,0.25);
}
.modal-emoji { font-size: 3.4rem; line-height: 1.1; }
.modal-title { color: #1e293b; margin: 8px 0 4px; font-size: 1.35rem; }
.modal-body { color: #475569; font-weight: 600; font-size: 0.95rem; line-height: 1.45; }
.modal-body p { margin: 8px 0; }
.btn-danger {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 6px auto 0;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: 18px;
  color: #b91c1c;
  background: #fee2e2;
  cursor: pointer;
}
.btn-danger.armed { background: #dc2626; color: #fff; }

/* ============ form factors ============
 * Base styles are phone-portrait. iPad and computer get bigger play
 * pieces and wider lists; short landscape phones get a compact game view.
 */

/* iPad portrait and up */
@media (min-width: 700px) {
  .world-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 760px;
    gap: 16px;
  }
  .track-header { grid-column: 1 / -1; font-size: 1.35rem; }
  .endless-card { grid-column: 1 / -1; }
  .level-list { max-width: 720px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .prize-list { max-width: 720px; }
  .grownups-content { max-width: 640px; }
  .login-inner { max-width: 560px; }
  .profile-list { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .complete-inner { max-width: 480px; }

  .prompt-bar { max-width: 720px; margin: 6px auto; width: calc(100% - 28px); }
  .prompt-text { font-size: 1.5rem; }
  .obj { font-size: 3.2rem; }
  .obj.small { font-size: 2.4rem; }
  .obj-group { max-width: 420px; }
  .tf-cell { width: 58px; height: 58px; font-size: 2.1rem; }
  .choice-btn { max-width: 200px; font-size: 3.2rem; padding: 22px 10px; }
  .choices { gap: 20px; padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
  .big-numeral { font-size: 8.5rem; }
  .medium-numeral { font-size: 4rem; }
  .seq-num { min-width: 90px; font-size: 3rem; }
  .word-tile { font-size: 3.8rem; padding: 16px 24px; }
  .sent-word { font-size: 2.6rem; }
  .sort-card { font-size: 4.4rem; padding: 22px 34px; }
  .rhyme-emoji { font-size: 6.5rem; }
  .dot-pattern { width: 250px; height: 250px; }
  .sub-dot { width: 54px; height: 54px; }
  .flash-cover { font-size: 5.5rem; }
  .nl-tick { width: 48px; }
  .nl-num { font-size: 1.35rem; }
  .nl-hero { font-size: 2.2rem; top: -36px; }
  .numline { padding: 40px 16px 12px; }
  .bars { width: min(80%, 560px); }
  .len-bar { height: 54px; }
}

/* computer: same big pieces, roomier lists */
@media (min-width: 1100px) {
  .world-list { max-width: 880px; }
  .level-list { max-width: 840px; }
  .grownups-content { max-width: 760px; }
}

/* short landscape (iPhone sideways): compress vertical chrome */
@media (max-height: 470px) {
  .topbar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .btn-icon { width: 42px; height: 42px; font-size: 1.2rem; }
  .prompt-bar { margin: 2px 12px; padding: 6px 12px; }
  .prompt-text { font-size: 0.95rem; }
  .btn-speak { width: 40px; height: 40px; font-size: 1.15rem; }
  .stage { min-height: 90px; padding: 4px 12px; }
  .obj { font-size: 1.9rem; }
  .obj-group { padding: 8px; min-height: 56px; }
  .tf-cell { width: 32px; height: 32px; font-size: 1.15rem; }
  .choice-btn { padding: 8px 6px; font-size: 1.8rem; min-width: 70px; }
  .choices { padding: 4px 12px calc(8px + env(safe-area-inset-bottom)); gap: 10px; }
  .big-numeral { font-size: 3.6rem; }
  .dot-pattern { width: 130px; height: 130px; }
  .sub-dot { width: 28px; height: 28px; }
  .flash-cover { font-size: 2.6rem; }
  .word-tile { font-size: 2rem; padding: 8px 12px; }
  .rhyme-emoji { font-size: 3rem; }
  .sentence-box { padding: 10px 14px; }
  .sent-word { font-size: 1.5rem; }
  .sort-card { font-size: 2.2rem; padding: 8px 16px; }
  .numline { padding: 24px 8px 6px; }
  .nl-hero { font-size: 1.3rem; top: -24px; }
  .login-dino { font-size: 3rem; }
  .login-title { font-size: 1.8rem; }
  .complete-emoji { font-size: 3rem; }
  .map-hero .hero-rig.big { width: 64px; height: 64px; font-size: 2.6rem; line-height: 64px; }
}

/* ---------- PIN pad ---------- */
.pin-dots { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 3px solid #94a3b8;
}
.pin-dot.on { background: #4f46e5; border-color: #4f46e5; }
.pin-dots.pin-bad { animation: shake 0.4s; }
.pin-dots.pin-bad .pin-dot { border-color: #dc2626; }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 0 auto 12px;
}
.pin-key {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  background: #f1f5f9;
  border: none;
  border-radius: 14px;
  padding: 12px 0;
  cursor: pointer;
}
.pin-key:active { background: #e2e8f0; transform: translateY(2px); }

/* ---------- grown-ups analytics ---------- */
.grownups-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 18px 28px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.ga-card {
  background: rgba(255,255,255,0.95);
  border-radius: 22px;
  padding: 16px 18px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.ga-name { font-size: 1.3rem; font-weight: 900; color: #1e293b; }
.ga-stats { font-size: 0.85rem; font-weight: 700; color: #64748b; margin: 2px 0 8px; }
.ga-track { border-top: 2px solid #e2e8f0; padding: 10px 0 4px; }
.ga-track-title { font-weight: 900; color: #334155; }
.ga-pos { font-size: 0.88rem; color: #475569; font-weight: 600; margin: 2px 0 6px; }
.ga-empty { font-size: 0.85rem; color: #94a3b8; font-weight: 600; }
.ga-label {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b45309;
  margin: 6px 0 2px;
}
.ga-label.strong { color: #15803d; }
.ga-skill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
}
.ga-skill-name { flex: 0 0 42%; }
.ga-bar {
  flex: 1;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.ga-fill { display: block; height: 100%; border-radius: 999px; background: #22c55e; }
.ga-fill.low { background: #f59e0b; }
.ga-pct { flex: 0 0 44px; text-align: right; color: #64748b; }
.ga-reset { margin-top: 12px; max-width: none; }
/* ---------- grades ---------- */
.grade-title {
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
  font-size: 0.9rem;
  margin: 8px 0 6px;
}
.grade-btn {
  font-size: 1.15rem;
  font-weight: 900;
  color: #4f46e5;
  background: rgba(255,255,255,0.85);
  border: 3px solid transparent;
  border-radius: 14px;
  width: 44px; height: 44px;
  cursor: pointer;
}
.grade-btn.sel { border-color: #facc15; background: #fff; transform: scale(1.1); }
.login-tagline {
  color: rgba(255,255,255,0.95);
  font-weight: 800;
  font-size: 0.95rem;
  margin: 2px 0 6px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.ga-grade {
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  padding: 3px 6px;
  margin-left: 8px;
  color: #334155;
  background: #f8fafc;
}

/* ---------- family gate + parent auth ---------- */
.family-card {
  background: rgba(255,255,255,0.35);
  border-radius: 22px;
  padding: 16px 16px 10px;
  margin-top: 10px;
}
.btn-white {
  background: #fff;
  color: #1e293b;
  font-size: 1.15rem;
  padding: 14px 18px;
}
.family-hint {
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 6px 4px 0;
}
.family-divider {
  color: rgba(255,255,255,0.85);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 14px 0 8px;
}
.family-msg { min-height: 20px; color: #fef9c3; font-weight: 700; font-size: 0.9rem; margin: 4px 0; }
#btn-family-link { margin-top: 8px; }
#btn-local-only { margin: 10px 0 4px; opacity: 0.85; }

.sync-code {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #4f46e5;
  background: #eef2ff;
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
  margin: 8px 0;
  user-select: all;
  -webkit-user-select: all;
}

/* addition teams merging into one big team */
.obj-area.merge { gap: 0; transition: gap 0.6s; }
.obj-area.merge .op-symbol { display: none; }
.obj-area.merge .obj-group {
  transition: all 0.6s;
  background: rgba(254, 249, 195, 0.85);
}
.obj-area.merge .obj-group:first-child { border-radius: 22px 0 0 22px; }
.obj-area.merge .obj-group + .obj-group { border-radius: 0 22px 22px 0; }
