*, *::before, *::after { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-lo); }

body {
  margin: 0;
  /* svh, not dvh: dvh grows and shrinks as the phone's address bar hides on scroll, which resized the page mid-scroll */
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font);
  font-weight: 800;
  font-size: var(--size-m);
  line-height: 1.3;
  color: var(--text);
  overflow-x: hidden;
}
body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -1; }
body::before { background: linear-gradient(var(--sky-hi), var(--sky-lo)); }
body::after { background: linear-gradient(var(--night-hi), var(--night-lo)); opacity: 0; transition: opacity .9s ease; }
[data-theme="after"] body::after { opacity: 1; }

/* day and night share one page: each set is hidden while the other theme is on */
html:not([data-theme="after"]) .is-night, [data-theme="after"] .is-day { display: none; }

a { color: inherit; }
svg { display: block; }
.sprite { position: absolute; width: 0; height: 0; }

:focus-visible { outline: 3px solid var(--text); outline-offset: 6px; }

/* clouds: each one is the same puff drawn three times (shadow, outline, fill).
   For the reveal they fill the screen behind the checker, then slide off left and right.
   A few small ones stay in the corners as background. */

.cloud {
  position: absolute;
  top: var(--y);
  width: var(--w);
  aspect-ratio: 210 / 130;
  overflow: visible;
}
.cloud use { stroke-width: 9; stroke-linejoin: round; }
.cloud use:nth-child(1) { fill: var(--cloud-shadow); stroke: var(--cloud-shadow); transform: translate(5px, 8px); }
.cloud use:nth-child(2) { fill: var(--cloud-outline); stroke: var(--cloud-outline); }
.cloud use:nth-child(3) { fill: var(--c); stroke: none; }

