@font-face { font-family: 'Press Start 2P'; src: url(/fonts/press-start-2p.woff2) format('woff2'); font-display: block; }
@font-face { font-family: 'VT323'; src: url(/fonts/vt323.woff2) format('woff2'); font-display: swap; }


/* ---------- palettes (the supplied coolors sets) ----------
   The 1st color of each palette is the background. The other four are ranked by
   brightness (relative luminance):
     brightest     --title    the words
     2nd           --link     buttons and the share pop-up's text
     3rd           --extrude  the 3D edge behind the letters
     darkest       --spots    background dots, and the monster (same color)
   If the darkest is too close to the background to see (CIELAB distance < 40),
   the monster/dots take the next brighter color and swap with the 3D edge.
   Dots and confetti are always two shades of the same color: --spots and --spots-2, both
   contrasting with the background (contrast ratio >= 2, or a CIELAB distance >= 70 for a
   strong hue clash like red on sky blue). Panels and outlines are darker shades of the background. */
:root, :root[data-palette="campfire"] {
  --c1: #233D4D; --c2: #FE7F2D; --c3: #FCCA46; --c4: #A1C181; --c5: #619B8A;
  --title: #FCCA46; --link: #A1C181; --extrude: #FE7F2D; --spots: #619B8A; --monster: #619B8A; --accent: #FE7F2D;
  --spots-2: #A0C3B9;
}
:root[data-palette="playground"] {
  --c1: #5BC0EB; --c2: #FDE74C; --c3: #9BC53D; --c4: #E55934; --c5: #FA7921;
  --title: #FDE74C; --link: #9BC53D; --extrude: #FA7921; --spots: #E55934; --monster: #E55934; --accent: #FA7921;
  --spots-2: #A03E24;
  --popup-text: #FDE74C; --focus-ring: #E55934; /* pop-up words yellow, dashed SHARE border red */
}
:root[data-palette="lagoon"] {
  --c1: #0081A7; --c2: #00AFB9; --c3: #FDFCDC; --c4: #FED9B7; --c5: #F07167;
  --title: #FED9B7; --link: #FED9B7; --extrude: #F07167; --spots: #FDFCDC; --monster: #F07167; --accent: #00AFB9;
  --spots-2: #F2EDB8;
  --popup-text: #FDFCDC; --share-bg: #F07167; /* light pink words on dark pink, cream dots and pop-up words, dark pink SHARE */
}
:root[data-palette="sage"] { /* shown as "Lollipop"; the id stays "sage" so existing links keep it */
  /* Pink background, white words on yellow, yellow monster, black + dark gray dots/confetti,
     purple pop-up and panels with white text, yellow buttons with black text and a white dashed SHARE border. */
  --c1: #EE4266; --c2: #540D6E; --c3: #FFD23F; --c4: #F3FCF0; --c5: #1F271B;
  --title: #F3FCF0; --link: #FFD23F; --extrude: #FFD23F; --monster: #FFD23F; --accent: #EE4266;
  --spots: #1F271B; --spots-2: #4C5249;
  --popup-bg: #540D6E; --popup-text: #F3FCF0; --share-bg: #FFD23F; --focus-ring: #F3FCF0;
  --shade: #540D6E; --ink: #1F271B; --navy: #540D6E; --cream: #F3FCF0; --orange: #1F271B; --ground: #540D6E;
}
:root[data-palette="spring"] {
  --c1: #F0CF65; --c2: #93B5C6; --c3: #DDEDAA; --c4: #D7816A; --c5: #BD4F6C;
  --title: #93B5C6; --link: #DDEDAA; --extrude: #D7816A; --spots: #BD4F6C; --monster: #BD4F6C; --accent: #D7816A;
  --spots-2: #84374C;
  --popup-bg: #DDEDAA; --popup-text: #BD4F6C; --share-bg: #D7816A; /* green pop-up, dark pink words, coral SHARE */
  --focus-ring: #BD4F6C; /* dashed SHARE border */
  /* Dark tints (outlines, panels) come from the blue, not the yellow, so nothing turns brown; green ground. */
  --shade: #93B5C6; --ground: #DDEDAA;
}
/* Spring's pop-up and share-page panels/cards are light green: text, borders and shadows go dark pink,
   field and option backgrounds go clear, and buttons are coral like SHARE. */
