@font-face {
  font-family: "Fredoka";
  src: url("fonts/Fredoka-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: block;
}

/* Greek, which Fredoka has no letters for: M PLUS Rounded 1c cut to the Greek
   block and sized to Fredoka (docs/LOCALIZATION.md, item 7). The browser
   loads it only for a page with Greek on it. */
@font-face {
  font-family: "Fredoka";
  src: url("fonts/MPLUSRounded1cGreek-ExtraBold.ttf") format("truetype");
  font-weight: 600;
  font-display: block;
  unicode-range: U+0370-03FF;
}

:root {
  --sky: #EAF7F3;
  --paper: #FFFCF3;
  --card: #FFFEFA;
  --outline: #4A3A31;
  --ink: #2D4542;
  --muted: #62716C;
  --sun: #FFCB45;
  --sun-lip: #E29B1E;
  --grass: #A7DA7C;
  --grass-lip: #6BA84A;
  --coral: #FFA184;
  --lip: #DCCBA8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
  color: var(--ink);
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app {
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen[hidden] { display: none; }

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  gap: 16px;
}

h1 { font-size: 26px; margin: 8px 0 0; }
p { font-size: 18px; color: var(--muted); margin: 0; max-width: 28em; line-height: 1.35; }

.art { width: min(60vw, 240px); aspect-ratio: 1; margin-top: 8vh; }
.art svg { width: 100%; height: 100%; }

form { display: flex; flex-direction: column; gap: 14px; width: min(100%, 360px); }

/* "How to play?" under the code: quiet and folded; it opens to three
   steps for a grown-up who came here without the QR code. */
.howto { width: min(100%, 360px); }
.howto summary {
  display: block;
  min-height: 48px;
  padding: 8px 16px;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
/* An inline-block takes no underline from its parent. */
.howto summary::after { content: "\25BE"; margin-inline-start: 6px; display: inline-block; }
.howto[open] summary::after { content: "\25B4"; }
.howto summary:focus-visible { outline: 3px solid var(--outline); outline-offset: 2px; border-radius: 12px; }
.howto ol {
  margin: 4px 0 0;
  padding: 14px 16px 14px 40px;
  text-align: start;
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 18px;
}
.howto li + li { margin-top: 8px; }
.howto li::marker { font-weight: 600; }
.howto-tip { margin: 10px 4px 0; font-size: 15px; line-height: 1.35; color: var(--ink); text-align: start; }

input {
  font: inherit;
  font-size: 40px;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 8px 14px calc(8px + 0.25em);
  border: 3px solid var(--outline);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
}

button.big {
  font: inherit;
  font-size: 26px;
  padding: 16px;
  border: 3px solid var(--outline);
  border-radius: 22px;
  background: var(--sun);
  box-shadow: 0 6px 0 var(--sun-lip);
  color: var(--outline);
}

.topline {
  width: min(100%, 420px);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--muted);
}
#link-text { flex: 1; text-align: start; }
/* The gear, top right: the grown-up's settings sheet. A 48 px target. */
.gear {
  flex: none;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -6px -4px -6px 0;
  padding: 0;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--lip);
  touch-action: manipulation;
}
.gear svg { width: 26px; height: 26px; fill: currentColor; }
.gear[hidden] { display: none; }

.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--grass-lip); border: 2px solid var(--outline); }
.dot.away { background: var(--coral); }

.obstacle {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 16 / 9;
  background: var(--paper);
  border: 3px solid var(--outline);
  border-radius: 22px;
  overflow: hidden;
}
.obstacle svg { width: 100%; height: 100%; display: block; }
/* The tablet's own picture (art/<id>.webp, 16:9). In a lower box it is
   cut at the top, so the obstacle and its path stay in view. */
.obstacle img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 50% 85%; }

