/* A picture book: one day from morning to bedtime. Paper, ink and soft colour, with the sky doing the work. */
:root {
  --ink: #23324d; --paper: #fff8ec; --paper2: #fdeed6; --blue: #19d3ff; --blue-deep: #2f8fc4;
  --pink: #ff9db8; --peanut: #e6b26c; --grass: #8fd18a; --grass2: #6fbf74; --muted: #5d6a82;
  --display: 'Bagel Fat One', 'Nunito', sans-serif; --body: 'Nunito', system-ui, sans-serif;
  --shadow: 0 5px 0 var(--ink);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body { margin: 0; color: var(--ink); font: 700 18px/1.55 var(--body); overflow-x: hidden; overflow-x: clip; background: #ffd9a8; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
.defs { position: absolute; }
:focus-visible { outline: 4px solid var(--blue-deep); outline-offset: 3px; border-radius: 8px; }
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; }
[hidden] { display: none !important; }

/* ---------- The sky ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #ffd9a8; }
.sun { position: absolute; left: 0; top: 0; width: 130px; height: 130px; border-radius: 50%; background: #ffe27a; box-shadow: 0 0 70px 24px rgba(255, 226, 122, .55); will-change: transform; }
.stars { position: absolute; inset: 0; opacity: 0; }
.stars i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.cloud { position: absolute; width: 190px; height: 58px; border-radius: 60px; background: rgba(255, 255, 255, .85); animation: drift 70s linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 84px; height: 84px; left: 28px; top: -38px; }
.cloud::after { width: 62px; height: 62px; right: 30px; top: -24px; }
.c1 { top: 13%; left: 8%; }
.c2 { top: 26%; left: 62%; transform: scale(.7); animation-duration: 95s; }
.c3 { top: 6%; left: 78%; transform: scale(.5); animation-duration: 120s; }
@keyframes drift { from { translate: -12vw 0; } to { translate: 22vw 0; } }
.hill { position: absolute; left: -10%; width: 120%; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.hill.far { bottom: -12vh; height: 34vh; background: var(--hill-far, #a9dc9f); }
.hill.near { bottom: -18vh; height: 34vh; left: -30%; width: 110%; background: var(--hill-near, #8fd18a); }

/* ---------- Bar ---------- */
.bar { position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: 18px; max-width: 1180px; margin: 12px auto 0; padding: 8px 10px 8px 14px; background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: var(--shadow); width: calc(100% - 24px); }
.logo img { display: block; }
.logo { display: flex; align-items: center; gap: 8px; font: 400 22px var(--display); text-decoration: none; }
.bar nav { display: flex; gap: 4px; margin-left: auto; }
.bar nav a { padding: 5px 13px; border-radius: 12px; font-weight: 800; text-decoration: none; }
.bar nav a:hover { background: var(--paper2); }
.x-chip { display: grid; place-items: center; flex: none; width: 42px; height: 42px; background: var(--paper2); border: 3px solid var(--ink); border-radius: 14px; }
.x-chip:hover { background: var(--blue); }
.pill { padding: 7px 16px; font-weight: 900; font-size: 15px; white-space: nowrap; text-decoration: none; background: var(--pink); border: 3px solid var(--ink); border-radius: 14px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 26px; font: 400 21px var(--display); text-decoration: none; background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--pink); }
.btn.off { opacity: .75; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; margin: 26px 0; }
.actions.center { justify-content: center; }

