/* =========================================================
   Hanvi's Fun Games – one fixed screen per page, fits every
   phone / iPad / desktop in portrait and landscape.
   ========================================================= */
/* ---------- Colours: light mode (default) ---------- */
:root {
  --bg: #fff8e7;
  --ink: #3b2f5c;
  --surface: #ffffff;          /* buttons, cards, menu */
  --matched: #d6ffe9;          /* matched memory cards */
  --track: rgba(59, 47, 92, 0.12);
  --overlay: rgba(255, 248, 231, 0.97);
  --sky-top: #8fd3ff;
  --sky-bottom: #dff4ff;
  --outline: #3b2f5c;          /* dark outline round coloured words */
  --pink: #ff7aa2;
  --green: #4cc9a0;
  --blue: #6c8cff;
  --yellow: #ffd166;
  --shadow: 0 6px 0 rgba(59, 47, 92, 0.15);
  color-scheme: light;
  --gap: clamp(8px, 2vmin, 20px);
  --btn: 52px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

/* ---------- Colours: dark mode (set by js/theme.js, switched from the master header) ---------- */
:root[data-theme="dark"] {
  --bg: #1d1830;
  --ink: #f3eefe;
  --surface: #2c2548;
  --matched: #1f4d3a;
  --track: rgba(255, 255, 255, 0.14);
  --overlay: rgba(29, 24, 48, 0.97);
  --sky-top: #0d1a3a;
  --sky-bottom: #2f4a85;
  --outline: #1b1530;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none;   /* no iOS long-press menu */
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* The page itself never moves: no scroll, no bounce, no zoom. */
html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", "Trebuchet MS", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* ---------- Top bar (game pages) ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  position: relative;
  z-index: 10;
}
.topbar h1 {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: clamp(1rem, 4.5vw, 2rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: var(--btn);
  height: var(--btn);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: calc(var(--btn) * 0.5);
  display: grid;
  place-items: center;
  text-decoration: none;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 47, 92, 0.15); }

.home-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--btn);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--yellow);
  color: #3b2f5c;                /* dark text on yellow in both modes */
  font-size: calc(var(--btn) * 0.4);
  font-weight: bold;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 0 #e0a92e;
}
.home-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #e0a92e; }

/* Short screens (phones in landscape): smaller bar */
@media (max-height: 500px) {
  :root { --btn: 42px; }
  .topbar { padding: 6px 12px; }
}

/* ---------- Master page (index.html): shared header + frame for every page ---------- */
.shell iframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  display: block;
  background: var(--bg);
}
.master {
  z-index: 60;                  /* stays above the welcome screen */
  --btn: 48px;
}
.top-actions { flex: none; display: flex; gap: 8px; }
.site-footer {                  /* © line under every page (master page only) */
  flex: none;
  text-align: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 5px 8px 6px;
  color: var(--ink);
  opacity: 0.6;
  background: var(--bg);
  border-top: 1px solid var(--track);
  white-space: nowrap;
}
.icon-btn.off { opacity: 0.6; }
.overlay.shell-overlay {        /* welcome screen fills the screen; the master header stays on top */
  padding-top: calc(var(--safe-t) + 84px);
  background: var(--bg);
}
@media (max-width: 420px) {
  .master { --btn: 42px; gap: 6px; padding: 8px 10px; }
  .master h1 { font-size: clamp(0.95rem, 4.6vw, 1.2rem); }
  .master .home-btn { padding: 0 12px; }
  .master .home-label { display: none; }   /* just 🏠 on small phones */
  .top-actions { gap: 6px; }
}