:root[data-palette="spring"] :is(.win, .lib-card) {
  --navy: #DDEDAA; --cream: #BD4F6C; --slate: transparent;
  --sun: #BD4F6C; --green: #BD4F6C; --pink: #BD4F6C; --orange: #BD4F6C; --link: #BD4F6C;
  color: var(--cream);
}
:root[data-palette="spring"] :is(.win, .lib-card) :is(input, textarea, select, .monster-line, .palette-pick, .form-err, .status-line) { background: transparent; }
:root[data-palette="spring"] .btn:not(.btn-ghost) { --sun: #D7816A; --orange: #BD4F6C; } /* coral buttons, like SHARE */
:root[data-palette="arcade"] {
  --c1: #EAF2E3; --c2: #61E8E1; --c3: #F25757; --c4: #F2E863; --c5: #F2CD60;
  --title: #F25757; --link: #F25757; --extrude: #F2E863; --monster: #F2CD60; --accent: #F25757;
  /* Dots and confetti: the red and the blue (a deeper blue, so it shows on the white). */
  --spots: #F25757; --spots-2: #49AEA9;
  --popup-bg: #F2E863; --popup-text: #EAF2E3; --share-bg: #F25757; --focus-ring: #49AEA9;
  --shade: #61E8E1; --ground: #61E8E1; /* outlines and dark tints come from the blue, not gray; blue ground */
}
:root[data-palette="arcade"] :is(.is-app[data-view="scene"], body.is-app:not([data-view])) .foot a { color: var(--ink); }
/* Arcade's pop-up and share-page panels/cards are the yellow: dark text and borders, red buttons
   like SHARE. The pop-up's white words get a dark outline so they stay readable on the yellow. */
:root[data-palette="arcade"] :is(.win, .lib-card) {
  --navy: #F2E863; --cream: var(--ink); --slate: transparent; --teal: #F25757;
  --sun: var(--ink); --green: var(--ink); --pink: #B42323; --orange: var(--ink); --link: var(--ink);
  color: var(--cream);
}
:root[data-palette="arcade"] :is(.win, .lib-card) :is(input, textarea, select, .monster-line, .palette-pick, .form-err, .status-line) { background: transparent; }
:root[data-palette="arcade"] .btn:not(.btn-ghost) { --sun: #F25757; }
:root[data-palette="arcade"] .prompt-text { text-shadow: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink), 2px 2px var(--ink); }
:root[data-palette="bubblegum"] {
  --c1: #FF7477; --c2: #E69597; --c3: #CEB5B7; --c4: #B5D6D6; --c5: #9CF6F6;
  --title: #9CF6F6; --link: #B5D6D6; --extrude: #E69597; --spots: #9CF6F6; --monster: #9CF6F6; --accent: #CEB5B7;
  --spots-2: #CFFAFA; /* #CEB5B7 was too close to the coral background */
}

:root {
  --bg: var(--c1);
  /* Dark tints come from the background (--c1) unless a palette names a --shade color. */
  --ink: color-mix(in srgb, var(--shade, var(--c1)) 22%, #0B0B0E);   /* outlines */
  --navy: color-mix(in srgb, var(--shade, var(--c1)) 38%, #101014);  /* window panels */
  --slate: color-mix(in srgb, var(--shade, var(--c1)) 58%, #101014); /* inner borders, ghost buttons */
  --ground: color-mix(in srgb, var(--shade, var(--c1)) 70%, #000);   /* scene ground band */
  --sun: var(--link);                                      /* buttons and legends */
  --orange: color-mix(in srgb, var(--link) 45%, #000);     /* hard button shadow */
  --teal: var(--accent);                                   /* input borders */
  --green: var(--link);                                    /* hints */
  --ice: var(--link);
  --cream: #FBF6EC;                                        /* body text, window borders */
  --pink: #FF9C9C;                                         /* errors */
}

:root {
  /* 4px pixel squares in the spot color */
  --spot-a: conic-gradient(from 270deg at 4px 4px, var(--spots) 90deg, transparent 0);
  --spot-b: conic-gradient(from 270deg at 4px 4px, var(--spots-2, var(--spots)) 90deg, transparent 0);
  --confetti-a: var(--spots); --confetti-b: var(--spots-2, var(--spots)); /* confetti matches the dots */
  --px: 'Press Start 2P', ui-monospace, monospace;
  --body: 'VT323', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image: var(--spot-a), var(--spot-b);
  background-size: 72px 72px, 120px 120px;
  background-position: 14px 18px, 70px 58px;
  color: var(--cream);
  font: 24px/1.2 var(--body);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--link); }
a:hover { color: var(--cream); }
:focus-visible { outline: 4px dashed var(--focus-ring, var(--ice)); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only, .visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- the scene ---------- */
.scene {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--bg);
  background-image: var(--spot-a), var(--spot-b), linear-gradient(to bottom, transparent 0 86%, var(--ground) 86% 100%);
  background-size: 72px 72px, 120px 120px, 100% 100%;
  background-position: 14px 18px, 70px 58px, 0 0;
  background-repeat: repeat, repeat, no-repeat;
}
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.stage {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
  padding: 2vh 2vw 7vh;
}
.scene[data-state="prompt"] { align-items: flex-start; }
.scene[data-state="prompt"] .stage { padding-top: 3vh; }
.scene[data-state="prompt"] .punch { margin-top: 2vh; margin-top: 2svh; }
.scene[data-state="prompt"] .hand { height: 30vh; height: 30svh; }
.scene[data-state="prompt"] .punch-svg { max-height: 30vh; max-height: 30svh; }
.hand {
  position: relative;
  height: 42vh; height: 42svh;
  max-height: 120vw;
  aspect-ratio: 32 / 45;
}
.sprite { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
/* Hand box is 32x45 sprite units. The hand canvas fills it; the finger and thumb sit in
   clips that end where they join the palm, so they slide up out of their knuckles. */
.hand .fist { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 1; }
.finger-clip { position: absolute; left: 40.625%; width: 21.875%; top: -6.6667%; height: 51.1111%; overflow: hidden; z-index: 2; }
.hand .finger {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 86.9565%;
  transform: translateY(60%);
}
.thumb-clip { position: absolute; left: 0; width: 25%; top: 33.3333%; height: 28.8889%; overflow: hidden; z-index: 2; }
.hand .thumb {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 76.9231%;
  transform: translateY(40%);
}
/* The hand stays hidden until the sequence starts, then the fist only gets a quick jolt. */
.scene:not([data-state]) .hand { visibility: hidden; }
.scene[data-state="fist"] .hand { animation: fist-shake 0.25s steps(1, end) both; }
.hand.is-up .finger, .hand.is-up .thumb { transform: translateY(0); }
/* The pop: snap straight to a slight overshoot on the reveal frame, then drop into place. */
.hand.is-popping .finger { animation: finger-pop 0.12s steps(2, end); }
.hand.is-popping .thumb { animation: thumb-pop 0.12s steps(2, end); }
.hand.is-popping { animation: fist-squash 0.18s steps(2, end); transform-origin: 50% 100%; }

@keyframes fist-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5%, 0); }
  50% { transform: translate(1.5%, 0.6%); }
  75% { transform: translate(-1%, 0); }
}
@keyframes finger-pop {
  0% { transform: translateY(-10%); }
  100% { transform: translateY(0); }
}
@keyframes thumb-pop {
  0% { transform: translateY(-10%); }
  100% { transform: translateY(0); }
}
@keyframes fist-squash {
  0% { transform: scale(1, 1); }
  50% { transform: scale(1.04, 0.94); }
  100% { transform: scale(1, 1); }
}

.punch {
  position: relative; z-index: 1;
  margin: 3vh 0 0; margin: 3svh 0 0;
  width: min(96vw, 1200px);
  line-height: 0;
  font-size: 1rem;
  visibility: hidden;
}
.punch.is-on { visibility: visible; animation: punch-pop 0.22s steps(2, end); }
.punch.is-still { animation: none; }
.punch-svg { display: block; width: 100%; height: auto; max-height: 44vh; max-height: 44svh; overflow: visible; }
.punch-svg text { font-family: var(--px); font-size: 100px; }
.t-shadow { fill: var(--ink); stroke: var(--ink); stroke-width: 16px; stroke-linejoin: miter; }
.t-extrude { fill: var(--extrude); stroke: var(--extrude); stroke-width: 16px; stroke-linejoin: miter; }
.t-outline { fill: var(--ink); stroke: var(--ink); stroke-width: 16px; stroke-linejoin: miter; }
.t-fill { fill: var(--title); }
@keyframes punch-pop {
  0% { transform: scale(0.55); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---------- RPG windows & controls ---------- */
.win {
  background: var(--navy);
  border: 4px solid var(--cream);
  box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 4px var(--slate), 8px 8px 0 4px var(--ink);
  padding: 18px 20px;
  margin: 0 0 24px;
  border-radius: 0;
}
fieldset.win { min-width: 0; }
legend, .legend {
  font: 14px/1.4 var(--px);
  color: var(--sun);
  padding: 0 8px;
  margin: 0 0 10px;
  background: var(--navy);
}
.legend { padding: 0; }
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px;
  padding: 12px 18px;
  font: 14px/1.2 var(--px);
  color: var(--ink);
  background: var(--sun);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--orange);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  user-select: none;
}
.btn::before { content: '▶'; width: 0; overflow: hidden; transition: none; }
.btn:hover::before, .btn:focus-visible::before { width: 1em; }
.btn:hover { background: var(--cream); color: var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn:disabled, .btn.is-busy { opacity: 0.6; cursor: progress; }
.btn-big { font-size: 18px; min-height: 60px; padding: 16px 26px; }
.btn-small { font-size: 11px; min-height: 44px; padding: 8px 12px; }
.btn-ghost { background: var(--slate); color: var(--cream); box-shadow: 4px 4px 0 var(--ink); border-color: var(--cream); }
.btn-ghost:hover { background: var(--teal); color: var(--ink); }
.btn-wide { width: 100%; }
.menu { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.menu-row { margin: 16px 0 6px; }

label { display: block; margin: 12px 0 4px; color: var(--cream); }
input[type=text], input[type=search], input[type=password], input:not([type]), textarea, select {
  width: 100%;
  font: 24px/1.15 var(--body);
  color: var(--cream);
  background: var(--ink);
  border: 4px solid var(--teal);
  border-radius: 0;
  padding: 8px 10px;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { border-color: var(--sun); outline: none; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--pink); }
textarea { resize: vertical; min-height: 64px; }
.hint { color: var(--green); font-size: 20px; margin: 6px 0; }
.req, .opt { color: var(--green); font-size: 20px; }
.field-err { color: var(--pink); margin: 6px 0 0; min-height: 0; }
.field-err:empty { display: none; }
.form-err { margin: 0 0 14px; background: var(--ink); padding: 6px 10px; }
.status-line { color: var(--sun); }
.status-line:not(:empty) { display: inline-block; background: var(--ink); padding: 4px 10px; }
.center { text-align: center; }

/* ---------- share prompt: full-width RPG dialogue box over the scene ---------- */
.prompt {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background-image: conic-gradient(rgba(27, 42, 51, 0.4) 25%, transparent 0 50%, rgba(27, 42, 51, 0.4) 0 75%, transparent 0);
  background-size: 4px 4px;
  animation: dither-in 0.3s steps(3, end);
}
.prompt-box {
  width: 100%;
  max-width: 1100px;
  display: flex; gap: 20px; align-items: flex-start;
  margin: 0;
  padding: 22px;
  animation: box-in 0.24s steps(3, end);
}
.portrait { flex: 0 0 auto; width: 96px; border: 4px solid var(--cream); background: var(--slate); padding: 6px; }
.portrait canvas { width: 100%; height: auto; }
.prompt-body { flex: 1; min-width: 0; }
.prompt-text { font: clamp(16px, 2.6vw, 26px)/1.5 var(--px); color: var(--popup-text, var(--link)); margin: 0 0 18px; min-height: 3em; }
/* A palette can give the pop-up its own background (--popup-bg) and SHARE color (--share-bg). */
.prompt-box { background: var(--popup-bg, var(--navy)); }
/* SHARE has no block shadow, just an always-on dashed border in a color other than its background:
   the palette's --focus-ring if it sets one, else the word color (never the same as --link). */
#btn-share {
  --sun: var(--share-bg, var(--link));
  box-shadow: none;
  outline: 4px dashed var(--focus-ring, var(--title)); outline-offset: 3px;
}
@keyframes dither-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes box-in { from { transform: translateY(40%); } to { transform: translateY(0); } }

/* ---------- views ---------- */
.view { min-height: 100vh; padding: 20px 16px 40px; background: transparent; }
.view-inner { max-width: 1100px; margin: 0 auto; }
.view-inner.narrow { max-width: 720px; }
.view-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 6px 0 26px; }
.view-title {
  font: clamp(18px, 3.4vw, 30px)/1.3 var(--px); color: var(--title); margin: 0;
  text-shadow: -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink), 6px 6px 0 var(--ink);
}
.view-title:focus { outline: none; }
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.col { min-width: 0; }

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pick {
  position: relative;
  padding: 0; margin: 0;
  aspect-ratio: 1;
  border: 4px solid var(--slate);
  background: var(--ink);
  cursor: pointer;
  overflow: hidden;
}
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick[aria-checked="true"] { border-color: var(--sun); box-shadow: 0 0 0 4px var(--orange); }
.pick[aria-checked="true"]::after {
  content: '▶'; position: absolute; left: 4px; top: 4px;
  font: 12px/1 var(--px); color: var(--ink); background: var(--sun); padding: 4px;
}
.pick-tag { position: absolute; right: 0; bottom: 0; font: 9px/1 var(--px); background: var(--orange); color: var(--ink); padding: 4px; }
.upload-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.slug-row { display: flex; align-items: stretch; gap: 0; }
.slug-host {
  display: flex; align-items: center;
  padding: 0 8px; background: var(--slate); border: 4px solid var(--teal); border-right: 0;
  color: var(--green); white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis;
}
.slug-row input { flex: 1; min-width: 0; }
.slug-row .btn { margin-left: 10px; box-shadow: none; }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; cursor: pointer; }
.check input { width: 28px; height: 28px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--sun); }
.notice p { margin: 0 0 8px; }
.notice strong { color: var(--sun); }

