/* ---------- Theme tokens ---------- */
:root {
  /* Light: pastel desk */
  --desk: #f4ebff;
  --desk-dots: #e2d3fa;
  --ink: #3d2c5e;          /* pixel outlines */
  --pen: #4a3f94;          /* handwriting ink */
  --ink-soft: #7a6a9a;
  --label: #c0508f;
  --accent: #b48ce6;
  --highlight: #ffe38a;
  --cover: #f4a9c6;
  --paper: #fffaf0;
  --paper-edge: #f1e4cf;
  --rule: #cfe0f5;
  --margin: #f7b3c2;
  --ring: #d9d2e6;
  --ring-hi: #ffffff;
  --ring-shade: #aa9fc0;
  --stitch: rgba(255, 255, 255, 0.7);
  --reload: #ffd0e2;
  --step: #cfe8ff;
  --play: #b8ecd3;
  --pause: #fff1a8;
  --stop: #ffc2b8;
  --sticky-yellow: #fff1a8;
  --sticky-pink: #ffd0e2;
  --sticky-quote: #fff6c8;
  --tape-pink: #ffb8d2;
  --tape-blue: #b5dcff;
  --tape-mint: #b8ecd3;
  --tape-lilac: #d9c6ff;
  --sticker-edge: #ffffff;
  --steam: #ffffff;
  --skin: #ffe1cf;
  --star-1: #ffd36e;
  --star-2: #ff9ec7;
  --star-3: #9fd4ff;
  --star-4: #b48ce6;
  --shadow: rgba(61, 44, 94, 0.85);
  --screen-edge: var(--ink);
  --hatch-pink: #f59cc2;
  --hatch-blue: #92c4f0;
  --hatch-mint: #7fd4ae;
  --hatch-yellow: #f2cf57;
  --hatch-coral: #f39c88;
  color-scheme: light;
}

/* Dark: moody desk at midnight */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #110d1b;
    --desk-dots: #1f1830;
    --ink: #06040c;
    --pen: #ddd0f7;
    --ink-soft: #9d90b8;
    --label: #e09ac2;
    --accent: #9b7ad1;
    --highlight: #4d3a78;
    --cover: #5a2848;
    --paper: #221b31;
    --paper-edge: #2e2542;
    --rule: rgba(165, 175, 235, 0.13);
    --margin: rgba(224, 154, 194, 0.32);
    --ring: #6c6385;
  --ring-hi: #9a90b3;
  --ring-shade: #4a4260;
  --stitch: rgba(224, 154, 194, 0.4);
    --reload: #6a2f55;
    --step: #2c3a5c;
    --play: #2d5b52;
    --pause: #7a6230;
    --stop: #7a3040;
    --sticky-yellow: #6b5b2e;
    --sticky-pink: #5e3049;
    --sticky-quote: #3d3450;
    --tape-pink: #8a4a6a;
    --tape-blue: #3e5a82;
    --tape-mint: #2f6358;
    --tape-lilac: #5d4c8a;
    --sticker-edge: #cbbde0;
    --steam: #8c80a6;
    --skin: #e9c3ad;
    --star-1: #ffe29a;
    --star-2: #f5a3cf;
    --star-3: #a9d8ff;
    --star-4: #cdb4ff;
    --shadow: rgba(0, 0, 0, 0.8);
  --hatch-pink: #b86a93;
  --hatch-blue: #5b7fb8;
  --hatch-mint: #4a9680;
  --hatch-yellow: #b09344;
  --hatch-coral: #b0605a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #110d1b;
  --desk-dots: #1f1830;
  --ink: #06040c;
  --pen: #ddd0f7;
  --ink-soft: #9d90b8;
  --label: #e09ac2;
  --accent: #9b7ad1;
  --highlight: #4d3a78;
  --cover: #5a2848;
  --paper: #221b31;
  --paper-edge: #2e2542;
  --rule: rgba(165, 175, 235, 0.13);
  --margin: rgba(224, 154, 194, 0.32);
  --ring: #6c6385;
  --ring-hi: #9a90b3;
  --ring-shade: #4a4260;
  --stitch: rgba(224, 154, 194, 0.4);
  --reload: #6a2f55;
  --step: #2c3a5c;
  --play: #2d5b52;
  --pause: #7a6230;
  --stop: #7a3040;
  --sticky-yellow: #6b5b2e;
  --sticky-pink: #5e3049;
  --sticky-quote: #3d3450;
  --tape-pink: #8a4a6a;
  --tape-blue: #3e5a82;
  --tape-mint: #2f6358;
  --tape-lilac: #5d4c8a;
  --sticker-edge: #cbbde0;
  --steam: #8c80a6;
  --skin: #e9c3ad;
  --star-1: #ffe29a;
  --star-2: #f5a3cf;
  --star-3: #a9d8ff;
  --star-4: #cdb4ff;
  --shadow: rgba(0, 0, 0, 0.8);
  --hatch-pink: #b86a93;
  --hatch-blue: #5b7fb8;
  --hatch-mint: #4a9680;
  --hatch-yellow: #b09344;
  --hatch-coral: #b0605a;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background-color: var(--desk);
  background-image: radial-gradient(var(--desk-dots) 2px, transparent 2px);
  background-size: 22px 22px;
  color: var(--pen);
  font-family: "Pixelify Sans", ui-monospace, monospace;
  display: grid;
  place-items: center;
  padding: 76px 130px 88px;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}
