@font-face { font-family: "Caveat"; src: url("/fonts/caveat-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("/fonts/caveat-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Patrick Hand"; src: url("/fonts/patrick-hand-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("/fonts/pixelify-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("/fonts/pixelify-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("/fonts/pixelify-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("/fonts/pixelify-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --night: #221d42;
  --dusk: #3a3270;
  --gold: #ffcd4f;
  --gold-deep: #c9901c;
  --grass: #8fcf72;
  --panel: #f3f1ff;
  --panel-2: #e6e2fb;
  --line: #2b2550;
  --line-soft: #c9c2f0;
  --ink: #241f45;
  --ink-soft: #5d5784;
  --on-night: #e9e5ff;
  --on-night-soft: #a49fd0;
  --coral: #ff7a8a;
  --px: "Pixelify Sans", ui-rounded, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  color-scheme: dark;
}
/* The page is always night-time; light and dark share one palette on purpose. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --night: #221d42; } }
:root[data-theme="dark"] { --night: #221d42; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--night);
  color: var(--on-night);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100svh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ---------- stage ---------- */
.stage-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  background: linear-gradient(to bottom, #1c1739 0%, #2e2760 40%, #4a408c 63.8%, #5a9649 64%, #93cc74 65.4%, #93cc74 100%);
  padding-top: env(safe-area-inset-top);
}
.stage {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: manipulation;
}
.turn {
  position: absolute;
  bottom: 18px;
  width: 44px; height: 44px;
  border: 0; padding: 0;
  background: none;
  cursor: pointer;
  display: grid; place-items: center;
}
.turn span {
  width: 28px; height: 28px;
  background: rgba(34, 29, 66, .72);
  border: 2px solid var(--on-night-soft);
  border-radius: 4px;
  display: grid; place-items: center;
}
.turn span::before {
  content: ""; width: 0; height: 0;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.turn-l { left: 10px; } .turn-l span::before { border-right: 8px solid var(--on-night); margin-right: 2px; }
.turn-r { right: 10px; } .turn-r span::before { border-left: 8px solid var(--on-night); margin-left: 2px; }
.turn:active span { background: var(--dusk); }

/* ---------- steps ---------- */
.steps {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 14px 16px 0;
  padding: 0;
  font-family: var(--px);
  font-size: 14px;
  color: var(--on-night-soft);
}
.steps li { flex: 1; text-align: center; padding-bottom: 6px; border-bottom: 3px solid #3d3672; }
.steps li.on { color: var(--gold); border-color: var(--gold); }
.steps li.past { color: var(--on-night); border-color: #6d64b0; }

.view { padding: 14px 16px 0; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--panel), inset 0 0 0 4px var(--line-soft), 0 4px 0 #15122c;
}
.intro { padding: 20px 20px 22px; }
.intro h1 {
  font-family: var(--px);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: .01em;
}
.intro p { margin: 0 0 10px; font-size: 17px; line-height: 1.5; max-width: 34ch; }
.intro p:last-child { margin-bottom: 0; }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 10px;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 3;
  background: var(--night);
  padding-top: 6px; padding-bottom: 6px;
}
/* while customising, the stage stays in view and the tabs pin right under it */
body.pinned .stage-wrap { position: sticky; top: 0; z-index: 6; box-shadow: 0 6px 12px rgba(10, 8, 30, .45); }
body.pinned .tabs, body.pinned .tray { top: var(--stage-h, 0px); z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font-family: var(--px);
  font-size: 16px;
  padding: 8px 12px 7px;
  border: 2px solid #3d3672;
  border-radius: 5px;
  background: transparent;
  color: var(--on-night-soft);
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); border-color: var(--panel); }

/* ---------- options ---------- */
.options { padding: 16px 14px 18px; }
.group + .group { margin-top: 18px; padding-top: 16px; border-top: 2px dashed var(--line-soft); }
.group h2 {
  font-family: var(--px);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 10px;
}
.chips { display: grid; grid-template-columns: repeat(3, 100px); gap: 10px 8px; justify-content: space-between; }
.chip {
  position: relative;
  width: 100px; padding: 0;
  border: 2px solid var(--line-soft);
  border-radius: 5px;
  background: var(--panel-2);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
}
.chip canvas { width: 96px; height: 96px; image-rendering: pixelated; display: block; }
.chip .lbl {
  font-family: var(--px); font-size: 13px; line-height: 1;
  color: var(--ink-soft);
  width: 100%; text-align: center;
  padding: 5px 2px 6px;
  background: var(--panel);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip[aria-pressed="true"] { border-color: var(--line); box-shadow: 0 0 0 2px var(--gold); }
.chip[aria-pressed="true"] .lbl { color: var(--ink); background: var(--gold); }
.note {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border-radius: 5px; padding: 8px 10px; margin-bottom: 16px;
}
.note p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.link {
  flex: 0 0 auto; border: 0; background: none; padding: 6px 2px; cursor: pointer;
  font-family: var(--px); font-size: 15px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw {
  width: 36px; height: 36px; padding: 0;
  border: 2px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .25);
}
.sw[aria-pressed="true"] { outline: 3px solid var(--gold); outline-offset: 2px; }
.sub { font-family: var(--body); font-size: 13px; color: var(--ink-soft); margin: 12px 0 8px; }
.sub:first-child { margin-top: 0; }

/* ---------- message ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-family: var(--px); font-size: 15px; color: var(--on-night-soft); margin-bottom: 6px; }
.field input {
  width: 100%;
  font-family: var(--px); font-size: 19px;
  padding: 11px 12px 10px;
  background: #2c2657;
  border: 2px solid #4c4490;
  border-radius: 6px;
  color: var(--on-night);
}
.field input::placeholder { color: #7d77ad; }
.dialog {
  display: block;
  background: #fbfaff;
  border: 3px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px #fbfaff, inset 0 0 0 5px #8fb4e8, 0 4px 0 #15122c;
  padding: 14px 16px;
}
.dialog textarea {
  display: block;
  width: 100%;
  min-height: 150px;
  resize: none;
  border: 0; outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--px);
  font-size: 19px;
  line-height: 1.5;
  overflow: hidden;
}
.dialog textarea::placeholder { color: #9a95bd; }
.dialog:focus-within { box-shadow: inset 0 0 0 3px #fbfaff, inset 0 0 0 5px var(--gold-deep), 0 4px 0 #15122c; }
.hint { font-size: 14px; color: var(--on-night-soft); margin: 12px 2px 0; line-height: 1.45; }
.error { font-size: 15px; color: #ffd0d6; background: #5a2440; border-radius: 6px; padding: 10px 12px; margin: 12px 0 0; }

/* ---------- bottom bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 10px;
  max-width: 440px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--night) 70%, rgba(34, 29, 66, 0));
}
.btn {
  flex: 1;
  font-family: var(--px); font-size: 18px; font-weight: 600;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 7px;
  border: 3px solid #4c4490;
  background: #2c2657;
  color: var(--on-night);
  cursor: pointer;
  box-shadow: 0 4px 0 #15122c;
}
.btn-primary {
  flex: 1.7;
  background: var(--gold);
  border-color: #7a5410;
  color: #3a2608;
  box-shadow: inset 0 -4px 0 var(--gold-deep), 0 4px 0 #15122c;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #15122c; }
.btn-primary:active { box-shadow: inset 0 -2px 0 var(--gold-deep), 0 2px 0 #15122c; }
.btn[disabled] { opacity: .55; cursor: default; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.dialog textarea:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}

.demo-note { font-size: 14px !important; color: var(--ink-soft); border-top: 2px dashed var(--line-soft); padding-top: 10px; margin-top: 14px !important; }

.chip .pick {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--gold); color: #3a2608; font-family: var(--px); font-size: 13px; line-height: 20px; text-align: center;
  border: 2px solid var(--line);
}
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9;
  background: var(--panel); color: var(--ink); font-family: var(--px); font-size: 16px; padding: 10px 14px; border-radius: 7px;
  border: 3px solid var(--line); box-shadow: 0 4px 0 #15122c; max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- clue letter: the paper resting on its opened envelope ---------- */
.letter {
  --paper: #fbf6e9; --rule: rgba(90, 120, 180, .22); --ink: #26325c; --lh: 30px;
  --env: #d9b98a; --env-dark: #c29e6c; --liner-a: #f2d7a8; --liner-b: #e7c48c; --env-text: #3a2f4f;
  --flap: 74px; --strip: 66px;
  position: relative; margin: 10px 4px 28px; padding: calc(var(--flap) + 14px) 16px var(--strip);
  transform: rotate(var(--tilt, 0deg));
  filter: drop-shadow(0 6px 0 rgba(10, 8, 30, .45));
}
.letter.paper-cream { --paper: #fbf6e9; }
.letter.paper-white { --paper: #ffffff; --rule: rgba(80, 100, 160, .2); }
.letter.paper-blush { --paper: #fde7ea; --rule: rgba(200, 90, 120, .22); }
.letter.paper-peach { --paper: #ffe9d9; --rule: rgba(200, 110, 70, .22); }
.letter.paper-mint { --paper: #e5f6ec; --rule: rgba(60, 140, 100, .22); }
.letter.paper-sky { --paper: #e6f1fd; --rule: rgba(70, 110, 190, .25); }
.letter.paper-lilac { --paper: #efe8fc; --rule: rgba(120, 90, 190, .22); }
.letter.paper-kraft { --paper: #f1e3c8; --rule: rgba(120, 80, 40, .22); }
.letter.paper-lemon { --paper: #fdf6cf; --rule: rgba(170, 140, 40, .25); }
.letter.env-kraft { --env: #d4ac78; --env-dark: #b98f5c; }
.letter.env-white { --env: #f4f1ea; --env-dark: #d9d3c7; }
.letter.env-blush { --env: #f4b9c4; --env-dark: #df98a6; }
.letter.env-mint { --env: #a9dcc1; --env-dark: #86c3a4; }
.letter.env-sky { --env: #a9cdf0; --env-dark: #86b0dc; }
.letter.env-lilac { --env: #c9b8ef; --env-dark: #ab97da; }
.letter.env-mustard { --env: #ebc85f; --env-dark: #cfa841; }
.letter.env-red { --env: #e0656f; --env-dark: #c24c58; --env-text: #fff4ea; }
.letter.env-navy { --env: #4a5788; --env-dark: #374270; --env-text: #fdf6e3; }
.letter.env-forest { --env: #4f7d62; --env-dark: #3d634d; --env-text: #f6f1df; }
.letter.ink-navy { --ink: #26325c; } .letter.ink-plum { --ink: #5a2a55; }
.letter.ink-forest { --ink: #24493a; } .letter.ink-cocoa { --ink: #5a3826; }

/* envelope: back panel, the open flap above it (lined), and the front pocket */
.env-back { position: absolute; left: 0; right: 0; top: var(--flap); bottom: 0; background: var(--env-dark); border-radius: 5px; }
.env-flap-open { position: absolute; left: 0; right: 0; top: 0; height: calc(var(--flap) + 1px); z-index: 1; transform-origin: 50% 100%; background: var(--liner-a); }
.flap-point .env-flap-open { clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.flap-straight .env-flap-open { clip-path: polygon(0 100%, 13% 0, 87% 0, 100% 100%); border-radius: 6px 6px 0 0; }
.flap-round .env-flap-open { border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.liner-stripes .env-flap-open { background: repeating-linear-gradient(90deg, var(--liner-a) 0 8px, var(--liner-b) 8px 16px); }
.liner-dots .env-flap-open { background: radial-gradient(var(--liner-b) 2.5px, transparent 3px) 0 0 / 12px 12px, var(--liner-a); }
.liner-checks .env-flap-open { background: conic-gradient(var(--liner-b) 25%, var(--liner-a) 0 50%, var(--liner-b) 0 75%, var(--liner-a) 0) 0 0 / 16px 16px; }
.liner-stars .env-flap-open { background: radial-gradient(circle, #fff6c8 1.6px, transparent 2px) 0 0 / 14px 14px, radial-gradient(circle, #fff6c8 1.2px, transparent 1.6px) 7px 7px / 14px 14px, #3a3270; }
.liner-waves .env-flap-open { background: radial-gradient(circle at 50% 120%, transparent 6px, var(--liner-b) 6.5px 9px, transparent 9.5px) 0 0 / 18px 10px, var(--liner-a); }
.env-front {
  position: absolute; left: 0; right: 0; top: var(--flap); bottom: 0; z-index: 2;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), rgba(0, 0, 0, .09) 50%, transparent calc(50% + 1px)) left bottom / 50% 62% no-repeat,
    linear-gradient(to top left, transparent calc(50% - 1px), rgba(0, 0, 0, .09) 50%, transparent calc(50% + 1px)) right bottom / 50% 62% no-repeat,
    var(--env);
  clip-path: polygon(0 12px, 50% 44px, 100% 12px, 100% 100%, 0 100%);
  border-radius: 0 0 5px 5px;
}
.body-dots .env-front { background-image: radial-gradient(rgba(255, 255, 255, .28) 2px, transparent 2.5px); background-size: 14px 14px; }
.body-hearts .env-front { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 11 11' shape-rendering='crispEdges'%3E%3Cpath fill='%23fff' fill-opacity='.3' d='M3 3h2v1h1V3h2v3H7v1H6v1H5V7H4V6H3z'/%3E%3C/svg%3E"); background-size: 22px 22px; }
.body-stars .env-front { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' shape-rendering='crispEdges'%3E%3Cpath fill='%23fff' fill-opacity='.32' d='M5 2h1v2h2v1H6v2H5V5H3V4h2zM17 13h1v1h1v1h-1v1h-1v-1h-1v-1h1z'/%3E%3C/svg%3E"); background-size: 24px 24px; }
.body-airmail .env-front::after {
  content: ""; position: absolute; inset: 0; border: 7px solid transparent; border-radius: 0 0 5px 5px;
  border-image: repeating-linear-gradient(45deg, #d6453d 0 9px, #fffaf0 9px 18px, #3f6fb5 18px 27px, #fffaf0 27px 36px) 7;
}
.env-to { position: absolute; left: 20px; bottom: 16px; color: var(--env-text); opacity: .9; font-size: 21px !important; line-height: 1; }
.env-front .stamp {
  position: absolute; bottom: 12px; right: 16px; padding: 5px; background: #fffdf7;
  transform: rotate(4deg); box-shadow: 1px 2px 0 rgba(0, 0, 0, .2);
  -webkit-mask: radial-gradient(circle 2.5px at 50% 50%, #0000 96%, #000) -4px -4px / 8px 8px;
  mask: radial-gradient(circle 2.5px at 50% 50%, #0000 96%, #000) -4px -4px / 8px 8px;
}
.env-front .stamp canvas { display: block; image-rendering: pixelated; outline: 2px solid #e4dccb; }
.postmark {
  position: absolute; right: 40px; bottom: 14px; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(40, 30, 60, .32); transform: rotate(-12deg);
  background: linear-gradient(transparent 44%, rgba(40, 30, 60, .3) 44% 52%, transparent 52%);
}
.postmark::after { content: ""; position: absolute; left: 30px; top: 6px; width: 34px; height: 18px;
  background: repeating-linear-gradient(transparent 0 4px, rgba(40, 30, 60, .3) 4px 6px); }

/* the closed flap and its wax seal (only before the letter is opened) */
.env-flap-closed { position: absolute; left: 0; right: 0; top: var(--flap); height: 118px; z-index: 4; transform-origin: 50% 0; display: none; }
.env-flap-closed::before { content: ""; position: absolute; inset: 0; background: var(--env-dark); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08); }
.flap-point .env-flap-closed::before { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.flap-straight .env-flap-closed::before { clip-path: polygon(0 0, 100% 0, 86% 100%, 14% 100%); }
.flap-round .env-flap-closed::before { border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.letter.sealed .env-flap-closed { display: block; }
.letter.sealed .env-flap-open { transform: scaleY(0); }
.letter.sealed .letter-paper { clip-path: inset(0 0 100% 0); }
.env-flap-closed .seal { position: absolute; left: 50%; bottom: -8px; margin-left: -18px; z-index: 1; }
.letter .seal {
  position: absolute; width: 36px; height: 36px; border-radius: 47% 53% 50% 48%;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .18), inset -3px -4px 0 rgba(0, 0, 0, .18), 2px 3px 0 rgba(0, 0, 0, .25);
  display: grid; place-items: center; color: rgba(255, 255, 255, .6); font: 700 16px/1 var(--px);
}
.seal.mark-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); }
.seal.mark-heart::after { content: "\2665"; font-size: 17px; }
.seal.mark-star::after { content: "\2605"; font-size: 16px; }
.seal-red { background: #c73a4a; } .seal-gold { background: #d9a43a; } .seal-teal { background: #2f8f86; } .seal-purple { background: #7b4fb8; } .seal-pink { background: #e06a98; }

/* the paper */
.letter-paper { position: relative; z-index: 3; color: var(--ink); padding: 24px 20px 70px; min-height: 210px; }
.letter-paper::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background-color: var(--paper); box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.letter.rule-lines .letter-paper::before, .letter.rule-notebook .letter-paper::before {
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px) var(--lh)); background-position: 0 17px;
}
.letter.rule-notebook .letter-paper { padding-left: 42px; }
.letter.rule-notebook .letter-paper::before {
  background-image:
    radial-gradient(circle 4px at 14px 50%, rgba(40, 30, 60, .28) 90%, transparent) 0 0 / 28px 46px repeat-y,
    linear-gradient(90deg, transparent 31px, rgba(214, 69, 61, .45) 31px 33px, transparent 33px),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px) var(--lh));
  background-position: 0 10px, 0 0, 0 17px;
}
.letter.rule-grid .letter-paper::before { background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 18px 18px; }
.letter.rule-dots .letter-paper::before { background-image: radial-gradient(var(--rule) 1.4px, transparent 1.6px); background-size: 16px 16px; }
.letter.edge-scallop .letter-paper::before {
  -webkit-mask: radial-gradient(8px at 50% 8px, #0000 98%, #000) 50% -8px / 20px 100% repeat-x;
  mask: radial-gradient(8px at 50% 8px, #0000 98%, #000) 50% -8px / 20px 100% repeat-x;
}
.letter.edge-deckle .letter-paper::before {
  -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 9px 51% repeat-x, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 9px 51% repeat-x;
  mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 9px 51% repeat-x, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 9px 51% repeat-x;
}
/* it was folded to fit the envelope */
.letter.creased .letter-paper::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(transparent calc(33.3% - 1px), rgba(0, 0, 0, .07) calc(33.3% - 1px) 33.3%, rgba(255, 255, 255, .55) 33.3% calc(33.3% + 1px), transparent calc(33.3% + 1px) calc(66.6% - 1px), rgba(0, 0, 0, .07) calc(66.6% - 1px) 66.6%, rgba(255, 255, 255, .55) 66.6% calc(66.6% + 1px), transparent calc(66.6% + 1px));
}
.letter-paper p { margin: 0; overflow-wrap: anywhere; position: relative; z-index: 1; }
.sticker-room { float: right; display: block; margin: -10px -8px 0 6px; }
.letter.hand-caveat .letter-paper, .letter.hand-caveat .env-to { font-family: "Caveat", "Patrick Hand", cursive; font-size: 25px; line-height: var(--lh); }
.letter.hand-patrick .letter-paper, .letter.hand-patrick .env-to { font-family: "Patrick Hand", "Caveat", cursive; font-size: 20px; line-height: var(--lh); }
.letter-greet { font-weight: 600; margin-bottom: 4px !important; }
.letter-body { white-space: pre-wrap; }
.letter-sign { text-align: right; margin-top: 10px !important; clear: both; }
.letter .sticker { position: absolute; z-index: 2; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); line-height: 0; }
.letter .sticker canvas {
  image-rendering: pixelated;
  filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(1px 2px 1px rgba(0, 0, 0, .3));
}
.letter-intro { font-size: 14px; color: var(--on-night-soft); margin: 18px 2px 0; line-height: 1.45; }
.handover { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; }
.handover .bubble {
  flex: 1; background: #fbfaff; color: var(--ink); border: 3px solid var(--line); border-radius: 8px;
  font-family: var(--px); font-size: 16px; line-height: 1.4; padding: 10px 12px; box-shadow: 0 4px 0 #15122c;
}

/* ---------- things you carry ---------- */
.tray {
  position: sticky; top: 0; z-index: 3;
  margin: 0 -16px 10px; padding: 8px 16px 10px;
  background: var(--night);
}
.tray-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.tray-head h2 { font-family: var(--px); font-size: 16px; font-weight: 600; color: var(--on-night); margin: 0; }
.tray-head .link { color: var(--gold); font-size: 14px; padding: 4px 0; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot {
  position: relative; min-width: 0; padding: 4px 6px 6px; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center;
  background: #2e2760; border: 2px solid #4a4290; border-radius: 6px; color: var(--on-night);
}
.slot canvas { grid-row: 1 / span 2; width: 36px; height: 36px; image-rendering: pixelated; }
.slot b { font-family: var(--px); font-weight: 500; font-size: 13px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot small { font-size: 11px; line-height: 1.2; color: var(--on-night-soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot .x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); color: var(--ink); border: 2px solid var(--line); font: 600 13px/16px var(--px); text-align: center; }
.slot.empty { border-style: dashed; color: var(--on-night-soft); cursor: default; display: flex; align-items: center; justify-content: center; min-height: 48px; font-family: var(--px); font-size: 13px; }
.chip.item { background: #2e2760; border-color: #4a4290; }
.chip.item[aria-pressed="true"] { border-color: var(--line); }

/* ---------- name & message extras ---------- */
.name-field { margin: 16px 0 0; }
.name-field .field-label { color: var(--ink-soft); }
.name-field input { font-size: 20px; }
.intro .error { margin: 10px 0 0; }
.intro .field input { background: #fff; color: var(--ink); border-color: var(--line-soft); }
.intro .field input::placeholder { color: #9a95bd; }
.intro .field input:focus { outline: none; border-color: var(--gold-deep); box-shadow: 0 0 0 2px var(--gold); }
.name-hint { font-size: 14px !important; color: var(--ink-soft); margin: 10px 0 0 !important; line-height: 1.4 !important; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.quick button {
  border: 2px solid #4a4290; background: #2e2760; color: var(--on-night); border-radius: 999px;
  padding: 6px 11px; font-size: 15px; line-height: 1.1; cursor: pointer;
}
.quick button:active { background: var(--dusk); }

/* ---------- deleting an entry ---------- */
.danger-zone { margin: 18px 2px 0; text-align: center; }
.link-danger {
  border: 0; background: none; padding: 10px 6px; cursor: pointer; min-height: 44px;
  font-family: var(--body); font-size: 15px; color: #ff9aa6; text-decoration: underline; text-underline-offset: 3px;
}
.confirm {
  width: min(360px, calc(100vw - 32px)); padding: 20px 18px 18px; border: 3px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); box-shadow: 0 6px 0 #15122c;
}
.confirm::backdrop { background: rgba(10, 8, 30, .66); }
.confirm h2 { font-family: var(--px); font-size: 22px; margin: 0 0 8px; }
.confirm p { margin: 0 0 16px; font-size: 16px; line-height: 1.45; color: var(--ink-soft); }
.confirm-btns { display: flex; gap: 10px; }
.confirm .btn { color: var(--ink); background: var(--panel-2); border-color: var(--line-soft); }
.btn-danger { background: #d6453d !important; border-color: #7a1f1a !important; color: #fff !important; box-shadow: inset 0 -4px 0 #a8322b, 0 4px 0 #15122c; }
.steps li.past { cursor: pointer; }

/* ---------- audit fixes (stage 4 review) ---------- */
/* progress steps are buttons: keyboard reachable, big enough to tap */
.steps li { padding-bottom: 0; }
.steps li button {
  all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 40px; padding: 4px 0 6px; color: inherit; font: inherit; text-align: center; cursor: default;
}
.steps li.past button { cursor: pointer; }
.steps li button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
[tabindex="-1"]:focus { outline: none; }
.loading-note { font-family: var(--px); color: var(--on-night-soft); text-align: center; margin: 24px 0; font-size: 16px; }

/* tiles shrink with the screen, so nothing overflows at 320px */
.chips { grid-template-columns: repeat(3, minmax(0, 100px)); }
.chip { width: 100%; max-width: 100px; min-width: 0; }
.chip canvas { width: 100%; height: auto; aspect-ratio: 1; }
.chip.item .lbl { white-space: normal; text-overflow: clip; line-height: 1.1; min-height: calc(2.2em + 11px); display: flex; align-items: center; justify-content: center; }
.slot { padding-right: 12px; }
.slot b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot .x { top: -9px; right: -9px; }

/* when the tabs don't fit, the row fades at the edge that has more */
.tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
.tabs.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); }
.tabs.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
@media (min-width: 700px) { .tabs { flex-wrap: wrap; overflow-x: visible; } }

/* tap targets of at least 40px */
.tab { min-height: 40px; }
.sw { width: 40px; height: 40px; }
.tray-head .link, .note .link { min-height: 40px; display: inline-flex; align-items: center; padding-inline: 6px; }
.quick button { min-height: 40px; }

@media (max-width: 340px) {
  .view { padding-left: 12px; padding-right: 12px; }
  .tabs, .tray { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .steps { margin-left: 12px; margin-right: 12px; font-size: 13px; gap: 4px; }
  .chips { gap: 8px 6px; }
}
/* narrow phones: the carried items stack (picture over name) so names aren't cut short */
@media (max-width: 360px) {
  .slot { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 4px 4px 6px; row-gap: 2px; }
  .slot canvas { grid-row: auto; }
  .slot small { display: none; }
}

/* ---------- signing in with a name and PIN ---------- */
.pin-field input { font-size: 26px; letter-spacing: .5em; width: 7.2em; font-variant-numeric: tabular-nums; text-align: center; padding-left: .5em; }
.join-switch, .sign-out { margin: 12px 0 0; text-align: center; }
.join-switch .link, .sign-out .link { min-height: 40px; }
.sign-out .link { color: var(--on-night-soft); font-family: var(--body); font-size: 15px; }
.share-box { padding: 16px 16px 18px; margin-top: 18px; }
.share-box h2 { font-family: var(--px); font-size: 19px; margin: 0 0 6px; }
.share-box p { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: var(--ink-soft); }
.share-row { display: flex; gap: 8px; align-items: center; }
.share-link { flex: 1; min-width: 0; font-family: var(--px); font-size: 15px; background: #fff; border: 2px solid var(--line-soft); border-radius: 6px; padding: 10px 10px; overflow-wrap: anywhere; color: var(--ink); }
.share-row .btn { flex: 0 0 auto; min-height: 44px; }
.btn, button, h1, h2, h3 { font-variant-ligatures: none; }

/* the sign-in page: what this is */
.about { margin: 4px 0 14px; }
.about-steps { margin: 0 0 10px; padding-left: 22px; display: grid; gap: 6px; }
.about-steps li { line-height: 1.35; }
.about-small { margin: 0; font-size: 14px; opacity: .8; }
.about-lead { margin: 0 0 8px; font-weight: 700; }

/* ---------- photos for the credits ---------- */
.photos-box { padding: 14px 14px 16px; margin-top: 18px; }
.photos-box h3 { font-family: var(--px); font-size: 17px; margin: 0 0 4px; }
.photos-box h3 .opt { font-family: var(--body); font-size: 12px; font-weight: 400; color: var(--ink-soft); margin-left: 4px; }
.photos-help { margin: 0 0 12px; font-size: 14px; line-height: 1.4; color: var(--ink-soft); }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo-tile { position: relative; margin: 0; background: #fff; border: 2px solid var(--line); border-radius: 4px; padding: 5px 5px 4px; box-shadow: 0 3px 0 #15122c; display: flex; flex-direction: column; gap: 4px; }
.photo-tile:nth-child(3n+1) { transform: rotate(-1.5deg); }
.photo-tile:nth-child(3n+2) { transform: rotate(1deg); }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel-2); }
.photo-tile textarea { width: 100%; border: 0; border-top: 1px dashed var(--line-soft); resize: none; font: 13px/1.25 var(--body); color: var(--ink); background: transparent; padding: 4px 2px 0; min-height: 36px; }
.photo-tile textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.photo-tile.adding { align-items: center; justify-content: center; aspect-ratio: 3 / 4; font-size: 13px; color: var(--ink-soft); }
.photo-x { position: absolute; top: -10px; right: -10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--coral); color: #fff; font: 700 18px/1 var(--body); display: grid; place-items: center; padding: 0; cursor: pointer; }
.photo-add { aspect-ratio: 3 / 4; border: 2px dashed var(--line-soft); border-radius: 4px; background: transparent; color: var(--ink-soft); font: 600 13px/1.2 var(--body); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.photo-add span { font: 700 28px/1 var(--px); color: var(--ink); }
.photo-add:focus-visible { outline: 3px solid var(--gold); }
@media (max-width: 340px) { .photo-grid { gap: 8px; } .photo-tile textarea { font-size: 12px; } }