.clouds { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.clouds-on .clouds { z-index: 2; pointer-events: auto; }
.clouds-on .clouds--front { z-index: 11; }

/* three layers: front clouds (packed so they hide the checker), checker, a few back clouds.
   Clouds pop: they shrink away toward their side and bounce back in. --n staggers them.
   Opening: front clouds, then the checker parts while the back clouds pop away.
   Closing: front clouds first, then the checker and back clouds fill in behind them. */
.clouds > .cloud--l { left: var(--x); transform: translateX(-30vw) scale(0); }
.clouds > .cloud--r { right: var(--x); transform: translateX(30vw) scale(0); }
.clouds > .cloud, .group { transition: transform var(--t-clouds) var(--ease-pop-out); }

/* the front layer pops as 8 groups, not 65 separate clouds: each group is painted once and only scaled */
.group { position: absolute; width: 0; height: 0; transform-origin: 25vw 12vh; }
.group--l { transform: translateX(-30vw) scale(0); }
.group--r { transform: translateX(30vw) scale(0); }
.clouds-on .group, .clouds-on .clouds > .cloud, .clouds-on .band { will-change: transform; }
html:not(.clouds-on) .clouds { display: none; }
.clouds-open .clouds > * { transition-delay: calc(.42s + var(--n, 0) * 15ms); }
.clouds-open .clouds--front > * { transition-delay: calc(var(--n, 0) * 15ms); }

.clouds-on:not(.clouds-open) .clouds > * { transform: none; transition-timing-function: var(--ease-bounce); transition-delay: calc(.38s + var(--n, 0) * 15ms); }
.clouds-on:not(.clouds-open) .clouds--front > * { transition-delay: calc(var(--n, 0) * 15ms); }

.clouds__star {
  position: fixed;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: var(--clasp);
  margin: calc(var(--clasp) / -2) 0 0 calc(var(--clasp) / -2);
  display: none;
  color: var(--star);
  filter: drop-shadow(0 6px 0 var(--cloud-shadow));
  pointer-events: none;
  transition: transform calc(var(--t-clouds) * 1.4) var(--ease-part);
}
.clouds-on .clouds__star { display: block; }
.clouds-open .clouds__star { transform: translateX(80vw) rotate(1turn); }

/* checker: two halves that meet in the middle and cover the page, then part into the top and bottom bars */

.band {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  height: calc(50vh + 2px);
  background: conic-gradient(var(--band-a) 25%, var(--band-b) 0 50%, var(--band-a) 0 75%, var(--band-b) 0) 0 100% / var(--band) var(--band);
  transition: transform calc(var(--t-clouds) * 1.2) var(--ease-part);
}
.band--top { top: 0; border-bottom: var(--stroke) solid var(--outline); box-shadow: 0 var(--lift) 0 var(--edge); transform: translateY(calc(var(--band) + var(--stroke) - 100%)); }
.band--bottom { bottom: 0; background-position: 0 0; border-top: var(--stroke) solid var(--outline); transform: translateY(calc(100% - var(--band) - var(--stroke))); }
.clouds-open .band { transition-delay: .42s; }
.clouds-on:not(.clouds-open) .band { transform: none; transition-delay: .38s; }

/* sky */

/* fixed to the tallest screen height so clouds and sparkles don't shift when the address bar hides */
.sky { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 0; pointer-events: none; color: var(--sparkle); }
.sky .cloud { opacity: .9; transition: transform 1.3s var(--ease-part); }
.sky .cloud use { transition: fill .9s ease, stroke .9s ease; }
[data-theme="after"] .sky .cloud { transform: translate(var(--mx), var(--my)); }
.sky svg { transition: color .9s ease; }
.sky .tw svg { display: block; width: 100%; }
.sky .sky__moon {
  position: absolute;
  left: auto;
  right: -1%;
  top: 14%;
  width: clamp(54px, 13vmin, 110px);
  color: var(--star);
  opacity: 1;
  animation: none;
  transform: translateY(110vh) rotate(-40deg);
  transition: transform 1.3s var(--ease-part);
}
[data-theme="after"] .sky .sky__moon { transform: rotate(-12deg); }
/* sparkles twinkle with transform and opacity on an HTML wrapper, which the
   phone's compositor runs on its own; animating the SVG directly restyled the page every frame */
.sky .tw {
  position: absolute;
  display: block;
  left: var(--x);
  top: var(--y);
  width: var(--w, 26px);
  opacity: .75;
  animation: twinkle var(--d, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: opacity;
}

/* layout */

main {
  position: relative;
  z-index: 1;
  width: min(100% - 72px, 540px);
  margin: 0 auto;
  padding: calc(var(--band) + 44px) 0 calc(var(--band) + 48px);
  text-align: center;
}

.logo { display: block; width: 100%; height: auto; }
/* own layer + a hair of rotation stops desktop browsers rounding the slow bob to whole pixels */
.logo-wrap { margin: 0; animation: bob 4.5s ease-in-out infinite; will-change: transform; }

.tag { margin: 12px auto 26px; max-width: 30em; color: var(--text); font-family: var(--font-hand); font-size: 1.45rem; font-weight: 400; line-height: 1.2; }

.links { list-style: none; margin: 0; padding: 0; display: grid; gap: calc(var(--gap) + 6px); }
.links li { animation: pop var(--t-pop) var(--ease-bounce) both; animation-delay: calc(var(--i) * 70ms + 150ms); }
.clouds-on:not(.clouds-open) .links li { animation-play-state: paused; }
.links .links__wide { margin-top: 10px; }

/* the after-dark links fly up out of the 18+ button's spot */
[data-theme="after"] .links .is-night { animation: fly .55s var(--ease-bounce) both; animation-delay: calc(var(--i) * 90ms); }

.foot { margin: 38px 0 0; font-size: var(--size-s); font-weight: 600; color: var(--text-soft); }

@media (min-width: 860px) {
  main { padding-top: calc(var(--band) + 64px); }
  .links li:nth-child(odd) { translate: -34px 0; }
  .links li:nth-child(even) { translate: 34px 0; }
  .links .links__wide { translate: 0 0; margin-inline: -34px; }
}

/* framed button: a thick shaded rim around an inset panel */

.btn {
  --d: var(--lift);
  position: relative;
  display: block;
  width: 100%;
  padding: var(--rim-w, 7px);
  border: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(var(--rim-hi), var(--rim) 55%, var(--rim-lo));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / .7),
    inset 0 -3px 0 rgb(61 42 112 / .14),
    0 0 0 var(--stroke) var(--outline),
    0 var(--d) 0 var(--stroke) var(--edge),
    0 calc(var(--d) * 1.8) 0 var(--stroke) var(--edge-2);
  color: var(--text);
  font: inherit;
  font-family: var(--font-game);
  font-weight: var(--font-game-weight);
  font-size: 1.35rem;
  line-height: 1.15;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-press) var(--ease-bounce), box-shadow var(--t-press) ease-out;
}
.btn:hover { --d: calc(var(--lift) + 3px); transform: translateY(-3px); }
.btn:active { --d: 0px; transform: translateY(var(--lift)); }

