/* PLAYRADOX: flat colour, bold type, a lime mascot and room to play.
   Rules and reasons: design-system/paradox-pocket/MASTER.md. Use these tokens, not raw values. */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('src/fonts/bricolage-grotesque-latin-variable.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito Sans';
  src: url('src/fonts/nunito-sans-latin-variable.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  /* Brand */
  --cream: #fffdec;
  --ink: #111332;
  --ink-soft: #57586e;
  --lavender: #c5b6f2;
  --lavender-light: #ede7fc;
  --mascot-bg: #c3b4f5;
  --lime: #bcef00;
  --lime-dark: #a8d900;
  --orange: #f56538;

  /* Surfaces */
  --paper: #f1efdf;
  --paper-2: #fffef6;
  --line: #e4dfcc;
  --play-bg: #f0ebfc;
  --pencil: #686979;

  /* Accents */
  --mint: #c6eacb;
  --pink: #f6c6df;
  --blue: #c5d9fa;
  --red-ink: #a13223;
  --blue-ink: #3634a7;
  --wrong-bg: #fbe0d5;
  --wrong-ink: #923522;
  --info-bg: #e3edcf;
  --info-ink: #354c28;
  --hint-bg: #f0f6cf;

  /* Type */
  --font-display: 'Bricolage Grotesque', ui-rounded, system-ui, sans-serif;
  --font-body: 'Nunito Sans', system-ui, sans-serif;

  /* Shape */
  --radius-s: 14px;
  --radius-m: 20px;
  --radius-l: 30px;
  --tap: 52px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Motion */
  --t-press: 130ms;
  --t-ui: 220ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

html {
  min-width: 280px;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
  /* Pinch zoom stays on for accessibility; this only stops accidental double-tap zoom. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
body[data-screen='play'] {
  background: var(--play-bg);
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
p {
  margin-top: 0;
  text-wrap: pretty;
}
a {
  color: var(--blue-ink);
  text-underline-offset: 4px;
}
img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
:focus-visible {
  outline: 3px solid var(--blue-ink);
  outline-offset: 4px;
}
h1[tabindex='-1']:focus,
h2[tabindex='-1']:focus {
  outline: none;
}

.eyebrow {
  margin: 0 0 var(--space-3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#app {
  width: min(1184px, 100%);
  margin: 0 auto;
  padding: var(--space-2) max(40px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom))
    max(40px, env(safe-area-inset-left));
}

/* ---------- Icons and doodles ---------- */
.icon-line {
  flex: none;
  width: 24px;
  height: 24px;
}
.doodle {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  vertical-align: middle;
  overflow: visible;
  flex: none;
}

/* ---------- Brand bar: the logo leads home from every screen ---------- */
.brand-bar {
  width: min(1184px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(40px, env(safe-area-inset-right)) 14px
    max(40px, env(safe-area-inset-left));
}
.brand-home {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-1);
  margin-left: calc(-1 * var(--space-1));
  border-radius: var(--radius-s);
}
.brand-home img {
  width: 210px;
  height: auto;
}
body[data-screen='launch'] .brand-bar {
  display: none;
}

/* ---------- Launch: the logo pops in while the game starts ---------- */
.launch-screen {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--lavender);
}
.launch-logo {
  width: min(480px, 80vw);
  height: auto;
  animation: logo-reveal 850ms var(--ease-spring) both;
}
.launch-tagline {
  margin: var(--space-4) 0 0;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.06em;
  animation: rise 350ms 300ms both;
}

/* ---------- Buttons: flat and rounded; the hit area never moves ---------- */
.btn,
.choice,
.hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 24px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  transition:
    background-color var(--t-ui),
    scale var(--t-press) var(--ease-out);
}
.btn.primary {
  background: var(--ink);
  color: var(--cream);
}
.btn.ghost {
  background: transparent;
  border: 1.5px solid #cbc8b9;
}
.btn.small {
  min-height: 48px;
  padding: 8px 16px;
  font-size: 14px;
}
.btn .icon-line,
.btn .doodle {
  width: 22px;
  height: 22px;
}
.icon {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border-radius: 50%;
  background: var(--paper);
  transition: background-color var(--t-ui);
}
.icon .doodle,
.icon .icon-line {
  width: 24px;
  height: 24px;
}
:is(.btn, .choice, .hint-btn, .icon, .tile, .grid .cell, .door, .room[data-room]):active:not(:disabled) {
  scale: 0.97;
}
@media (hover: hover) {
  .btn.primary:hover:not(:disabled) {
    background: #2b2d50;
  }
  .btn.ghost:hover:not(:disabled) {
    background: var(--paper);
  }
  .btn:not(.primary, .ghost):hover:not(:disabled),
  .choice:hover:not(:disabled),
  .icon:hover:not(:disabled) {
    background: var(--lavender);
  }
  .hint-btn:hover:not(:disabled) {
    background: var(--lime-dark);
  }
  .grid .cell:hover:not(:disabled),
  .tile:hover {
    box-shadow: inset 0 0 0 2px var(--ink);
  }
}

/* ---------- Screens rise in ---------- */
.menu,
.levels,
.board-screen,
.onboarding,
.play {
  animation: rise 260ms var(--ease-out) backwards;
}

/* ---------- Menu: one expressive hero, destinations underneath ---------- */
.hero-panel {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
  border-radius: 34px;
  background: var(--mascot-bg);
}
.hero-copy {
  padding: 42px 42px 38px;
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-right: 0;
  border-radius: 34px 0 0 34px;
}
.hero-copy .eyebrow {
  color: var(--ink-soft);
}
.hero-copy h1 {
  margin: 0 0 var(--space-4);
  font-size: clamp(40px, 4.8vw, 60px);
  line-height: 0.96;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}
.tagline {
  max-width: 32ch;
  margin: 0 0 var(--space-5);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.menu-buttons {
  display: flex;
}
.menu-buttons .btn {
  flex: 1;
  max-width: 320px;
  min-height: 56px;
  font-size: 17px;
}
.hero-art {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 380px;
}
.hero-art > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}
.art-sticker {
  position: absolute;
  z-index: 1;
  top: 24px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  padding: 12px;
  background: var(--orange);
  color: var(--ink);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  text-transform: uppercase;
  rotate: 12deg;
}

.menu-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 92px;
  padding: 18px 22px;
  border-radius: 24px;
  background: var(--paper);
  text-align: left;
  transition: scale var(--t-press) var(--ease-out);
}
.daily-tile {
  background: var(--lime);
}
.levels-tile {
  background: var(--lavender);
}
.board-tile {
  background: var(--pink);
}
.tile-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border: 1.5px solid rgb(17 19 50 / 22%);
  border-radius: 50%;
}
.tile-copy {
  flex: 1;
  min-width: 0;
}
.tile-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.tile-copy small {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #3f4054;
}
.daily-count {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}
.tile-done {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--ink);
  color: var(--lime);
}
.tile-done .icon-line {
  width: 20px;
  height: 20px;
}

.streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  font-weight: 800;
}
.streak .doodle {
  width: 24px;
  height: 24px;
}
.note {
  margin: var(--space-3) 0 0;
  color: var(--ink-soft);
  text-align: center;
}
.streak:empty,
.note:empty {
  display: none;
}

/* Today's top solvers: a mint panel under the tiles */
.top-note {
  margin-top: var(--space-4);
  padding: 20px 24px;
  border-radius: 24px;
  background: var(--mint);
}
.top-note h2 {
  margin: 0 0 var(--space-3);
  font-size: 22px;
}
.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.top-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 42px;
  font-weight: 700;
}
.top-row .who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.top-row .stat {
  white-space: nowrap;
  font-weight: 400;
}
.top-row.mine .who {
  text-decoration: underline 3px var(--ink);
  text-underline-offset: 5px;
}
.top-total {
  margin: var(--space-2) 0 0;
  font-size: 14px;
}
.top-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.top-you {
  font-weight: 800;
}
/* Wide screens: the note sits beside the hero, so the whole menu still fits on one screen */
@media (min-width: 900px) and (min-height: 501px) {
  .menu:has(.top-note:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    column-gap: var(--space-4);
  }
  .menu:has(.top-note:not([hidden])) > * {
    grid-column: 1 / -1;
  }
  .menu:has(.top-note:not([hidden])) > .hero-panel {
    grid-column: 1;
    grid-row: 1;
  }
  .menu:has(.top-note:not([hidden])) .hero-copy {
    padding: 30px 32px;
  }
  .menu:has(.top-note:not([hidden])) .hero-copy h1 {
    font-size: clamp(34px, 3.4vw, 46px);
  }
  .menu:has(.top-note:not([hidden])) .hero-art {
    min-height: 0;
  }
  .menu:has(.top-note:not([hidden])) > .top-note {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }
}

/* ---------- Welcome slides ---------- */
.onboarding {
  max-width: 1020px;
  margin: 0 auto;
}
.intro-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.intro-count {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}
.skip-intro {
  min-height: 48px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.intro-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border-radius: 32px;
  background: var(--lavender-light);
}
.intro-1 .intro-layout {
  background: var(--lime);
}
.intro-2 .intro-layout {
  background: var(--pink);
}
.intro-art {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 460px;
  background: var(--mascot-bg);
}
.intro-art > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.intro-art .art-sticker {
  width: 100px;
  height: 100px;
  font-size: 14px;
}
.intro-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 44px 42px 32px;
}
.intro-copy h1 {
  margin: 0 0 var(--space-4);
  font-size: clamp(38px, 4vw, 54px);
  line-height: 1;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}
.intro-body {
  max-width: 34ch;
  font-size: 17px;
  color: var(--ink);
}
.intro-dots {
  display: flex;
  margin: var(--space-1) 0 var(--space-3) -14px;
}
.intro-dots button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
}
.intro-dots button::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 8px;
  background: var(--pencil);
  transition: width var(--t-ui);
}
.intro-dots button[aria-current='step']::after {
  width: 26px;
  background: var(--ink);
}
.intro-actions {
  display: flex;
  width: 100%;
  gap: 10px;
  margin-top: auto;
}
.intro-actions .btn.primary {
  flex: 1;
}
.intro-note {
  margin: var(--space-3) 0 0;
  font-size: 13px;
  color: var(--ink);
}

/* ---------- Level select ---------- */
.levels,
.board-screen {
  max-width: 860px;
  margin: var(--space-2) auto 0;
}
.levels-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.levels-head h2 {
  flex: 1;
  margin: 0;
  font-size: clamp(34px, 4vw, 48px);
}
.progress {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.grid .cell {
  position: relative;
  min-height: 132px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  border-radius: 22px;
  background: var(--lavender-light);
  text-align: left;
  transition:
    background-color var(--t-ui),
    box-shadow var(--t-ui),
    scale var(--t-press) var(--ease-out);
  animation: pop-in 0.35s var(--ease-spring) backwards;
  animation-delay: calc(var(--i, 0) * 0.03s);
}
.grid .cell .num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
}
.grid .cell .level-name {
  display: block;
  margin-top: var(--space-3);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}
