/* Shape Quilt: its own look (warm linen, fabric patches with stitched edges, a soft basket for the tray).
   Calm by design: soft colors, slow smooth motion (0.4 to 0.8 s, ease in and out), one thing moving at a time. */
:root {
  --paper: #f6ecd9;
  --card: #fffaf0;
  --linen: #fbf3e2;
  --ink: #4a3620;
  --soft: #7a6047;
  --thread: #b89a6a;
  --green: #5f9a5a;
  --green-d: #42763f;
  --sun: #e9b949;
  --radius: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 500 18px/1.45 'Fredoka', system-ui, sans-serif;
  overscroll-behavior: none;
}
h1, h2 { font-weight: 700; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: #2f5f8f; }
[hidden] { display: none !important; }

/* 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 svg { display: block; }
.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(24px + env(safe-area-inset-bottom)); }
.screen { display: grid; gap: 18px; }

/* home */
.hero { text-align: center; display: grid; gap: 8px; justify-items: center; }
.hero h1 { font-size: clamp(34px, 9vw, 52px); }
.lede { margin: 0; font-size: 20px; color: var(--soft); }
.demo { width: min(46vw, 190px); 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; }
.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: 8px 4px 10px;
  display: grid; justify-items: center; align-content: start; gap: 2px; font-weight: 700; font-size: 17px; line-height: 1.15; min-height: 56px;
}
.pick button svg { width: min(22vw, 96px); height: auto; margin-bottom: 4px; }
.pick button small { font-size: 14px; font-weight: 500; color: var(--soft); }
.pick button[aria-pressed='true'] { background: #e3f0de; 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); }
.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 #4a362033; }
.grownups summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.grownups p, .about p { margin: 10px 0 0; }
.about h2 { font-size: 22px; }
.small { font-size: 14px; color: var(--soft); }
.grown-text, .parents { display: grid; gap: 8px; }
.grown-text h2, .parents h2 { margin: 8px 0 0; }
.grown-text h3 { margin: 6px 0 0; font-size: 19px; }
.grown-text p, .grown-text ul, .parents p { margin: 0; }
.grown-text ul { padding-left: 22px; display: grid; gap: 6px; }

/* the board: one picture with the quilt square and the tray */
#play-screen { gap: 8px; }
.dots { list-style: none; display: flex; justify-content: center; gap: 6px; margin: 0; padding: 0; }
.dots li { width: 16px; height: 16px; border-radius: 4px; background: #eadbbd; border: 2px solid #cdb68b; }
.dots li.now { background: var(--sun); border-color: var(--ink); }
.dots li.done { background: var(--green); border-color: var(--green-d); }
.board-wrap { position: relative; height: min(calc(100dvh - 150px - env(safe-area-inset-top)), calc((min(100vw, 792px) - 32px) * 1.5)); min-height: 260px; }
#board { display: block; width: 100%; height: 100%; touch-action: none; }
.said { margin: 0; min-height: 26px; text-align: center; font-size: 17px; color: var(--soft); }
.next { position: absolute; z-index: 2; width: auto; animation: fade .5s ease-in-out both; }

.patch { fill: var(--linen); stroke: #c9ad7f; stroke-width: .8; }
.patch-stitch { fill: none; stroke: var(--thread); stroke-width: .45; stroke-dasharray: 1.6 1.2; }
.hole { fill: #ecdcbc; stroke: var(--thread); stroke-width: .7; stroke-dasharray: 1.8 1.2; stroke-linejoin: round; transition: stroke-width .6s ease-in-out; }
.hole.want { stroke: #c8902a; stroke-width: 1.1; }
.big-hole { stroke: #a8885a; stroke-width: 1; stroke-dasharray: none; }
.deco { fill: none; stroke: #8a6d4b; stroke-width: .9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.deco.dot { fill: #5a432a; stroke: none; }
.basket { fill: #f1e2c4; stroke: #d2b98d; stroke-width: .6; }

/* fabric pieces */
.piece .cloth { stroke: #00000038; stroke-width: 2px; stroke-linejoin: round; transition: stroke-width .6s ease-in-out; }
.piece .stitch { fill: none; stroke: #ffffffa8; stroke-width: 1.5px; stroke-dasharray: 4 3; }
.f-circle .cloth { fill: #d98896; }
.f-square .cloth { fill: #f0a98a; }
.f-triangle .cloth { fill: #8fae7e; }
.f-rectangle .cloth { fill: #a58fc0; }
.f-hexagon .cloth { fill: #e0b44c; }
.f-trapezoid .cloth { fill: #c7654d; }
.f-rhombus .cloth { fill: #5b7fa6; }
.f-thin .cloth { fill: #cdb48a; }
.layer-tray .piece, .layer-fly .piece { cursor: grab; }
.piece.lifted .cloth { stroke-width: 3px; }
/* The hint: the screen dims around it (spotlight.js, Doug's standing rule Oct 6: no circles). */
.piece.ghost { opacity: .35; animation: fade .6s ease-in-out both; pointer-events: none; }
.piece.ghost .stitch { display: none; }
.piece.nope { animation: nope .7s ease-in-out; }
.piece.arrive { animation: fade .5s ease-in-out both; }
.piece.leave { opacity: 0; transition: opacity .5s ease-in-out; pointer-events: none; }

/* finish: the quilt with a kitten asleep under it */
#finish { text-align: center; padding-top: 6px; gap: 14px; }
.cheer { font-size: clamp(30px, 8vw, 44px); }
.quilt-bed { display: grid; justify-items: center; animation: fade .6s ease-in-out both; }
.quilt {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; width: min(100%, 420px); background: #c7654d;
  border-radius: 16px; border: 3px solid var(--ink); box-shadow: 0 6px 0 #4a362055; outline: 2px dashed #ffffff99; outline-offset: -7px;
}
.quilt svg { display: block; width: 100%; height: auto; }
.kitten { width: min(46%, 190px); margin-top: -10px; }
.talk { margin: 0; background: #fff8e6; border: 2px dashed var(--thread); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; }

/* Evening look (after 6 PM unless a grown-up changes it): dimmer and warmer, same layout. */
body.evening { --paper: #e6d4b2; --card: #f1e4c8; background: var(--paper); }
body.evening main, body.evening .top { filter: brightness(.86) sepia(.18); }

/* Motion: slow, smooth, once. Nothing loops or shakes. */
@keyframes fade { from { opacity: 0; } }
@keyframes nope { 40% { opacity: .5; } }

@media (min-width: 700px) {
  .big { max-width: 520px; justify-self: center; }
  .next { max-width: none; }
}
/* short, wide screens (a phone held sideways): less room above the board */
@media (orientation: landscape) and (max-height: 520px) {
  .top { min-height: 52px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 2px; }
  .board-wrap { height: calc(100dvh - 104px); }
  .said { min-height: 0; font-size: 15px; }
  .dots li { width: 12px; height: 12px; }
  .next { min-height: 64px; font-size: 26px; }
}