.btn--alt { --rim-hi: var(--rim-alt-hi); --rim: var(--rim-alt); --rim-lo: var(--rim-alt-lo); --face: var(--face-alt-soft); --face-strong: var(--rim-alt); }
.btn--ice {
  --rim-hi: var(--white);
  --rim: var(--ice);
  --rim-lo: var(--ice-deep);
  --face: var(--white);
  --face-strong: var(--ice-deep);
  --slot: rgb(207 228 255 / .55);
  --text: var(--ice-night);
  --text-soft: #3F5FB0;
  --pat-a: rgb(111 168 245 / .3);
  --pat-b: rgb(111 168 245 / .3);
}
.btn--gold { --rim-hi: color-mix(in srgb, var(--star), white 60%); --rim: var(--star); --rim-lo: var(--star-deep); }

.btn__panel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 5px;
  border-radius: var(--r-pill);
  background: var(--face);
  box-shadow: inset 0 3px 0 rgb(61 42 112 / .18);
  overflow: hidden;
}
.btn__panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; }
.btn__panel > * { position: relative; }

.btn__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--face-strong);
  border: 3px solid var(--outline);
  color: var(--star);
  font-size: 1.15rem;
  transition: rotate .45s var(--ease-bounce);
}
.btn__badge svg { width: 62%; }
.btn__badge img { width: 62%; height: 62%; object-fit: contain; }
.btn__badge--icon { background: var(--white); }
.btn:hover .btn__badge { rotate: 72deg; }
.btn:hover .btn__badge--keep, .btn:hover .btn__badge--icon { rotate: -8deg; }

.btn__label { min-width: 46%; padding: 3px 22px 4px 18px; border-radius: var(--r-pill); background: var(--slot); }
.btn__label small { display: block; font-family: var(--font); font-size: var(--size-s); font-weight: 600; color: var(--text-soft); }

.btn--solid .btn__panel { justify-content: center; min-height: 42px; background: transparent; box-shadow: none; text-align: center; }
.btn--solid .btn__label { min-width: 0; padding: 0 2px; background: none; }

/* button patterns */

.pat-plaid::before {
  background:
    repeating-linear-gradient(0deg, transparent 0 13px, var(--pat-b) 13px 15px, transparent 15px 22px),
    repeating-linear-gradient(90deg, transparent 0 13px, var(--pat-b) 13px 15px, transparent 15px 22px),
    repeating-linear-gradient(0deg, var(--pat-a) 0 8px, transparent 8px 22px),
    repeating-linear-gradient(90deg, var(--pat-a) 0 8px, transparent 8px 22px);
}
.pat-crochet::before {
  --ring: transparent 0 4px, var(--pat-a) 4px 6.5px, transparent 6.5px 9.5px, var(--pat-a) 9.5px 12px, transparent 12px;
  background:
    radial-gradient(circle at 50% 100%, var(--ring)) 0 0 / 24px 14px,
    radial-gradient(circle at 50% 100%, var(--ring)) 12px 7px / 24px 14px;
}
.pat-dots::before {
  background:
    radial-gradient(circle, var(--pat-a) 0 5px, transparent 5.5px) 0 0 / 26px 26px,
    radial-gradient(circle, var(--pat-b) 0 3px, transparent 3.5px) 13px 13px / 26px 26px;
}
.pat-stars::before {
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5.5l1.8 3.9 4.2.5-3.1 2.9.8 4.2L12 15l-3.7 2 .8-4.2L6 9.9l4.2-.5z' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  background: var(--pat-a);
  -webkit-mask: var(--tile) 0 0 / 34px 34px, var(--tile) 17px 17px / 34px 34px;
  mask: var(--tile) 0 0 / 34px 34px, var(--tile) 17px 17px / 34px 34px;
}