.grid .cell .mark {
  position: absolute;
  top: 16px;
  right: 16px;
  line-height: 0;
}
.grid .cell .mark .doodle {
  width: 28px;
  height: 28px;
}
.grid .cell.next {
  background: var(--lime);
}
.grid .cell.done {
  background: var(--mint);
}
.grid .cell.locked {
  background: var(--paper);
  color: var(--pencil);
  opacity: 1;
}
.grid .cell.locked .mark .doodle {
  width: 22px;
  height: 22px;
}
.chapter + .chapter {
  margin-top: var(--space-6);
}
.chapter-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0 0 var(--space-3);
  font-size: 22px;
}
.chapter-num {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- Leaderboard ---------- */
.board-screen {
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.board-screen .levels-head {
  margin-bottom: 0;
}
.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--paper);
  border-radius: var(--radius-m);
}
.tab {
  flex: 1;
  min-height: var(--tap);
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 15px;
  font-weight: 800;
}
.tab[aria-pressed='true'] {
  background: var(--ink);
  color: var(--cream);
}
.board-paper {
  padding: var(--space-4) var(--space-5);
  border: 1.5px solid var(--line);
  border-radius: 24px;
  background: var(--paper-2);
}
.board-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  color: var(--ink-soft);
  font-size: 14px;
}
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.board-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.board-row:last-child {
  border-bottom: 0;
}
.board-row .who {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.board-row .stat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.board-row .stat .doodle {
  width: 18px;
  height: 18px;
}
.board-row.mine {
  background: var(--lavender-light);
  border-radius: var(--radius-s);
  border-bottom-color: transparent;
}
.sticker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--paper);
  font-size: 14px;
  font-weight: 800;
}
.medal-1 .sticker {
  background: var(--lime);
}
.medal-2 .sticker {
  background: var(--lavender);
}
.medal-3 .sticker {
  background: var(--pink);
}
.board-gap {
  padding: 6px;
  text-align: center;
  color: var(--ink-soft);
  letter-spacing: 0.3em;
}
.board-me {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-m);
  background: var(--lavender-light);
  text-align: center;
}
.board-me:empty {
  display: none;
}
.board-me p {
  margin: 0 0 var(--space-3);
}
.board-me strong {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.02em;
}
.me-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}
.board-small {
  margin: 0;
  text-align: center;
  font-size: 14px;
}
.board-small a,
.privacy-back a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
}

/* ---------- Play: one card in the middle of the screen ---------- */
.play {
  position: relative;
  width: min(640px, 100%);
  margin: max(0px, calc((100dvh - 760px) / 2)) auto 0;
  padding: 22px 32px 30px;
  display: flex;
  flex-direction: column;
  border: 1.5px solid #e6e1cf;
  border-radius: var(--radius-l);
  background: var(--paper-2);
}
.bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.bar-title {
  flex: 1;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hint-btn {
  min-width: 112px;
  padding: 10px 20px;
  border-radius: var(--radius-l);
  background: var(--lime);
  font-size: 15px;
}
.hint-btn .doodle {
  width: 22px;
  height: 22px;
}
.hint-btn[aria-busy='true'] {
  animation: breathe 1s ease-in-out infinite;
}
.title {
  margin: 0 0 var(--space-3);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: #6a5a80;
}
.prompt {
  margin: 0;
  text-align: center;
  font: 800 clamp(25px, 3.1vw, 32px) / 1.1 var(--font-display);
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.stage {
  position: relative;
  min-height: 280px;
  padding: var(--space-5) 0 var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
}
.stage.shake {
  animation: shake 330ms ease;
}

/* Hints open below the puzzle, so nothing the player is about to tap moves. */
.hint-box {
  margin-top: var(--space-3);
  padding: 16px 20px;
  border-radius: var(--radius-m);
  background: var(--hint-bg);
  font-size: 15px;
  animation: rise 200ms ease;
}
.hint-box ol {
  margin: 0;
  padding-left: 20px;
}
.hint-box li + li {
  margin-top: var(--space-2);
}

/* Wrong tries and tips: a note that floats over the bottom of the card */
.toast {
  position: absolute;
  left: 50%;
  bottom: var(--space-3);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: var(--radius-s);
  background: var(--wrong-bg);
  color: var(--wrong-ink);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity var(--t-ui),
    transform 0.3s var(--ease-spring);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.info {
  background: var(--info-bg);
  color: var(--info-ink);
}

/* ---------- Win: celebrate, then the reason ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgb(17 19 50 / 62%);
  animation: fade 200ms ease;
}
.win-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  padding: 32px 32px 26px;
  border-radius: var(--radius-l);
  background: var(--cream);
  text-align: center;
  animation: modal-in 350ms var(--ease-spring);
}
.win-eyebrow {
  display: inline-block;
  margin: 0 0 var(--space-3);
  padding: 4px 12px;
  border-radius: var(--radius-s);
  background: var(--lime);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.stamp {
  margin: 0 0 var(--space-4);
  font-size: 54px;
  line-height: 0.96;
  letter-spacing: -0.055em;
}
.fact-title {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 800;
}
.win-card p {
  margin: 0 0 var(--space-4);
}
.win-card .fact {
  margin-bottom: var(--space-5);
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
}
.win-card .actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.win-card pre {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--paper);
  border-radius: var(--radius-s);
}
.win-card .streak {
  margin: 0 0 var(--space-3);
}
.rank-line {
  font-weight: 800;
}
.confetti-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti {
  position: absolute;
  top: 22%;
  left: 50%;
  width: 11px;
  height: 15px;
  border-radius: 3px;
  pointer-events: none;
}

/* ---------- Shared level pieces ---------- */
.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
}
.choice {
  min-width: 122px;
  min-height: 58px;
  border: 1.5px solid #ded8ec;
  font-size: 17px;
}
.choice.big {
  width: 148px;
  height: 148px;
  padding: 20px;
  border: 0;
  border-radius: 24px;
  background: var(--lavender);
  display: grid;
  place-items: center;
}
.choice.big:nth-child(2) {
  background: var(--lime);
}
.choice.big .doodle {
  width: 100%;
  height: 100%;
}
/* Something picked up with a tap, waiting for the second tap. Its picture pulses; the tap area stays put. */
.selected {
  outline: 3px solid var(--orange);
  outline-offset: 5px;
}
.selected .doodle {
  animation: pulse 0.8s ease-in-out infinite;
}

/* ---------- Liar ---------- */
.liar-card {
  position: relative;
  max-width: 340px;
  padding: 52px 30px 32px;
  border-radius: 24px;
  background: var(--lavender);
  font: 800 28px/1.1 var(--font-display);
  letter-spacing: -0.035em;
  text-align: center;
}
.liar-card.flip {
  animation: flip-card 550ms var(--ease-out);
}
.liar-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3f3858;
}
.liar-x .doodle {
  width: 16px;
  height: 16px;
}

/* ---------- Zeno ---------- */
.track {
  position: relative;
  width: 100%;
  height: 130px;
  border-bottom: 3px solid var(--ink);
  background: repeating-linear-gradient(90deg, transparent 0 18px, var(--pencil) 18px 20px) bottom / 100% 6px no-repeat;
}
.runner {
  position: absolute;
  bottom: 2px;
  transform: translateX(-50%);
  transition: left 550ms var(--ease-out);
  line-height: 0;
}
.runner .doodle {
  width: 64px;
  height: 64px;
  animation: bob 700ms ease-in-out infinite;
}
.runner.tortoise .doodle {
  width: 72px;
  height: 72px;
  animation-duration: 1400ms;
}
.finish {
  position: absolute;
  bottom: -3px;
  width: 56px;
  height: 130px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: 12px;
  cursor: grab;
  touch-action: none;
}
.finish .pole {
  width: 5px;
  flex: 1;
  background: repeating-linear-gradient(var(--ink) 0 8px, var(--paper-2) 8px 16px);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
}
.finish .flag {
  line-height: 0;
  margin-bottom: -6px;
  translate: 14px 0;
}
.finish .flag .doodle {
  width: 46px;
  height: 46px;
  animation: flutter 1200ms ease-in-out infinite;
  transform-origin: 20% 50%;
}
.finish.dragging {
  cursor: grabbing;
}

/* ---------- Hilbert ---------- */
.hotel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}
.room {
  width: 70px;
  height: 92px;
  padding: 5px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid #c2b3e4;
  border-radius: 15px 15px 8px 8px;
  background: var(--lavender-light);
  font: 800 20px/1.2 var(--font-display);
}
.room .who {
  line-height: 0;
  transition:
    translate 0.5s var(--ease-out),
    opacity 0.4s ease 0.2s;
}
.room .who .doodle {
  width: 46px;
  height: 46px;
}
.room.shift .who {
  translate: 80px 0;
  opacity: 0;
}
.room.dots {
  justify-content: center;
  background: transparent;
  border-style: dashed;
  font-size: 23px;
}
.guest {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--ink);
  border-radius: 50%;
  background: var(--lime);
  touch-action: none;
  cursor: grab;
}
/* The doodle bobs, the button doesn't: a tap target should never move under the finger. */
.guest .doodle {
  width: 64px;
  height: 64px;
  animation: bob 1400ms ease-in-out infinite;
}
.guest.back {
  transition: transform 350ms var(--ease-spring);
}

/* ---------- Drawn props you can tap (no card around them) ---------- */
.big-red,
.cat-box,
.donkey,
.hay,
.wall {
  display: grid;
  place-items: center;
  line-height: 0;
}
:is(.big-red, .cat-box, .donkey, .hay, .wall) .doodle {
  width: 100%;
  height: 100%;
  transition: scale var(--t-press) var(--ease-out);
}
:is(.big-red, .cat-box, .donkey, .hay, .wall):active .doodle {
  scale: 0.94;
}

/* ---------- Don't ---------- */
.beg {
  min-height: 1.3em;
  margin: 0;
  font: 800 23px/1.3 var(--font-display);
  color: var(--red-ink);
  text-align: center;
}
.big-red {
  width: 180px;
  height: 160px;
}
/* The longer you wait, the bigger and twitchier it gets (--temptation counts the seconds) */
.big-red .doodle {
  scale: calc(1 + var(--temptation, 0) * 0.07);
  transition: scale 0.6s var(--ease-spring);
  animation: jiggle calc(1.4s - var(--temptation, 0) * 0.18s) ease-in-out infinite;
}

/* ---------- Schrödinger ---------- */
.cat-box {
  width: 160px;
  height: 160px;
}
.cat-box .doodle {
  animation: rattle 3.2s ease-in-out infinite;
}
.cat-box.open .doodle {
  animation: pop-in 0.4s var(--ease-spring);
}

/* ---------- Buridan ---------- */
.field {
  position: relative;
  width: 100%;
  height: 150px;
  border-bottom: 3px solid var(--ink);
}
.field > button {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
}
.hay {
  width: 84px;
  height: 84px;
  touch-action: none;
  cursor: grab;
}
.donkey {
  left: 50%;
  width: 100px;
  height: 100px;
  transition: left 0.9s var(--ease-out);
}
.donkey.dither .doodle {
  animation: dither 1.1s ease-in-out;
}
.donkey:is(.eat-left, .eat-right) .doodle {
  animation: munch 0.3s ease-in-out 1s 4;
}
.donkey.eat-left .doodle {
  rotate: -8deg;
}
.donkey.eat-right .doodle {
  rotate: 8deg;
}