/* ---------- Home page ---------- */
/* Top centre menu (Games / Learn) */
.menu {
  flex: none;
  display: flex;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: clamp(8px, 2vh, 18px) auto 0;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.menu-btn {
  padding: clamp(6px, 1.4vh, 12px) clamp(16px, 5vw, 34px);
  border-radius: 999px;
  font-size: clamp(1rem, min(4.6vw, 3.8vh), 1.6rem);
  font-weight: bold;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.menu-btn.active { background: var(--pink); color: #fff; box-shadow: 0 4px 0 #e0567f; }
@media (max-width: 480px) {                     /* three tabs fit on small phones */
  .menu { gap: 2px; padding: 5px; max-width: calc(100% - 16px); }
  .menu-btn { padding: clamp(6px, 1.4vh, 10px) clamp(8px, 2.6vw, 14px); font-size: clamp(0.85rem, 4vw, 1.05rem); }
}
.menu-btn:active { transform: translateY(3px); }

.hero { flex: none; text-align: center; padding: clamp(6px, 2vmin, 24px) 16px clamp(4px, 1vmin, 8px); }
@media (max-height: 500px) { .hero p { display: none; } }
.hero h1 {
  font-size: clamp(1.7rem, min(8vw, 8vh), 3.8rem);
  color: #ff5d8f;
  text-shadow: 3px 3px 0 var(--yellow);
}
.hero p { font-size: clamp(1rem, min(4vw, 3.5vh), 1.4rem); margin-top: 4px; }

.games {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);        /* portrait: 2 across, 4 rows */
  grid-auto-rows: 1fr;
  gap: var(--gap);
  padding: var(--gap) 16px;
}
.game-card {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 22px;
  color: #fff;
  text-align: center;
  line-height: 1.1;
  text-decoration: none;
  font-size: clamp(0.95rem, min(4.6vw, 3vh), 1.8rem);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.15s;
}
.game-card .emoji { font-size: clamp(1.8rem, min(12vw, 8vh), 5rem); line-height: 1; }
.game-card:active { transform: translateY(4px); }
.c1 { background: var(--pink); }
.c2 { background: var(--green); }
.c3 { background: var(--blue); }
.c4 { background: #ff9f43; }
.c5 { background: #a66cff; }
.c6 { background: #2bb3d9; }
.c7 { background: #34b56f; }
.c8 { background: #ff6b81; }
.c9 { background: linear-gradient(135deg, #3d3a8f, #6a5acd); }   /* night blue, for bedtime stories */

/* Family Time: a few big story cards, centred */
.games.family {
  grid-template-columns: repeat(auto-fit, minmax(150px, 280px));
  grid-auto-rows: min(34vh, 240px);
  justify-content: center;
  align-content: center;
}
.games.family .game-card { font-size: clamp(1.1rem, min(5vw, 3.6vh), 1.9rem); }
.games.family .game-card .emoji { font-size: clamp(2.6rem, min(16vw, 12vh), 5.5rem); }

@media (orientation: landscape) {
  .games {
    grid-template-columns: repeat(4, 1fr);      /* landscape: 4 across, 2 rows */
    max-width: 1100px;
  }
  .game-card { font-size: clamp(0.9rem, min(2.4vw, 4.5vh), 1.7rem); }
  .game-card .emoji { font-size: clamp(1.8rem, min(8vw, 14vh), 5rem); }
}

/* ---------- Start / win overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(24px, 3.5vh);
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  text-align: center;
  background: var(--overlay);
}
.overlay .emoji { font-size: min(7rem, 20vmin); line-height: 1.1; }   /* still: no bouncing before Play */
.overlay h2 { font-size: clamp(1.4rem, min(7vw, 7vh), 2.8rem); }

.big-btn {
  background: var(--green);
  color: #fff;
  font-size: clamp(1.3rem, min(6vw, 6vh), 2rem);
  padding: min(18px, 2.5vh) 48px;
  border-radius: 999px;
  box-shadow: 0 8px 0 #2f9c79;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #2f9c79; }

/* ---------- Confetti ---------- */
.confetti {
  position: fixed;
  top: -20px;
  width: 12px;
  height: 16px;
  z-index: 100;
  pointer-events: none;
  border-radius: 3px;
  animation: fall linear forwards;
}

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(6deg); }
}
@keyframes grow { 50% { transform: scale(1.2); } }

/* ---------- Balloon Pop ---------- */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
}
.score {
  position: fixed;
  bottom: calc(12px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--surface);
  padding: 6px 24px;
  border-radius: 999px;
  font-size: clamp(1.3rem, min(6vw, 6vh), 2rem);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.balloon-wrap { position: absolute; left: 0; top: 0; will-change: transform; cursor: pointer; padding-bottom: 60px; }
.balloon {
  position: relative;
  width: var(--s);
  height: calc(var(--s) * 1.2);
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.65) 0 11%, transparent 12%),
    var(--c);
}
.balloon::before {               /* knot */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 10px solid var(--c);
}
.balloon::after {                /* string */
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: 2px;
  height: 50px;
  background: rgba(0, 0, 0, 0.25);
}
.balloon.popped { animation: popped 0.25s forwards; }
@keyframes popped { to { transform: scale(1.6); opacity: 0; } }

/* ---------- Animal Match ---------- */
.level { flex: none; text-align: center; font-size: clamp(1rem, 3vh, 1.4rem); }
.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
}
.board { display: grid; gap: var(--gap); --cw: 100px; }
.card { width: var(--cw); height: calc(var(--cw) * 4 / 3); padding: 0; perspective: 800px; }
.card .inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s;
  transform-style: preserve-3d;
}
.card.flipped .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: calc(var(--cw) * 0.15);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
}
.card .front {
  background: var(--blue) radial-gradient(circle, rgba(255, 255, 255, 0.25) 2px, transparent 3px) 0 0 / 16px 16px;
  font-size: calc(var(--cw) * 0.4);
}
.card .back { background: var(--surface); transform: rotateY(180deg); font-size: calc(var(--cw) * 0.6); }
.card.matched .back { background: var(--matched); }
.card.matched .inner { animation: matched 0.5s 0.4s; }
@keyframes matched { 50% { transform: rotateY(180deg) scale(1.12); } }

/* ---------- Find the Color ---------- */
.prompt {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: min(12px, 1.5vh) 16px;
  font-size: clamp(1.5rem, min(8vw, 7vh), 3.2rem);
}
.prompt .word {
  text-shadow: 2px 2px 0 var(--outline), -2px 2px 0 var(--outline), 2px -2px 0 var(--outline), -2px -2px 0 var(--outline);
}
.choices {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--gap);
  --size: 120px;
}
.choice {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}
.choice:active { transform: translateY(4px); }
.choice.wrong { animation: wobble 0.5s; }
.choice.right { animation: grow 0.6s; }
.stars {
  flex: none;
  text-align: center;
  font-size: clamp(1.1rem, min(6vw, 5vh), 2.2rem);
  min-height: 1.5em;
  letter-spacing: 2px;
  padding: 0 16px min(12px, 2vh);
  white-space: nowrap;
}

/* ---------- Learn (picture cards) ---------- */
.progress {
  flex: none;
  height: 10px;
  margin: 0 16px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width 0.3s; }

.flash-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-areas: "card card" "prev next";
  align-content: center;
  justify-content: center;
  justify-items: center;
  align-items: center;
  gap: var(--gap) clamp(24px, 10vw, 80px);
  padding: var(--gap);
}
.flash-card { grid-area: card; }
.nav-btn.prev { grid-area: prev; }
.nav-btn.next { grid-area: next; }

.nav-btn {
  width: clamp(56px, 15vmin, 96px);
  height: clamp(56px, 15vmin, 96px);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(1.4rem, 6vmin, 2.6rem);
  box-shadow: var(--shadow);
}
.nav-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 47, 92, 0.15); }