.choices {
  flex: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.choice {
  flex: 1;
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  font: inherit;
  font-size: clamp(34px, 11vw, 56px);
  letter-spacing: 0.04em;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--lip);
  touch-action: manipulation;
  transition: transform 60ms ease-out, opacity 150ms;
}
.choice svg { height: 100%; max-height: 110px; aspect-ratio: 1; flex: none; }
.choice span { flex: 1; text-align: left; }
.choice.pressed { transform: translateY(5px); box-shadow: 0 2px 0 var(--lip); background: #FFF4CF; }
.choices.done .choice:not(.pressed) { opacity: 0.35; }
.choices.done .choice { pointer-events: none; }
.choices.done .choice.pressed { opacity: 1; }

/* One line for the grown-up over the buttons, where a kind needs it. */
.hint { font-size: 16px; line-height: 1.3; margin: -6px 0; }
.hint[hidden] { display: none; }
/* Four buttons (three choices and the surprise) stay on one screen: a
   lower picture of the obstacle and lower buttons. */
.many .obstacle { aspect-ratio: 16 / 6; }
.many .choices { gap: 10px; }
.many .choice { min-height: 68px; padding: 6px 16px; font-size: clamp(28px, 9vw, 44px); }
.many .choice svg { max-height: 64px; }
.many.screen { gap: 12px; }
/* A short phone: the same, so three choices fit without scrolling. */
@media (max-height: 700px) {
  .obstacle { aspect-ratio: 16 / 6; }
  .choice { min-height: 68px; padding: 6px 16px; }
  .choice svg { max-height: 72px; }
}
/* The surprise: the "?" card's button. */
.choice.surprise { background: #FFF4CF; border-style: dashed; box-shadow: 0 7px 0 var(--sun-lip); }
.choice.surprise.pressed { box-shadow: 0 2px 0 var(--sun-lip); background: var(--sun); }

/* The grown-up's controls under the choices: small, never in the way. */
.grownup {
  align-self: stretch;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.grownup[hidden] { display: none; }
#finish-line {
  flex-basis: 100%;
  padding: 8px 14px;
  border-radius: 14px;
  background: #FFF4CF;
  border: 2px solid var(--sun-lip);
  font-size: 18px;
  color: var(--outline);
  text-align: center;
}
#finish-line:empty { display: none; }
.art.small-art { width: min(36vw, 140px); margin-top: 2vh; }

button.small, button.quiet {
  font: inherit;
  font-size: 18px;
  min-height: 48px;
  padding: 8px 16px;
  color: var(--outline);
  border-radius: 16px;
  touch-action: manipulation;
}
button.small { background: var(--card); border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--lip); }
button.quiet { background: none; border: none; color: var(--muted); text-decoration: underline; }
button[hidden] { display: none; }

.numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: min(100%, 420px);
  margin-top: 8px;
}
.numbers button, .kind-list button {
  font: inherit;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--lip);
  touch-action: manipulation;
}
.numbers button {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.numbers strong { font-size: clamp(48px, 16vw, 72px); line-height: 1; }
.numbers span { font-size: 18px; color: var(--muted); }
.numbers button.picked, .kind-list button.picked { background: var(--sun); box-shadow: 0 6px 0 var(--sun-lip); }
.numbers button.picked span { color: var(--outline); }
#finish-ok { width: min(100%, 420px); }

.kind-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 420px);
}
.kind-list button {
  min-height: 88px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
}
.kind-list strong { font-size: 26px; }
.kind-list span { font-size: 17px; color: var(--muted); }

/* The settings sheet: a title with Done, then the groups, each with a
   short heading; it scrolls when it is longer than the phone. */
.sheet { align-items: stretch; text-align: start; width: min(100%, 420px); margin: 0 auto; gap: 18px; }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 8px;
  background: var(--sky);
}
.sheet-head h1 { margin: 0; }
.sheet-head button { background: var(--sun); box-shadow: 0 4px 0 var(--sun-lip); min-width: 96px; }
.group { display: flex; flex-direction: column; gap: 10px; }
.group[hidden] { display: none; }
.group h2 { font-size: 21px; margin: 0; color: var(--outline); }
.group .kind-list, .group .math-settings { width: 100%; }
.note { font-size: 16px; line-height: 1.35; margin: 0; text-align: start; }
.note.strong { color: var(--outline); }
.group #open-finish { align-self: flex-start; }

/* MATH: the sum with its answer, then ✓ and HELP. */
.sum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 14px;
  font-size: clamp(34px, 11vw, 52px);
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 22px;
}
/* A long sum (big numbers): smaller digits, and it may wrap. */
.sum.long { flex-wrap: wrap; font-size: clamp(22px, 7vw, 34px); overflow-wrap: anywhere; }
.sum strong {
  padding: 2px 16px;
  background: var(--sun);
  border: 3px solid var(--outline);
  border-radius: 16px;
  font-weight: 600;
}
.choices.math .choice { justify-content: center; }
.choices.math .choice span { flex: none; text-align: center; }
.choice.ok { background: var(--grass); box-shadow: 0 7px 0 var(--grass-lip); font-size: clamp(56px, 18vw, 84px); }
.choice.ok.pressed { background: var(--grass); box-shadow: 0 2px 0 var(--grass-lip); }
.choice.help { flex: 0.6; min-height: 76px; background: #FFF4CF; box-shadow: 0 7px 0 var(--sun-lip); font-size: clamp(26px, 8vw, 38px); }
.choice.help.spent { opacity: 0.4; }

/* MATH's settings: the type of question and how hard, as tiles. */
.math-settings { width: min(100%, 420px); display: flex; flex-direction: column; gap: 8px; }
.math-settings:empty { display: none; }
.math-settings p { font-size: 16px; text-align: start; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; }
.tiles button {
  font: inherit;
  font-size: 17px;
  min-height: 56px;
  padding: 6px 4px;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--lip);
  touch-action: manipulation;
}
.tiles button.picked { background: var(--sun); box-shadow: 0 4px 0 var(--sun-lip); }