/* ---------- Count Me ---------- */
.decoy {
  max-width: 340px;
  margin: 0;
  padding: 18px 22px;
  border-radius: var(--radius-m);
  background: var(--mint);
  line-height: 1.5;
}
.counter {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.counter .icon {
  font: 700 30px/1 var(--font-display);
}
.count {
  min-width: 2ch;
  font: 800 52px/1 var(--font-display);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

/* ---------- Skip This Level ---------- */
.wall {
  width: 200px;
  height: 170px;
}
.wall-note {
  margin: 0;
  font-size: 18px;
  color: var(--ink-soft);
}

/* ---------- Galileo ---------- */
.pairs {
  padding: 16px 28px;
  border-radius: var(--radius-m);
  background: var(--lavender-light);
  font: 700 24px/1.7 var(--font-display);
  text-align: center;
}

/* ---------- Monty Hall ---------- */
.doors {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}
.door {
  position: relative;
  width: 96px;
  height: 148px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 40px 40px 10px 10px;
  font: 800 38px/1 var(--font-display);
  transition: scale var(--t-press) var(--ease-out);
}
.door::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 52%;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-2);
}
.door:nth-child(1) {
  background: var(--lime);
}
.door:nth-child(2) {
  background: var(--pink);
}
.door:nth-child(3) {
  background: var(--lavender);
}
.door:disabled {
  opacity: 1;
}
.door.picked {
  outline: 3px solid var(--orange);
  outline-offset: 5px;
}
.door.open {
  background: var(--paper);
  border-style: dashed;
  animation: swing-open 0.45s var(--ease-spring);
}
.door.open::after {
  display: none;
}
.door .doodle {
  width: 72px;
  height: 72px;
}
.monty-note {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  color: var(--ink-soft);
}

/* ---------- Daily cards ---------- */
.card-setup {
  margin: 0 0 var(--space-5);
  padding: 20px 22px;
  border-radius: var(--radius-m);
  background: var(--lavender-light);
  font-size: 17px;
  line-height: 1.55;
}
.card-setup p {
  margin: 0;
}
.card-setup .doodle {
  float: right;
  width: 48px;
  height: 48px;
  margin: -2px 0 8px 14px;
}
.card-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
}
.card-choices .choice {
  flex: 1 1 40%;
}
.number-answer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
}
.number-answer .counter {
  gap: var(--space-3);
}
.number-input {
  width: 4.5ch;
  min-height: var(--tap);
  padding: 4px 8px;
  font: 800 30px/1 var(--font-display);
  text-align: center;
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid #cbc4de;
  border-radius: var(--radius-s);
  -webkit-user-select: text;
  user-select: text;
}
.unit {
  color: var(--ink-soft);
}

/* ---------- Pieces that can be dragged onto a spot (dragOrTap in src/drag.js) ---------- */
.spring-back {
  transition: translate 0.3s var(--ease-spring);
}
.drop-spot,
.slot,
.tri-space,
.dock,
.floor,
.ground {
  display: grid;
  place-items: center;
  border: 2px dashed var(--pencil);
  border-radius: var(--radius-s);
}

/* ---------- Chapter 2: time and infinity ---------- */

/* Bootstrap Key */
.bootstrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.clock,
.chest {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 24px;
  background: var(--lavender-light);
}
.clock .doodle,
.chest .doodle {
  width: 80px;
  height: 80px;
}
.clock.rewind .doodle {
  animation: rewind 0.9s linear;
}
.chest.open .doodle {
  animation: pop-in 0.4s var(--ease-spring);
}
.future {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  animation: walk-in 0.6s var(--ease-out) backwards;
}
.future-me .doodle {
  width: 60px;
  height: 60px;
}
.key {
  display: grid;
  place-items: center;
  width: 68px;
  height: 52px;
  border-radius: var(--radius-s);
  background: var(--lime);
}
.key .doodle {
  width: 48px;
  height: 48px;
}

/* Endless Hourglass */
.table-top {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 28px;
  width: 100%;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--ink);
}
.glass {
  display: grid;
  place-items: center;
  width: 96px;
  height: 116px;
}
.glass .doodle {
  width: 100px;
  height: 110px;
}
.glass.turn .doodle {
  animation: turn-over 0.5s var(--ease-out);
}
.slot {
  width: 130px;
  height: 64px;
}
.slot.filled {
  border-color: transparent;
}
.slot .lying {
  width: 88px;
  height: 88px;
  rotate: 90deg;
}
.sand-note,
.floor-note,
.time-note,
.coast-length,
.grain-note,
.wait-note {
  margin: 0;
  font-weight: 800;
  text-align: center;
}

/* Penrose Stairs: positions are % of the picture, so it can shrink on short screens */
.penrose {
  position: relative;
  width: 220px;
  height: 180px;
}
.stairs-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.stairs-art > .doodle {
  width: 91%;
  height: auto;
  aspect-ratio: 1;
}
.walker {
  position: absolute;
  width: 22%;
  aspect-ratio: 1;
  line-height: 0;
  transition:
    left 0.5s var(--ease-out),
    top 0.5s var(--ease-out),
    opacity 0.4s ease;
}
.walker .doodle {
  width: 100%;
  height: 100%;
}
.walker[data-step='0'] {
  left: 15%;
  top: 13%;
}
.walker[data-step='1'] {
  left: 39%;
  top: -4%;
}
.walker[data-step='2'] {
  left: 62%;
  top: 13%;
}
.walker[data-step='3'] {
  left: 39%;
  top: 29%;
}
.walker.gone {
  opacity: 0;
}
.stairs-door {
  position: absolute;
  left: 20%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-s);
}
.stairs-door .doodle {
  width: 26px;
  height: 26px;
}

/* Impossible Triangle */
.tri-scene {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
}
.tri {
  position: relative;
  width: 170px;
  height: 160px;
}
.tri-body {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.tri-body .doodle {
  width: 100%;
  height: 100%;
}
.corner {
  position: absolute;
  left: calc(50% - 26px);
  top: -16px;
  width: 52px;
  height: 52px;
  border: 2.5px dashed var(--orange);
  border-radius: 50%;
}
.tri-space {
  width: 110px;
  height: 110px;
}

/* The Arrow: holding a finger anywhere on the puzzle must not scroll or open the long-press menu */
.stage:has(.range) {
  touch-action: none;
  -webkit-touch-callout: none;
}
.range {
  position: relative;
  width: 100%;
  height: 110px;
  touch-action: none;
}
.arrow-btn {
  position: absolute;
  top: calc(50% - 32px);
  display: grid;
  place-items: center;
  width: 88px;
  height: 64px;
}
.arrow-btn .doodle {
  width: 84px;
  height: 84px;
}
.target {
  position: absolute;
  right: 0;
  top: calc(50% - 48px);
  width: 96px;
  height: 96px;
}
.target .doodle {
  width: 100%;
  height: 100%;
}

/* Coastline */
.coast-view {
  width: min(320px, 100%);
  height: 140px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-m);
}
.coast-zoom {
  width: 100%;
  height: 100%;
  transform-origin: 46% 30%;
  transition: scale 0.5s var(--ease-out);
}
.coast-zoom .doodle {
  width: 100%;
  height: 100%;
}
.coast-tools {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.choice[data-pick='infinite'] {
  font-size: 28px;
}

/* Infinite Monkeys */
.monkey {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
}
.monkey .doodle {
  width: 108px;
  height: 108px;
}
.paper {
  min-width: 220px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper-2);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-align: center;
}
.text-answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.text-label {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}
.text-input {
  width: 12ch;
  min-height: var(--tap);
  padding: 6px 12px;
  font: 700 20px var(--font-body);
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid #cbc4de;
  border-radius: var(--radius-s);
  -webkit-user-select: text;
  user-select: text;
}

/* Grandfather Button */
.then-and-now {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-3);
}
.then-and-now .doodle {
  width: 84px;
  height: 84px;
}
.then-and-now .machine .doodle {
  width: 70px;
  height: 70px;
}
.present-you {
  transition: opacity 0.4s ease;
}
.vanish .present-you {
  opacity: 0.12;
}
.pressed .machine .doodle {
  animation: pulse 0.4s 2;
}

/* Ship of Theseus */
.harbour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}
.ship-new {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mast {
  width: 6px;
  height: 32px;
  border-radius: 3px;
  background: var(--ink);
}
.hull {
  display: flex;
  gap: 4px;
  padding: 6px 12px 12px;
  border-radius: 6px 6px 40px 40px;
  background: #7b5534;
}
.plank {
  width: 52px;
  height: 48px;
  border: 2px solid rgb(17 19 50 / 30%);
  border-radius: 6px;
  background: #b98a5a;
}
.plank.new,
.plank:disabled {
  background: #f2cd96;
  opacity: 1;
}
.shore {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}
.old-pile {
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  background: #c99b6a;
  font-weight: 800;
}
.dock {
  width: 110px;
  height: 64px;
}
.dock .doodle {
  width: 76px;
  height: 76px;
}
.captain {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--lavender-light);
}
.captain .doodle {
  width: 52px;
  height: 52px;
}

/* Surprise Test */
.week {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.day {
  width: 58px;
  height: 64px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
  font-weight: 800;
}
.quiz {
  margin: 0;
  padding: 14px 22px;
  border-radius: var(--radius-m);
  background: var(--orange);
  font: 800 26px var(--font-display);
  letter-spacing: -0.02em;
  animation: pop-in 0.4s var(--ease-spring);
}

/* ---------- Chapter 3: real logic ---------- */

/* Birthday Room */
.party {
  display: flex;
  gap: 6px;
}
.party .doodle {
  width: 56px;
  height: 56px;
}

/* Lucky Coin */
.coins {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 320px;
}
.coins .doodle {
  width: 32px;
  height: 32px;
}

/* Two Guards */
.gate {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
}
.g-door {
  width: 64px;
  height: 92px;
  border: 2px solid var(--ink);
  border-radius: 30px 30px 8px 8px;
  background: var(--lavender);
  font: 800 24px var(--font-display);
}
.g-door[data-door='right'] {
  background: var(--pink);
}
.g-door.open {
  background: var(--paper);
  border-style: dashed;
}
.guard .doodle {
  width: 72px;
  height: 72px;
}
.questions .choice {
  flex: 1 1 100%;
  min-height: var(--tap);
  padding: 8px 14px;
  font-size: 15px;
}

/* The Barber */
.barbershop {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-5);
}
.barber {
  position: relative;
  width: 140px;
  height: 140px;
}
.barber-face .doodle {
  width: 140px;
  height: 140px;
}
.beard {
  position: absolute;
  left: 42px;
  top: 50px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
}
.beard .doodle {
  width: 56px;
  height: 56px;
}
.floor {
  width: 110px;
  height: 64px;
}
.floor .fallen {
  width: 44px;
  height: 44px;
  rotate: 80deg;
}

/* Trolley of Ducks */
.rails {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 150px;
}
.rails::before {
  content: '';
  position: absolute;
  left: 70px;
  top: 58px;
  width: 52px;
  height: 4px;
  background: var(--ink);
  transform-origin: left center;
  rotate: 48deg;
}
.rail {
  position: absolute;
  left: 92px;
  right: 0;
  height: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  border-bottom: 4px solid var(--ink);
}
.rail.main {
  top: 6px;
}
.rail.side {
  top: 90px;
}
.ducks {
  display: flex;
  line-height: 0;
}
.ducks .doodle {
  width: 36px;
  height: 36px;
}
.trolley-car {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  height: 80px;
  line-height: 0;
  transition:
    top 0.5s var(--ease-out),
    left 0.5s var(--ease-out);
}
.trolley-car .doodle {
  width: 100%;
  height: 100%;
}
.rails[data-route='side'] .trolley-car {
  top: 70px;
  left: 40px;
}
.rails[data-route='both'] .trolley-car {
  opacity: 0.35;
}
.rails[data-route='both'] .ducks .doodle {
  animation: bob 0.5s ease-in-out infinite;
}
.lever[aria-pressed='true'] {
  background: var(--lavender);
}

