:root {
  --bg1: #2b2e4a;
  --bg2: #533483;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Comic Sans MS", "Chalkboard SE", "Baloo", system-ui, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  /* Prevent accidental text selection / callouts on toddler taps */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app { height: 100%; width: 100%; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px;
}
.screen.active { display: flex; flex-direction: column; }

/* ---------- HOME ---------- */
.home-title {
  text-align: center;
  color: #fff;
  font-size: clamp(28px, 7vw, 56px);
  margin: 8px 0 16px;
  text-shadow: 0 4px 0 rgba(0,0,0,0.2);
}
.home-title span { color: #ffe66d; }

.tile-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 14px;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (max-width: 680px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}

.tile {
  border: none;
  border-radius: 28px;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 0 rgba(0,0,0,0.18), inset 0 2px 8px rgba(255,255,255,0.4);
  transition: transform .08s ease;
}
.tile:active { transform: scale(0.94) translateY(4px); box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
.tile-emoji { font-size: clamp(40px, 9vw, 80px); }
.tile-label {
  font-size: clamp(18px, 3.5vw, 30px);
  font-weight: bold;
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

/* ---------- PLAY ---------- */
#homeBtn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  z-index: 20;
  width: 64px; height: 64px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  font-size: 32px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.2);
}
#homeBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }

#stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 88px 8px 24px;
}
/* Scenes that fit on one screen center themselves vertically */
#stage > .center { margin-top: auto; margin-bottom: auto; }

/* Big rolling grid used by letters/numbers/animals/shapes */
.pad-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 900px;
  padding: 8px;
}

.pad {
  border: none;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--c1, #fff), var(--c2, #ddd));
  color: #fff;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
  font-weight: bold;
  line-height: 1;
}
.pad:active { transform: scale(0.92); box-shadow: 0 2px 0 rgba(0,0,0,0.18); }
.pad .big { font-size: clamp(30px, 8vw, 64px); text-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.pad .small { font-size: clamp(22px, 5vw, 40px); }
.pad .cap { font-size: clamp(11px, 2.2vw, 18px); margin-top: 4px; opacity: .95; }

/* Big center reveal card */
.reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: clamp(80px, 30vw, 280px);
  color: #fff;
  z-index: 15;
  animation: pop .35s ease;
  pointer-events: none;
}
.reveal .word { font-size: clamp(28px, 8vw, 64px); margin-top: 12px; text-shadow: 0 3px 0 rgba(0,0,0,0.25); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- DRAW ---------- */
#drawCanvas { background: #fff; border-radius: 18px; touch-action: none; box-shadow: 0 8px 0 rgba(0,0,0,0.2); }
.draw-tools { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 52px; height: 52px; border-radius: 50%; border: 4px solid #fff; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.25); }
.swatch.active { transform: scale(1.18); }
.tool-btn {
  border: none; border-radius: 16px; padding: 12px 18px; font-size: 22px;
  background: #fff; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.2); font-weight: bold;
}
.tool-btn:active { transform: translateY(3px); }

/* ---------- MUSIC ---------- */
.keys { display: flex; gap: 8px; width: 100%; max-width: 920px; height: 60vh; align-items: stretch; }
.key {
  flex: 1; border: none; border-radius: 0 0 18px 18px; cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.25); color: rgba(255,255,255,0.85);
  font-size: 28px; font-weight: bold; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 18px;
}
.key:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0,0,0,0.25); }

/* ---------- SHOW ---------- */
.show-stage {
  position: relative; width: 100%; height: 100%; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.show-count { font-size: clamp(60px, 22vw, 220px); color: #ffe66d; text-shadow: 0 4px 0 rgba(0,0,0,0.3); }
.actor { position: absolute; font-size: clamp(50px, 14vw, 130px); }
.float { animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-26px) rotate(4deg); } }
.walk { animation: walk 6s linear infinite; }
@keyframes walk { from { left: -20%; } to { left: 110%; } }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