/* pixel magic-wand cursor; hotspot is the centre of the star */
html { cursor: url("wand-cursor.svg") 9 9, auto; }
a, button:not([disabled]) { cursor: url("wand-cursor.svg") 9 9, pointer; }
button { font: inherit; color: inherit; }
svg { display: block; fill: currentColor; }
.sprite svg { width: 100%; height: auto; }

.desk { position: relative; width: 100%; max-width: 1100px; }

/* ---------- The book ---------- */
.book {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--cover);
  padding: 18px 20px 26px;
  /* pixel outline: four offset copies leave the corners notched, plus a stepped drop shadow */
  box-shadow:
    0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink),
    0 12px 0 -4px var(--shadow), 0 8px 0 0 var(--shadow);
  transition: background-color 0.4s ease;
}
/* dashed pixel stitching around the cover */
.book::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 3px dashed var(--stitch);
  pointer-events: none;
}

.page {
  --line: 28px;
  position: relative;
  padding: 56px 36px 56px 68px;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent 48px, var(--margin) 48px, var(--margin) 50px, transparent 50px),
    repeating-linear-gradient(to bottom, transparent 0 26px, var(--rule) 26px 28px);
  border: 3px solid var(--ink);
  transition: background-color 0.4s ease;
}
/* stacked sheets peeking out underneath */
.page--left {
  border-right-width: 1px;
  box-shadow:
    -6px 6px 0 -3px var(--paper-edge), -6px 6px 0 0 var(--ink),
    -12px 12px 0 -3px var(--paper-edge), -12px 12px 0 0 var(--ink);
}
.page--right {
  border-left-width: 1px;
  box-shadow:
    6px 6px 0 -3px var(--paper-edge), 6px 6px 0 0 var(--ink),
    12px 12px 0 -3px var(--paper-edge), 12px 12px 0 0 var(--ink);
}
/* gutter shading near the spine */
.page::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 56px;
  pointer-events: none;
}
.page--left::before { right: 0; background: linear-gradient(to left, rgba(40, 20, 70, 0.13) 0 9px, rgba(40, 20, 70, 0.08) 9px 21px, rgba(40, 20, 70, 0.04) 21px 36px, transparent 36px); }
.page--right::before { left: 0; background: linear-gradient(to right, rgba(40, 20, 70, 0.13) 0 9px, rgba(40, 20, 70, 0.08) 9px 21px, rgba(40, 20, 70, 0.04) 21px 36px, transparent 36px); }