/* Simpson's Hospitals */
.stats {
  border-collapse: collapse;
  min-width: 260px;
  font-size: 15px;
}
.stats caption {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}
.stats th,
.stats td {
  padding: 6px 14px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.stats tbody th {
  text-align: left;
  font-weight: 700;
}
.stats .overall {
  background: var(--lavender-light);
  font-weight: 800;
}

/* Where Is Everyone */
.space {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 220px;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--ink);
}
.star-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
}
.star-btn .doodle {
  width: 30px;
  height: 30px;
}
.earth {
  position: absolute;
  left: 8%;
  bottom: -28px;
  width: 112px;
  height: 112px;
}
.earth .doodle {
  width: 100%;
  height: 100%;
}
.you-are-here {
  position: absolute;
  left: calc(8% + 66px);
  bottom: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 10px;
  border-radius: var(--radius-s);
  background: rgb(17 19 50 / 85%);
  color: var(--cream);
  font-size: 12px;
  font-weight: 800;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
}

/* Sand Heap */
.heap-scene {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-5);
  width: 100%;
  border-bottom: 3px solid var(--ink);
}
.heap {
  position: relative;
  width: 200px;
  height: 150px;
}
.grains {
  display: grid;
  place-items: end center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.grains .doodle {
  flex: none;
  width: 200px;
  height: 200px;
}
/* A sign stuck in the lower half of the pile, so the sand still shows above it */
.heap-word {
  position: absolute;
  left: calc(50% - 42px);
  top: 86px;
  min-width: 84px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-s);
  background: var(--cream);
  font: 800 20px var(--font-display);
  letter-spacing: 0.05em;
}
.ground {
  width: 110px;
  height: 56px;
  margin-bottom: 6px;
  font: 800 20px var(--font-display);
}
.ground.dropped {
  border-style: solid;
}

/* ---------- Shared: slider (slider() in src/drag.js) and number answers (src/number-entry.js) ---------- */
.slider-track {
  position: relative;
  display: block;
  width: 100%;
  max-width: 280px;
  height: 48px;
  cursor: pointer;
  touch-action: none;
}
.slider-track::before,
.slider-fill {
  content: '';
  position: absolute;
  left: 0;
  top: calc(50% - 3px);
  height: 6px;
  border-radius: 3px;
}
.slider-track::before {
  right: 0;
  background: var(--line);
}
.slider-fill {
  background: var(--ink);
}
.slider-thumb {
  position: absolute;
  top: 0;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  border-radius: 50%;
  cursor: grab;
}
.slider-thumb::after {
  content: '';
  width: 26px;
  height: 26px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lime);
}
.number-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

/* ---------- Chapter 4: seeing is deceiving ---------- */

/* Same Grey: the board's greys are part of the puzzle, so they are not brand tokens */
.grey-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.board {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  grid-template-rows: repeat(5, 34px);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 6px;
}
.square {
  display: grid;
  place-items: center;
  color: #fff;
  font: 800 20px var(--font-body);
}
.square.pale {
  background: #d9d9d9;
}
.square.mid {
  background: #8a8a8a;
}
.square.deep {
  background: #4a4a4a;
}
.board.masked .square:not(.marked) {
  background: var(--cream);
}
.mask-card {
  width: 64px;
  height: 80px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    radial-gradient(circle at 32% 30%, var(--ink) 0 8px, transparent 9px),
    radial-gradient(circle at 68% 70%, var(--ink) 0 8px, transparent 9px), var(--cream);
}

/* Two Tables */
.tables {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-3);
}
.table-pick,
.table-right {
  display: grid;
  place-items: center;
  width: 130px;
  height: 130px;
  border-radius: var(--radius-s);
}
.table-pick .doodle,
.table-right .doodle {
  width: 120px;
  height: 120px;
}
.table-right.traced {
  outline: 3px dashed var(--orange);
  outline-offset: 2px;
}

/* Arrow Lines: each arrowhead overlaps the end of its line */
.ml-lines {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ml-row {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ml-line {
  width: 150px;
  height: 4px;
  background: var(--ink);
  transition: width 0.3s var(--ease-out);
}
.ml-row.stretched .ml-line {
  width: 185px;
}
.fin {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
}
.fin .doodle {
  width: 40px;
  height: 40px;
}
.fin.out-left {
  margin-right: -32px;
}
.fin.out-right {
  margin-left: -32px;
}
.fin.in-left {
  margin-right: -14px;
}
.fin.in-right {
  margin-left: -14px;
}
.fin.out-right .doodle,
.fin.in-left .doodle {
  rotate: 180deg;
}
.fin.gone {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.fin.gone:disabled {
  opacity: 0;
}

/* Ghost Dots: the Hermann grid only works in pure black and white */
.hermann {
  display: grid;
  grid-template-columns: repeat(5, 40px);
  grid-auto-rows: 40px;
  gap: 9px;
  padding: 9px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.hermann span {
  background: #000;
}

/* Count the Triangles */
.kanizsa .doodle {
  width: 170px;
  height: 170px;
}

/* The Fork */
.fork-view {
  position: relative;
  width: 200px;
  height: 150px;
  overflow: hidden;
}
.fork-art {
  display: grid;
  place-items: center;
  height: 100%;
}
.fork-art .doodle {
  width: 150px;
  height: 150px;
}
.fork-cover {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  border: 2px dashed var(--pencil);
  border-radius: var(--radius-s);
  background: var(--paper);
}
.fork-slider {
  width: min(280px, 100%);
}

/* The Cube */
.necker .doodle {
  width: 170px;
  height: 170px;
}
.necker.flip .doodle {
  animation: flip-card 0.55s var(--ease-out);
}

/* Café Wall: grey mortar between shifted black and white tiles */
.wall-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.cafe {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 240px;
  padding: 3px 0;
  background: #8a8a8a;
}
.tiles {
  height: 28px;
  background: repeating-linear-gradient(90deg, #111 0 30px, #fff 30px 60px);
  transition: rotate 0.3s ease;
}
.tiles:nth-child(2),
.tiles:nth-child(4) {
  background-position: 10px 0;
}
.tiles:nth-child(3) {
  background-position: 20px 0;
}
.cafe.nudged .tiles:nth-child(even) {
  rotate: 2deg;
}
.cafe.nudged .tiles:nth-child(odd) {
  rotate: -2deg;
}
.ruler-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 32px;
  height: 3px;
  background: var(--orange);
}
.ruler {
  width: 48px;
  height: 150px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: repeating-linear-gradient(0deg, #f2cd96 0 10px, #e9b97a 10px 20px);
}

/* Afterimage: the flag's colours are the puzzle */
.flag-negative {
  position: relative;
  width: 220px;
  height: 140px;
  border: 2px solid var(--ink);
  background: linear-gradient(#33c3d6 0 33.3%, #111332 33.3% 66.6%, #f2d000 66.6%);
}
.flag-negative.white {
  background: #fff;
}
.stare-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px;
  border-radius: 50%;
  background: #e8423f;
}
.stare-note {
  margin: 0;
  font-weight: 800;
}
.pots .choice {
  min-width: 0;
  padding: 8px 12px;
  font-size: 15px;
}

/* Spinning Wheel */
.spin-wheel {
  display: block;
  width: 150px;
  height: 150px;
  line-height: 0;
}
.spin-wheel .doodle {
  width: 100%;
  height: 100%;
}
.spin-note {
  margin: 0;
  font-weight: 800;
}
.spin-slider {
  width: min(280px, 100%);
}

/* ---------- Chapter 5: words that bite ---------- */

/* Long answers stacked one per row (also used in chapter 6) */
.plans .choice {
  flex: 1 1 100%;
  min-height: var(--tap);
  padding: 8px 14px;
  font-size: 15px;
}

/* Read First */
.steps {
  max-width: 360px;
  margin: 0;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.45;
}
.shapes {
  display: flex;
  gap: var(--space-3);
}
.shape {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
}
.circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
}
.square-shape {
  width: 28px;
  height: 28px;
  background: var(--ink);
}
.triangle {
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 28px solid var(--ink);
}
.shape .doodle {
  width: 36px;
  height: 36px;
}

/* Odd One Out */
.symbols {
  display: grid;
  grid-template-columns: repeat(6, 48px);
  gap: 6px;
}
.symbol {
  height: 48px;
  border-radius: 10px;
  background: var(--lavender-light);
  font: 800 28px var(--font-body);
}

/* Candle on the Wall */
.kit {
  display: flex;
  gap: var(--space-5);
}
.kit-item .doodle {
  width: 84px;
  height: 84px;
}

/* Twelve Months, Half of Thirty */
.calendar {
  max-width: 300px;
  margin: 0;
  text-align: center;
  word-spacing: 6px;
  font-weight: 800;
  color: var(--ink-soft);
}
.sum-card {
  margin: 0;
  font: 800 30px var(--font-display);
}

/* Rooster on the Roof */
.rooftop {
  position: relative;
  width: 200px;
  height: 120px;
}
.roof {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70px;
  background: #ec9a7c;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.roof-bird {
  position: absolute;
  top: 0;
  left: calc(50% - 30px);
  width: 60px;
  height: 60px;
  line-height: 0;
}
.roof-bird .doodle {
  width: 60px;
  height: 60px;
}

/* Hole in the Ground */
.hole {
  display: grid;
  place-items: center;
  width: 160px;
  height: 70px;
  border-radius: 8px;
  background: #8fd18a;
}
.hole span {
  width: 90px;
  height: 40px;
  border-radius: 6px;
  background: #3f2d1d;
}

/* Second Place */
.race {
  display: flex;
  gap: 4px;
}
.race .doodle {
  width: 56px;
  height: 56px;
}

/* Silk */
.silk-btn {
  min-width: 160px;
  min-height: 64px;
  border-radius: var(--radius-m);
  background: var(--lime);
  font: 800 28px var(--font-display);
  letter-spacing: 0.05em;
}
.silk-count {
  margin: 0;
  font-weight: 800;
  color: var(--ink-soft);
}
.silk-question {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.silk-ask {
  margin: 0;
  font: 800 22px var(--font-display);
}

/* ---------- Chapter 6: chance and choice ---------- */

/* Bean Machine */
.galton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.pins {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.pin-row {
  display: flex;
  gap: 42px;
}
.pin {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}
.bins {
  display: flex;
  gap: 6px;
}
.bin {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 52px;
  height: 110px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--paper-2);
}
.bin-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: var(--lavender);
  transition: height 0.8s var(--ease-out);
}
.bin-count {
  position: relative;
  margin-bottom: 4px;
  font-weight: 800;
}

/* Lost Robot */
.walk-track {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  width: min(320px, 100%);
  height: 90px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--ink);
}
.spot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
}
.spot.start {
  width: 14px;
  height: 14px;
  background: var(--orange);
}
.walker-bot {
  position: absolute;
  bottom: 14px;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  line-height: 0;
  transition: left 0.2s ease;
}
.walker-bot .doodle {
  width: 100%;
  height: 100%;
}

/* Buffon's Needles: lines every 40px, the same as a needle's length */
.needle-floor {
  position: relative;
  width: min(300px, 100%);
  height: 160px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: repeating-linear-gradient(180deg, var(--pencil) 0 2px, var(--paper-2) 2px 40px);
}
.needle {
  position: absolute;
  width: 40px;
  height: 3px;
  margin-top: -1.5px;
  background: var(--orange);
}
.needle-note {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* Random Dots */
.skies {
  display: flex;
  gap: var(--space-4);
}
.sky {
  position: relative;
  width: 140px;
  height: 140px;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--ink);
}
.dot-star {
  position: absolute;
  width: 7px;
  height: 7px;
  margin: -3.5px;
  border-radius: 50%;
  background: var(--lime);
}

/* Best Pick */
.card-row {
  display: flex;
  gap: 6px;
}
.card-back {
  width: 24px;
  height: 36px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--lavender);
}

/* The Big Poll */
.polls {
  display: flex;
  gap: var(--space-3);
}
.poll {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 170px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: var(--lavender-light);
  font-size: 13px;
}
.poll strong {
  font: 800 18px var(--font-display);
}

/* Shared Field */
.field-shared {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 100%);
}
.grass-meter {
  height: 14px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}