.flash-card {
  --w: min(86vw, 46vh, 460px);
  --tint: var(--pink);
  width: var(--w);
  height: calc(var(--w) * 1.18);
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2%;
  padding: 6%;
  text-align: center;
  background: var(--surface);
  border: 6px solid var(--tint);
  border-radius: calc(var(--w) * 0.09);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer;
  outline: none;
}
.flash-card.pop { animation: cardIn 0.35s ease-out; }
.flash-card.tap { animation: grow 0.4s; }
@keyframes cardIn { from { transform: scale(0.85) rotate(-3deg); opacity: 0.3; } }

.fc-big { line-height: 1; font-weight: bold; color: var(--tint); font-size: 10vmin; font-size: 24cqh; }
.fc-art {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  max-width: 100%;
  line-height: 1.1;
  font-size: 16vmin; font-size: 34cqh;
}
.has-big .fc-art { font-size: 11vmin; font-size: 24cqh; }
.has-big .fc-art.some { font-size: 8vmin; font-size: 16cqh; }
.has-big .fc-art.many { font-size: 6vmin; font-size: 12cqh; }
.fc-art svg { width: 55%; width: 62cqw; height: auto; }
.fc-word { font-weight: bold; line-height: 1.1; font-size: 6vmin; font-size: 11cqh; }
.fc-sub { line-height: 1.2; opacity: 0.8; font-size: 4vmin; font-size: 7cqh; }

@media (orientation: landscape) {
  .flash-stage { grid-template-areas: "prev card next"; gap: clamp(16px, 4vw, 48px); }
  .flash-card { --w: calc(min(64vh, 540px) / 1.18); }
}