/* after-dark button: gold frame, night panel, clouds over the panel */

.btn--night {
  --rim-w: 9px;
  --face: var(--night-hi);
  --face-strong: #6A45C4;
  --slot: rgb(23 15 54 / .6);
  --text: var(--blush);
  --text-soft: var(--periwinkle);
  --pat-a: rgb(255 227 153 / .55);
  font-size: 1.45rem;
}
.btn--night .btn__panel { min-height: 92px; padding: 10px; }
.btn--night .btn__badge { width: 66px; font-size: 1.35rem; }

.btn__cover { position: absolute; inset: 0; }
.btn__cover::before { content: ""; position: absolute; inset: 0; background: var(--cloud-1); transition: opacity .3s; }
.btn__cover .cloud { top: 50%; width: 66%; margin-top: -20.4%; transition-duration: .55s; transition-timing-function: var(--ease-bounce); }
.btn__cover .cloud--l { left: 0; transform: translateX(-10%); }
.btn__cover .cloud--r { right: 0; transform: translateX(10%); }
.btn--night:hover .cloud--l, .btn--night:focus-visible .cloud--l { transform: translateX(-58%); }
.btn--night:hover .cloud--r, .btn--night:focus-visible .cloud--r { transform: translateX(58%); }
.btn--night.is-open .cloud--l { transform: translateX(-125%); }
.btn--night.is-open .cloud--r { transform: translateX(125%); }
.btn--night:hover .btn__cover::before, .btn--night:focus-visible .btn__cover::before, .btn--night.is-open .btn__cover::before { opacity: 0; }
.btn__peek {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink);
  font-size: 1.5rem;
  transition: opacity .25s, scale .35s var(--ease-bounce);
}
.btn__peek small { display: block; font-size: var(--size-s); font-weight: 600; }
.btn--night:hover .btn__peek, .btn--night:focus-visible .btn__peek, .btn--night.is-open .btn__peek { opacity: 0; scale: .6; }

/* star burst */

.burst {
  position: fixed;
  z-index: 20;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  margin: calc(var(--w) / -2) 0 0 calc(var(--w) / -2);
  color: var(--c);
  pointer-events: none;
  animation: burst .7s cubic-bezier(.15, .7, .3, 1) forwards;
}

/* Winnie the pixel cat follows the pointer and chases the mouse toy when it is thrown */

/* the white outline is drawn into the sprite images, so moving them needs no filter repaint */
.winnie, .toy { image-rendering: pixelated; will-change: transform; }
.winnie { width: 64px; height: 64px; background: url(assets/cat.png?v=2b29644f) 0 0 / 512px 320px no-repeat; }
.winnie { position: fixed; z-index: 8; left: 0; top: 0; margin: -52px 0 0 -32px; pointer-events: none; }
.toy {
  position: fixed;
  z-index: 8;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  background: url(assets/mouse.png?v=0e85c81f) center / 48px 48px no-repeat;
  cursor: grab;
  touch-action: none;
}
.toy:active { cursor: grabbing; }

/* fit every button on one screen: tighten on short phones, go two-up on short wide screens */