.grass-fill {
  display: block;
  height: 100%;
  background: #8fd18a;
  transition: width 0.4s ease;
}
.flocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.flock {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 40px;
  padding: 4px;
  border-radius: 10px;
  background: #e3f2d6;
}
.flock .doodle {
  width: 32px;
  height: 32px;
}

/* Dollar Auction */
.auction {
  text-align: center;
}
.prize {
  margin: 0;
  font: 800 28px var(--font-display);
}
.bids {
  margin: 4px 0 0;
  font-weight: 700;
}

/* Bent Coin */
.bent .doodle {
  width: 84px;
  height: 84px;
  rotate: -12deg;
  scale: 1 0.8;
}

/* Rainy Weekend */
.forecast {
  display: flex;
  gap: var(--space-3);
}
.day-chance {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border-radius: var(--radius-m);
  background: var(--blue);
  font-weight: 700;
}
.day-chance strong {
  font: 800 20px var(--font-display);
}

/* ---------- Chapter 7: things that move ---------- */
/* Physics scenes play once when the level adds .go (watch() in src/watch.js). */

/* Ship's Mast: the ship sails right (the waves slide left); the ball falls straight down the mast */
.mast-scene {
  position: relative;
  width: 240px;
  height: 150px;
}
.mast-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: #e3eeff;
}
.waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  background: repeating-linear-gradient(90deg, #8fb6f0 0 20px, #b9d3ff 20px 40px);
  animation: slide-left 1s linear infinite;
}
.mast-ship {
  position: absolute;
  left: calc(50% - 70px);
  bottom: 8px;
  width: 140px;
  height: 140px;
  line-height: 0;
}
.mast-ship .doodle {
  width: 100%;
  height: 100%;
}
.mast-ball {
  position: absolute;
  left: calc(50% - 7px);
  top: 6px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--orange);
}
.mast-scene.go .mast-ball {
  animation: mast-drop 0.8s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
}
.deck-spots {
  position: absolute;
  left: 50%;
  top: 41px;
  display: flex;
  gap: 4px;
  translate: -50% 0;
}
.land-spot {
  width: 52px;
  height: 48px;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius-s);
}
.land-spot.marked {
  border-style: solid;
  border-color: var(--orange);
  background: rgb(245 101 56 / 18%);
}
.x-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
}
.x-mark .doodle {
  width: 32px;
  height: 32px;
}

/* Drop or Throw: one ball falls, the other also slides right, and they land together */
.throw-scene {
  position: relative;
  width: 220px;
  height: 150px;
}
.cliff {
  position: absolute;
  left: 0;
  top: 30px;
  bottom: 0;
  width: 46px;
  border-radius: 0 10px 0 0;
  background: #d9c7a3;
}
.fall-x {
  position: absolute;
  left: 48px;
  top: 16px;
}
.fall-x.throw {
  left: 30px;
}
.ball {
  display: block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lavender);
}
.ball.thrown {
  background: var(--orange);
}
.ground-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--ink);
}
.throw-scene.go .fall-x.throw {
  animation: throw-across 0.9s linear forwards;
}
.throw-scene.go .fall-y {
  display: block;
  animation: fall-down 0.9s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
}

/* Balloon in a Car */
.car-scene {
  position: relative;
  width: 220px;
  height: 140px;
}
.car-art {
  position: absolute;
  left: calc(50% - 75px);
  bottom: -20px;
  width: 150px;
  height: 150px;
  line-height: 0;
}
.car-art .doodle {
  width: 100%;
  height: 100%;
}
.car-scene::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 34px;
  width: 30px;
  height: 22px;
  background: repeating-linear-gradient(180deg, var(--ink) 0 3px, transparent 3px 9px);
  border-radius: 2px;
}
.lean-spot {
  position: absolute;
  top: 0;
  width: 60px;
  height: 64px;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius-s);
}
.lean-spot[data-lean='back'] {
  left: 40px;
}
.lean-spot[data-lean='forward'] {
  right: 40px;
}
.lean-ghost {
  display: grid;
  place-items: center;
  visibility: hidden;
  line-height: 0;
}
.lean-ghost .doodle {
  width: 44px;
  height: 44px;
  rotate: 18deg;
}
.car-scene.forward .lean-spot[data-lean='forward'] {
  border-style: solid;
}
.car-scene.forward .lean-ghost {
  visibility: visible;
}
.car-scene.go .car-art {
  animation: drive-off 0.9s var(--ease-out) forwards;
}
.car-balloon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
}
.car-balloon .doodle {
  width: 48px;
  height: 48px;
}

/* Falling Slinky: the top collapses onto the bottom, which waits (marked in orange),
   then the whole spring drops onto the floor. Slow enough to see the wait. */
.slinky-scene {
  position: relative;
  width: 170px;
  height: 150px;
  overflow: hidden;
}
.slinky-hand {
  position: absolute;
  left: calc(50% - 26px);
  top: 0;
  width: 52px;
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffe0c7;
}
.slinky-top,
.slinky-bottom {
  position: absolute;
  left: calc(50% - 22px);
  width: 44px;
  height: 10px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--lavender);
}
.slinky-top {
  top: 14px;
}
.slinky-bottom {
  top: 96px;
  background: var(--orange);
}
.slinky-label {
  position: absolute;
  left: calc(100% + 8px);
  top: -6px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.slinky-coil {
  position: absolute;
  left: calc(50% - 20px);
  top: 22px;
  width: 40px;
  height: 76px;
  background: repeating-linear-gradient(180deg, #9d8ad8 0 3px, transparent 3px 10px);
  transform-origin: bottom;
}
.slinky-floor {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--ink);
}
.slinky-scene.go .slinky-hand {
  animation: let-go 0.4s ease forwards;
}
.slinky-scene.go .slinky-top {
  animation: slinky-top 2s linear forwards;
}
.slinky-scene.go .slinky-coil {
  animation: slinky-coil 2s linear forwards;
}
.slinky-scene.go .slinky-bottom {
  animation: slinky-bottom 2s linear forwards;
}

/* Stacked Balls: the balls hang at --lift above the ground until Drop */
.bounce-scene {
  --lift: 80px;
  position: relative;
  width: 200px;
  height: calc(var(--lift) + 124px);
}
.big-ball,
.small-ball {
  position: absolute;
  bottom: var(--lift);
  display: grid;
  place-items: center;
}
.big-ball {
  left: 30px;
  width: 72px;
  height: 72px;
}
.small-ball {
  right: 30px;
  width: 48px;
  height: 48px;
  transition:
    right 0.3s var(--ease-out),
    bottom 0.3s var(--ease-out);
}
.bounce-scene.stacked .small-ball {
  right: 106px;
  bottom: calc(var(--lift) + 72px);
}
.ball-fall,
.ball-fall span {
  display: block;
  border-radius: 50%;
}
.big-ball .ball-fall span {
  width: 64px;
  height: 64px;
  border: 3px solid var(--ink);
  background: var(--lavender);
}
.small-ball .ball-fall span {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ink);
  background: var(--orange);
}
.bounce-scene.go .big-ball .ball-fall {
  animation: big-bounce 1s ease-in forwards;
}
.bounce-scene.go .small-ball .ball-fall {
  animation: small-bounce 1s ease-in forwards;
}
.bounce-scene.go.stacked .small-ball .ball-fall {
  animation: small-launch 1.1s ease-in forwards;
}