/* ---------- Hero ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 24px; min-height: calc(100vh - 90px); padding: 30px 0 50px; }
.kicker { margin: 0 0 8px; font-weight: 900; font-size: 16px; letter-spacing: .03em; }
h1 { font-size: clamp(38px, 4.6vw, 68px); line-height: 1.05; }
h1 em { font-style: normal; color: #d93d6c; }
.lede { max-width: 30em; margin: 20px 0 0; font-size: 21px; }
.contract { display: flex; align-items: center; gap: 10px; max-width: 560px; padding: 10px 12px 10px 16px; background: var(--paper); border: 3px dashed var(--ink); border-radius: 14px; }
.contract-label { font-weight: 900; font-size: 15px; }
.contract code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 700 14px ui-monospace, Menlo, monospace; }
.copy { flex: none; padding: 4px 12px; font-weight: 900; font-size: 14px; background: var(--blue); border: 3px solid var(--ink); border-radius: 10px; }
.tiny { margin: 8px 0 0; font-size: 14.5px; }
.hero-baby { position: relative; display: grid; justify-items: center; }
.baby-button { display: block; width: min(100%, 560px); padding: 0; background: none; border: 0; touch-action: manipulation; border-radius: 50%; }
.baby-art { display: block; width: 100%; height: auto; transform-origin: 50% 96%; animation: breathe 3.2s ease-in-out infinite; pointer-events: none; }
.baby-button:hover .baby-art { animation-duration: 1.6s; }
.baby-button.boop .baby-art { animation: boop .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes breathe { 50% { transform: scale(1.018, .985); } }
@keyframes boop { 0% { transform: scale(1); } 30% { transform: scale(1.12, .86); } 62% { transform: scale(.94, 1.09); } 100% { transform: scale(1); } }
.boops { margin: 2px 0 0; padding: 4px 16px; font-weight: 900; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; }
.toots { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.toot { position: absolute; font: 400 34px var(--display); color: var(--ink); animation: toot 1.1s ease-out forwards; }
@keyframes toot { from { opacity: 0; transform: translate(0, 10px) scale(.5) rotate(var(--r)); } 20% { opacity: 1; } to { opacity: 0; transform: translate(var(--x), -130px) scale(1.2) rotate(var(--r)); } }

/* ---------- The day ---------- */
.clock { display: flex; justify-content: center; margin: 60px 0 22px; }
.clock span { padding: 4px 18px; font: 400 21px var(--display); background: var(--paper); border: 4px solid var(--ink); border-radius: 30px; box-shadow: 0 4px 0 var(--ink); }
.page { position: relative; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; gap: 34px; padding: 40px 46px; background: var(--paper); border: 5px solid var(--ink); border-radius: 30px; box-shadow: 0 10px 0 var(--ink); }
.page.tilt-l { rotate: -1deg; }
.page.tilt-r { rotate: .8deg; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.page h2, .token h2 { font-size: clamp(38px, 5vw, 62px); line-height: 1.02; }
.page p { margin: 14px 0 0; font-size: 20px; }
.page .btn { margin-top: 20px; }
.chapter { margin: 0 0 4px !important; font-weight: 900; font-size: 15px !important; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.page-art { position: relative; display: grid; place-items: center; min-height: 300px; }
.page-art img { width: min(100%, 400px); height: auto; }
.art-yawn img { transform: rotate(-6deg); animation: wobble 4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(3deg); } }
.art-bath { overflow: visible; }
.art-bath img { width: min(100%, 330px); margin-bottom: -86px; }
.tub { position: relative; z-index: 1; width: min(100%, 380px); height: 120px; border: 5px solid var(--ink); border-radius: 18px 18px 60px 60px; background: linear-gradient(#bfeeff 0 26%, #fff 26%); }
.tub i { position: absolute; top: -18px; width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 4px solid var(--ink); animation: bubble 3s ease-in-out infinite; }
.tub i:nth-child(1) { left: 8%; }
.tub i:nth-child(2) { left: 22%; width: 26px; height: 26px; top: -10px; animation-delay: .5s; }
.tub i:nth-child(3) { right: 12%; width: 44px; height: 44px; top: -22px; animation-delay: 1s; }
.tub i:nth-child(4) { right: 28%; width: 22px; height: 22px; top: -8px; animation-delay: 1.6s; }
@keyframes bubble { 50% { translate: 0 -8px; } }
.drop { position: absolute; z-index: 2; width: 18px; height: 24px; background: #19d3ff; border: 3px solid #000; border-radius: 50% 50% 50% 50% / 62% 62% 40% 40%; animation: drop 900ms cubic-bezier(.3, .6, .6, 1) forwards; }
@keyframes drop { from { opacity: 1; transform: translate(0, 0) scale(.7); } 45% { transform: translate(calc(var(--x) * .6), var(--y)) scale(1); } to { opacity: 0; transform: translate(var(--x), 70px) scale(.8); } }
.moon { position: absolute; width: min(92%, 340px); aspect-ratio: 1; overflow: hidden; border-radius: 50%; background: #f4f0dd; box-shadow: 0 0 60px 12px rgba(244, 240, 221, .28); }
.moon::after { content: ''; position: absolute; left: 34%; top: -6%; width: 86%; height: 86%; border-radius: 50%; background: #24315a; }
.art-sleep .sleeper { position: relative; width: min(84%, 340px); transform: rotate(-9deg); animation: snooze 4.5s ease-in-out infinite; }
@keyframes snooze { 50% { transform: rotate(-9deg) scale(1.025, .98); } }
.held-nut { position: absolute; left: 12%; top: 26%; width: 54px; transform: rotate(-24deg); }
.zzz { position: absolute; z-index: 2; right: 6%; top: 4%; font: 400 40px var(--display); animation: zzz 3s ease-in-out infinite; }
@keyframes zzz { 50% { translate: 8px -14px; opacity: .55; } }
.night { background: #24315a; color: #f6f1e3; }
.night .chapter { color: #b7c3de; }

/* ---------- Game ---------- */
.game-page { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); }
.score-line { font-weight: 900; }
.score-line b { font: 400 26px var(--display); }
.game-wrap { position: relative; }
canvas { display: block; width: 100%; height: auto; touch-action: pan-y; background: linear-gradient(#ffe9b8, #c7ecd0); border: 5px solid var(--ink); border-radius: 22px; cursor: ew-resize; }
canvas.playing { touch-action: none; }
.game-start { position: absolute; left: 50%; top: 50%; translate: -50% -50%; margin: 0 !important; }

/* ---------- Token ---------- */
.token { margin: 70px auto 40px; padding: 44px; text-align: center; color: var(--ink); background: var(--paper); border: 5px solid var(--ink); border-radius: 30px; box-shadow: 0 10px 0 var(--ink); }
.token-sub { margin: 4px 0 26px; font-size: 21px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 30px; }
.fact { padding: 16px; background: var(--paper2); border: 4px solid var(--ink); border-radius: 18px; }
.fact span { display: block; font-size: 14.5px; font-weight: 900; color: var(--muted); }
.fact b { display: block; font: 400 24px var(--display); overflow-wrap: anywhere; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: step; text-align: left; font-size: 17px; }
.steps li { counter-increment: step; padding: 16px; background: #fff; border: 4px solid var(--ink); border-radius: 18px; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 8px; font: 400 21px var(--display); background: var(--blue); border: 3px solid var(--ink); border-radius: 50%; }
footer { max-width: 760px; margin: 0 auto; padding: 16px 20px 44px; text-align: center; font-size: 15.5px; color: #f6f1e3; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; }
}
@media (max-width: 940px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: 22px; }
  .hero-baby { order: -1; }
  .baby-button { width: min(78vw, 400px); }
  .page, .page.tilt-r, .game-page { grid-template-columns: minmax(0, 1fr); padding: 26px 22px; gap: 14px; rotate: 0deg; }
  .page-art { min-height: 220px; }
  .page-art img { width: min(76%, 300px); }
  .page.tilt-r .page-art { order: -1; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .token { padding: 26px 18px; }
  .bar nav { display: none; }
  .bar .x-chip { margin-left: auto; }
  .x-chip[hidden] + .pill { margin-left: auto; }
}
@media (min-width: 600px) and (max-width: 940px) {
  h1 { font-size: 56px; }
  .baby-button { width: min(70vw, 500px); }
}
@media (max-width: 480px) {
  body { font-size: 17px; }
  .logo span { font-size: 19px; }
  .lede { font-size: 19px; }
  .page p { font-size: 18px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .btn { flex: 1 1 auto; min-height: 52px; padding: 0 18px; font-size: 19px; }
}
@media (max-width: 400px) {
  .bar { gap: 6px; padding: 6px 6px 6px 8px; }
  .logo { min-height: 40px; }
  .logo img { width: 34px; height: 34px; }
  .logo span { font-size: 15px; }
  .pill { padding: 6px 8px; font-size: 13px; }
  .x-chip { width: 36px; height: 36px; }
}
@media (max-width: 350px) {
  .logo span { display: none; }
  .logo { min-width: 42px; justify-content: center; }
  h1 { font-size: 34px; }
}
/* A phone on its side has little height: keep the two columns, let the bar scroll away, and fit the game on screen. */
@media (max-height: 500px) and (orientation: landscape) {
  .bar { position: relative; top: 0; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 0; padding: 18px 0 30px; }
  .hero-baby { order: 0; }
  .baby-button { width: min(42vw, 62vh); }
  h1 { font-size: 38px; }
  .lede { margin-top: 10px; font-size: 16px; }
  .actions { margin: 14px 0; }
  .btn { min-height: 46px; padding: 0 16px; font-size: 17px; }
  .page, .page.tilt-r, .game-page { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 20px 24px; }
  .page.tilt-r .page-art { order: 0; }
  .page-art { min-height: 200px; }
  .page-art img { width: min(90%, 240px); }
  .game-wrap { max-width: calc((100vh - 40px) * 640 / 420); margin-left: auto; }
  .moon { width: min(92%, 210px); }
  .art-bath img { width: min(90%, 190px); margin-bottom: -50px; }
  .tub { height: 80px; }
}
