/* Multiplication: its own look (a spring orchard: green morning, a patch of brown soil, wooden toy trees). A big-kid
   game, still calm: soft colors, smooth motion (0.4 to 0.8 s, ease in and out), one row at a time, nothing loops. */
:root {
  --bg: #eef4e6;
  --bg-2: #e2ecd6;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --blue: #3f7fc4;
  --blue-d: #1f5fa8;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --wood: #d9a066;
  --wood-d: #a8713a;
  /* The soil patch fits a 10 by 10 orchard; buttons stay at least 2 cm (76 CSS px) on every phone (rule 12). */
  --field: min(100vw - 32px, 420px, 100dvh - 470px);
  --btn: 76px;
  --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 { flex-direction: column; align-items: center; gap: 6px; }
.demo-grid { display: grid; grid-template-columns: repeat(4, 40px); gap: 2px; padding: 8px; border-radius: 16px; background: #c99a63; border: 3px solid var(--ink); }
.demo-grid svg { display: block; width: 100%; height: auto; }
.demo-fact { font-size: 26px; font-weight: 700; }
.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: 10px; justify-items: center; grid-template-columns: minmax(0, 1fr); }
.dots { list-style: none; display: flex; justify-content: center; gap: 8px; margin: 0; padding: 0; }
.dots li { width: 16px; height: 16px; border-radius: 50%; background: #d6e3d0; border: 2px solid #a3bc9a; }
.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 soil patch: always room for 10 rows of 10, so a fact's size shows next to the others. */
.field-wrap { display: grid; justify-items: center; gap: 4px; }
.field {
  --cell: calc((var(--field) - 24px) / 10);
  width: max(var(--field), 220px); aspect-ratio: 1; padding: 12px; display: grid; align-content: center; justify-content: center; gap: 0;
  border: 4px solid var(--ink); border-radius: 22px; box-shadow: inset 0 4px 0 #fff4, 0 6px 0 #6b4a2a55; transition: box-shadow .6s ease-in-out;
  background: radial-gradient(circle at 20% 25%, #b78653 0 3%, transparent 4%), radial-gradient(circle at 70% 80%, #b78653 0 3%, transparent 4%), #c99a63;
}
.field.right { box-shadow: inset 0 4px 0 #fff4, 0 0 0 6px var(--sun); }
.row { display: flex; }
.spot { width: var(--cell); height: var(--cell); display: grid; place-items: center; position: relative; }
/* A hole for each tree in the plan. */
.spot::before { content: ''; position: absolute; width: 38%; height: 26%; top: 60%; border-radius: 50%; background: #7e5530; opacity: .75; }
.spot svg { position: relative; display: block; width: 100%; height: 100%; opacity: 0; transform: translateY(18%) scale(.6); transition: opacity .5s ease-in-out, transform .5s ease-in-out; }
.row.up .spot svg { opacity: 1; transform: none; }
.fact { margin: 0; min-height: 34px; font-size: 28px; font-weight: 700; }
/* Rows and trees in each row: big plus and minus buttons. */
.controls { display: grid; gap: 8px; width: min(100%, 460px); }
.stepper { display: grid; grid-template-columns: 1fr var(--btn) 64px var(--btn); align-items: center; gap: 8px; }
.stepper .lab { font-weight: 700; font-size: 20px; }
.stepper .val { text-align: center; font-size: 34px; }
.step {
  width: var(--btn); height: 64px; border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--ink);
  display: grid; place-items: center;
}
.step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.step:disabled { opacity: .4; }
.stepper.locked .step { visibility: hidden; }
.controls .big { min-height: 68px; }
.controls .big:disabled { opacity: .55; }

/* finish */
#finish { text-align: center; padding-top: 10px; }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; animation: arrive .6s ease-in-out both; }
.facts li { padding: 6px 14px; border: 3px solid var(--ink); border-radius: 14px; background: var(--card); font-size: 22px; font-weight: 700; }
.round-total { margin: 0; font-size: 20px; font-weight: 700; }
@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 orchard on the left, the buttons on the right. */
@media (min-width: 900px) {
  :root { --field: min(520px, 100dvh - 260px); }
  #play-screen { grid-template-columns: auto minmax(0, 420px); justify-content: center; align-items: center; column-gap: 40px; }
  .dots, .ask { grid-column: 1 / -1; }
  #finish { max-width: 900px; margin: 0 auto; }
}
/* Phones held sideways: the orchard beside the buttons. */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --field: min(46vw, 100dvh - 150px); }
  #play-screen { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 20px; }
  .dots, .ask { grid-column: 1 / -1; }
  .top { min-height: 52px; padding-top: max(6px, env(safe-area-inset-top)); }
}