/* spiral rings */
.rings {
  position: absolute;
  z-index: 6;
  top: 38px; bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.rings span { display: block; width: 54px; height: 15px; }
.rings svg { width: 100%; height: 100%; }

/* ribbon bookmark */
.ribbon {
  position: absolute;
  z-index: 1; /* above the cover stitching, emerging just below the page stacks */
  top: calc(100% - 14px);
  left: calc(50% + 56px);
  width: 24px;
  animation: sway 4s ease-in-out infinite;
  transform-origin: top center;
}

/* ---------- Washi tape & sticky notes ---------- */
.tape {
  position: absolute;
  z-index: 7;
  width: 96px;
  height: 24px;
  opacity: 0.9;
  background: repeating-linear-gradient(90deg, var(--tc) 0 6px, color-mix(in srgb, var(--tc) 62%, white) 6px 12px);
  clip-path: polygon(
    0 0, 100% 0, 100% 25%, calc(100% - 4px) 25%, calc(100% - 4px) 50%, 100% 50%, 100% 75%,
    calc(100% - 4px) 75%, calc(100% - 4px) 100%, 4px 100%, 4px 75%, 0 75%, 0 50%, 4px 50%, 4px 25%, 0 25%);
  pointer-events: none;
}
.tape--pink { --tc: var(--tape-pink); }
.tape--blue { --tc: var(--tape-blue); }
.tape--mint { --tc: var(--tape-mint); }
.tape--lilac { --tc: var(--tape-lilac); }
.tape--tl { top: -12px; left: 36px; }
.tape--tr { top: -12px; right: 44px; }

.sticky {
  position: relative;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  color: var(--pen);
  font-size: 17px;
  line-height: 1.25;
  padding: 18px 14px 16px;
  transition: background-color 0.4s ease;
}
.sticky .tape { top: -14px; left: 50%; width: 72px; margin-left: -36px; }
.sticky--yellow { background: var(--sticky-yellow); }
.sticky--pink { background: var(--sticky-pink); }
.sticky--quote { background: var(--sticky-quote); }

/* ---------- Desk decor ---------- */
.decor > * { position: absolute; z-index: 8; pointer-events: none; }
.deco-pencil { width: 190px; left: -70px; bottom: -34px; transform: rotate(-16deg); }
.deco-pen { width: 210px; right: 70px; top: -62px; transform: rotate(7deg); }
.deco-mug { width: 92px; right: -118px; bottom: 60px; }
.deco-note-1 { width: 140px; left: -104px; top: 30px; transform: rotate(-8deg); }
.deco-note-2 { width: 96px; right: -96px; top: 90px; transform: rotate(7deg); text-align: center; }
.deco-star { width: 46px; left: -70px; top: 250px; transform: rotate(-12deg); }
.deco-heart { width: 42px; right: -72px; top: 230px; transform: rotate(10deg); }
.deco-moon { width: 44px; left: 38%; top: -58px; transform: rotate(-10deg); }
.deco-flower { width: 50px; right: 26%; bottom: -70px; transform: rotate(14deg); }

.sticker {
  filter:
    drop-shadow(3px 0 0 var(--sticker-edge)) drop-shadow(-3px 0 0 var(--sticker-edge))
    drop-shadow(0 3px 0 var(--sticker-edge)) drop-shadow(0 -3px 0 var(--sticker-edge))
    drop-shadow(3px 4px 0 var(--shadow));
}

.steam { position: absolute; left: 22px; top: -34px; width: 50px; height: 40px; }
.steam i {
  position: absolute;
  bottom: 0;
  width: 7px; height: 7px;
  background: var(--steam);
  opacity: 0;
  animation: steam 2.4s steps(6) infinite;
}
.steam i:nth-child(1) { left: 4px; }
.steam i:nth-child(2) { left: 20px; animation-delay: 0.8s; }
.steam i:nth-child(3) { left: 36px; animation-delay: 1.6s; }

/* ---------- Theme toggle (a sticker in the corner) ---------- */
.theme-toggle {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 30;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--sticky-pink);
  color: var(--label);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--shadow);
  transform: rotate(4deg);
}
.theme-toggle:active { transform: rotate(4deg) translateY(4px); box-shadow: none; }
.theme-toggle svg { width: 22px; height: 22px; }
.icon-sun { display: none !important; }
:root[data-theme="dark"] .icon-moon { display: none !important; }
:root[data-theme="dark"] .icon-sun { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: none !important; }
  :root:not([data-theme="light"]) .icon-sun { display: block !important; }
}

/* ---------- Left page ---------- */
.title-block { position: relative; }
.title {
  display: inline;
  margin: 0;
  font-size: 38px;
  font-weight: 600;
  line-height: 56px;
  color: var(--pen);
  background: linear-gradient(transparent 58%, var(--highlight) 58%, var(--highlight) 86%, transparent 86%);
}
.title__star {
  display: inline-block;
  width: 22px; height: 22px;
  margin-left: 6px;
  vertical-align: 4px;
  color: var(--accent);
  animation: twinkle-soft 2.4s ease-in-out infinite;
}
.subtitle { margin: 0; font-size: 17px; line-height: var(--line); color: var(--ink-soft); }

