/* Little Lantern - the Tending Game.
   Calm, pastel, low-saturation base with a few saturated accents on the two
   touchable tools (P18). Big targets (P02). Small, slow, interruptible motion
   that switches off under reduced motion or in the evening (P19, P20). A warm
   overlay veils the scene as evening comes on (P14). */

:root {
  --sky-top: #DCEBEA;
  --sky-bottom: #EFF3EA;
  --ground: #E7D6B8;
  --ground-wet: #D8C29B;
  --ink: #4A4038;
  --ink-soft: #7A6E60;
  --panel: #F5EFE4;
  --water: #6FB6C9;
  --light: #E7B24C;
  --shadow: 0 10px 24px rgba(74, 64, 56, 0.14);
  --warm-overlay: rgba(255, 176, 92, 0);
  --tap-min: 96px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky-bottom);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Warm evening veil over the whole page, driven by the responsible-screen layer. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: var(--warm-overlay);
  transition: background 1.2s ease;
  z-index: 50;
}
.reduced-motion body::after,
.reduced-motion *::after { transition: none !important; }

.skip-adult {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--panel);
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.skip-adult:focus { left: 12px; top: 12px; z-index: 60; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 4px;
  color: var(--ink-soft);
}
.topbar__mark { display: inline-flex; }
.topbar__name { font-size: 15px; letter-spacing: 0.02em; }

/* The scene grows to fill available height. */
.scene {
  position: relative;
  flex: 1 1 auto;
  min-height: 46vh;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 62%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.ground {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 20%;
  z-index: 0;
  background: linear-gradient(180deg, var(--ground) 0%, var(--ground-wet) 100%);
  border-top-left-radius: 40% 30px;
  border-top-right-radius: 40% 30px;
  transition: filter 1.5s ease;
}
.scene.is-watered .ground { filter: brightness(0.94) saturate(1.08); }

.plant {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  width: min(60vw, 300px);
  z-index: 2;
  transform-origin: 50% 100%;
  animation: sway 6s ease-in-out infinite;
}
.plant-svg { width: 100%; height: auto; display: block; }
.plant.grow-pop { animation: growpop 0.7s ease-out; }

.reduced-motion .plant { animation: none; }

@keyframes sway {
  0%, 100% { transform: translateX(-50%) rotate(-1.1deg); }
  50% { transform: translateX(-50%) rotate(1.1deg); }
}
@keyframes growpop {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.06); }
  100% { transform: translateX(-50%) scale(1); }
}