/* ---------- Number Puzzle (games/puzzle.html) ---------- */
.puzzle-page {
  --grass: #8fd16a;
  --grass-dark: #6fb84d;
  --cell: min(27vw, 22vh, 170px);                 /* size of one hole / number */
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 40%, var(--grass) 40%, var(--grass-dark));
}
:root[data-theme="dark"] .puzzle-page { --grass: #2f6b3a; --grass-dark: #234f2c; }

.scene { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.scene span { position: absolute; line-height: 1; }
.scene .tree  { left: -4vmin; top: -6vmin; font-size: 34vmin; }
.scene .cloud { right: 4vw; top: 3vh; font-size: 18vmin; opacity: 0.9; }
.scene .bush  { top: calc(40% - 9vmin); font-size: 12vmin; }
.scene .b1 { left: 38%; }
.scene .b2 { right: 6%; }
.scene .flower { font-size: 5vmin; }
.scene .f1 { left: 6%; top: 66%; }
.scene .f2 { right: 8%; top: 62%; }
.scene .f3 { left: 55%; bottom: 4%; }
.scene .leaf { bottom: -2vmin; font-size: 14vmin; }
.scene .l1 { left: -2vmin; }
.scene .l2 { right: -2vmin; }

.puzzle {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: var(--gap);
}

/* The wooden board on its stand (own class names: .board is used by Animal Match) */
.stand { display: flex; flex-direction: column; align-items: center; }
.plank {
  display: flex;
  gap: calc(var(--cell) * 0.1);
  padding: calc(var(--cell) * 0.12) calc(var(--cell) * 0.14);
  border-radius: calc(var(--cell) * 0.18);
  background:
    repeating-linear-gradient(4deg, rgba(150, 90, 40, 0.07) 0 2px, transparent 2px 11px),
    linear-gradient(#f6d39c, #dfac6a);
  box-shadow: inset 0 -5px 0 rgba(120, 70, 20, 0.18), inset 0 3px 0 rgba(255, 255, 255, 0.45),
              0 7px 0 #b98245, 0 14px 18px rgba(0, 0, 0, 0.18);
}
.legs { display: flex; justify-content: space-between; width: 72%; }
.legs span {
  width: calc(var(--cell) * 0.22);
  height: calc(var(--cell) * 0.32);
  background: linear-gradient(90deg, #9c6233, #b97a45, #9c6233);
  border-radius: 0 0 6px 6px;
}

/* Numbers: the holes and the pieces use the same chunky rounded digits */
.hole, .piece {
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  font-family: "Arial Rounded MT Bold", "Arial Rounded MT", "Comic Sans MS", "Chalkboard SE", sans-serif;
  font-weight: 900;
  font-size: calc(var(--cell) * 0.95);
  line-height: 1;
  letter-spacing: -0.04em;
}
.hole.two, .piece.two { font-size: calc(var(--cell) * 0.7); }

.hole {                                       /* carved into the wood */
  color: #b07a42;
  text-shadow: 0 -2px 2px rgba(80, 40, 10, 0.55), 0 2px 1px rgba(255, 240, 210, 0.7);
  cursor: pointer;
}
.hole.filled {
  color: var(--c);
  -webkit-text-stroke: calc(var(--cell) * 0.025) rgba(0, 0, 0, 0.18);
  text-shadow: 0 calc(var(--cell) * 0.035) 0 var(--d);
  animation: grow 0.4s;
}

.tray {
  display: flex;
  gap: calc(var(--cell) * 0.12);
  justify-content: center;
}
.piece {                                      /* a chunky coloured number to pick up */
  position: relative;
  color: var(--c);
  -webkit-text-stroke: calc(var(--cell) * 0.025) rgba(0, 0, 0, 0.18);
  text-shadow: 0 calc(var(--cell) * 0.045) 0 var(--d), 0 calc(var(--cell) * 0.09) calc(var(--cell) * 0.06) rgba(0, 0, 0, 0.25);
  cursor: grab;
  touch-action: none;
  will-change: transform;
}
.piece.dragging { z-index: 20; cursor: grabbing; }
.piece.chosen { animation: chosen 0.9s ease-in-out infinite; }
.piece.wrong { animation: wobble 0.5s; }
@keyframes chosen { 50% { transform: scale(1.12); } }

@media (orientation: landscape) {
  .puzzle-page { --cell: min(20vw, 26vh, 170px); }
  .puzzle { justify-content: space-around; }
}

/* ---------- Family Time: picture stories (family/*.html) ---------- */
.story-page { background: linear-gradient(#1d1b3a, #2c2556); color: #f3eefe; }   /* cosy, bedtime-dark */
.story {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--gap);
}
.story-scene {
  position: relative;
  flex: none;
  width: min(100%, 720px, calc((100vh - 230px) * 4 / 3));
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  container-type: inline-size;
  cursor: pointer;
}
.story-scene.turn { animation: pageIn 0.6s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: scale(0.97); } }

.art {
  position: absolute;
  line-height: 1;
  font-size: calc(var(--s) * 0.5vmin);         /* fallback for older browsers */
  font-size: calc(var(--s) * 1cqw);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}
.art.float   { animation: artFloat 4s ease-in-out infinite; }
.art.bob     { animation: artBob 2.6s ease-in-out infinite; }
.art.sway    { animation: artSway 3s ease-in-out infinite; }
.art.twinkle { animation: artTwinkle 2.2s ease-in-out infinite; }
@keyframes artFloat   { 50% { transform: translate(-50%, -62%); } }
@keyframes artBob     { 50% { transform: translate(-50%, -54%); } }
@keyframes artSway    { 0%, 100% { transform: translate(-50%, -50%) rotate(-7deg); } 50% { transform: translate(-50%, -50%) rotate(7deg); } }
@keyframes artTwinkle { 50% { transform: translate(-50%, -50%) scale(0.75); opacity: 0.55; } }

.story-side { display: flex; flex-direction: column; align-items: center; gap: min(14px, 1.8vh); width: 100%; }
.story-text {
  max-width: 32em;
  min-height: calc(1.35em * 3);                /* room for 3 lines, so the buttons do not jump */
  text-align: center;
  font-size: clamp(1.05rem, min(4.8vw, 3.4vh), 1.7rem);
  line-height: 1.35;
}
.story-nav { display: flex; gap: clamp(16px, 6vw, 40px); }
.story-nav .nav-btn { width: clamp(48px, 12vmin, 76px); height: clamp(48px, 12vmin, 76px); font-size: clamp(1.2rem, 5vmin, 2rem); }
.story-nav .nav-btn:disabled { opacity: 0.35; }
.story-nav .auto { background: var(--yellow); color: #3b2f5c; }
.story-dots { display: flex; gap: 6px; }
.story-dots span { width: 9px; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.3); transition: width 0.3s, background 0.3s; }
.story-dots span.on { width: 22px; background: var(--yellow); }
.overlay.story-end { background: rgba(16, 14, 44, 0.93); color: #f3eefe; }

@media (orientation: landscape) {
  .story { flex-direction: row; }
  .story-scene { width: min(62%, calc((100vh - 2 * var(--gap) - 10px) * 4 / 3)); }
  .story-side { flex: 1; max-width: 460px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Find the Animal (games/animals.html) — a still meadow, nothing moves until tapped ---------- */
body.animals-page { background: linear-gradient(#bfe9ff 0%, #e8f8ff 46%, #c9efa6 46%, #9fdc7c 100%); }
:root[data-theme="dark"] body.animals-page { background: linear-gradient(#1b2a55 0%, #2f4a85 46%, #24553a 46%, #1c4430 100%); }
.animals-page .prompt .word { color: #ff9f1c; }
.meadow {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: center;
  justify-content: center;
  gap: var(--gap);
  padding: var(--gap);
  --size: 120px;
}
.animal-card {
  width: var(--size);
  height: var(--size);
  border-radius: 24%;
  background: var(--surface);
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 0 rgba(59, 47, 92, 0.18);
  font-size: calc(var(--size) * 0.62);
  line-height: 1;
  display: grid;
  place-items: center;
  position: relative;
}
.animal-card:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(59, 47, 92, 0.18); }
.animal-card.wrong { animation: wobble 0.5s; }
.animal-card.done { background: #d6ffe9; border-color: #4cc9a0; animation: grow 0.5s; }
:root[data-theme="dark"] .animal-card.done { background: #1f4d3a; }
.animal-card.done::after {
  content: "⭐";
  position: absolute;
  top: -8%;
  right: -8%;
  font-size: calc(var(--size) * 0.28);
}
.found-row {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 1.6em;
  padding: 0 16px min(12px, 2vh);
  font-size: clamp(1.1rem, min(6vw, 5vh), 2rem);
}
.found-row span { opacity: 0.5; }
.found-row .on { opacity: 1; }

/* ---------- Main page (start.html): two big doors into the site ---------- */
body.start-page {
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 214, 102, 0.45), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(155, 93, 229, 0.25), transparent 45%),
    linear-gradient(160deg, #fff4e0, #ffe9f1 55%, #eee8ff);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  align-items: center;
}
:root[data-theme="dark"] body.start-page {
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 214, 102, 0.12), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(155, 93, 229, 0.25), transparent 45%),
    linear-gradient(160deg, #1d1830, #241b3d 55%, #17142b);
}
.start-hello { flex: none; text-align: center; padding: min(3vh, 24px) 16px min(2vh, 16px); }
.start-kicker {
  font-size: clamp(0.85rem, 2.4vh, 1.05rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.6;
  font-weight: 600;
}
.start-hello h2 { font-size: clamp(1.35rem, min(6.5vw, 5vh), 2.4rem); font-weight: 800; margin-top: 4px; }

.zones {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.5vmin, 28px);
  padding: 0 clamp(16px, 4vw, 40px) max(clamp(16px, 4vh, 40px), var(--safe-b));
}
@media (min-aspect-ratio: 1/1) { .zones { flex-direction: row; } }

.zone {
  flex: 1;
  min-height: 0;
  max-height: 460px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(2vh, 16px);
  padding: 20px;
  border-radius: clamp(24px, 5vmin, 40px);
  color: #fff;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 10px 0 var(--edge), 0 18px 36px rgba(59, 47, 92, 0.22);
  animation: zoneIn 0.45s ease-out both;
  transition: transform 0.12s, box-shadow 0.12s;
}
.zone:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--edge), 0 6px 14px rgba(59, 47, 92, 0.2); }
.zone-astro { animation-delay: 0.08s; }
@keyframes zoneIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } }

.zone-kids {
  --edge: #e0705f;
  background:
    radial-gradient(circle at 80% 15%, rgba(255, 255, 255, 0.45), transparent 35%),
    linear-gradient(135deg, #ff7eb3, #ff9f6b 55%, #ffd166);
}
.zone-astro {
  --edge: #24124f;
  background:
    radial-gradient(1.5px 1.5px at 18% 22%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 72% 14%, #fff, transparent),
    radial-gradient(2px 2px at 86% 58%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 30% 78%, #fff, transparent),
    radial-gradient(1px 1px at 55% 40%, #fff, transparent),
    radial-gradient(1px 1px at 10% 60%, #fff, transparent),
    radial-gradient(circle at 75% 80%, rgba(255, 196, 255, 0.35), transparent 40%),
    linear-gradient(135deg, #2a1a63, #4b2c94 55%, #7a4cc7);
}

.zone-art { position: relative; flex: none; width: min(34vmin, 170px); height: min(26vmin, 130px); }
.zone-main {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: min(20vmin, 100px); line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.18));
}
.zone-bit { position: absolute; line-height: 1; font-size: min(8vmin, 40px); }
.zone-bit.b1 { left: 0; top: 6%; transform: rotate(-12deg); }
.zone-bit.b2 { right: 0; top: 0; transform: rotate(10deg); }
.zone-bit.b3 { right: 8%; bottom: 0; font-size: min(5vmin, 26px); }

.zone-text { display: flex; flex-direction: column; gap: 4px; }
.zone-title { font-size: clamp(1.5rem, min(7.5vw, 5.2vh), 2.6rem); font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.zone-kids .zone-title { font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", sans-serif; }
.zone-astro .zone-title { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.04em; }
.zone-sub { font-size: clamp(0.9rem, min(4vw, 2.6vh), 1.2rem); opacity: 0.92; font-weight: 600; }

.zone-go {
  position: absolute; right: 18px; bottom: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.3); font-size: 18px;
}
.zone-badge {
  position: absolute; right: 16px; top: 16px;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
}
@media (max-height: 560px) {
  .zone-art { height: min(22vmin, 100px); }
  .zone-go { width: 36px; height: 36px; right: 12px; bottom: 12px; }
  .zone-badge { top: 10px; right: 10px; font-size: 0.7rem; }
}

