/* Postcards. Airmail paper, navy ink, postal red and blue.
   The envelope is the one loud thing; everything else stays quiet.
   Two kinds of surface: paper objects (letter, notes, photos, stamps, vouchers) have
   small corners like real paper; app chrome (panels, buttons, fields) is rounder. */

:root {
  --paper: #EBF0F7;
  --sheet: #FBFCFE;
  --ink: #1B2A4A;
  --ink-soft: #56627C;
  --rule: #D3DBE8;
  --line: #C9D7EE;          /* ruled lines on letter paper */
  --red: #C8102E;           /* fills: buttons, seals, stamp */
  --red-text: #C8102E;      /* red used as text or outline */
  --blue: #2B5BA8;
  --gold: #E3B13E;
  --good: #2E7D4F;
  --print: #FFFFFF;         /* photo prints and stamp paper */
  --envelope: #FBFCFE;
  --tint: rgba(27, 42, 74, .06);
  --shadow: 0 1px 0 rgba(27, 42, 74, .06), 0 8px 24px -12px rgba(27, 42, 74, .28);
  --hand: "Patrick Hand", "Segoe Print", "Comic Sans MS", cursive;
  --sans: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-ui: 14px;
  --r-paper: 4px;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0F1729;
    --sheet: #18223A;
    --ink: #E6EBF5;
    --ink-soft: #A3AEC6;
    --rule: #2E3B5C;
    --line: #2C3D63;
    --red: #D02840;
    --red-text: #FF7385;
    --blue: #8AB0F0;
    --gold: #F0C55E;
    --good: #5CC08A;
    --print: #E3E8F0;
    --envelope: #1F2B47;
    --tint: rgba(230, 235, 245, .06);
    --shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 10px 26px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--sans);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom)); outline: none; }
main.full { max-width: none; padding: 0; }

/* Type scale: 14 / 15 / 17 / 19 / 22 / 38 */
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 2.25rem; line-height: 1.05; letter-spacing: -.025em; font-variation-settings: "opsz" 96; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--blue); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; line-height: 1.45; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 36px; }
.section > h2 { margin-bottom: 4px; }
.section > h2:only-child, .section > h2 + :not(p) { margin-bottom: 12px; }
.label { font-size: .875rem; font-weight: 600; color: var(--ink-soft); }
[hidden] { display: none !important; }

/* ---- buttons and fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0;
  background: var(--ink); color: var(--paper); font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--rule); }
.btn.small { min-height: 38px; padding: 0 16px; font-size: .9rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { border-radius: 999px; outline-offset: 3px; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
textarea, input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--rule);
  background: var(--sheet);
}
::placeholder { color: var(--ink-soft); opacity: .8; }
textarea { min-height: 96px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--blue); }
label.field { display: block; }
label.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.actions { margin-top: 14px; display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: center; }

/* ---- the header strip on each screen ---- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.top h1 { margin-top: 2px; }
.top .where { margin-top: 6px; color: var(--ink-soft); line-height: 1.4; }
.top .where + .where { margin-top: 2px; }
.top .where b { color: var(--ink); font-weight: 600; }
.countdown { margin-top: 10px; font: 400 1.2rem/1.2 var(--hand); color: var(--ink); }

/* The stamp balance: a perforated postage stamp. The outer link carries the tilt and the
   shadow (a mask would clip a shadow); .perf is the perforated paper, cut by a mask of
   circles centred exactly on its edges (size is a whole number of 9px holes each way);
   .print is the red design inside it, with a thin engraved frame. */
