/* ===== Toddler Learning World — shared styles ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #03a9f4 0%, #4fc3f7 35%, #b3e5fc 62%, #aed581 88%, #8bc34a 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: #333;
  user-select: none;
  overflow-x: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 4px solid #ff9800;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.topbar .home-btn {
  font-size: 1.6rem;
  text-decoration: none;
  background: #ffe082;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #d8a200;
  transition: transform .1s;
}
.topbar .home-btn:active { transform: scale(.92); }
.star-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff9e3;
  border: 3px solid #ffd54f;
  border-radius: 40px;
  padding: 8px 18px;
  font-size: 1.4rem;
  font-weight: bold;
  color: #b8860b;
}
.star-meter .star-icon { font-size: 1.7rem; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }

.page-title {
  text-align: center;
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  margin: 22px 10px 6px;
  color: #fff;
  text-shadow: 2px 2px 0 #4527a0, -1px -1px 0 #4527a0;
}
.page-subtitle {
  text-align: center;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: #fff;
  text-shadow: 1px 1px 0 rgba(69,39,160,.6);
  margin: 0 10px 22px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px 60px;
}

/* ===== Home menu cards ===== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #fff;
  background: #fff;
  border-radius: 26px;
  padding: 28px 16px 20px;
  border: 4px solid rgba(255,255,255,.65);
  box-shadow: 0 6px 0 rgba(0,0,0,.22);
  transition: transform .15s, box-shadow .15s;
  position: relative;
}
.menu-card:hover { transform: translateY(-5px) scale(1.02); }
.menu-card:active { transform: scale(.96); }
.menu-card .emoji { font-size: 4rem; margin-bottom: 10px; filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); }
.menu-card .name { font-size: 1.4rem; font-weight: bold; text-shadow: 1px 2px 0 rgba(0,0,0,.22); }
.menu-card .ar-name { font-size: 1.08rem; font-weight: bold; color: rgba(255,255,255,.95); margin-top: 2px; text-shadow: 1px 1px 0 rgba(0,0,0,.18); }
.menu-card .desc { font-size: .95rem; color: rgba(255,255,255,.92); margin-top: 4px; text-align: center; }
.menu-card .card-stars {
  position: absolute; top: 10px; right: 14px;
  font-size: .95rem; color: #fff9c4; font-weight: bold; text-shadow: 1px 1px 0 rgba(0,0,0,.25);
}
.c1 { background: linear-gradient(160deg, #ff7043, #e64a19); }
.c2 { background: linear-gradient(160deg, #29b6f6, #0277bd); }
.c3 { background: linear-gradient(160deg, #9ccc65, #558b2f); }
.c4 { background: linear-gradient(160deg, #ab47bc, #6a1b9a); }
.c5 { background: linear-gradient(160deg, #ffa726, #ef6c00); }
.c6 { background: linear-gradient(160deg, #26a69a, #00695c); }
.c7 { background: linear-gradient(160deg, #ec407a, #ad1457); }
.c8 { background: linear-gradient(160deg, #5c6bc0, #283593); }

/* ===== Big tappable tiles (letters/numbers) ===== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 14px;
}
.tile {
  background: #fff;
  border-radius: 20px;
  border: 3px solid #e0e0e0;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
  color: #444;
}
.tile:hover { transform: scale(1.06); border-color: #ffd54f; }
.tile:active { transform: scale(.92); }
.tile .tile-word { font-size: .85rem; font-weight: normal; color: #999; margin-top: 4px; }
.tile.done { border-color: #81c784; background: #f1f8e9; }
.tile.done::after { content: "⭐"; position: absolute; font-size: 1rem; margin-top: -64px; margin-right: -70px; }
.tile { position: relative; }

/* ===== Quiz styles ===== */
.quiz-area { text-align: center; }
.quiz-prompt {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  margin: 10px 0 20px;
  color: #fff;
  text-shadow: 2px 2px 0 #4527a0;
  min-height: 3rem;
}
.quiz-prompt .target { color: #e91e63; font-size: 1.3em; }
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}
.quiz-option {
  background: #fff;
  border: 4px solid #42a5f5;
  border-radius: 24px;
  min-width: 120px;
  min-height: 120px;
  padding: 16px 22px;
  font-size: 2.6rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  color: #333;
}
.quiz-option:hover { transform: scale(1.07); }
.quiz-option:active { transform: scale(.93); }
.quiz-option.correct { border-color: #66bb6a; background: #e8f5e9; animation: wiggle .5s; }
.quiz-option.wrong { border-color: #ef5350; background: #ffebee; animation: shake .4s; }
@keyframes wiggle { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-5deg)} 75%{transform:rotate(5deg)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.feedback {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  min-height: 2.6rem;
  margin: 18px 0 4px;
  font-weight: bold;
  color: #2e7d32;
  display: inline-block;
  background: rgba(255,255,255,.88);
  border-radius: 22px;
  padding: 2px 26px;
}

.big-btn {
  background: linear-gradient(180deg, #ffd54f, #ffb300);
  border: none;
  border-radius: 40px;
  padding: 14px 34px;
  font-size: 1.3rem;
  font-weight: bold;
  font-family: inherit;
  color: #5d4000;
  cursor: pointer;
  box-shadow: 0 4px 0 #c68400;
  margin: 8px;
  transition: transform .1s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c68400; }
.big-btn.alt { background: linear-gradient(180deg, #90caf9, #42a5f5); color: #0d3b66; box-shadow: 0 4px 0 #1565c0; }
.big-btn.alt:active { box-shadow: 0 1px 0 #1565c0; }

.mode-switch { text-align: center; margin-bottom: 18px; }
.progress-bar {
  max-width: 420px;
  margin: 8px auto 20px;
  background: rgba(255,255,255,.55);
  border-radius: 20px;
  height: 22px;
  border: 2px solid rgba(255,255,255,.85);
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #81c784, #4caf50);
  border-radius: 20px;
  width: 0%;
  transition: width .4s;
}
.progress-label { text-align: center; color: #fff; text-shadow: 1px 1px 0 rgba(69,39,160,.55); font-size: .95rem; margin-bottom: 4px; }

/* ===== Letter detail popup ===== */
.popup-overlay {
  position: fixed; inset: 0;
  background: rgba(60,40,90,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.popup-card {
  background: #fff;
  border-radius: 30px;
  border: 6px solid #ffd54f;
  padding: 36px 48px;
  text-align: center;
  max-width: 90vw;
  animation: popIn .25s;
}
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.popup-card .big-letter { font-size: 6rem; font-weight: bold; color: #5b4bb3; line-height: 1.1; }
.popup-card .big-emoji { font-size: 5rem; margin: 10px 0; }
.popup-card .big-word { font-size: 2rem; color: #e91e63; font-weight: bold; }
.popup-card .big-word-ar { font-size: 2.2rem; color: #00838f; font-weight: bold; }

/* ===== Physics play area ===== */
.tank {
  position: relative;
  max-width: 640px;
  height: 300px;
  margin: 16px auto;
  background: linear-gradient(180deg, #b3e5fc 0%, #4fc3f7 30%, #0288d1 100%);
  border-radius: 18px 18px 30px 30px;
  border: 5px solid #795548;
  border-top-width: 3px;
  overflow: hidden;
}
.tank .water-line {
  position: absolute;
  top: 24%;
  left: 0; right: 0;
  border-top: 3px dashed rgba(255,255,255,.7);
}
.physics-items {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin: 14px 0;
}
.phys-item {
  font-size: 3rem;
  background: #fff;
  border-radius: 18px;
  border: 3px solid #b0bec5;
  width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .12s;
}
.phys-item:hover { transform: scale(1.1); }
.phys-item:active { transform: scale(.92); }
.phys-item.guessed { opacity: .35; pointer-events: none; }
.tank-object {
  position: absolute;
  font-size: 3rem;
  transition: top 1.1s ease-in, left .3s;
  transform: translateX(-50%);
}
.drop-area {
  position: relative;
  max-width: 640px;
  height: 340px;
  margin: 16px auto;
  background: linear-gradient(180deg, #e1f5fe 70%, #a1887f 70%);
  border-radius: 18px;
  border: 4px solid #90a4ae;
  overflow: hidden;
}
.bouncing-ball {
  position: absolute;
  font-size: 3.4rem;
  transform: translateX(-50%);
}

/* ===== Chemistry mixing ===== */
.mix-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.potion {
  width: 110px; height: 130px;
  border-radius: 18px 18px 46px 46px;
  border: 5px solid #78909c;
  background: #eceff1;
  display: flex; align-items: flex-end;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.potion:hover { transform: scale(1.05); }
.potion.selected { border-color: #ab47bc; box-shadow: 0 0 0 4px #e1bee7; }
.potion .liquid {
  width: 100%;
  height: 62%;
  transition: background .6s;
  border-radius: 0 0 40px 40px;
}
.potion .label {
  position: absolute;
  top: 8px; left: 0; right: 0;
  text-align: center;
  font-weight: bold;
  font-size: .9rem;
  color: #555;
}
.mix-result {
  width: 150px; height: 170px;
  border-radius: 20px 20px 60px 60px;
  border: 6px solid #7e57c2;
  background: #f3e5f5;
  display: flex; align-items: flex-end;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
}
.mix-result .liquid {
  width: 100%; height: 66%;
  background: transparent;
  transition: background .8s;
  border-radius: 0 0 54px 54px;
}
.mix-symbol { font-size: 2.4rem; color: #7e57c2; font-weight: bold; }

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* Sticker gallery */
.sticker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}
.sticker {
  font-size: 2.6rem;
  filter: grayscale(1);
  opacity: .3;
  transition: all .3s;
}
.sticker.earned { filter: none; opacity: 1; transform: scale(1.1); }

@media (max-width: 560px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
  .tile { font-size: 2rem; }
  .quiz-option { min-width: 96px; min-height: 96px; font-size: 2rem; }
}

/* ===== Story Time ===== */
.story-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 32, 84, .82);
  z-index: 400;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 12px 30px;
}
.story-panel {
  background: linear-gradient(180deg, #fffde7, #fff);
  border-radius: 28px;
  border: 6px solid #ffca28;
  max-width: 640px;
  width: 100%;
  padding: 18px 16px 24px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  margin: auto;
}
.story-close {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 401;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #ef5350;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #b71c1c;
}
.story-heading { color: #5b4bb3; margin: 4px 0 2px; font-size: 1.7rem; }
.story-sub { color: #999; margin: 0 0 14px; }
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.story-card {
  position: relative;
  background: #fff;
  border: 4px solid #b39ddb;
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s;
  box-shadow: 0 4px 0 rgba(91, 75, 179, .25);
}
.story-card:hover { transform: scale(1.04); }
.story-card:active { transform: scale(.96); }
.story-card img { width: 100%; height: 110px; object-fit: cover; display: block; }
.story-name { padding: 8px 6px; font-weight: bold; color: #4a3a8c; font-size: 1.02rem; }
.story-check {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #66bb6a;
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 2px solid #fff;
}
.story-reader { max-width: 560px; }
.story-cover {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 18px;
  border: 4px solid #ffe082;
  margin: 8px 0;
}
.story-scene-emoji { font-size: 4.2rem; margin: 6px 0; }
.story-text {
  font-size: 1.35rem;
  color: #37474f;
  line-height: 1.55;
  font-weight: 600;
  margin: 8px 6px 10px;
}
.story-dots { color: #b39ddb; font-size: 1.1rem; letter-spacing: 4px; margin-bottom: 12px; }
.story-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.story-next { background: linear-gradient(180deg, #a5d6a7, #66bb6a); color: #1b5e20; box-shadow: 0 4px 0 #2e7d32; }

/* ===== Word Games (literacy activities) ===== */
.shake { animation: litShake .4s; }
@keyframes litShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Build-a-Sentence */
.bs-slots { display: flex; gap: 10px; justify-content: center; margin: 14px 0; flex-wrap: wrap; position: relative; }
.bs-slot { min-width: 92px; min-height: 66px; border: 3px dashed #b39ddb; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; background: #faf7ff; position: relative; padding: 4px; }
.bs-tray { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0;
  min-height: 76px; position: relative; background: #f2ecff; border-radius: 16px; padding: 10px; }
.bs-word { padding: 12px 20px; border-radius: 14px; font-size: 1.5rem; font-weight: bold; color: #fff;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  box-shadow: 0 3px 0 rgba(0,0,0,.25); transition: transform .15s; }
.bs-word:active { transform: scale(.93); }
.pos-n { background: #42a5f5; } .pos-v { background: #ef5350; }
.pos-adj { background: #66bb6a; } .pos-o { background: #ab47bc; }

/* Sight Word Pop */
.sw-stage { position: relative; height: 360px; overflow: hidden; border-radius: 18px; margin: 10px 0;
  background: linear-gradient(180deg, #e1f5fe, #b3e5fc); border: 3px solid #81d4fa; }
.sw-balloon { position: absolute; width: 100px; height: 122px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: bold; color: #fff; cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: none; border-radius: 50% 50% 48% 52% / 58% 58% 42% 42%;
  box-shadow: inset -6px -8px 0 rgba(0,0,0,.12); animation: swFloat linear infinite; text-align: center; padding: 6px; }
.sw-balloon::after { content: ''; position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: inherit; }
@keyframes swFloat { from { top: 105%; } to { top: -45%; } }
.sw-pop { animation: swPop .35s forwards !important; font-size: 2.2rem !important; background: none !important; box-shadow: none !important; }
@keyframes swPop { to { transform: scale(1.7); opacity: 0; } }
.sw-wobble { outline: 5px solid #fff; filter: brightness(1.25); }

/* Interactive Storybooks */
.rb-passage { font-size: 1.45rem; line-height: 2.15; color: #4a3a8c; background: #fffdf5;
  border: 3px solid #ffe082; border-radius: 16px; padding: 14px 18px; margin: 10px 0; }
.rb-hard { color: #7b1fa2; font-weight: bold; border-bottom: 3px dotted #7b1fa2; cursor: pointer;
  padding: 0 3px; border-radius: 6px; touch-action: none; }
.rb-flash { background: #e1bee7; }

/* Spelling Factory */
.sf-belt { position: relative; height: 116px; border-radius: 16px; margin: 12px 0; overflow: hidden;
  border: 4px solid #546e7a;
  background: repeating-linear-gradient(90deg, #90a4ae 0 24px, #78909c 24px 48px);
  animation: beltMove 1.1s linear infinite; }
@keyframes beltMove { to { background-position: 48px 0; } }
.sf-item { position: absolute; top: 12px; left: -130px; font-size: 4.4rem; animation: sfSlide 1.15s ease-out .15s forwards; }
@keyframes sfSlide { to { left: calc(50% - 38px); } }
.sf-slots { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; position: relative; }
.sf-slot { width: 58px; height: 68px; border: 3px solid #ffb300; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 2rem; font-weight: bold; background: #fff; color: #e65100; }
.sf-team { background: #ffe082 !important; animation: sfPulse .7s infinite alternate; }
@keyframes sfPulse { to { transform: scale(1.14); } }
.sf-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0;
  min-height: 76px; position: relative; background: #f2ecff; border-radius: 16px; padding: 10px; }
.sf-tile { width: 58px; height: 68px; border-radius: 12px; background: #ffca28; color: #4e342e;
  font-size: 2rem; font-weight: bold; display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; box-shadow: 0 3px 0 #ff8f00; }

/* Punctuation Station */
.pu-sent { font-size: 1.7rem; color: #4a3a8c; font-weight: bold; margin: 14px 6px; line-height: 1.9; }
.pu-blank { display: inline-block; min-width: 54px; border: 3px dashed #9575cd; border-radius: 10px;
  color: #b39ddb; font-size: 1.4rem; line-height: 1.2; vertical-align: middle; }
.pu-marks { display: flex; gap: 18px; justify-content: center; margin: 14px 0; }
.pu-mark { width: 84px; height: 84px; border-radius: 20px; font-size: 2.6rem; font-weight: bold;
  background: #fff; border: 4px solid #9575cd; color: #5e35b1; cursor: pointer; box-shadow: 0 4px 0 #9575cd;
  transition: transform .12s; }
.pu-mark:active { transform: scale(.92); }
.pu-mark.correct { background: #c8e6c9; border-color: #66bb6a; color: #1b5e20; }
.pu-mark.wrong { background: #ffcdd2; border-color: #ef5350; color: #b71c1c; }