.block { margin-top: var(--line); }
.label {
  margin: 0;
  font-family: "Silkscreen", monospace;
  font-weight: 400;
  font-size: 13px;
  line-height: var(--line);
  color: var(--label);
  letter-spacing: 0.5px;
}
.label::before { content: "~ "; }
.howto { margin: 0; padding-left: 26px; font-size: 18px; line-height: var(--line); }
.howto li::marker { color: var(--label); font-family: "Silkscreen", monospace; font-size: 13px; }

.checks { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.seg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 19px;
  line-height: var(--line);
  color: var(--pen);
}
.box {
  position: relative;
  width: 24px; height: 24px;
  --hatch: transparent;
}
.tick {
  position: absolute;
  z-index: 2;
  left: 1px; top: -7px;
  width: 30px; height: 30px;
  overflow: visible;
  fill: none;
  stroke: var(--label);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* the tick path is ~30 units long; a fixed dash avoids pathLength, which Safari handles poorly */
  stroke-dasharray: 40 80;
  stroke-dashoffset: 40;
  opacity: 0;
  transition: stroke-dashoffset 0.35s ease, opacity 0.1s ease;
}
.seg[aria-checked="true"] .box { --hatch: var(--hatch-pink); }
.seg[aria-checked="true"] .tick { stroke-dashoffset: 0; opacity: 1; }
.seg[aria-checked="true"] { text-decoration: underline wavy var(--label) 2px; text-underline-offset: 5px; }
.seg:hover .box { --hatch: var(--hatch-pink); }
.seg:not([aria-checked="true"]):hover .sketch-line .hatch { opacity: 0.45; }

/* ---------- Hand-drawn controls ----------
   Each .sketch element gets a rough, double-stroked pen outline and an
   optional colored-pencil hatch fill (colour from --hatch), drawn by app.js. */
.sketch { position: relative; }
.sketch > .sketch-line { position: absolute; z-index: 1; pointer-events: none; overflow: visible; color: var(--pen); }
.sketch-line path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sketch-line .ink { stroke: currentColor; stroke-width: 1.9; }
.sketch-line .ink--2 { stroke-width: 1.2; opacity: 0.65; }
.sketch-line .hatch { stroke: var(--hatch, transparent); stroke-width: 1.7; opacity: 0.8; transition: opacity 0.15s ease; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }

.btn {
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--pen);
  transition: transform 0.08s ease, opacity 0.2s ease;
}
.btn > svg:not(.sketch-line), .btn__label { position: relative; z-index: 2; }
.btn:hover .sketch-line .hatch { opacity: 1; }
.btn:hover { transform: rotate(-0.6deg); }
.btn:active, .btn.is-pressed { transform: translate(1px, 2px); }
.btn:focus-visible, .seg:focus-visible, .theme-toggle:focus-visible, .copy:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}
.btn[disabled] { opacity: 0.35; cursor: url("wand-cursor.svg") 9 9, default; }
.btn[disabled]:hover { transform: none; }

.btn--reload {
  --hatch: var(--hatch-pink);
  margin-top: var(--line);
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 21px;
  font-weight: 500;
}
.btn--reload svg { width: 14px; height: 14px; color: var(--label); }
.btn--reload.is-loading > svg:not(.sketch-line) { animation: twinkle-soft 0.6s ease-in-out infinite; }

.timer { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 16px; }
.btn--step { --hatch: var(--hatch-blue); display: grid; place-items: center; padding: 0; height: 48px; }
.btn--step .icon { width: 20px; height: 20px; }
.clock {
  height: 48px;
  display: grid;
  place-items: center;
  font-family: "Silkscreen", monospace;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--pen);
}
.clock #time { position: relative; z-index: 2; }
.clock.is-running #time { color: var(--label); }
.clock.is-done #time { animation: blink 0.5s steps(2) 6; }
.progress { position: absolute; z-index: 2; left: 9px; right: 9px; bottom: 7px; height: 3px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: 2px; background: var(--label); transition: width 0.3s linear; }

.transport { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }
.transport .btn { height: 42px; display: grid; place-items: center; }
.transport .icon { width: 22px; height: 22px; }
.btn--play { --hatch: var(--hatch-mint); }
.btn--pause { --hatch: var(--hatch-yellow); }
.btn--stop { --hatch: var(--hatch-coral); }

.kbd-hint { margin: 18px 0 0; font-family: "Silkscreen", monospace; font-size: 11px; color: var(--ink-soft); }
kbd { font-family: inherit; padding: 0 4px; border: 2px solid currentColor; border-radius: 3px; }