/* Soft light glow (behind the plant) when the lantern is tapped. */
.glow {
  position: absolute;
  left: 50%;
  top: 26%;
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0.6);
  background: radial-gradient(circle, rgba(247, 210, 126, 0.85) 0%, rgba(247, 210, 126, 0) 68%);
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
  z-index: 1;
}
.glow.glow--on { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.reduced-motion .glow { transition: opacity 0.2s linear; }

/* Falling water droplets. */
.drops { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.drop {
  position: absolute;
  top: 30%;
  width: 10px;
  height: 14px;
  background: var(--water);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  opacity: 0.85;
  animation: drip 1s ease-in forwards;
}
@keyframes drip {
  0% { transform: translateY(0); opacity: 0.9; }
  100% { transform: translateY(34vh); opacity: 0; }
}

.message {
  text-align: center;
  font-size: clamp(20px, 3.4vw, 26px);
  line-height: 1.35;
  color: var(--ink);
  min-height: 2.2em;
  margin: 14px 8px 6px;
  font-weight: 500;
}

/* The two big care tools - the only saturated things on the page. */
.tools {
  display: flex;
  justify-content: center;
  gap: clamp(20px, 6vw, 56px);
  padding: 8px 0 6px;
}
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 128px;
  min-height: var(--tap-min);
  padding: 16px 20px;
  border: 3px solid transparent;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}
.tool:active { transform: translateY(2px) scale(0.97); box-shadow: 0 4px 12px rgba(74,64,56,0.16); }
.tool:focus-visible { outline: 4px solid rgba(111, 182, 201, 0.6); outline-offset: 3px; }
.tool--water { border-color: var(--water); }
.tool--light { border-color: var(--light); }
.tool__label { font-size: 20px; font-weight: 600; color: var(--ink); }
.reduced-motion .tool { transition: none; }

.paper-panel {
  margin: 10px 0 4px;
  padding: 18px 20px;
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.paper-panel__script {
  margin: 0 0 14px;
  font-size: clamp(16px, 2.6vw, 19px);
  line-height: 1.45;
  color: var(--ink-soft);
}
.paper-btn {
  min-height: 60px;
  padding: 0 28px;
  border: none;
  border-radius: 18px;
  background: var(--light);
  color: #3d2f16;
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.paper-btn:active { transform: translateY(2px) scale(0.98); }
.paper-btn:focus-visible { outline: 4px solid rgba(231, 178, 76, 0.6); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .plant, .glow, .drop, .tool, .paper-btn, .ground, body::after { animation: none !important; transition: none !important; }
}

/* ---------- The gem game ---------- */
.app.gems { max-width: 960px; }
.home-link { font-size: 15px; color: var(--ink-soft); text-decoration: none; padding: 6px 4px; margin-right: auto; }

.gem-top { display: flex; align-items: baseline; justify-content: center; gap: 10px; padding: 2px 0 8px; color: var(--ink-soft); font-size: 18px; }
.gem-top__num { font-size: clamp(40px, 9vw, 62px); font-weight: 700; color: var(--ink); line-height: 1; min-width: 1.1em; text-align: center; }

.board {
  position: relative; flex: 1 1 auto; min-height: 52vh;
  border-radius: 28px; overflow: hidden; touch-action: none;
  background: linear-gradient(180deg, #EFF3EA 0%, #F5EFE4 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.plate {
  position: absolute; transform: translate(-50%, -50%);
  width: clamp(82px, 19vw, 120px); aspect-ratio: 1; border-radius: 50%;
  background: var(--plate); border: 4px solid var(--rim);
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.plate--glow { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.55), 0 0 22px 6px var(--rim); transform: translate(-50%, -50%) scale(1.08); }
.plate__target { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.plate__target svg { width: 62%; height: 62%; opacity: 0.5; }
/* A scene disc a game may place inside its plates (see createBoard's
   decoratePlate note): full-bleed, clipped to the circle, under stack + badge. */
.plate__target .plate__scene { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.plate__stack { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; justify-content: center; width: 78%; max-height: 78%; }
.plate__count {
  position: absolute; right: -6px; bottom: -6px; min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 15px; background: #fff; border: 2px solid var(--rim); color: var(--ink);
  font-weight: 700; font-size: 17px; line-height: 26px; text-align: center;
}

.bowl {
  position: absolute; transform: translate(-50%, -50%); min-width: 150px; min-height: 90px; padding: 14px 22px;
  border-radius: 24px; border: 3px solid #C98A4B; background: #fff; box-shadow: var(--shadow);
  font-family: inherit; font-size: 20px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.bowl:active { transform: translate(-50%, -50%) scale(0.97); }

.gem {
  position: absolute; width: 64px; height: 64px; padding: 0; border: none; background: none;
  cursor: grab; touch-action: none; filter: drop-shadow(0 3px 4px rgba(74, 64, 56, 0.25));
}
.gem svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.gem:not(.gem--active):not(.gem--placed) { transition: left 0.28s ease, top 0.28s ease; }
.gem--active { cursor: grabbing; z-index: 20; transform: scale(1.12); }
.gem--placed { position: static; width: 22px; height: 22px; filter: none; cursor: default; }
.gem--dropping { animation: gemdrop 0.5s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes gemdrop { 0% { transform: translateY(-40px) scale(0.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.gem--nudge { animation: gemnudge 0.42s ease; }
@keyframes gemnudge { 0%, 100% { transform: none; } 30% { transform: rotate(-8deg); } 60% { transform: rotate(8deg); } }

.gem-done__btns { display: flex; gap: 20px; justify-content: center; align-items: center; flex-wrap: wrap; }
.paper-btn--ghost { background: #fff; color: var(--ink); border: 2px solid var(--light); }
/* Child icon buttons: sized toward the P02 child tap floor, round in BOTH axes,
   with a wide gap so a near-miss lands on neither neighbour. */
.paper-btn--icon {
  width: 88px; min-width: 88px; height: 88px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.paper-btn--icon svg { width: 42px; height: 42px; display: block; }

.reduced-motion .gem, .reduced-motion .gem--dropping, .reduced-motion .plate { animation: none !important; transition: none !important; }

/* ---------- Home ---------- */
.app.home { max-width: 820px; }
.home__title { text-align: center; font-size: clamp(24px, 5vw, 34px); font-weight: 600; color: var(--ink); margin: 12px 0 24px; }
.home__tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 260px)); justify-content: center; gap: 18px; padding-bottom: 24px; }
@media (max-width: 460px) { .home__tiles { grid-template-columns: 1fr; } }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 18px; background: #fff; border-radius: 26px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); border: 3px solid transparent;
  transition: transform 0.14s ease;
}
.tile:active { transform: translateY(2px) scale(0.99); }
.tile:focus-visible { outline: 4px solid rgba(231, 178, 76, 0.6); outline-offset: 3px; }
.tile__art { width: 100%; height: 190px; display: flex; align-items: center; justify-content: center; }
.tile__name { font-size: 21px; font-weight: 600; }
.reduced-motion .tile { transition: none; }

/* Illustrated scenes: on tiles (still, one per card) and as an activity welcome
   scene in the idle state (single, gently breathing, calmed under reduced motion). */
.tile-scene { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; display: block; }
.tile-scene[hidden] { display: none; }
.welcome-scene {
  display: block; width: auto; height: auto; max-width: min(78%, 420px); max-height: 30vh;
  margin: 4px auto 12px; border-radius: 22px; box-shadow: var(--shadow);
  animation: breathe 4.5s ease-in-out infinite;
}
.welcome-scene[hidden] { display: none; }
.reduced-motion .welcome-scene { animation: none !important; }

/* ---------- Letter Lantern ---------- */
.app.letters { max-width: 780px; }
.letter-stage { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; min-height: 44vh; }

.letter-shelf { display: flex; justify-content: center; gap: clamp(14px, 4vw, 28px); flex-wrap: wrap; padding: 10px 0; }
.letter-card {
  width: clamp(96px, 26vw, 148px); aspect-ratio: 3 / 4; border-radius: 24px; border: 3px solid var(--light);
  background: #fff; box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease;
}
.letter-card:active { transform: translateY(2px) scale(0.97); }
.letter-card:focus-visible { outline: 4px solid rgba(231, 178, 76, 0.6); outline-offset: 3px; }
.letter-card__char { font-size: clamp(56px, 16vw, 92px); font-weight: 700; color: var(--ink); }

.letter-play { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.letter-hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 8px; }
.letter-lantern {
  position: absolute; top: 42%; left: 50%; width: 210px; height: 210px; transform: translate(-50%, -50%) scale(0.7);
  background: radial-gradient(circle, rgba(247, 210, 126, 0.85) 0%, rgba(247, 210, 126, 0) 68%);
  opacity: 0; transition: opacity 0.5s ease, transform 0.5s ease; pointer-events: none;
}
.letter-lantern.on { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.letter-hero__char { position: relative; font-size: clamp(84px, 24vw, 140px); font-weight: 700; color: var(--ink); line-height: 1; }
.letter-say {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 6px 18px; border-radius: 16px;
  border: 2px solid var(--water); background: #fff; color: var(--water); font-family: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
}
.letter-say:active { transform: translateY(1px); }

.pic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 3vw, 20px); width: min(92%, 460px); margin: 0 auto; }
.pic-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px 10px; border-radius: 22px;
  border: 3px solid transparent; background: #fff; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease;
}
.pic-card:active { transform: translateY(2px) scale(0.98); }
.pic-card:focus-visible { outline: 4px solid rgba(111, 182, 201, 0.6); outline-offset: 3px; }
.pic-card svg { width: clamp(62px, 17vw, 92px); height: clamp(62px, 17vw, 92px); }
.pic-card__word { font-size: 18px; font-weight: 600; color: var(--ink-soft); }
.pic-card--match { border-color: #7FB069; background: #F1F7EC; }
.pic-card--match .pic-card__word { color: #4C7A3A; }
.pic-card--nudge { animation: gemnudge 0.42s ease; }
.reduced-motion .letter-lantern, .reduced-motion .pic-card, .reduced-motion .letter-card { transition: none !important; animation: none !important; }

/* ---------- The Making Room: Move Your Body ---------- */
.app.move { max-width: 720px; }
.move-stage { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; min-height: 44vh; gap: 18px; }
.move-lantern {
  position: absolute; top: 44%; left: 50%; width: 240px; height: 240px; transform: translate(-50%, -50%) scale(0.7);
  background: radial-gradient(circle, rgba(247, 210, 126, 0.8) 0%, rgba(247, 210, 126, 0) 68%);
  opacity: 0; transition: opacity 0.5s ease, transform 0.5s ease; pointer-events: none;
}
.move-lantern.on { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
.move-word { position: relative; font-size: clamp(30px, 8vw, 52px); font-weight: 700; color: var(--ink); text-align: center; line-height: 1.2; margin: 0; padding: 0 16px; }
.move-again { align-self: center; margin: 8px auto 22px; min-height: 64px; font-size: 22px; }
.move-img {
  position: relative; width: min(88%, 520px); aspect-ratio: 4 / 3; max-height: 50vh; object-fit: contain;
  display: block; border-radius: 24px; box-shadow: var(--shadow);
}
.move-img.is-hidden { display: none; } /* set on load error: falls back to word-only */
.move-img.is-shown { animation: breathe 4.5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.03) translateY(-5px); } }
.reduced-motion .move-lantern { transition: none !important; }
.reduced-motion .move-img.is-shown { animation: none !important; }