@media (max-height: 780px) and (max-width: 859px) {
  main { padding-top: calc(var(--band) + 20px); padding-bottom: calc(var(--band) + 20px); }
  .logo { width: 82%; margin-inline: auto; }
  .tag { margin: 6px auto 14px; font-size: 1.2rem; }
  .links { gap: 13px; }
  .links .links__wide { margin-top: 4px; }
  .btn { --rim-w: 5px; font-size: 1.2rem; }
  .btn__panel { min-height: 44px; padding: 4px; }
  .btn__badge { width: 36px; }
  .btn--night { --rim-w: 7px; font-size: 1.3rem; }
  .btn--night .btn__panel { min-height: 62px; padding: 6px; }
  .btn--night .btn__badge { width: 48px; font-size: 1.1rem; }
  .foot { margin-top: 26px; }
}

@media (max-height: 840px) and (min-width: 860px) {
  main { width: min(100% - 72px, 780px); padding-top: calc(var(--band) + 30px); }
  .logo { width: 62%; margin-inline: auto; }
  .links { grid-template-columns: 1fr 1fr; }
  .links li:nth-child(n) { translate: 0 0; }
  .links .links__wide { grid-column: 1 / -1; margin-inline: 12%; }
}

@media (max-height: 610px) {
  .logo { width: 60%; }
  .tag { margin: 4px auto 10px; font-size: 1.05rem; }
  .links { gap: 10px; }
}

/* motion */

@keyframes fly { from { opacity: 0; transform: translateY(170px) scale(.3) rotate(-10deg); } }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(24px); } }
@keyframes bob { 0%, 100% { transform: translate3d(0, 0, 0) rotate(.01deg); } 50% { transform: translate3d(0, -10px, 0) rotate(.01deg); } }
@keyframes nudge { 50% { translate: -6px 0; } }
@keyframes sway { 0%, 100% { rotate: -8deg; } 50% { rotate: 8deg; } }
/* fade only: Firefox for Android redraws an SVG from scratch whenever it is scaled or rotated */
@keyframes twinkle { 0%, 100% { opacity: .75; } 50% { opacity: .2; } }
@keyframes burst {
  from { transform: translate(0, 0) rotate(0) scale(.3); opacity: 1; }
  70% { opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .clouds__star { display: none !important; }
}
.btn__badge svg:has(use[href="#candy"]) { width: 78%; }


/* 18+ check */
.gate {
  overflow: visible; width: min(22rem, calc(100vw - 2rem)); padding: 1.5rem 1.3rem 1.3rem;
  /* same frame as the buttons: gradient rim, white outline, two-step lifted edge */
  --d: var(--lift);
  border: var(--rim-w, 7px) solid transparent; border-radius: 1.8rem; text-align: center; color: var(--ink);
  background: linear-gradient(var(--white), var(--white)) padding-box, linear-gradient(var(--rim-hi), var(--rim) 55%, var(--rim-lo)) border-box;
  box-shadow:
    inset 0 3px 0 rgb(61 42 112 / .12),
    0 0 0 var(--stroke) var(--outline),
    0 var(--d) 0 var(--stroke) var(--edge),
    0 calc(var(--d) * 1.8) 0 var(--stroke) var(--edge-2);
}
.gate::backdrop { background: rgb(23 15 54 / .6); }
.gate[open] { animation: gate-in .4s var(--ease-bounce); }
@keyframes gate-in { from { scale: .8; opacity: 0; } }
.gate__cat { position: absolute; top: -57px; right: 10px; width: 64px; height: 64px; background: url(assets/cat.png?v=2b29644f) 0 0 / 512px 320px no-repeat; }
.gate__title { margin: 0 0 .25rem; font: 400 1.7rem var(--font-game); }
.gate__text { margin: 0 0 1.1rem; font: 1.2rem/1.3 var(--font-hand); }
/* room for each button's lifted edge, so the stack doesn't touch */
.gate form { display: grid; gap: calc(var(--lift) * 1.8 + 12px); padding: 0 .5rem calc(var(--lift) * 1.8 + 4px); }