.page-num {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  font-family: "Silkscreen", monospace;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Right page ---------- */
.page--right { display: flex; }
.mascot {
  position: absolute;
  z-index: 9; /* above washi tape, sparkles and page decorations */
  top: 22px; right: 26px;
  width: 104px; height: 104px;
  animation: bob 3s ease-in-out infinite;
}
.mascot.is-thinking { animation: wiggle 0.3s ease-in-out infinite; }
/* face left, chin tilted up a little */
.mascot > svg { transform: rotate(10deg) scaleX(-1); }
.mascot .wings { transform-origin: 5px 9px; animation: flutter 0.5s ease-in-out infinite; }
.mascot.is-thinking .wings { animation-duration: 0.18s; }
.mascot .wand-star { transform-origin: 14.5px 3.5px; animation: twinkle-soft 1.6s ease-in-out infinite; }
.mascot.is-thinking .wand-star { animation: spin-star 0.6s linear infinite; }

.card__content {
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease;
}
.page--right.is-loading .card__content { opacity: 0; filter: blur(4px); transform: scale(0.98); }

.date {
  margin: 0 0 var(--line);
  font-family: "Silkscreen", monospace;
  font-size: 13px;
  line-height: var(--line);
  color: var(--label);
}
.prompt { margin: 0; }
.row { margin-bottom: var(--line); }
dt {
  font-family: "Silkscreen", monospace;
  font-size: 13px;
  line-height: var(--line);
  color: var(--label);
}
dt::after { content: ":"; }
dd {
  margin: 0;
  padding-left: 14px;
  font-size: 23px;
  font-weight: 500;
  line-height: var(--line);
  min-height: var(--line);
  color: var(--pen);
}
dd.is-typing::after { content: "▌"; color: var(--accent); animation: blink 0.7s steps(2) infinite; }

.sticky--quote {
  margin: auto auto 0;
  max-width: 380px;
  padding: 24px 22px 20px;
  text-align: center;
}
.quote { margin: 0; }
.quote p { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.quote p::before { content: "“"; }
.quote p::after { content: "”"; }
.quote cite { font-style: normal; font-family: "Silkscreen", monospace; font-size: 11px; color: var(--ink-soft); }
.quote cite::before { content: "— "; }

.copy {
  position: absolute;
  z-index: 5;
  right: 24px; bottom: 14px;
  font-size: 16px;
  padding: 4px 12px;
  background: none;
  border: 0;
  color: var(--ink-soft);
}
.copy > .sketch-line { color: var(--ink-soft); }
.copy:hover { color: var(--label); --hatch: var(--hatch-pink); }
.copy .btn__label { position: relative; z-index: 2; }
.copy:hover > .sketch-line { color: var(--label); }
.page-sticker { position: absolute; z-index: 4; width: 34px; left: 70px; bottom: 14px; transform: rotate(-14deg); }

/* ---------- Sparkle loader ---------- */
.sparkles { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.sparkle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  color: var(--c);
  transform: translate(-50%, -50%) scale(0) rotate(0deg);
  animation: sparkle var(--dur) ease-in-out var(--delay) infinite;
  filter: drop-shadow(0 0 6px var(--c));
}
.sparkle svg { width: 100%; height: 100%; }
.loading-label {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: "Silkscreen", monospace;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--label);
  animation: pulse 0.9s ease-in-out infinite;
  white-space: nowrap;
}
.burst {
  position: fixed;
  width: 14px; height: 14px;
  pointer-events: none;
  color: var(--c);
  z-index: 50;
  animation: burst 0.7s ease-out forwards;
}

/* ---------- Credits ---------- */
.credit {
  position: fixed;
  z-index: 20;
  bottom: 14px;
  margin: 0;
  font-family: "Silkscreen", monospace;
  font-size: 11px;
  color: var(--ink-soft);
}
.credit--left { left: 18px; }
.credit--right { right: 18px; }
.credit a { color: var(--label); text-decoration: underline wavy; text-underline-offset: 3px; }
.credit a:hover { color: var(--pen); }

/* ---------- Cursor sparkle trail ---------- */
.trail {
  position: fixed;
  z-index: 60;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  color: var(--c);
  pointer-events: none;
  filter: drop-shadow(0 0 4px var(--c));
  animation: trail 0.8s ease-out forwards;
}
.trail svg { width: 100%; height: 100%; }
@keyframes trail {
  0%   { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), 22px) scale(0) rotate(120deg); opacity: 0; }
}