.stamp {
  flex: none; display: block; margin-top: 4px; color: #fff; text-decoration: none;
  rotate: 4deg; filter: drop-shadow(0 1px 1px rgba(27, 42, 74, .22)) drop-shadow(0 4px 6px rgba(27, 42, 74, .16));
}
.stamp .perf {
  --r: 3px;
  display: grid; width: 72px; height: 81px; padding: 7px; background: var(--print);
  -webkit-mask:
    radial-gradient(var(--r), #0000 97%, #000) calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r)) no-repeat;
  mask:
    radial-gradient(var(--r), #0000 97%, #000) calc(-1.5 * var(--r)) calc(-1.5 * var(--r)) / calc(3 * var(--r)) calc(3 * var(--r)),
    linear-gradient(#000 0 0) 50% / calc(100% - 3 * var(--r)) calc(100% - 3 * var(--r)) no-repeat;
}
.stamp .print {
  display: grid; place-content: center; justify-items: center; gap: 3px;
  background: var(--red);
  box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 4px rgba(255, 255, 255, .7);
}
.stamp strong { font-size: 1.55rem; line-height: .9; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stamp.long strong { font-size: 1.2rem; }
.stamp .print span { font: 400 .85rem/1 var(--hand); opacity: .95; }
.stamp:focus-visible { outline: none; }
.stamp:focus-visible .perf { background: var(--gold); }
.stamp.bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: rotate(-8deg) scale(1.12); } }

/* ---- the envelope: the one moment of theatre ---- */
.envelope {
  position: relative; display: block; margin-top: 24px; aspect-ratio: 1.6; width: 100%;
  border: 0; padding: 0; cursor: pointer; background: none; perspective: 900px; color: inherit;
}
.envelope .body {
  position: absolute; inset: 0; border-radius: 8px; background: var(--envelope); box-shadow: var(--shadow);
  overflow: hidden;
}
.envelope .body::before {
  /* airmail border */
  content: ""; position: absolute; inset: 0; border-radius: 8px;
  background: repeating-linear-gradient(-45deg, var(--red) 0 14px, transparent 14px 24px, var(--blue) 24px 38px, transparent 38px 48px);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 9px;
}
.envelope .flap {
  position: absolute; left: 9px; right: 9px; top: 9px; height: 58%;
  background: var(--envelope); clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .7s cubic-bezier(.5, 0, .2, 1);
  filter: drop-shadow(0 2px 2px rgba(27, 42, 74, .22));
  z-index: 2;
}
.envelope .seal {
  position: absolute; left: 50%; top: 58%; width: 54px; height: 54px; margin: -27px 0 0 -27px; z-index: 3;
  border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center;
  font: 400 1.6rem/1 var(--hand); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 2px 4px rgba(27, 42, 74, .2);
  transition: opacity .25s, transform .25s;
}
/* Address and hint hang from the seal so they never collide with it on narrow phones. */
.envelope .addr {
  position: absolute; left: 0; right: 0; top: calc(58% + 29px); text-align: center; font: 400 1.4rem/1.2 var(--hand);
  color: var(--ink); z-index: 1;
}
.envelope .tap { position: absolute; left: 0; right: 0; top: calc(58% + 60px); text-align: center; font-size: .85rem; line-height: 1.3; color: var(--ink-soft); z-index: 1; }
@media (max-width: 379px) { .envelope .tap { display: none; } }
.envelope.opening .seal { opacity: 0; transform: scale(.6); }
.envelope.opening .flap { transform: rotateX(180deg); }
.envelope.waiting { cursor: default; }
.envelope.waiting .seal { background: var(--ink-soft); }
.envelope.waiting .addr { color: var(--ink-soft); }
button.envelope:focus-visible { outline: none; }
button.envelope:focus-visible .body { box-shadow: var(--shadow), 0 0 0 3px var(--paper), 0 0 0 6px var(--blue); }
.env-note { margin-top: 10px; text-align: center; }

/* The letter itself, in his handwriting, on ruled paper. The rules live only in the
   content box, one per line, sitting just under the handwriting baseline. */
.letter {
  --lh: 1.8rem;
  position: relative; margin-top: 24px; padding: 28px 22px 32px; border-radius: var(--r-paper);
  box-shadow: var(--shadow);
  font: 400 1.32rem/var(--lh) var(--hand);
  background:
    linear-gradient(transparent calc(var(--lh) - 1px), var(--line) 0) 0 -4px / 100% var(--lh) repeat-y content-box,
    linear-gradient(var(--sheet) 0 0);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.letter h2 { font: 400 1.6rem/var(--lh) var(--hand); margin-bottom: var(--lh); position: relative; top: -2px; letter-spacing: 0; }
.letter.rise { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(36px) scale(.98); } }
.letter-meta { margin-top: 8px; }

/* ---- panels ---- */
.panel { margin-top: 16px; padding: 18px; border-radius: var(--r-ui); background: var(--sheet); box-shadow: var(--shadow); }
.panel.flat, .panel.notice { box-shadow: none; border: 2px dashed var(--rule); background: transparent; }
.panel.notice h2 { font-size: 1.08rem; }
.panel h2 + p, .panel h3 + p { margin-top: 6px; }

.game-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; }
.game-card .score { font-size: 2rem; font-weight: 800; line-height: 1; text-align: right; }
.game-card .score small { display: block; font-size: .78rem; font-weight: 400; color: var(--ink-soft); }
.squares { letter-spacing: 2px; }

/* Today's question: he wrote it, so it's in his hand. */
.question .q { margin: 2px 0 14px; font: 400 1.6rem/1.2 var(--hand); letter-spacing: 0; text-wrap: pretty; }
.question .actions .muted { flex: 1; }
.answers { display: grid; gap: 10px; }
.answer { padding: 10px 14px 12px; border-radius: 12px; background: var(--paper); }
.answer .who { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.answer p { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer.theirs { background: color-mix(in srgb, var(--blue) 12%, var(--sheet)); }
.answers + .actions { margin-top: 10px; }

/* List of days: a strip of postmarks, two weeks in two rows. */
.days { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px 6px; margin-top: 14px; }
.day-dot {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; text-decoration: none;
  border: 2px dashed var(--rule); color: var(--ink-soft); font-weight: 600; font-size: .95rem; position: relative;
  font-variant-numeric: tabular-nums;
}
.day-dot.open { border-style: solid; border-color: var(--ink); color: var(--ink); font-weight: 800; }
.day-dot.todo::after {
  content: ""; position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 2px var(--paper);
}
.day-dot.done { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.day-dot.today { outline: 2px solid var(--red-text); outline-offset: 2px; }
.day-dot:focus-visible { border-radius: 50%; }
.days-more { margin-top: 14px; }

/* Open-when notes: small envelopes, flap drawn as a V with a little seal at its point. */
.notes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.note {
  --flap: 38px;
  position: relative; min-height: 104px; padding: calc(var(--flap) + 12px) 14px 12px; border: 0; border-radius: var(--r-paper);
  text-align: left; cursor: pointer; color: var(--ink);
  background:
    linear-gradient(to bottom left, transparent calc(50% - 1px), var(--rule) 0 calc(50% + 1px), transparent 0) left top / 50% var(--flap) no-repeat,
    linear-gradient(to bottom right, transparent calc(50% - 1px), var(--rule) 0 calc(50% + 1px), transparent 0) right top / 50% var(--flap) no-repeat,
    var(--envelope);
  box-shadow: var(--shadow); font: 400 1.15rem/1.2 var(--hand);
}
.note::after {
  content: ""; position: absolute; left: 50%; top: var(--flap); width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: var(--red); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.note.opened { color: var(--ink-soft); }
.note.opened::after { background: var(--rule); box-shadow: none; }

/* ---- bottom tabs ---- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--sheet); border-top: 1px solid var(--rule);
}
#tabs a {
  position: relative; flex: 1; max-width: 112px; display: grid; justify-items: center; gap: 2px; padding: 6px 0 5px;
  border-radius: 12px; color: var(--ink-soft); text-decoration: none; font-size: .75rem; font-weight: 600;
}
#tabs a svg { width: 24px; height: 24px; }
#tabs a[aria-current=page] { color: var(--ink); background: var(--tint); }
#tabs a:focus-visible { border-radius: 12px; outline-offset: -3px; }
#tabs a .dot { position: absolute; top: 4px; left: 58%; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--sheet); }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); z-index: 2000;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: .95rem; box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .4);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- login ---- */
.login { min-height: 80dvh; display: grid; align-content: center; gap: 24px; }
.login h1 { font-size: 3rem; }
.login h1 + p { margin-top: 6px; }
.login .envelope { margin: 0; cursor: default; }

/* ---- games ---- */
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-height: 28px; }
.prompt-line { margin: 2px 0 14px; }
.after { margin-top: 12px; }
.pips { display: flex; gap: 6px; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: var(--rule); }
.pip.now { background: var(--ink); }
.pip.g { background: var(--good); } .pip.y { background: var(--gold); } .pip.r { background: var(--red); }

/* Polaroid prints. The frame hugs the photo, whatever its shape. */
.photo-frame {
  width: fit-content; max-width: 100%; margin: 0 auto;
  background: var(--print); padding: 10px 10px 30px; border-radius: 3px; box-shadow: var(--shadow); rotate: -1deg;
}
.photo-frame img { width: auto; max-width: 100%; max-height: 50dvh; background: #d9dee8; border-radius: 1px; }
.photo-frame .cap { margin-top: 8px; font: 400 1.15rem/1.2 var(--hand); color: #1B2A4A; }
.photo-frame .cap:empty { display: none; }

/* Where were we: photo, map and button share one screen, so the button never covers the map. */
.where-play {
  display: flex; flex-direction: column; gap: 14px;
  height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom) - 152px); min-height: 460px;
}
.where-play .photo-frame { flex: none; padding-bottom: 22px; }
.where-play .photo-frame img { height: 25dvh; max-height: none; }
.guess-map { height: 44dvh; min-height: 260px; margin-top: 16px; border-radius: var(--r-ui); overflow: hidden; box-shadow: var(--shadow); }
.where-play .guess-map { flex: 1 1 auto; height: auto; min-height: 180px; margin: 0; }
.where-play .lock { position: static; margin: 0; }

.lock { position: sticky; bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom)); margin-top: 16px; z-index: 500; }
.lock.next { position: static; scroll-margin-bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); }
.reveal { margin-top: 16px; }
.reveal .game-card h3 { font-size: 1.15rem; font-weight: 800; }
.reveal .big { font-size: 2.6rem; font-weight: 800; line-height: .9; text-align: right; font-variant-numeric: tabular-nums; }
.reveal .big small { display: block; margin-top: 4px; font-size: .8rem; font-weight: 400; color: var(--ink-soft); }
.reveal .facts { margin-top: 10px; }
.reveal .facts p + p { margin-top: 2px; }
.round-nav { margin-top: 16px; }
.big-squares { font-size: 1.6rem; margin: 14px 0 10px; }
.finish-actions { margin-top: 22px; }
.counter { margin-top: 10px; font-variant-numeric: tabular-nums; }

.years { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 18px; }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px; }
.chip {
  min-height: 42px; padding: 0 12px; border-radius: 999px; border: 2px solid var(--rule); background: var(--sheet); cursor: pointer;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.years .chip { padding: 0; }
.months .chip { padding: 0; border-radius: 10px; }
.chip[aria-pressed=true] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:disabled { cursor: default; }
.chip:disabled:not([aria-pressed=true]) { opacity: .55; }

/* Which came first: two square prints side by side (square crops treat portrait and
   landscape photos the same). After the guess, the older one gets a green ring. */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pair button { border: 0; padding: 0; background: none; cursor: pointer; text-align: left; color: inherit; border-radius: 4px; }
.pair button:disabled { cursor: default; }
.pair .photo-frame { width: auto; padding: 7px 7px 28px; }
.pair button:nth-child(2) .photo-frame { rotate: 1.2deg; }
.pair .photo-frame img { width: 100%; aspect-ratio: 1; max-height: none; object-fit: cover; }
.pair .photo-frame .cap { display: block; min-height: 1.2em; margin-top: 6px; font-size: 1.05rem; }
.pair .right .photo-frame { box-shadow: 0 0 0 4px var(--good), var(--shadow); }
.pair .wrong .photo-frame { box-shadow: 0 0 0 4px var(--red-text), var(--shadow); }
.pair .right .cap { color: #1F6B42; }

.jigsaw { display: grid; gap: 2px; width: 100%; aspect-ratio: 1; background: var(--ink); padding: 2px; border-radius: var(--r-paper); touch-action: manipulation; }
.tile { border: 0; padding: 0; background-repeat: no-repeat; cursor: pointer; border-radius: 1px; }
.tile.sel { outline: 4px solid var(--gold); outline-offset: -4px; }
.tile:focus-visible { outline-offset: -3px; border-radius: 1px; }
.jigsaw.solved { gap: 0; padding: 0; transition: gap .4s, padding .4s; }

/* ---- map ---- */
.map-wrap { position: relative; height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom)); }
.map-wrap .leaflet-container { height: 100%; background: var(--paper); font: inherit; }
.map-head {
  position: absolute; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); z-index: 600;
  padding: 12px 16px 13px; border-radius: var(--r-ui); background: var(--sheet); box-shadow: var(--shadow);
}
.map-head p + p { margin-top: 2px; }
.leaflet-container a { color: var(--blue); }
.leaflet-control-attribution { font-size: 10px; }
.here-pin { width: 22px; height: 22px; border-radius: 50%; background: var(--red); border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(200, 16, 46, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgba(200, 16, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0); } }
.stop-pin { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #1B2A4A; }
/* Photo pins are tiny Polaroids; unseen ones get a red frame. */
.card-pin { width: 46px; height: 46px; border-radius: 2px; border: solid #fff; border-width: 3px 3px 9px; background: #ccc center/cover; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); rotate: -3deg; }
.card-pin.new { border-color: #C8102E; }
.guess-pin { width: 18px; height: 18px; border-radius: 50%; background: #2B5BA8; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.true-pin { width: 18px; height: 18px; border-radius: 50%; background: #C8102E; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; max-height: 88dvh; overflow: auto;
  padding: 26px 16px calc(24px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--paper);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .3); animation: up .3s ease both;
}
.sheet::before { content: ""; position: absolute; top: 9px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--rule); }
.sheet .inner { max-width: 560px; margin: 0 auto; }
.sheet .letter { margin-top: 0; }
@keyframes up { from { transform: translateY(100%); } }
.scrim { position: fixed; inset: 0; z-index: 1400; background: rgba(15, 23, 41, .5); }

/* ---- shop ---- */
.shop-list { margin-top: 20px; border-radius: var(--r-ui); background: var(--sheet); box-shadow: var(--shadow); overflow: hidden; }
.item { display: grid; grid-template-columns: 36px 1fr auto; gap: 2px 12px; align-items: start; padding: 16px; }
.item + .item { border-top: 1px solid var(--rule); }
.item .emoji { font-size: 1.6rem; line-height: 1.2; text-align: center; }
.item h3 { line-height: 1.25; }
.item .price { font-weight: 800; font-size: 1.15rem; line-height: 1.1; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item .price small { display: block; font-size: .75rem; font-weight: 400; color: var(--ink-soft); }
.item .buy { grid-column: 2 / 4; justify-self: start; margin-top: 8px; }
.item div.buy { display: flex; align-items: center; }
.item p.buy { margin-top: 6px; color: var(--ink); font-size: .82rem; font-weight: 600; }
.item.locked { opacity: .55; }
.item.locked .emoji { filter: grayscale(1); }

/* Vouchers: tickets with a tear-off stub. */
.voucher {
  --stub: 58px;
  position: relative; margin-top: 12px; padding: 14px 16px 14px calc(var(--stub) + 16px); border-radius: var(--r-paper);
  background:
    repeating-linear-gradient(var(--rule) 0 5px, transparent 5px 10px) calc(var(--stub) - 1px) 0 / 2px 100% no-repeat,
    linear-gradient(color-mix(in srgb, var(--red) 9%, var(--sheet)) 0 0) 0 0 / var(--stub) 100% no-repeat,
    var(--sheet);
  -webkit-mask:
    radial-gradient(circle 8px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle 8px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle 8px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle 8px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.voucher .emoji { position: absolute; left: 0; width: var(--stub); top: 50%; transform: translateY(-50%); text-align: center; font-size: 1.6rem; }
.voucher h3 + p { margin-top: 2px; }
.voucher .linkish { margin-top: 6px; }
.voucher.used { opacity: .6; }
.voucher.used h3 { text-decoration: line-through; text-decoration-thickness: 2px; }

/* ---- dares ---- */
.challenge { margin-top: 12px; padding: 14px 16px; border-radius: var(--r-ui); background: var(--sheet); box-shadow: var(--shadow); }
.challenge .text { font: 400 1.3rem/1.3 var(--hand); }
.challenge .actions { margin-top: 10px; }
.challenge.done { background: color-mix(in srgb, var(--good) 9%, var(--sheet)); }
.challenge img { margin-top: 10px; border-radius: 8px; width: 100%; max-height: 50dvh; object-fit: cover; }
.picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.picker button { border: 0; padding: 0; aspect-ratio: 1; background: #ccc center/cover; border-radius: 6px; cursor: pointer; }
.picker button[aria-pressed=true] { outline: 4px solid var(--red-text); outline-offset: -4px; }
form.panel > .actions { margin-top: 12px; }

/* ---- practice ---- */
.modes { display: grid; gap: 12px; margin-top: 20px; }
.mode { display: block; padding: 18px; border-radius: var(--r-ui); background: var(--sheet); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.mode h2 + p { margin-top: 4px; }

/* ---- Jordan's write pages ---- */
.status { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 16px; font-size: .82rem; line-height: 1.3; color: var(--ink-soft); }
.status div { padding: 8px 12px 9px; border-radius: 10px; background: var(--sheet); }
.status b { display: block; font-size: 1.15rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.status .warn { background: color-mix(in srgb, var(--red) 12%, var(--sheet)); }
.status .warn b { color: var(--red-text); }
.sec-intro { margin-bottom: 10px; }

/* Collapsible rows: days, shop items and the open-when / shop sections. */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary:focus-visible { border-radius: var(--r-ui); outline-offset: -3px; }
details.day-edit, details.shop-edit { margin-top: 8px; border-radius: 12px; background: var(--sheet); box-shadow: var(--shadow); }
details.day-edit > summary, details.shop-edit > summary { padding: 11px 14px; display: flex; gap: 12px; align-items: center; }
details.day-edit > summary .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--ink); font-weight: 800; font-size: .9rem;
}
details.day-edit[open] > summary .n { background: var(--ink); color: var(--paper); }
summary .what { display: grid; min-width: 0; line-height: 1.3; }
summary .what .small { line-height: 1.3; }
details.day-edit > summary .flag { margin-left: auto; font-size: .78rem; font-weight: 600; color: var(--red-text); white-space: nowrap; }
details.day-edit > summary .flag.ok { color: var(--good); }
details.day-edit .edit-body, details.shop-edit .edit-body { padding: 4px 14px 16px; border-top: 1px solid var(--rule); }
details.day-edit .edit-body { padding-top: 14px; }
details.shop-edit > summary .emoji { flex: none; width: 28px; font-size: 1.4rem; text-align: center; }
details.shop-edit > summary > .small { margin-left: auto; white-space: nowrap; font-weight: 600; }

.write-sec { margin-top: 36px; }
.write-sec > summary { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; }
.write-sec > summary h2 { flex: none; }
.write-sec > summary::after {
  content: ""; align-self: center; margin-left: auto; width: 9px; height: 9px; flex: none;
  border: solid var(--ink-soft); border-width: 0 2px 2px 0; transform: translateY(-3px) rotate(45deg); transition: transform .2s;
}
.write-sec[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.write-sec .sec-body { padding-top: 8px; }

.shop-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.shop-fields .f-emoji { grid-column: 1; }
.shop-fields .f-title { grid-column: 2 / 4; }
.shop-fields .f-desc { grid-column: 1 / -1; }
.shop-fields input { padding: 9px 12px; }
.note-edit { padding: 14px; }
.note-edit .actions { margin-top: 10px; }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; min-width: 0; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.thumb .meta { font-size: .72rem; color: var(--ink-soft); line-height: 1.25; margin-top: 3px; }
.thumb .acts { display: flex; gap: 4px; margin-top: 4px; }
.thumb .acts button { flex: 1; min-height: 32px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper); font-size: .75rem; cursor: pointer; }
.prompt { margin: 14px 0 10px; padding: 10px 12px; border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; background: var(--paper); font-size: .9rem; }
.pool { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; }
.pool button { position: relative; border: 0; padding: 0; aspect-ratio: 1; background: #ccc center/cover; cursor: pointer; border-radius: 4px; }
.pool button.vetoed::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff; background: rgba(200, 16, 46, .62); border-radius: 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.edit-list > * + * { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---- Sealed: the private drawer ----
   The same airmail world after hours: the paper goes to deep ink, the envelope's red becomes
   oxblood sealing wax, and brass stands in for the stamp gold. Tokens are swapped on <body>
   so every shared component (buttons, sheets, inputs, tabs) follows without its own rules. */
body.after-dark {
  --paper: #0D1424;
  --sheet: #162036;
  --ink: #EDE6D8;
  --ink-soft: #A79F91;
  --rule: #2B3654;
  --red: #7A1023;
  --red-text: #E58A97;
  --gold: #C9A35B;
  --blue: #D9C39A;
  --tint: rgba(237, 230, 216, .06);
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 30px -16px rgba(0, 0, 0, .9);
  color-scheme: dark;
}
body.after-dark #tabs { background: #111A2D; border-top-color: #222C46; }

.wax {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #A0243A, #6A0D1E 62%, #4E0915);
  color: #F3D9B1; font: 400 1.4rem/1 var(--hand);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3), 0 0 0 4px rgba(122, 16, 35, .25);
}

.btn.gold { background: var(--gold); color: #1A1406; }

.sealed-head { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; }
.sealed-head .wax { grid-row: span 2; width: 52px; height: 52px; font-size: 1.6rem; }
.sealed-head h1 { font-size: 2rem; }
.sealed-head .where { color: var(--ink-soft); margin: 0; }

.sealed-gate { min-height: 70dvh; display: grid; align-content: center; gap: 22px; }
.sealed-gate > p { color: var(--ink-soft); }

.sealed-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.sealed-compose {
  margin-top: 22px; padding: 16px; border-radius: var(--r-ui); background: var(--sheet);
  border: 1px solid var(--rule); display: grid; gap: 12px;
}
.sealed-compose .row { flex-wrap: wrap; }
.sealed-compose .row > .linkish { flex: none; color: var(--gold); }
.sealed-compose .idea { font: 400 1.25rem/1.3 var(--hand); color: var(--gold); }
.sealed-compose progress { width: 100%; accent-color: var(--gold); }
.once { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--ink-soft); cursor: pointer; }
.once input { margin-top: 3px; accent-color: var(--gold); width: 18px; height: 18px; }

.sealed-grid { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sealed-tile {
  position: relative; display: grid; gap: 4px; justify-items: start; align-content: start;
  min-height: 138px; padding: 16px 14px 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--rule); border-radius: var(--r-paper); background: var(--sheet); color: var(--ink);
}
/* the flap, drawn as a fold line */
.sealed-tile::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 46px;
  background: linear-gradient(to bottom right, transparent calc(50% - 1px), var(--rule) 50%, transparent calc(50% + 1px)) left / 50% 100% no-repeat,
              linear-gradient(to bottom left, transparent calc(50% - 1px), var(--rule) 50%, transparent calc(50% + 1px)) right / 50% 100% no-repeat;
}
.sealed-tile .wax { position: relative; width: 34px; height: 34px; font-size: 1rem; margin: 22px 0 6px; }
.sealed-tile.mine .wax { filter: saturate(.3) brightness(.8); }
.sealed-tile.fresh { border-color: var(--gold); }
.sealed-tile.fresh .wax { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3), 0 0 0 4px rgba(201, 163, 91, .35); }
.sealed-tile .what { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.sealed-tile .once-tag { font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(201, 163, 91, .18); color: var(--gold); }
.sealed-tile .from { font-size: .8rem; color: var(--ink-soft); }
.sealed-tile .cap { font: 400 1.05rem/1.25 var(--hand); color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sealed-tile .react { position: absolute; top: 10px; right: 10px; font-size: 1.2rem; }
.sealed-empty { margin-top: 28px; text-align: center; font: 400 1.25rem var(--hand); }

.sealed-view img, .sealed-view video {
  display: block; width: 100%; max-height: 70dvh; object-fit: contain; border-radius: var(--r-paper);
  background: #000; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.sealed-caption { margin-top: 12px; font: 400 1.35rem/1.35 var(--hand); }
.reactions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.react-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--rule); background: var(--sheet);
  font-size: 1.35rem; cursor: pointer;
}
.react-btn.on { border-color: var(--gold); background: rgba(201, 163, 91, .18); }

/* The way in, at the foot of each day: quiet unless something's waiting. */
.sealed-link {
  position: relative; margin-top: 36px; display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: var(--r-ui); text-decoration: none; color: var(--ink);
  border: 1px dashed var(--rule);
}
.sealed-link .wax { width: 36px; height: 36px; font-size: 1.1rem; }
.sealed-link > span:nth-child(2) { display: grid; }
.sealed-link .dot { position: absolute; top: 12px; right: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* ---- What came next? (old Messenger chats) ---- */
.chat-when { font-size: .85rem; color: var(--ink-soft); text-align: center; margin-bottom: 10px; }
.chat { display: flex; flex-direction: column; gap: 6px; }
.bubble {
  max-width: 82%; align-self: flex-start; padding: 8px 13px; border-radius: 18px 18px 18px 6px;
  background: var(--tint); color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; font-size: .98rem;
}
.bubble.mine { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--blue); color: #fff; }
.bubble.punch { outline: 2px solid var(--gold); outline-offset: 2px; }
.bubble.said { animation: rise .4s ease both; }
.chat-ask { margin: 18px 0 10px; }
.chat-options { display: grid; gap: 8px; }
.chat-option {
  text-align: left; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--rule); background: var(--sheet);
  color: var(--ink); font: inherit; cursor: pointer; overflow-wrap: anywhere;
}
.chat-option:disabled { cursor: default; }
.chat-option.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--sheet)); }
.chat-option.wrong { border-color: var(--red-text); opacity: .8; }
.chat-decoys { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; color: var(--ink-soft); }
.chat-decoys .is-answer { color: var(--ink); font-weight: 600; }
.review-actions { margin-top: 16px; }
.chat-divider {
  display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; font-size: .8rem; color: var(--ink-soft);
}
.chat-divider::before, .chat-divider::after { content: ""; flex: 1; border-top: 1px dashed var(--rule); }

/* ---- Us: the board ---- */
.sec-intro { margin: 4px 0 12px; }
h3.sub { margin: 22px 0 6px; font-size: 1rem; color: var(--ink-soft); }
#board .sealed-link, .sealed-link:first-child { margin-top: 0; }
.board-compose { display: grid; gap: 4px; }
.board-compose .actions { margin-top: 6px; }
.wall { display: grid; gap: 12px; margin-top: 18px; }
/* Each post is a small card pinned to the wall, in the hand of whoever wrote it. */
.thought {
  padding: 14px 16px 10px; border-radius: var(--r-paper); background: var(--sheet); box-shadow: var(--shadow);
  border-left: 4px solid var(--blue);
}
.thought.mine { border-left-color: var(--red); }
.thought .body { font: 400 1.3rem/1.35 var(--hand); white-space: pre-wrap; overflow-wrap: anywhere; }
.thought .meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: .8rem; color: var(--ink-soft); flex-wrap: wrap; }
.thought .meta .grow { flex: 1; }
.thought .chips { display: inline-flex; gap: 2px; font-size: 1rem; }
.small-reacts { margin-top: 10px; }
.small-reacts .react-btn { width: 38px; height: 38px; font-size: 1.1rem; }
.empty { margin-top: 16px; text-align: center; font: 400 1.2rem var(--hand); }
