/* Classic Stories: a warm storybook look (cream paper, a wooden shelf of friends), in the arcade's wooden-toy style.
   Calm by design: soft colors, slow smooth motion (0.4 to 0.8 s, ease in and out), one thing changing at a time,
   nothing loops or flashes. The word being read gets a soft, still highlight. */
:root {
  --paper: #f6efe2;
  --paper-2: #ece2cf;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --blue: #3f7fc4;
  --blue-d: #1f5fa8;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --sun-l: #fde9b0;
  --wood: #d9a066;
  --wood-d: #a8713a;
  --radius: 20px;
  color-scheme: light;
}
/* Evening: dimmer and warmer (rule 4). */
body.evening {
  --paper: #e9dcc4;
  --paper-2: #dccdb1;
  --card: #f6eedc;
  --green: #3d8a47;
  --sun-l: #f1dca6;
}
body.evening main, body.evening .top { filter: brightness(.9); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(circle at 12% 8%, #fbf7ee 0 14%, transparent 15%), radial-gradient(circle at 92% 30%, var(--paper-2) 0 10%, transparent 11%), var(--paper);
  color: var(--ink);
  font: 500 18px/1.45 'Fredoka', system-ui, sans-serif;
  overscroll-behavior: none;
  overflow-x: hidden;
}
h1, h2 { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue-d); }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 6px; min-height: 64px; }
.grow { flex: 1; }
.brand { width: 40px; height: 40px; }
.back, .round {
  min-height: 48px; min-width: 48px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card);
  box-shadow: 0 4px 0 var(--ink); font-weight: 700; padding: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.back:active, .round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#sound .mute { display: none; }
#sound[aria-pressed='false'] .mute { display: inline; }
#sound[aria-pressed='false'] .waves { display: none; }

main { max-width: 1600px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: 18px; }

/* home */
.hero { text-align: center; display: grid; gap: 8px; padding-top: 4px; }
.hero h1 { font-size: clamp(34px, 10vw, 54px); }
.lede { margin: 0; font-size: 20px; color: var(--soft); }

.pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.pick legend { font-weight: 700; font-size: 18px; margin-bottom: 8px; padding: 0; }
.pick button {
  border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--ink); padding: 10px 4px;
  display: grid; justify-items: center; align-content: center; gap: 2px; font-weight: 700; font-size: 20px; line-height: 1.15; min-height: 80px;
}
.pick button small { font-size: 14px; font-weight: 500; color: var(--soft); }
.pick button[aria-pressed='true'] { background: #dff3e1; border-color: var(--green-d); box-shadow: 0 4px 0 var(--green-d); outline: 3px solid var(--green); outline-offset: 1px; }
.pick button[aria-pressed='true']::before { content: '\2713'; color: var(--green-d); font-size: 18px; line-height: 1; }
.pick button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips button { display: inline-flex; min-height: 48px; padding: 6px 14px; font-size: 18px; align-items: center; }
.chips button[aria-pressed='true']::before { content: none; }

/* The shelf of friends: big cards, each one a tap. */
.friends { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.friend {
  display: grid; justify-items: center; align-content: start; gap: 4px; padding: 10px 8px 12px; min-height: 196px;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 var(--wood-d);
  text-align: center;
}
.friend:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--wood-d); }
.friend img { width: min(120px, 100%); height: auto; aspect-ratio: 1; }
.friend .n { font-weight: 700; font-size: 18px; line-height: 1.15; }

.grownups, .about, .credits { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 5px 0 #3b2a1a33; }
.grownups summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.grownups p, .about p { margin: 10px 0 0; }
.about h2 { font-size: 22px; margin-top: 14px; }
.about h2:first-child { margin-top: 0; }
.about h3 { font-size: 18px; margin: 12px 0 0; }
.about ul { padding-left: 22px; display: grid; gap: 6px; }
.small { font-size: 14px; color: var(--soft); }
.credits { border-width: 2px; box-shadow: none; font-size: 14px; color: var(--soft); }
.credits h2 { font-size: 18px; color: var(--ink); }
.credits p { margin: 8px 0 0; }
.credits ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }

