/* Rhyming Words: its own look (a warm wooden play table, a blue and a yellow puzzle half). Calm by design: soft colors,
   slow smooth motion (0.4 to 0.8 s, ease in and out), one thing moving at a time, nothing loops or flashes. */
:root {
  --bg: #f3eee4;
  --bg-2: #ebe2d1;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --blue: #3f7fc4;
  --blue-d: #1f5fa8;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --wood: #d9a066;
  --wood-d: #a8713a;
  /* Pieces: at least 2 cm (76 CSS px) on every phone (rule 12), bigger where there's room. */
  --piece: clamp(96px, 27vw, 150px);
  --half: min(40vw, 190px, (100dvh - 380px) * .5);
  --radius: 20px;
  color-scheme: light;
}
/* Evening: dimmer and warmer (rule 4). */
body.evening { --bg: #e6dcc8; --bg-2: #dacdb4; --card: #f6eedc; }
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 10% 6%, #faf6ee 0 14%, transparent 15%), radial-gradient(circle at 92% 28%, var(--bg-2) 0 12%, transparent 13%), var(--bg);
  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 { display: block; 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); }
.demo { display: flex; justify-content: center; margin-top: 6px; }
.demo-pair { width: min(70vw, 280px); }
.demo svg, .made-pair svg { display: block; width: 100%; height: auto; }
.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 76px;
  border: 3px solid var(--ink); border-radius: 24px; font-size: 30px; 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; }
.big.plain { background: var(--card); font-size: 24px; min-height: 64px; }
.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: start; gap: 4px; font-weight: 700; font-size: 20px; line-height: 1.15; min-height: 96px;
}
.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:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.mini-num { display: inline-grid; place-items: center; min-width: 64px; padding: 2px 8px; border-radius: 999px; background: #fff; border: 2px solid var(--ink); font-size: 15px; }
.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; }
.grownups, .about { 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); }

/* play */
#play-screen { gap: 14px; justify-items: center; }
.dots { list-style: none; display: flex; justify-content: center; gap: 8px; margin: 0; padding: 0; }
.dots li { width: 18px; height: 18px; border-radius: 50%; background: #e5dccb; border: 2px solid #b9ab92; }
.dots li.now { background: var(--sun); border-color: var(--ink); }
.dots li.done { background: var(--green); border-color: var(--green-d); }
.ask { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; }
.again-btn { flex: none; width: 56px; height: 56px; border: 3px solid var(--ink); border-radius: 50%; background: var(--card); box-shadow: 0 4px 0 var(--ink); display: grid; place-items: center; }
.said { margin: 0; min-height: 30px; font-size: clamp(18px, 5vw, 22px); font-weight: 700; color: var(--green-d); }
/* The puzzle on a wooden board: the picture's half, and the empty half the knob points into. */
.board {
  display: flex; align-items: center; padding: 14px 18px; border-radius: 26px; border: 4px solid var(--ink);
  background: repeating-linear-gradient(90deg, #0000 0 26px, #ffffff14 26px 28px, #0000 28px 60px, #0000000f 60px 62px), linear-gradient(#e9b97f, var(--wood));
  box-shadow: inset 0 4px 0 #fff6, inset 0 -8px 0 var(--wood-d), 0 6px 0 #6b4a2a55;
}
.half.left { width: calc(var(--half) * 1.2); position: relative; z-index: 2; pointer-events: auto; cursor: pointer; }
.half svg, .slot svg, .piece svg { display: block; width: 100%; height: auto; overflow: visible; }
.slot { width: var(--half); margin-left: calc(var(--half) * -.2); padding: 0; border: 0; background: none; position: relative; z-index: 1; border-radius: 16px; transition: box-shadow .6s ease-in-out; }
.slot.filled { visibility: hidden; }
/* The ring when the pieces join: still and soft, never flashing. */
.board.joined { box-shadow: inset 0 4px 0 #fff6, inset 0 -8px 0 var(--wood-d), 0 0 0 6px var(--sun); transition: box-shadow .6s ease-in-out; }
/* The pieces to pick from. */
.tray { display: flex; justify-content: center; gap: clamp(10px, 4vw, 24px); flex-wrap: wrap; width: 100%; }
.piece {
  width: var(--piece); padding: 6px; border: 0; background: none; border-radius: 18px; touch-action: none; position: relative; cursor: grab;
  transition: box-shadow .6s ease-in-out, opacity .6s ease-in-out;
}
/* The piece that is moving, or has joined, sits the same size as the empty half, so it fits it exactly. */
.piece.moving { z-index: 10; }
.piece.dragging { z-index: 20; cursor: grabbing; }
/* The hint: the screen dims around it (spotlight.js, Doug's standing rule Oct 6: no circles). */
.piece.done { opacity: .35; pointer-events: none; }

/* finish */
#finish { text-align: center; padding-top: 10px; }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.made { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; animation: arrive .6s ease-in-out both; }
.made-pair { width: clamp(130px, 40vw, 200px); }
@keyframes arrive { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
.talk { margin: 0; background: #f4fbf6; border: 2px dashed var(--green-d); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; }

/* Wide screens: the board and the pieces side by side, like a puzzle and its box. */
@media (min-width: 900px) {
  :root { --half: min(220px, (100dvh - 300px) * .55); --piece: 150px; }
  #finish { max-width: 900px; margin: 0 auto; }
}
/* Phones held sideways: the board beside the pieces. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --half: min(28vw, (100dvh - 170px) * .8); --piece: min(110px, 22vh); }
  .top { min-height: 52px; padding-top: max(6px, env(safe-area-inset-top)); }
}