/* ---------- Phone-only: tabs, theme option, quick bar ---------- */
.tabs, .theme-block { display: none; }



/* ---------- Animations ---------- */
@keyframes sparkle {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
  40%  { transform: translate(-50%, -50%) scale(1) rotate(90deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0) rotate(180deg); opacity: 0; }
}
@keyframes burst {
  0%   { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(180deg); opacity: 0; }
}
@keyframes steam {
  0%   { transform: translateY(0); opacity: 0; }
  20%  { opacity: 0.8; }
  100% { transform: translateY(-36px) translateX(4px); opacity: 0; }
}
@keyframes sway { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(3deg); } }
@keyframes twinkle-soft { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.75); opacity: 0.6; } }
@keyframes spin-star { to { transform: rotate(360deg); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes wiggle { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes flutter { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(0.82); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .sparkle { animation: none; transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1260px) {
  body { padding: 90px 60px 110px; }
  .deco-mug, .deco-heart, .deco-note-2, .deco-star { display: none; }
  .deco-note-1 { left: -40px; top: -58px; }
  .deco-pencil { left: -30px; }
}
/* Tabbed single-page layout: phones, tablets and narrow windows where the
   two-page spread would have to shrink too far to stay readable */
@media (max-width: 1100px) {
  .desk { max-width: 600px; }
  body { padding: 16px 16px 56px; place-items: start center; }
  .theme-toggle { display: none; }
  .book { grid-template-columns: 1fr; padding: 14px 14px 18px; }

  /* divider tabs sitting on top of the cover */
  .tabs {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding-left: 14px;
    margin-bottom: -4px;
  }
  .tab {
    height: 40px;
    padding: 0 16px;
    font-family: "Silkscreen", monospace;
    font-size: 13px;
    color: var(--ink-soft);
    background: var(--paper-edge);
    border: 3px solid var(--ink);
    border-bottom: 0;
  }
  .tab[aria-selected="true"] {
    height: 48px;
    color: var(--pen);
    background: var(--cover);
  }
  .tab:focus-visible { outline: 2px dashed var(--accent); outline-offset: 2px; }

  /* one page at a time */
  body:not([data-tab="prompt"]) .page--right,
  body[data-tab="prompt"] .page--left { display: none; }
  .page { --line: 26px; padding: 52px 14px 48px 46px; }
  .page-num { bottom: 14px; }
  .title { line-height: 52px; }
  .checks { gap: 4px 10px; }
  .seg { gap: 8px; font-size: 17px; }
  .box { width: 20px; height: 20px; }
  .tick { width: 26px; height: 26px; top: -6px; }
  .theme-block { display: block; }
  .clock { font-size: 21px; }
  .btn--reload { height: 46px; font-size: 19px; }
  .btn--step, .clock { height: 44px; }
  .transport .btn { height: 40px; }
  .page, .page--left, .page--right { border-width: 3px; box-shadow: 6px 6px 0 -3px var(--paper-edge), 6px 6px 0 0 var(--ink); }
  .page { background-image:
    linear-gradient(to right, transparent 34px, var(--margin) 34px, var(--margin) 36px, transparent 36px),
    repeating-linear-gradient(to bottom, transparent 0 24px, var(--rule) 24px 26px); }
  .page::before { display: none; }
  .rings, .ribbon { display: none; }
  .decor > * { display: none; }
  /* on phones the fairy perches on the book beside the tabs, visible on both pages */
  .page--right .mascot { display: none; }
  .mascot--perch {
    top: auto;
    right: -2px;
    bottom: -38px; /* feet dip over the top of the page */
    width: 84px; height: 84px;
  }
  .tab { flex-shrink: 0; white-space: nowrap; }
  .title { font-size: 32px; }
  dd { font-size: 21px; padding-left: 0; }
  .sticky--quote { margin-top: 8px; }
  .kbd-hint { display: none; }
  .page-sticker { display: none; }
  .credits { width: 100%; max-width: 560px; margin-top: 28px; text-align: center; }
  .credit { position: static; line-height: 1.8; }

  /* "new prompt" and the timer, moved under the prompt by app.js */
  .prompt-controls { margin-bottom: calc(var(--line) * 1.5); }
  .prompt-controls .btn--reload { margin-top: 0; }
}