/* a friend's card */
.card-big {
  display: grid; justify-items: center; gap: 8px; width: min(100%, 560px); padding: 16px; background: var(--card);
  border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 7px 0 var(--wood-d);
}
.card-big img { width: min(220px, 56vw, 30dvh); height: auto; aspect-ratio: 1; }
.card-big h2 { font-size: clamp(28px, 8vw, 40px); }
.free { margin: 0; font-size: 22px; font-weight: 700; color: var(--green-d); background: #e7f4e3; border: 2px solid var(--green-d); border-radius: 999px; padding: 4px 16px; }
.why { margin: 0; font-size: 19px; }
.source { margin: 0; }

.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: min(100%, 560px); min-height: 76px;
  border: 3px solid var(--ink); border-radius: 24px; font-size: 28px; font-weight: 700; box-shadow: 0 7px 0 var(--ink); padding: 10px 20px;
}
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.big.go { background: var(--green); color: #fff; text-shadow: 0 2px 0 #0003; }

/* "Watch the original" and the film screen */
.big.film-btn { background: var(--sun-l); }
#film { justify-items: center; text-align: center; }
.film-h { font-size: clamp(24px, 6vw, 34px); }
.film-silent { margin: 0; font-size: 19px; }
.film-box { width: min(100%, 960px); border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; background: #111; box-shadow: 0 6px 0 var(--wood-d); }
.film-box video { display: block; width: 100%; max-height: 62dvh; aspect-ratio: 4 / 3; background: #111; }
.film-source { margin: 0; max-width: 960px; color: var(--soft); overflow-wrap: anywhere; }
/* Grown-ups only: keep the film on this phone (Saved Videos). Small and plain, below the credit. */
.film-save { min-height: 48px; padding: 6px 16px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--ink); font-weight: 700; font-size: 17px; }
.film-save:disabled { opacity: .6; }
.film-saved { margin: 0; }
.film-saved:empty { display: none; }

/* the story */
#story { gap: 12px; min-height: calc(100dvh - 110px); grid-template-rows: auto 1fr auto; }
.dots { list-style: none; display: flex; justify-content: center; gap: 6px; margin: 0; padding: 0; }
.dots li { width: 16px; height: 16px; border-radius: 50%; background: var(--paper-2); border: 2px solid #c9b79a; }
.dots li.now { background: var(--sun); border-color: var(--ink); }
.dots li.done { background: var(--green); border-color: var(--green-d); }
.page {
  display: grid; justify-items: center; align-content: center; gap: 14px; padding: 16px; background: var(--card);
  border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--wood-d); max-width: 900px; width: 100%; margin: 0 auto;
}
.page img { width: min(200px, 46vw, 26dvh); height: auto; aspect-ratio: 1; }
.page.arrive { animation: arrive .6s ease-in-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.words { margin: 0; font-size: clamp(22px, 5.4vw, 32px); line-height: 1.5; font-weight: 600; text-align: center; max-width: 34ch; }
.words .w { border-radius: 8px; padding: 0 2px; }
/* The word being said: a soft, still yellow behind it and an underline, so it never depends on color alone. */
.words .w.on { background: var(--sun-l); box-shadow: inset 0 -3px 0 var(--sun); }
.turn { display: flex; justify-content: space-between; align-items: center; gap: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.hear-btn { min-width: 64px; min-height: 64px; border-radius: 20px; background: var(--sun); }
.next-btn {
  width: 104px; height: 104px; border-radius: 50%; border: 4px solid var(--ink); background: var(--green); color: #fff;
  box-shadow: 0 7px 0 var(--green-d); display: grid; place-items: center;
}
.next-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-d); }

/* the tiny game */
#game { gap: 14px; }
.ask-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; max-width: 900px; width: 100%; margin: 0 auto; }
.ask-row img { width: 64px; height: 64px; }
.ask { margin: 0; font-size: clamp(22px, 5vw, 28px); font-weight: 700; }
.board, .answers { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 900px; margin: 0 auto; }
.said { margin: 0; text-align: center; min-height: 32px; font-size: 22px; font-weight: 700; color: var(--green-d); }

.thing, .card, .choice {
  position: relative; display: grid; place-items: center; width: clamp(96px, 26vw, 140px); aspect-ratio: 1; padding: 8px;
  background: var(--card); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--wood-d);
}
.thing img, .card img, .choice img, .slot img { width: 100%; height: 100%; object-fit: contain; }
.thing:active, .card:active, .choice:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--wood-d); }
.thing .num, .thing .check {
  position: absolute; top: -10px; right: -10px; width: 40px; height: 40px; border-radius: 50%; display: none; place-items: center;
  background: var(--green); color: #fff; border: 3px solid var(--ink); font-size: 22px; font-weight: 700;
}
.thing.counted .num, .thing.found .check { display: grid; }
.thing .check::before { content: '\2713'; }
.thing.counted, .thing.found { background: #e7f4e3; border-color: var(--green-d); }
.numb {
  min-width: 96px; min-height: 96px; border: 4px solid var(--ink); border-radius: 24px; background: var(--card);
  box-shadow: 0 6px 0 var(--ink); font-size: 44px; font-weight: 700;
}
.numb:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.numb.right { background: #dff3e1; border-color: var(--green-d); }
/* The hint: the screen dims around it (spotlight.js, Doug's standing rule Oct 6: no circles). */

/* Find the pair: cards turn over slowly. */
.card { padding: 0; perspective: 600px; background: transparent; border: 0; box-shadow: none; }
.card .back, .card .front {
  position: absolute; inset: 0; border: 3px solid var(--ink); border-radius: 20px; display: grid; place-items: center; padding: 10px;
  backface-visibility: hidden; transition: transform .6s ease-in-out;
}
.card .back { background: repeating-linear-gradient(45deg, var(--wood) 0 10px, #e2b07a 10px 20px); box-shadow: 0 5px 0 var(--wood-d); }
.card .front { background: var(--card); transform: rotateY(180deg); box-shadow: 0 5px 0 var(--wood-d); }
.card.up .back { transform: rotateY(-180deg); }
.card.up .front { transform: none; }
.card.found .front { background: #e7f4e3; border-color: var(--green-d); }

/* Which comes next: numbered slots, then the choices. */
.board.next { flex-wrap: nowrap; gap: 8px; }
.slot {
  position: relative; display: grid; place-items: center; width: clamp(70px, 21vw, 130px); aspect-ratio: 1; padding: 8px;
  border: 3px dashed #c9b79a; border-radius: 18px; background: #fbf6ec;
}
.slot.placed { border-style: solid; border-color: var(--green-d); background: #e7f4e3; }
.slot.placed img { animation: arrive .6s ease-in-out both; }
.slot .n { position: absolute; top: 4px; left: 8px; font-weight: 700; color: var(--soft); font-size: 16px; }

/* finish */
#finish { text-align: center; justify-items: center; padding-top: 10px; }
#finish img { width: min(160px, 40vw); height: auto; aspect-ratio: 1; }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.talk { margin: 0; background: #f6fbf2; border: 2px dashed var(--green-d); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; max-width: 640px; }
.talk.fact { background: #fff8e8; border-color: var(--wood-d); }

/* Phones held sideways: picture beside the words. */
@media (orientation: landscape) and (max-height: 520px) {
  .top { min-height: 52px; padding-top: max(6px, env(safe-area-inset-top)); }
  #story { min-height: 0; }
  .page { grid-template-columns: auto 1fr; }
  .page img { width: min(160px, 34dvh); }
  .next-btn { width: 88px; height: 88px; }
}