/* MATH's types (2026-10-05): one row per type, the tick with its name and
   symbol on the left, "up to" and the number on the right, the numbers in
   one column across the rows (a subgrid); a ticked row has its quick picks
   under the number, an unticked one shows the number greyed. */
.math-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 84px;
  column-gap: 8px;
  row-gap: 8px;
}
.math-type {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  row-gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 18px;
}
.math-type.on { background: #FFF4CF; }
.math-type .tick {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 4px;
  color: var(--outline);
  background: none;
  border: none;
  text-align: start;
  min-width: 0;
  touch-action: manipulation;
}
.op-name { font-size: 19px; line-height: 1.2; min-width: 0; overflow-wrap: break-word; }
.op-sign { font-size: 21px; color: var(--outline); white-space: nowrap; }
.tick-box {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 10px;
}
.math-type.on .tick-box { background: var(--grass); }
.upto-label { font-size: 16px; color: var(--outline); text-align: end; }
.math-type:not(.on) .upto-label, .upto-off { color: var(--muted); opacity: 0.7; }
.upto-off { font-size: 20px; text-align: center; }
.math-type input {
  width: 100%;
  min-height: 48px;
  font-size: 22px;
  letter-spacing: 0;
  text-transform: none;
  padding: 6px 4px;
  border-radius: 14px;
}
.math-type .picks {
  grid-column: 2 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-bottom: 4px;
}
.math-type .picks button {
  font: inherit;
  font-size: 17px;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 6px;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--lip);
  touch-action: manipulation;
}
.math-type .picks button.picked { background: var(--sun); box-shadow: 0 3px 0 var(--sun-lip); }

/* The grown-up's switches: a whole row is the button. */
.kind-list:empty, p[hidden] { display: none; }
.kind-list button.switch {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-height: 76px;
}
.switch-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.switch-text strong { font-size: 22px; letter-spacing: 0; color: var(--outline); }
.switch .knob {
  flex: none;
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 3px solid var(--outline);
  background: var(--lip);
  color: var(--outline);
  font-size: 18px;
  text-align: center;
}
.switch.on .knob { background: var(--grass); }

/* Reconnecting: three dots pulse under the "No connection" hint. */
.trying {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.trying span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  background: var(--grass);
  animation: trying 1.2s ease-in-out infinite;
}
.trying span:nth-child(2) { animation-delay: 0.2s; }
.trying span:nth-child(3) { animation-delay: 0.4s; }
@keyframes trying {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .choice { transition: none; }
  .trying span { animation-name: trying-fade; animation-duration: 2.4s; }
}
@keyframes trying-fade {
  0%, 80%, 100% { opacity: 0.4; }
  40% { opacity: 1; }
}

/* The web build's hero pick (docs/ADVENTURE_WEB.md): the four starters as
   big picture buttons, two by two; a tap picks at once, like a word. */
.hero-list {
  flex: 1;
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: center;
  gap: 14px;
}
.hero {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 26px;
  box-shadow: 0 7px 0 var(--lip);
  touch-action: manipulation;
  transition: transform 60ms ease-out, opacity 150ms;
}
.hero img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.hero.pressed { transform: translateY(5px); box-shadow: 0 2px 0 var(--lip); background: #FFF4CF; }
.hero-list.done .hero:not(.pressed) { opacity: 0.35; }
.hero-list.done .hero { pointer-events: none; }
.taster { font-size: 15px; }
.taster a { color: var(--ink); }

/* MATH's tables (2026-10-05): under a ticked TIMES or DIVIDE, the switch
   between "Up to a number" and "Tables" as two big halves; with tables, a
   line with "All", a grid of big numbers (five to a row) and one line on
   what the table asks. Picked things are sun yellow, as everywhere. */
.math-type .tick.wide, .math-type .how, .math-type .tables-head, .math-type .tables, .math-type .tables-hint { grid-column: 1 / -1; }
.math-type .how { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 0 2px 4px; }
.math-type .how button, .math-type .tables button {
  font: inherit;
  min-height: 52px;
  padding: 6px 8px;
  color: var(--outline);
  background: var(--card);
  border: 3px solid var(--outline);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--lip);
  touch-action: manipulation;
}
.math-type .how button { font-size: 17px; line-height: 1.15; }
.math-type .how button.picked, .math-type .tables button.picked, .math-type .tables-head button.picked {
  background: var(--sun);
  box-shadow: 0 4px 0 var(--sun-lip);
}
.math-type .tables-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0 0 4px; }
.math-type .tables-head span { font-size: 16px; color: var(--outline); }
.math-type .tables-head button { font: inherit; font-size: 16px; white-space: nowrap; flex: none; min-height: 44px; min-width: 72px; padding: 4px 12px; border-radius: 12px; color: var(--outline); }
.math-type .tables { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding-left: 4px; }
.math-type .tables button { font-size: 22px; padding: 4px; }
.math-type .tables-hint { font-size: 15px; line-height: 1.35; color: var(--ink); text-align: start; margin: 0; padding: 0 0 6px 4px; }