/* Full-Length Mirror: the reflection is half your size, so it fits a mirror half your height */
.mirror-scene {
  --mirror: 1;
  position: relative;
  width: 190px;
  height: 128px;
}
.mirror-you {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 120px;
  height: 128px;
  line-height: 0;
}
.mirror-you .doodle {
  width: 100%;
  height: 100%;
}
.mirror-glass {
  position: absolute;
  right: 0;
  top: 4px;
  width: 52px;
  height: calc(var(--mirror) * 120px);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: #e3eeff;
  transition: height var(--t-ui);
}
.mirror-view {
  display: block;
  width: 60px;
  height: 60px;
  margin-left: -7px;
  line-height: 0;
}
.mirror-view .doodle {
  width: 100%;
  height: 100%;
}
.mirror-note {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* Sink Swirl */
.sinks {
  display: flex;
  gap: var(--space-5);
}
.sink {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 6px solid #d8d4cc;
  border-radius: 50%;
  background: #e3eeff;
}
.swirl {
  width: 52px;
  height: 52px;
  border: 4px dashed var(--blue-ink);
  border-radius: 50%;
  animation: spin 2.4s linear infinite;
}
.swirl.other-way {
  animation-direction: reverse;
}

/* Closest Sun: a (much exaggerated) oval path */
.orbit {
  position: relative;
  width: 220px;
  height: 110px;
  border: 2px dashed var(--pencil);
  border-radius: 50%;
}
.orbit-sun {
  position: absolute;
  left: 52px;
  top: calc(50% - 26px);
  width: 52px;
  height: 52px;
  line-height: 0;
}
.orbit-earth {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  line-height: 0;
  offset-path: path('M 14 69 A 110 55 0 1 1 234 69 A 110 55 0 1 1 14 69');
  offset-rotate: 0deg;
  animation: orbit 8s linear infinite;
}
:is(.orbit-sun, .orbit-earth) .doodle {
  width: 100%;
  height: 100%;
}

/* Moon Spin: the Moon rides on an arm round the Earth, so its marked side always faces in */
.moon-orbit {
  position: relative;
  width: 140px;
  height: 140px;
  margin-top: 17px; /* the Moon rides above the top of its path */
  border: 2px dashed var(--pencil);
  border-radius: 50%;
}
.moon-earth {
  position: absolute;
  inset: calc(50% - 24px);
  line-height: 0;
}
.moon-earth .doodle {
  width: 48px;
  height: 48px;
}
.moon-arm {
  position: absolute;
  inset: 0;
}
.moon-orbit.go .moon-arm {
  animation: spin 2.5s linear;
}
.moon-body {
  position: absolute;
  left: calc(50% - 17px);
  top: -17px;
  width: 34px;
  height: 34px;
  line-height: 0;
}
.moon-body .doodle {
  width: 100%;
  height: 100%;
}
.moon-face {
  position: absolute;
  left: calc(50% - 5px);
  bottom: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
}

/* Moon Laser */
.laser-scene {
  position: relative;
  width: 240px;
  height: 110px;
}
.laser-earth {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 44px;
  height: 44px;
  line-height: 0;
}
.laser-moon {
  position: absolute;
  right: 0;
  top: 0;
  width: 96px;
  height: 96px;
  line-height: 0;
}
:is(.laser-earth, .laser-moon) .doodle {
  width: 100%;
  height: 100%;
}
.laser-beam {
  position: absolute;
  left: 34px;
  bottom: 30px;
  width: 166px;
  height: 2px;
  background: #e8423f;
  transform-origin: left center;
  animation: sweep-beam 0.7s ease-in-out infinite alternate;
}
.laser-dot {
  position: absolute;
  left: 40px;
  top: 30px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e8423f;
  box-shadow: 0 0 8px #e8423f;
  animation: sweep-dot 0.7s ease-in-out infinite alternate;
}

/* ---------- Chapter 8: logic machines ---------- */

/* Hat Line */
.hat-line {
  display: flex;
  gap: var(--space-3);
}
.hat-person {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 84px;
  font-size: 13px;
  font-weight: 800;
}
.hat-person .doodle {
  width: 64px;
  height: 64px;
}
.hat {
  width: 40px;
  height: 22px;
  margin-bottom: -10px;
  border: 2px solid var(--ink);
  border-radius: 10px 10px 2px 2px;
  background: #d8d4cc;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
}
.hat.unknown::after {
  content: '?';
}
.hat-said {
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--lavender-light);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

/* River Crossing: two banks, and the boat's lane between them */
.river {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: var(--space-2);
  width: min(300px, 100%);
}
.bank,
.walk-bank {
  display: grid;
  gap: 4px;
  align-content: start;
}
.cargo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-s);
  background: #e3f2d6;
}
.cargo .doodle {
  width: 38px;
  height: 38px;
}
.cargo.gone,
.friend.gone {
  visibility: hidden;
}
.water {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: 6px;
  border-radius: var(--radius-s);
  background: #cfe1fb;
}
.raft-lane {
  position: relative;
  align-self: stretch;
  height: 56px;
}
.raft {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 56px;
  line-height: 0;
  transition: left 0.4s var(--ease-out);
}
.raft[data-at='right'] {
  left: calc(100% - 56px);
}
.raft .doodle {
  width: 100%;
  height: 100%;
}
.water .row {
  min-width: 0;
  padding: 10px 18px;
}
.river-note,
.bridge-note,
.tower-note,
.coin-note,
.switch-note,
.chain-note,
.fifteen-note,
.jug-note {
  margin: 0;
  max-width: 320px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* The Tower: discs sit on their peg from the bottom up */
.pegs {
  display: flex;
  gap: var(--space-2);
}
.peg {
  position: relative;
  width: 96px;
  height: 116px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
}
.peg-pole {
  position: absolute;
  left: calc(50% - 3px);
  top: 14px;
  bottom: 8px;
  width: 6px;
  border-radius: 3px;
  background: var(--ink);
}
.peg-discs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 2px;
}
.disc {
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  transition: translate var(--t-ui) var(--ease-spring);
}
.disc.d1 {
  width: 36px;
  background: var(--lime);
}
.disc.d2 {
  width: 58px;
  background: var(--lavender);
}
.disc.d3 {
  width: 82px;
  background: var(--orange);
}
.disc.lifted {
  translate: 0 -14px;
}

/* Measure Four: each jug's height matches how much it holds */
.jugs {
  display: flex;
  align-items: flex-end;
  gap: var(--space-5);
}
.jug-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.jug {
  --size: 1;
  position: relative;
  display: grid;
  place-items: center;
  width: 80px;
  height: calc(var(--size) * 116px);
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 6px 6px 18px 18px;
  background: var(--paper-2);
}
.jug-water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: var(--blue);
  transition: height 0.4s var(--ease-out);
}
.jug-amount {
  position: relative;
  font-size: 14px;
  font-weight: 800;
}
.jug-taps {
  display: flex;
  gap: 6px;
}
.jug-taps .btn {
  min-width: 48px;
  padding: 8px 12px;
}

/* Heavy Coin */
.balance {
  position: relative;
  width: 230px;
  height: 46px;
}
.beam {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--ink);
  transition: rotate 0.4s var(--ease-spring);
}
.balance::after {
  content: '';
  position: absolute;
  left: calc(50% - 10px);
  top: 16px;
  border: 10px solid transparent;
  border-bottom: 18px solid var(--ink);
  border-top: 0;
}
.balance[data-tilt='left'] .beam {
  rotate: -7deg;
}
.balance[data-tilt='right'] .beam {
  rotate: 7deg;
}
.pan-count {
  position: absolute;
  bottom: 0;
  min-width: 40px;
  font-size: 13px;
  white-space: nowrap;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--lavender-light);
  font-weight: 800;
  text-align: center;
}
.pan-count.left {
  left: 6px;
}
.pan-count.right {
  right: 6px;
}
.coin-grid {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 6px;
}
.coin-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #f2cf63;
  font-weight: 800;
}
.coin-btn.cleared {
  border-style: dashed;
  background: var(--paper);
  color: var(--ink-soft);
}
.coin-btn[data-side='left'] {
  background: var(--lavender);
}
.coin-btn[data-side='right'] {
  background: var(--blue);
}
.coin-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.pan-pick[aria-pressed='true'] {
  background: var(--lime);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.coin-btn[data-side='left']::after,
.coin-btn[data-side='right']::after {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font-size: 12px;
  line-height: 22px;
}
.coin-btn[data-side='left']::after {
  content: 'L';
}
.coin-btn[data-side='right']::after {
  content: 'R';
}

/* Three Switches */
.switch-wall {
  display: flex;
  gap: var(--space-3);
}
.switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 64px;
  height: 78px;
  border-radius: var(--radius-s);
  background: var(--paper);
  font-weight: 800;
}
.toggle {
  position: relative;
  width: 22px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-2);
}
.toggle::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 14px;
  border-radius: 3px;
  background: var(--ink-soft);
  transition: bottom var(--t-ui);
}
.switch[aria-pressed='true'] .toggle::after {
  bottom: 16px;
  background: var(--lime-dark);
}
.switch-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.room-lamp .doodle {
  width: 48px;
  height: 48px;
}

/* Night Bridge */
.bridge {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2);
  width: min(320px, 100%);
}
.walk-bank {
  grid-template-columns: 52px 52px;
}
.friend {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-s);
  background: var(--lavender-light);
  font: 800 18px/1 var(--font-display);
}
.friend small {
  font: 700 11px var(--font-body);
}
.bridge-span {
  position: relative;
  height: 14px;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, #a8743f 0 10px, #c8955e 10px 13px);
}
.torch {
  position: absolute;
  bottom: 14px;
  left: 0;
  width: 30px;
  height: 30px;
  line-height: 0;
  transition: left 0.4s var(--ease-out);
}
.torch[data-at='far'] {
  left: calc(100% - 30px);
}
.torch .doodle {
  width: 100%;
  height: 100%;
}

/* Loyd's Fifteen */
.fifteen-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.fifteen-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.fifteen {
  display: grid;
  grid-template-columns: repeat(4, 48px);
  gap: 3px;
}
.tile15,
.gap15 {
  width: 48px;
  height: 48px;
}
.tile15 {
  border-radius: 8px;
  background: var(--lavender-light);
  font: 800 18px var(--font-display);
}

/* Seven-Day Chain: a cut link opens up. The chain stays on one line: 7 links of 48px are wider
   than a small phone's card, so it may reach into the card's side padding (it stays centred). */
.chain {
  display: flex;
  flex: none;
  justify-content: center;
}
.link {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 56px;
}
.link span {
  width: 54px;
  height: 28px;
  border: 5px solid #9b9aa8;
  border-radius: 14px;
}
.link[aria-pressed='true'] span {
  width: 40px;
  border-color: var(--orange);
  border-style: dashed;
  rotate: 20deg;
}