/* link-preview mockup */
.chat { background: var(--slate); padding: 16px; border: 4px solid var(--ink); margin: 0 0 10px; }
.bubble { max-width: 360px; margin-left: auto; }
.card { background: #e9e9ea; color: #111; border: 4px solid var(--ink); overflow: hidden; }
.card img { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; background: #ccc; }
.card-body { padding: 8px 12px 10px; font-family: -apple-system, system-ui, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.3; }
.card-title { font-weight: 700; overflow-wrap: anywhere; }
.card-title.is-empty { color: #888; font-weight: 400; font-style: italic; }
.card-desc { color: #444; margin-top: 2px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-host { color: #777; font-size: 13px; margin-top: 4px; }

.url-box { margin: 10px 0 0; font-size: 22px; color: var(--sun) !important; }
.ready-note { margin: 0 0 12px; }

.lib-grid { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; }
.lib-card {
  display: block; width: 100%; padding: 10px; text-align: left; cursor: pointer;
  background: var(--navy); border: 4px solid var(--slate); color: var(--cream); font: inherit;
}
.lib-card:hover, .lib-card:focus-visible { border-color: var(--sun); }
.lib-card .card { pointer-events: none; }
.lib-slug { font: 11px/1.4 var(--px); color: var(--green); margin-top: 8px; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 0);
  visibility: hidden;
  background: var(--sun); color: var(--ink); border: 4px solid var(--ink); box-shadow: 4px 4px 0 var(--orange);
  font: 12px/1.4 var(--px); padding: 12px 16px; max-width: calc(100% - 32px);
  pointer-events: none;
}
.toast.is-on { visibility: visible; animation: box-in 0.2s steps(2, end); }

.foot { text-align: center; padding: 10px 16px 18px; font-size: 20px; background: var(--ink); }
.is-app[data-view="scene"] .foot, body.is-app:not([data-view]) .foot {
  position: absolute; left: 0; right: 0; bottom: 0; background: transparent; z-index: 3;
}

/* ---------- plain pages ---------- */
.page { min-height: 100vh; padding: 40px 16px; background: transparent; }
.page-win { max-width: 640px; margin: 8vh auto 24px; }
.page-code { font: 40px/1 var(--px); color: var(--orange); margin: 0 0 16px; }
.legal { max-width: 860px; margin: 0 auto 24px; }
.legal h2 { font: 14px/1.5 var(--px); color: var(--sun); margin: 28px 0 8px; }
.legal p, .legal li { line-height: 1.25; }

@media (max-width: 820px) {
  .create-grid { grid-template-columns: 1fr; }
  .bubble { max-width: none; }
}
@media (max-width: 560px) {
  body { font-size: 22px; }
  .stage { padding-bottom: 12vh; }
  .hand { height: 38vh; height: 38svh; }
  .punch-svg { max-height: 40svh; }
  .prompt { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .prompt-box { padding: 14px; gap: 10px; flex-direction: column; }
  .prompt-text { font-size: 14px; min-height: 0; margin-bottom: 12px; }
  .portrait { display: none; }
  .menu { gap: 12px; }
  .menu .btn { flex: 1 1 100%; }
  .prompt .menu .btn:not(.btn-big) { flex: 1 1 40%; font-size: 10px; padding: 8px; }
  .scene[data-state="prompt"] .hand { height: 31svh; }
  .scene[data-state="prompt"] .punch-svg { max-height: 24svh; }
  .btn-big { font-size: 16px; }
  .win { padding: 14px; box-shadow: 0 0 0 4px var(--ink), inset 0 0 0 4px var(--slate), 4px 4px 0 4px var(--ink); }
  .view { padding: 14px 16px 32px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .hand { height: 46svh; }
  .punch { width: 70vw; }
  .prompt-text { min-height: 0; margin-bottom: 10px; }
  .portrait { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- palette chooser ---------- */
.palette-dock { position: fixed; top: 10px; right: 10px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; }
.palette-toggle {
  font: 10px/1 var(--px); color: var(--cream); background: var(--ink);
  border: 3px solid var(--cream); padding: 10px 10px; min-height: 40px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--orange);
}
.palette-toggle:hover { background: var(--slate); }
.palette-menu {
  margin-top: 8px; background: var(--ink); border: 4px solid var(--cream); box-shadow: 4px 4px 0 var(--orange);
  padding: 8px; display: grid; gap: 6px; min-width: 220px;
}
.palette-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px;
  font: 10px/1 var(--px); color: var(--cream); background: var(--navy); border: 3px solid var(--slate); cursor: pointer; text-align: left;
}
.palette-opt:hover { border-color: var(--teal); }
.palette-opt[aria-checked="true"] { border-color: var(--sun); }
.palette-opt[aria-checked="true"]::after { content: '◀'; margin-left: auto; color: var(--sun); }
.palette-chips { display: inline-flex; border: 2px solid var(--ink); }
.palette-chips i { display: block; width: 12px; height: 18px; }
.palette-tag { margin-left: 6px; font-size: 8px; color: var(--green); }
.palette-admin { display: grid; gap: 6px; border-top: 3px solid var(--slate); padding-top: 8px; }
.palette-admin p { margin: 0; font-size: 18px; color: var(--green); }
.palette-reset { justify-content: center; background: var(--slate); }
.slug-url { margin: 6px 0 0; color: var(--sun); overflow-wrap: anywhere; }
.slug-url:empty { display: none; }

/* ---------- the confetti-eating monster ---------- */
/* Once the share box is open the monster walks on top of it, so the canvas moves in front. */
.confetti.is-front { z-index: 11; }
.monster-bubble {
  position: fixed; z-index: 12; left: 0; top: 0;
  transform: translate(-50%, -100%);
  max-width: min(70vw, 25.5em);
  padding: 0.73em 0.91em;
  /* --ui-k > 1 only on phones in "desktop site" mode (see core.js), where the page is shrunk. */
  font: calc(var(--ui-k, 1) * clamp(11px, 1.5vw / var(--ui-k, 1), 20px))/1.5 var(--px);
  color: var(--ink);
  background: #FFFFFF;
  border: 0.273em solid var(--ink);
  box-shadow: 0.273em 0.273em 0 var(--ink);
  text-align: center;
  pointer-events: none;
}
.monster-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -0.82em; width: 0.82em; height: 0.82em;
  margin-left: -0.36em; background: #FFFFFF; border-right: 0.273em solid var(--ink); border-bottom: 0.273em solid var(--ink);
  transform: rotate(45deg);
}
.monster-lines { display: grid; gap: 8px; }
.monster-line {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 8px 10px; cursor: pointer;
  background: var(--ink); border: 3px solid var(--slate);
}
.monster-line:has(input:checked) { border-color: var(--sun); }
.monster-line input { width: 24px; height: 24px; flex: 0 0 auto; margin: 0; accent-color: var(--sun); }

/* ---------- share page tabs: make your own / use someone else's ---------- */
.tabs { display: flex; gap: 0; margin: 0 0 22px; border-bottom: 4px solid var(--cream); }
.tab {
  flex: 0 1 auto; min-height: 48px; padding: 12px 18px; margin: 0 6px -4px 0; cursor: pointer;
  font: 13px/1.2 var(--px); color: var(--cream); background: var(--slate);
  border: 4px solid var(--cream); border-bottom-color: var(--cream);
}
.tab:hover { background: var(--navy); }
/* The selected tab is the same color as the pop-up's SHARE button. */
.tab[aria-current="page"] { background: var(--share-bg, var(--sun)); color: var(--ink); border-bottom-color: var(--share-bg, var(--sun)); }
@media (max-width: 560px) {
  .tabs { gap: 0; }
  .tab { flex: 1 1 50%; padding: 10px 6px; font-size: 10px; margin-right: 4px; }
}

/* ---------- create form: palette picker ---------- */
.palette-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.palette-pick {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; cursor: pointer;
  font: 10px/1.2 var(--px); background: var(--ink); border: 3px solid var(--slate);
}
.palette-pick:has(input:checked) { border-color: var(--sun); }
.palette-pick input { width: 22px; height: 22px; flex: 0 0 auto; margin: 0; accent-color: var(--sun); }

/* ---------- the monster's line on library cards and the reuse screen ---------- */
.monster-note { font: 10px/1.5 var(--px); color: var(--sun); margin-top: 8px; overflow-wrap: anywhere; }
#ready-monster .monster-note { margin: 0 0 12px; font-size: 12px; }