/* Lily Pond */
.pond {
  width: 200px;
  height: 90px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 22% 40%, #5fb85a 13px, transparent 14px),
    radial-gradient(circle at 40% 70%, #5fb85a 12px, transparent 13px),
    radial-gradient(circle at 58% 32%, #5fb85a 14px, transparent 15px),
    radial-gradient(circle at 76% 62%, #5fb85a 13px, transparent 14px),
    radial-gradient(circle at 34% 18%, #5fb85a 9px, transparent 10px),
    radial-gradient(circle at 66% 84%, #5fb85a 9px, transparent 10px), #8fd18a;
}

/* ---------- Chapter 9: mind tricks ---------- */

/* Count the Fs */
.f-text {
  max-width: 340px;
  margin: 0;
  font: 800 18px/1.45 var(--font-display);
  letter-spacing: 0.04em;
  text-align: center;
}

/* Spring in Paris */
.paris-sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 22px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-m);
  background: var(--lime);
}
.sign-line {
  display: flex;
  gap: 4px;
}
.sign-word {
  min-width: 48px;
  min-height: 48px;
  padding: 2px 8px;
  border-radius: 10px;
  font: 800 24px var(--font-display);
  letter-spacing: 0.02em;
}
@media (hover: hover) {
  .sign-word:hover {
    background: rgb(17 19 50 / 10%);
  }
}

/* Spot the Change: a blank flash between the two versions */
.change-scene {
  position: relative;
  width: min(300px, 100%);
  height: 170px;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: linear-gradient(#e3eeff 0 72%, #c6eacb 72%);
}
.change-scene.blank {
  background: #d8d4cc;
}
.change-scene.blank > * {
  opacity: 0;
}
.change-thing {
  position: absolute;
  display: grid;
  place-items: center;
  line-height: 0;
}
.change-thing .doodle {
  width: 100%;
  height: 100%;
}
.change-thing[data-thing='tree'] {
  left: 4px;
  top: 6px;
  width: 110px;
  height: 150px;
}
.change-scene.no-tree .big-tree .doodle {
  visibility: hidden;
}
.change-thing[data-thing='sun'] {
  right: 10px;
  top: 6px;
  width: 52px;
  height: 52px;
}
.change-thing[data-thing='house'] {
  left: 118px;
  bottom: 8px;
  width: 84px;
  height: 84px;
}
.change-thing[data-thing='car'] {
  right: 6px;
  bottom: 4px;
  width: 76px;
  height: 64px;
}

/* Count the Passes: the duck strolls across while the ball flies about */
.court {
  position: relative;
  width: min(300px, 100%);
  height: 160px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: var(--radius-m);
  background: #eef6e6;
}
.player,
.court-ball {
  position: absolute;
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
  translate: -50% -50%;
}
.player {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ink);
}
.player.green {
  background: #5fb85a;
}
.player.white {
  background: #fff;
}
.court-ball {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--orange);
  transition:
    left 0.45s ease,
    top 0.45s ease;
}
.court-duck {
  position: absolute;
  top: calc(50% - 22px);
  left: -60px;
  width: 44px;
  height: 44px;
  line-height: 0;
}
.court-duck .doodle {
  width: 100%;
  height: 100%;
}
.court.go .court-duck {
  animation: duck-walk 3.6s linear 0.6s forwards;
}
.pass-follow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.pass-ask {
  margin: 0;
  font: 800 20px var(--font-display);
  text-align: center;
}

/* Letter Soup */
.soup {
  margin: 0;
  white-space: nowrap;
  font: 800 20px var(--font-display);
  letter-spacing: 0.04em;
  text-align: center;
}
.soup-input {
  width: 16ch;
  text-transform: uppercase;
}

/* Popcorn Sizes */
.tubs {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
}
.tub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 800;
}
.tub-cup {
  width: 48px;
  border: 2px solid var(--ink);
  border-radius: 4px 4px 10px 10px;
  background: repeating-linear-gradient(90deg, #e8423f 0 8px, #fffdf7 8px 16px);
}
.tub.s .tub-cup {
  height: 44px;
}
.tub.m .tub-cup {
  height: 68px;
}
.tub.l .tub-cup {
  height: 76px;
}

/* Word List */
.word-list {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font: 800 20px var(--font-display);
}
.word-question {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

/* B or 13: the middle symbol is a squeezed 13 */
.b13 {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 48px);
  place-items: center;
  font: 800 36px var(--font-display);
}
.b13-top {
  grid-area: 1 / 2;
}
.b13-left {
  grid-area: 2 / 1;
}
.b13-mid {
  grid-area: 2 / 2;
}
.b13-right {
  grid-area: 2 / 3;
}
.b13-bottom {
  grid-area: 3 / 2;
}
.b13-mid span + span {
  margin-left: -0.2em;
}

/* Hundred Machines */
.machines {
  display: flex;
  gap: 2px;
}
.machines .doodle {
  width: 44px;
  height: 44px;
}

/* ---------- Chapter 10: forever and the end ---------- */

/* Endless Vase */
.vase-scene {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.vase {
  flex: none;
  width: 56px;
  height: 72px;
  border: 4px solid var(--ink);
  border-top-width: 0;
  border-radius: 6px 6px 28px 28px;
  background:
    radial-gradient(circle at 30% 70%, var(--orange) 6px, transparent 7px),
    radial-gradient(circle at 64% 76%, var(--lavender) 6px, transparent 7px),
    radial-gradient(circle at 46% 50%, var(--lime) 6px, transparent 7px), var(--lavender-light);
}
.vase-count,
.prime-list,
.diary-line,
.book-page {
  max-width: 280px;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

/* Holey Triangle */
.holey {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.holey-art {
  width: 120px;
  height: 120px;
  line-height: 0;
}
.holey-art .doodle {
  width: 100%;
  height: 100%;
}
.holey-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.holey-note {
  margin: 0;
  max-width: 140px;
  font-weight: 800;
  text-align: center;
}

/* Biggest Prime, Slow Writer */
.prime-machine,
.diary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* Endless Library */
.shelf {
  display: flex;
  gap: 4px;
  padding-bottom: 4px;
  border-bottom: 6px solid #a8743f;
}
.shelf-book {
  display: grid;
  place-items: center;
  width: 52px;
  height: 64px;
  line-height: 0;
}
.shelf-book .doodle {
  width: 52px;
  height: 64px;
}
.shelf-book:nth-child(2n) .doodle {
  color: var(--blue-ink);
}

/* Digits of Pi */
.pi-strip {
  width: min(300px, 100%);
  overflow: hidden;
  contain: inline-size; /* the endless digits must not widen the layout */
  padding: 8px 0;
  border-radius: var(--radius-s);
  background: var(--paper);
}
.pi-strip span {
  display: inline-block;
  white-space: nowrap;
  font:
    800 20px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  animation: marquee 30s linear infinite;
}

/* Picture in a Picture: every frame holds a half-size copy of itself in its corner */
.droste {
  position: relative;
  width: 160px;
  height: 160px;
  overflow: hidden;
  border-radius: var(--radius-s);
}
.frame {
  position: absolute;
  right: 6%;
  bottom: 6%;
  width: 50%;
  height: 50%;
  border: 2px solid var(--ink);
  background: var(--lavender-light);
}
.droste > .frame {
  inset: 0;
  width: 100%;
  height: 100%;
  border-width: 3px;
  border-radius: var(--radius-s);
  transform-origin: 88% 88%;
}
.frame .frame {
  background: var(--lime);
}
.frame .frame .frame {
  background: var(--lavender-light);
}
.frame .frame .frame .frame {
  background: var(--lime);
}
.frame .frame .frame .frame .frame {
  background: var(--lavender-light);
}
.frame > .doodle {
  position: absolute;
  left: 4%;
  top: 4%;
  width: 46%;
  height: 46%;
}
.droste.zoom > .frame {
  animation: droste-zoom 0.6s var(--ease-out);
}

/* Will It Stop? */
.program {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 330px;
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-m);
  background: var(--lavender-light);
  font-size: 14px;
}
.program strong {
  font: 800 18px var(--font-display);
}

/* Can't Be Proved */
.liar-card.godel {
  padding: 26px 26px;
}

/* The Way Out */
.way-out-door {
  line-height: 0;
}
.way-out-door .doodle {
  width: 90px;
  height: 90px;
}

@keyframes slide-left {
  to {
    background-position: -40px 0;
  }
}
@keyframes mast-drop {
  to {
    translate: 0 69px;
  }
}
@keyframes throw-across {
  to {
    translate: 150px 0;
  }
}
@keyframes fall-down {
  to {
    translate: 0 117px;
  }
}
@keyframes drive-off {
  to {
    translate: 24px 0;
  }
}
@keyframes let-go {
  to {
    translate: 0 -12px;
    opacity: 0;
  }
}
@keyframes slinky-top {
  65% {
    translate: 0 76px;
    animation-timing-function: ease-in;
  }
  to {
    translate: 0 111px;
  }
}
@keyframes slinky-coil {
  65% {
    scale: 1 0.06;
    translate: 0 0;
    animation-timing-function: ease-in;
  }
  to {
    scale: 1 0.06;
    translate: 0 35px;
  }
}
@keyframes slinky-bottom {
  65% {
    translate: 0 0;
    animation-timing-function: ease-in;
  }
  to {
    translate: 0 35px;
  }
}
@keyframes big-bounce {
  45% {
    translate: 0 var(--lift);
  }
  70% {
    translate: 0 calc(var(--lift) * 0.7);
  }
  to {
    translate: 0 var(--lift);
  }
}
@keyframes small-bounce {
  45% {
    translate: 0 var(--lift);
  }
  70% {
    translate: 0 calc(var(--lift) * 0.5);
  }
  to {
    translate: 0 var(--lift);
  }
}
@keyframes small-launch {
  45% {
    translate: 0 var(--lift);
    opacity: 1;
  }
  to {
    translate: 0 -400px;
    opacity: 0;
  }
}
@keyframes spin {
  to {
    rotate: 360deg;
  }
}
@keyframes orbit {
  to {
    offset-distance: 100%;
  }
}
@keyframes sweep-beam {
  from {
    rotate: -14deg;
  }
  to {
    rotate: -6deg;
  }
}
@keyframes sweep-dot {
  to {
    translate: 14px 30px;
  }
}
@keyframes duck-walk {
  to {
    left: calc(100% + 60px);
  }
}
@keyframes marquee {
  to {
    translate: -100% 0;
  }
}
@keyframes droste-zoom {
  from {
    scale: 1;
  }
  to {
    scale: 2;
  }
}

@keyframes rewind {
  to {
    rotate: -720deg;
  }
}
@keyframes turn-over {
  from {
    rotate: -180deg;
  }
}
@keyframes walk-in {
  from {
    opacity: 0;
    translate: 40px 0;
  }
}

/* ---------- Privacy page ---------- */
#app.privacy {
  max-width: 740px;
  padding-top: var(--space-4);
  line-height: 1.7;
  -webkit-user-select: text;
  user-select: text;
}
.privacy .brand-home {
  display: inline-flex;
}
.privacy h1 {
  margin: var(--space-5) 0 var(--space-3);
  font-size: 46px;
}
.privacy h2 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: 26px;
}
.privacy-lead {
  color: var(--ink-soft);
  font-size: 18px;
}

/* ---------- Keyframes ---------- */
@keyframes rise {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}
@keyframes logo-reveal {
  from {
    opacity: 0;
    scale: 0.78;
    rotate: -4deg;
  }
}
@keyframes modal-in {
  from {
    opacity: 0;
    translate: 0 18px;
    scale: 0.95;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    scale: 0.7;
  }
}
@keyframes flip-card {
  50% {
    transform: perspective(600px) rotateX(180deg);
  }
  to {
    transform: perspective(600px) rotateX(360deg);
  }
}
@keyframes swing-open {
  from {
    transform: perspective(500px) rotateY(80deg);
  }
}
@keyframes shake {
  20% {
    translate: -6px 0;
  }
  40% {
    translate: 6px 0;
  }
  60% {
    translate: -3px 0;
  }
  80% {
    translate: 3px 0;
  }
}
@keyframes bob {
  50% {
    translate: 0 -4px;
  }
}
@keyframes flutter {
  50% {
    transform: skewY(-6deg) scaleX(0.94);
  }
}
@keyframes pulse {
  50% {
    scale: 1.05;
  }
}
@keyframes jiggle {
  25% {
    rotate: -3deg;
  }
  75% {
    rotate: 3deg;
  }
}
@keyframes rattle {
  0%,
  80%,
  100% {
    rotate: 0deg;
  }
  84% {
    rotate: -6deg;
  }
  88% {
    rotate: 5deg;
  }
  92% {
    rotate: -3deg;
  }
}
@keyframes dither {
  20%,
  45% {
    scale: -1 1;
  }
  60%,
  85% {
    scale: 1 1;
  }
}
@keyframes munch {
  50% {
    translate: 0 4px;
  }
}
@keyframes breathe {
  50% {
    opacity: 0.5;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- Tablets and small laptops ---------- */
@media (max-width: 900px) {
  #app,
  .brand-bar {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }
  .hero-copy,
  .intro-copy {
    padding: 34px 28px;
  }
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- Phones (portrait) ---------- */
@media (max-width: 640px) {
  #app,
  .brand-bar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  #app {
    padding-top: 0;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .brand-bar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .brand-home img {
    width: 168px;
  }
  .hero-panel,
  .intro-layout {
    grid-template-columns: 1fr;
    border-radius: 27px;
  }
  .hero-art {
    grid-row: 1;
    min-height: 0;
    height: clamp(150px, 40vw, 210px);
  }
  .hero-art > img {
    object-position: 50% 30%;
  }
  .art-sticker {
    top: 14px;
    right: 14px;
    width: 72px;
    height: 72px;
    font-size: 13px;
  }
  .hero-copy {
    padding: 22px 22px 24px;
    border: 0;
    border-radius: 0;
  }
  .hero-copy .eyebrow {
    font-size: 11px;
    margin-bottom: var(--space-2);
  }
  .hero-copy h1 {
    font-size: clamp(32px, 9vw, 44px);
    margin-bottom: var(--space-3);
  }
  .tagline {
    margin-bottom: var(--space-4);
    font-size: 15px;
  }
  .menu-buttons .btn {
    max-width: none;
  }
  .menu-tiles {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
  }
  .daily-tile {
    grid-column: 1 / -1;
  }
  .tile {
    min-height: 68px;
    padding: 12px 14px;
    gap: var(--space-3);
    border-radius: var(--radius-m);
  }
  .tile-icon {
    width: 36px;
    height: 36px;
  }
  .tile-icon .icon-line {
    width: 20px;
    height: 20px;
  }
  .tile-copy strong {
    font-size: 18px;
  }
  .tile-copy small {
    font-size: 12px;
  }
  .levels-tile .tile-copy small,
  .board-tile .tile-copy small {
    display: none;
  }
  /* With today's top solvers showing, the mascot moves to a strip beside the words to make room */
  .menu:has(.top-note:not([hidden])) .hero-panel {
    grid-template-columns: 1fr 96px;
  }
  .menu:has(.top-note:not([hidden])) .hero-art {
    grid-row: 1;
    grid-column: 2;
    height: auto;
  }
  .menu:has(.top-note:not([hidden])) :is(.art-sticker, .tagline) {
    display: none;
  }
  .menu:has(.top-note:not([hidden])) .hero-copy h1 {
    font-size: 30px;
  }
  .top-note {
    padding: 16px 18px;
  }
  .intro-art {
    min-height: 0;
    height: clamp(180px, 50vw, 280px);
  }
  .intro-art > img {
    object-position: 50% 30%;
  }
  .intro-copy {
    padding: 24px 22px;
  }
  .intro-copy h1 {
    font-size: clamp(32px, 9vw, 44px);
  }
  .intro-body {
    font-size: 15px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
  .grid .cell {
    min-height: 112px;
    padding: 16px;
  }
  .play {
    padding: 16px 18px 24px;
    border-radius: 25px;
  }
  .bar {
    margin-bottom: var(--space-4);
  }
  .bar-title {
    font-size: 11px;
    letter-spacing: 0.05em;
  }
  .prompt {
    font-size: clamp(23px, 6.6vw, 30px);
  }
  .choice {
    min-width: 108px;
    padding: 12px 16px;
  }
  .choice.big {
    width: 126px;
    height: 132px;
    padding: 16px;
  }
  .card-setup {
    padding: 16px 18px;
    font-size: 15px;
    margin-bottom: var(--space-4);
  }
  .room {
    width: 58px;
    height: 82px;
  }
  .room .who .doodle {
    width: 40px;
    height: 40px;
  }
  .door {
    width: 80px;
    height: 128px;
  }
  .door .doodle {
    width: 58px;
    height: 58px;
  }
  .board-paper {
    padding: var(--space-2) var(--space-3);
  }
  .board-row {
    padding: 10px 6px;
    gap: 10px;
  }
  .win-card {
    padding: 28px 22px 22px;
  }
  .stamp {
    font-size: 46px;
  }
}

@media (max-width: 360px) {
  .choice.big {
    width: 112px;
    height: 120px;
  }
  .room {
    width: 52px;
    height: 76px;
  }
  .door {
    width: 72px;
    height: 118px;
  }
}

/* ---------- Phones on their side: words left, puzzle right, nothing below the fold ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .brand-bar {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 4px;
  }
  .brand-home img {
    width: 150px;
  }
  /* Puzzles need every pixel of height: the logo steps aside while playing. */
  body[data-screen='play'] .brand-bar {
    display: none;
  }
  #app {
    padding-top: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  body[data-screen='play'] #app {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .menu {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    column-gap: var(--space-4);
    align-items: start;
  }
  .menu > :not(.hero-panel, .menu-tiles) {
    grid-column: 1 / -1;
  }
  .hero-panel {
    grid-template-columns: 1fr 120px;
    border-radius: 24px;
  }
  .hero-copy {
    padding: 18px 20px;
    border-radius: 24px 0 0 24px;
  }
  .hero-copy .eyebrow {
    display: none;
  }
  .hero-copy h1 {
    font-size: 26px;
    margin-bottom: var(--space-2);
  }
  .tagline {
    font-size: 14px;
    margin-bottom: var(--space-3);
  }
  .hero-art {
    min-height: 0;
  }
  .art-sticker {
    display: none;
  }
  .menu-tiles {
    grid-template-columns: 1fr;
    gap: var(--space-2);
    margin-top: 0;
  }
  .tile {
    min-height: 56px;
    padding: 8px 14px;
    gap: var(--space-3);
    border-radius: var(--radius-m);
  }
  .tile-icon {
    width: 34px;
    height: 34px;
  }
  .tile-copy strong {
    font-size: 17px;
  }
  .tile-copy small {
    display: none;
  }
  .top-note {
    display: none !important;
  }

  .intro-layout {
    grid-template-columns: 0.8fr 1.2fr;
  }
  .intro-art {
    min-height: 0;
  }
  .intro-art .art-sticker {
    display: none;
  }
  .intro-copy {
    padding: 18px 24px;
  }
  .intro-copy h1 {
    font-size: 28px;
    margin-bottom: var(--space-2);
  }
  .intro-body {
    font-size: 14px;
    margin-bottom: 0;
  }
  .intro-dots {
    margin: 0;
  }

  .levels-head {
    margin-bottom: var(--space-3);
  }
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .grid .cell {
    min-height: 96px;
    padding: 14px;
  }

  .play {
    width: min(900px, 100%);
    margin-top: 0;
    padding: 10px 20px 12px;
    display: grid;
    grid-template-columns: minmax(200px, 38%) 1fr;
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: var(--space-5);
    align-content: start;
  }
  .bar {
    grid-column: 1 / -1;
    margin-bottom: var(--space-2);
  }
  .title {
    grid-column: 1;
    text-align: left;
    margin-bottom: var(--space-1);
  }
  .card-setup {
    grid-column: 1;
    margin: 0 0 var(--space-2);
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
  }
  .card-setup .doodle {
    width: 34px;
    height: 34px;
  }
  .prompt {
    grid-column: 1;
    text-align: left;
    font-size: 22px;
  }
  .hint-box {
    grid-column: 1;
    padding: 10px 14px;
    font-size: 14px;
  }
  .stage {
    grid-column: 2;
    grid-row: 2 / -1;
    min-height: 0;
    padding: 0;
    gap: var(--space-4);
  }
  .choice.big {
    width: 108px;
    height: 108px;
  }
  .card-choices {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--space-2);
    max-width: 340px;
  }
  .card-choices .choice {
    min-height: 50px;
    padding: 6px 14px;
    font-size: 15px;
  }
  .track {
    height: 105px;
  }
  .room {
    width: 52px;
    height: 72px;
  }
  .room .who .doodle {
    width: 34px;
    height: 34px;
  }
  .hotel {
    gap: var(--space-2);
  }
  .guest {
    width: 72px;
    height: 72px;
  }
  .guest .doodle {
    width: 48px;
    height: 48px;
  }
  .cat-box {
    width: 120px;
    height: 120px;
  }
  .big-red {
    width: 140px;
    height: 124px;
  }
  .wall {
    width: 160px;
    height: 130px;
  }
  .door {
    width: 80px;
    height: 120px;
  }
  .door .doodle {
    width: 54px;
    height: 54px;
  }
  .liar-card {
    padding: 40px 22px 22px;
    font-size: 22px;
  }
  .overlay {
    display: block;
  }
  .win-card {
    margin: 0 auto;
    padding-top: var(--space-5);
  }
  .stamp {
    font-size: 38px;
  }

  /* Chapters 2 and 3: smaller pieces so every control fits above the fold */
  .penrose {
    width: 170px;
    height: 139px;
  }
  .coast-view {
    height: 84px;
  }
  .choices .choice {
    min-height: 50px;
  }
  .gate {
    gap: 6px;
  }
  .g-door {
    width: 52px;
    height: 72px;
  }
  .guard .doodle {
    width: 56px;
    height: 56px;
  }
  .questions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }
  .questions .choice {
    padding: 6px 10px;
    font-size: 14px;
  }
  .clock,
  .chest {
    width: 88px;
    height: 88px;
  }
  .monkey {
    width: 84px;
    height: 84px;
  }
  .monkey .doodle {
    width: 80px;
    height: 80px;
  }
  .text-label {
    width: auto;
  }
  .barber,
  .barber-face .doodle {
    width: 120px;
    height: 120px;
  }
  .beard {
    left: 34px;
    top: 42px;
  }
  .space {
    height: 190px;
  }
  .coast-tools + .choices {
    flex-wrap: nowrap;
  }
  .coast-tools + .choices .choice {
    min-width: 0;
    padding: 6px 14px;
  }
  .heap {
    width: 170px;
    height: 124px;
  }
  .grains .doodle {
    width: 170px;
    height: 170px;
  }
  .heap-word {
    top: 68px;
  }

  /* Chapter 4 */
  .grey-scene + .choices,
  .fork-slider + .choices {
    flex-wrap: nowrap;
  }
  .grey-scene + .choices .choice,
  .fork-slider + .choices .choice {
    min-width: 52px;
    padding: 6px 14px;
  }
  .hermann {
    grid-template-columns: repeat(5, 32px);
    grid-auto-rows: 32px;
  }
  .kanizsa .doodle {
    width: 100px;
    height: 100px;
  }
  .fork-view {
    height: 110px;
  }
  .fork-art .doodle {
    width: 110px;
    height: 110px;
  }
  .necker .doodle {
    width: 120px;
    height: 120px;
  }
  .tiles {
    height: 20px;
  }
  .ruler {
    height: 116px;
  }
  .ruler-line {
    top: 24px;
  }
  .flag-negative {
    width: 180px;
    height: 110px;
  }
  .spin-wheel {
    width: 110px;
    height: 110px;
  }
  .table-pick,
  .table-right {
    width: 110px;
    height: 110px;
  }
  .table-pick .doodle,
  .table-right .doodle {
    width: 100px;
    height: 100px;
  }

  /* Chapters 5 and 6 */
  .plans {
    gap: var(--space-2);
  }
  .plans .choice {
    min-height: 48px;
    padding: 6px 10px;
    font-size: 14px;
  }
  .steps {
    font-size: 12px;
    line-height: 1.3;
  }
  .symbols {
    grid-template-columns: repeat(8, 48px);
  }
  .kit-item .doodle {
    width: 56px;
    height: 56px;
  }
  .rooftop {
    width: 160px;
    height: 96px;
  }
  .roof {
    height: 56px;
  }
  .roof-bird,
  .roof-bird .doodle {
    width: 48px;
    height: 48px;
  }
  .roof-bird {
    left: calc(50% - 24px);
  }
  .bin {
    height: 86px;
  }
  .needle-floor {
    height: 80px;
  }
  .sky {
    width: 120px;
    height: 120px;
  }
  .bent .doodle {
    width: 48px;
    height: 48px;
  }
  .card-back {
    height: 28px;
  }

  /* Chapters 7 to 10 */
  .slinky-scene,
  .moon-orbit {
    zoom: 0.7;
  }
  .mirror-scene {
    zoom: 0.6;
  }
  .bounce-scene {
    --lift: 40px;
  }
  .coin-grid {
    grid-template-columns: repeat(8, 48px);
  }
  .coin-btn {
    width: 48px;
    height: 48px;
  }
  .fifteen-play {
    flex-direction: row;
  }
  .tub.s .tub-cup {
    height: 24px;
  }
  .tub.m .tub-cup {
    height: 34px;
  }
  .tub.l .tub-cup {
    height: 38px;
  }
  .word-list {
    grid-template-columns: repeat(4, auto);
  }
  .droste {
    width: 140px;
    height: 140px;
  }
}

/* Every animation above is decoration: with reduced motion the game is still complete. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
