:root {
  --red: #b3202a;        /* fills (buttons, gift) */
  --red-dark: #8c1820;
  --red-ink: #b3202a;    /* red text */
  --green: #1d6b46;
  --green-ink: #1d6b46;
  --online: #22a565;
  --gold: #d9a441;
  --gold-ink: #8a5e0a;
  --bg: #fbf6ef;
  --bg-glow: #f8e1d3;
  --card: #ffffff;
  --soft: #f6efe7;       /* quiet fills: list rows, tiles */
  --text: #2a2220;
  --muted: #6f625c;
  --border: #eadfd5;
  --input: #fff;
  --shadow: 0 1px 2px rgb(74 30 20 / .06), 0 12px 32px -16px rgb(74 30 20 / .28);
  --snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='%23b3202a' fill-opacity='.07'%3E%3Ccircle cx='12' cy='18' r='2'/%3E%3Ccircle cx='70' cy='8' r='1.4'/%3E%3Ccircle cx='128' cy='30' r='2.4'/%3E%3Ccircle cx='40' cy='62' r='1.6'/%3E%3Ccircle cx='100' cy='80' r='2'/%3E%3Ccircle cx='150' cy='104' r='1.4'/%3E%3Ccircle cx='20' cy='118' r='2.4'/%3E%3Ccircle cx='76' cy='140' r='1.6'/%3E%3Ccircle cx='132' cy='152' r='2'/%3E%3C/svg%3E");
  --radius: 20px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --red: #c8303a;
    --red-dark: #9e1f28;
    --red-ink: #f27b82;
    --green: #22744c;
    --green-ink: #63c796;
    --online: #3ccf86;
    --gold: #e2b456;
    --gold-ink: #ecc56f;
    --bg: #14100e;
    --bg-glow: #2b1412;
    --card: #1f1815;
    --soft: #2a211c;
    --text: #f5ece4;
    --muted: #a99a90;
    --border: #382c26;
    --input: #181210;
    --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 14px 32px -16px rgb(0 0 0 / .7);
    --snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='%23fff' fill-opacity='.06'%3E%3Ccircle cx='12' cy='18' r='2'/%3E%3Ccircle cx='70' cy='8' r='1.4'/%3E%3Ccircle cx='128' cy='30' r='2.4'/%3E%3Ccircle cx='40' cy='62' r='1.6'/%3E%3Ccircle cx='100' cy='80' r='2'/%3E%3Ccircle cx='150' cy='104' r='1.4'/%3E%3Ccircle cx='20' cy='118' r='2.4'/%3E%3Ccircle cx='76' cy='140' r='1.6'/%3E%3Ccircle cx='132' cy='152' r='2'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(120% 420px at 50% -60px, var(--bg-glow), transparent 75%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
/* Falling snow: two fixed layers behind the content, one tile taller than the screen so that moving
   down exactly one tile loops seamlessly. The far layer has smaller, fainter, slower flakes. */
body::before, body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; z-index: 0; pointer-events: none;
  top: calc(-1 * var(--tile));
  background: var(--snow) 0 0 / var(--tile) var(--tile);
}
body::before { --tile: 160px; }
body::after { --tile: 104px; opacity: .7; background-position: 37px 51px; }
main {
  position: relative; z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}
h1, h2 { font-family: var(--serif); font-optical-sizing: auto; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; font-weight: 650; line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
[hidden] { display: none !important; }

/* ---------- Music toggle ---------- */
.music-toggle {
  position: absolute; z-index: 2;
  top: max(10px, env(safe-area-inset-top)); right: 12px;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--red-ink);
}
.music-toggle.off { color: var(--muted); }
.music-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.music-toggle .spk { fill: currentColor; }
.music-toggle .cross, .music-toggle.off .waves { display: none; }
.music-toggle.off .cross { display: inline; }
@media (hover: hover) { .music-toggle:hover { background: var(--card); } }
/* On narrow phones a centred compact title runs into the button, so start it from the left. */
@media (max-width: 359px) {
  body:not([data-screen="home"]) .brand { justify-content: flex-start; padding-left: 4px; }
}

/* ---------- Header ---------- */
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 0 18px; }
.brand h1 { font-size: 1.65rem; font-weight: 700; margin: 0; }
.mark {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--gold), 0 6px 14px -8px rgb(74 30 20 / .6);
}

body[data-screen="home"] .brand { flex-direction: column; gap: 4px; padding: 28px 0 6px; }
body[data-screen="home"] .brand h1 { font-size: 2.7rem; }
body[data-screen="home"] .mark {
  width: 124px; height: 124px; margin-bottom: 10px;
  box-shadow: 0 0 0 3px var(--gold), 0 16px 32px -14px rgb(74 30 20 / .6);
}

/* ---------- Layout ---------- */
.screen { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.spread { justify-content: space-between; }
.center { text-align: center; align-items: center; }
.center-text { text-align: center; }

/* ---------- Text ---------- */
.lead { text-align: center; color: var(--muted); font-size: 1.05rem; margin-bottom: 6px; }
.label { font-family: inherit; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.hint { font-size: .9rem; color: var(--muted); }
.msg { color: var(--red-ink); text-align: center; font-size: .95rem; font-weight: 500; }
.msg:empty, .conn-status:empty, .callout:empty { display: none; }
.mono { font-family: var(--mono); letter-spacing: .08em; }
.big { font-size: 3.6rem; line-height: 1; }
.callout {
  font-size: .93rem; text-align: center;
  padding: 12px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 13%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
}

/* ---------- Room code ---------- */
.code { display: flex; justify-content: center; gap: 6px; }
.code span {
  flex: 0 1 46px; min-width: 0; height: 58px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: clamp(1.35rem, 6.5vw, 1.8rem); font-weight: 700;
  color: var(--red-ink);
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / .05);
}

/* ---------- QR ---------- */
.qr-wrap { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr {
  padding: 12px; line-height: 0;
  background: #fff; border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px -10px rgb(74 30 20 / .35);
}
.qr-wrap figcaption { font-size: .85rem; color: var(--muted); }

/* ---------- Inputs ---------- */
input {
  font: inherit; font-size: 16px; /* prevents iOS zoom */
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--input); color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 26%, transparent); }
#input-code { text-align: center; text-transform: uppercase; letter-spacing: .28em; font-family: var(--mono); font-weight: 600; }
#input-code::placeholder { text-transform: none; letter-spacing: normal; font-family: system-ui, sans-serif; font-weight: 400; }
#join-link { background: var(--soft); color: var(--muted); }

/* ---------- Buttons ---------- */
button {
  font: inherit; font-weight: 600;
  border: 0; border-radius: 14px;
  padding: 14px 18px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, background-color .15s, box-shadow .15s, filter .15s;
}
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:not(:disabled):active { transform: translateY(1px) scale(.99); }
button.primary {
  background: linear-gradient(180deg, var(--red), var(--red-dark));
  color: #fff; font-size: 1.05rem; padding: 16px 18px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 10px 20px -10px color-mix(in srgb, var(--red) 80%, transparent);
}
button.primary:disabled { box-shadow: none; }
button.secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
button.small { padding: 13px 16px; border-radius: 12px; background: var(--green); color: #fff; white-space: nowrap; }
button.link, a.link {
  background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  font-weight: 500; padding: 8px 12px; align-self: center; font-size: .95rem; border-radius: 8px;
}
@media (hover: hover) {
  button.primary:not(:disabled):hover { filter: brightness(1.08); }
  button.secondary:not(:disabled):hover { background: var(--soft); }
  button.small:not(:disabled):hover { filter: brightness(1.1); }
  button.link.danger:hover { color: var(--red-ink); }
  a.link:hover { color: var(--text); }
}

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- How it works ---------- */
.how { padding: 6px 4px 0; display: flex; flex-direction: column; gap: 12px; }
.how ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: how; }
.how li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: .95rem; counter-increment: how; }
.how li::before {
  content: counter(how); flex: none;
  width: 28px; height: 28px; margin-top: -3px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; color: var(--red-ink);
  background: color-mix(in srgb, var(--red) 11%, transparent);
}
.how strong { color: var(--text); font-weight: 600; }

/* ---------- Host progress ---------- */
.steps { list-style: none; margin: 0; padding: 0 2px; display: flex; align-items: center; gap: 8px; counter-reset: step; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); white-space: nowrap; counter-increment: step; }
.steps li:last-child { flex: none; }
.steps li::before {
  content: counter(step); flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .78rem;
  background: var(--card); border: 1.5px solid var(--border);
}
.steps li:not(:last-child)::after { content: ""; flex: 1; min-width: 8px; height: 2px; border-radius: 2px; background: var(--border); }
.steps li.current { color: var(--text); }
.steps li.current::before { background: var(--red); border-color: var(--red); color: #fff; }
.steps li.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: #fff; }
.steps li.done::after { background: var(--green); }

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
  background: var(--soft); color: var(--muted);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: color-mix(in srgb, var(--green) 14%, var(--card)); color: var(--green-ink); }
.pill.warn { background: color-mix(in srgb, var(--gold) 20%, var(--card)); color: var(--gold-ink); }

/* ---------- Players ---------- */
.count {
  display: inline-grid; place-items: center; vertical-align: 3px;
  min-width: 26px; height: 26px; padding: 0 8px; margin-left: 4px;
  border-radius: 99px; background: var(--soft); color: var(--muted);
  font-family: system-ui, sans-serif; font-size: .82rem; font-weight: 700;
}
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 8px 7px 7px; border-radius: 14px;
  background: var(--soft);
}
.players li.empty {
  justify-content: center; padding: 18px; text-align: center;
  color: var(--muted); background: none; border: 1.5px dashed var(--border);
}
.players .name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; font-weight: 500; }
.players .name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .note { flex: none; font-size: .75rem; font-weight: 600; color: var(--muted); }
.avatar {
  position: relative; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: .95rem; color: #fff;
  background: var(--av, var(--red));
}
.avatar::after {
  content: ""; position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--border); border: 2.5px solid var(--soft);
}
.avatar.on::after { background: var(--online); }
.avatar.local::after, .avatar.editable::after { display: none; }
.avatar.has-photo { background: var(--soft); }
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
button.avatar { padding: 0; border: 0; border-radius: 50%; font: inherit; font-weight: 700; font-size: .95rem; color: #fff; }
.avatar .cam {
  position: absolute; right: -6px; bottom: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: .78rem; line-height: 1;
  box-shadow: 0 2px 6px -2px rgb(0 0 0 / .35);
  background: var(--card); border: 1.5px solid var(--border);
}
@media (hover: hover) { button.avatar:hover { filter: brightness(1.08); } }
.av-0 { --av: #b3202a; } .av-1 { --av: #1d6b46; } .av-2 { --av: #8a5a0c; }
.av-3 { --av: #6a3d9a; } .av-4 { --av: #1d6a86; } .av-5 { --av: #9c3f1f; }
.tag {
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  padding: 3px 9px; border-radius: 99px;
  color: var(--muted); background: var(--card);
}
.tag.ok { color: var(--green-ink); background: color-mix(in srgb, var(--green) 14%, var(--card)); }
.remove {
  flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: none; color: var(--muted); font-size: 1.35rem; line-height: 1; font-weight: 400;
}
@media (hover: hover) {
  .remove:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red-ink); }
}

/* ---------- Secret pairings ---------- */
.card.secret { display: block; padding: 0; }
.secret summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-radius: var(--radius);
  font-weight: 600; cursor: pointer; list-style: none;
}
.secret summary::-webkit-details-marker { display: none; }
.secret summary::after { content: "›"; font-size: 1.4rem; line-height: 1; color: var(--muted); transform: rotate(90deg); transition: transform .2s ease; }
.secret[open] summary::after { transform: rotate(-90deg); }
.secret summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.secret-body { display: flex; flex-direction: column; gap: 12px; padding: 0 20px 20px; }
.pair-form { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.pair-form button { grid-column: 1 / -1; }
.pair-arrow { color: var(--muted); font-weight: 700; }
.pair-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pair-list:empty { display: none; }
.pair-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--soft); }
.pair-list .pair-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pair-list .remove { margin-left: auto; }
select {
  font: inherit; font-size: 16px; /* prevents iOS zoom */
  width: 100%; min-width: 0; padding: 12px 32px 12px 12px;
  border: 1.5px solid var(--border); border-radius: 12px; color: var(--text);
  -webkit-appearance: none; appearance: none;
  background: var(--input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a7d76' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 12px 8px;
  text-overflow: ellipsis;
}
select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 26%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Photos ---------- */
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-btn {
  flex: none; width: 72px; height: 72px; padding: 0; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 1.7rem;
  background: var(--soft); border: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}
.photo-btn.has-photo { border: 3px solid var(--gold); }
.photo-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.photo-copy .hint { font-size: .85rem; }
button.link.small-link { padding: 2px 0; font-size: .85rem; align-self: flex-start; }
.photo-actions { justify-content: center; gap: 12px; }
.photo-actions button.link.small-link { align-self: center; }
button.secondary.slim { padding: 10px 18px; font-size: .95rem; }
.wait-avatar { line-height: 1; }
.wait-avatar img {
  width: 108px; height: 108px; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid var(--gold); box-shadow: var(--shadow);
}
.reveal-photo {
  width: 116px; height: 116px; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid var(--gold); background: var(--soft);
  box-shadow: 0 10px 22px -12px rgb(0 0 0 / .55);
}
.reveal.compact .reveal-photo { width: 60px; height: 60px; border-width: 2px; }

/* ---------- Waiting-room quiz ---------- */
.quiz h2 { font-size: 1.2rem; }
.quiz-body { display: flex; flex-direction: column; gap: 12px; }
.quiz-bar { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.quiz-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .3s ease; }
.quiz-q { font-size: 1.05rem; font-weight: 600; outline: none; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt {
  text-align: left; padding: 12px 14px; border-radius: 12px; font-weight: 500;
  background: var(--soft); color: var(--text); border: 1.5px solid var(--border);
}
@media (hover: hover) { .quiz-opt:not(:disabled):hover { border-color: var(--gold); } }
.quiz-opt:disabled { cursor: default; opacity: .55; }
.quiz-opt.right, .quiz-opt.wrong { opacity: 1; font-weight: 700; }
.quiz-opt.right { background: color-mix(in srgb, var(--green) 15%, var(--card)); border-color: var(--green); color: var(--green-ink); }
.quiz-opt.wrong { background: color-mix(in srgb, var(--red) 11%, var(--card)); border-color: var(--red); color: var(--red-ink); }
.quiz-opt.right::after { content: "  ✓"; }
.quiz-opt.wrong::after { content: "  ✗"; }
.quiz-feedback { font-size: .93rem; }
.quiz-feedback:empty { display: none; }
.quiz-score { position: relative; text-align: center; font-family: var(--serif); font-size: 2.8rem; font-weight: 700; line-height: 1.1; outline: none; }
.quiz-rating { text-align: center; font-weight: 600; font-size: 1.05rem; }
.quiz-best { text-align: center; font-size: .9rem; color: var(--muted); }

/* ---------- Players without a phone ---------- */
.add-local summary {
  display: flex; align-items: center; gap: 10px; width: fit-content;
  padding: 4px 6px 4px 2px; border-radius: 8px;
  font-weight: 600; color: var(--red-ink); cursor: pointer; list-style: none;
}
.add-local summary::-webkit-details-marker { display: none; }
.add-local summary::before {
  content: "+"; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.1rem; line-height: 1;
  background: color-mix(in srgb, var(--red) 11%, transparent);
  transition: transform .2s ease;
}
.add-local[open] summary { margin-bottom: 10px; }
.add-local[open] summary::before { transform: rotate(45deg); }
.add-local summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.local-reveals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.local-reveals li { display: flex; flex-direction: column; gap: 8px; }
.local-reveals .who { font-weight: 600; }
.reveal.compact { min-height: 96px; padding: 16px; border-radius: 14px; }
.reveal.compact .reveal-cover { padding: 8px 14px; font-size: .95rem; }
.reveal.compact .reveal-name { gap: 4px; }
.reveal.compact .reveal-name strong { font-size: 1.7rem; }
.reveal.compact .reveal-name strong.long { font-size: min(1.4rem, 6.5vw); }
.reveal.compact .reveal-name strong.xlong { font-size: min(1.15rem, 5vw); }
.reveal.compact.shown { outline-offset: -7px; }
.reveal.compact.shown::before { top: 12px; left: 14px; font-size: 1rem; }
.reveal.compact.shown::after { top: 13px; right: 16px; font-size: .75rem; }

/* ---------- Gift reveal ---------- */
.reveal-box { align-self: stretch; }
.reveal {
  position: relative; width: 100%; min-height: 184px; padding: 24px 20px;
  display: grid; place-items: center;
  border-radius: 18px; color: var(--text);
  background:
    linear-gradient(90deg, transparent calc(50% - 13px), var(--gold) 0 calc(50% + 13px), transparent 0),
    linear-gradient(0deg, transparent calc(50% - 13px), var(--gold) 0 calc(50% + 13px), transparent 0),
    radial-gradient(circle, rgb(255 255 255 / .16) 2px, transparent 2.5px) 0 0 / 22px 22px,
    radial-gradient(circle, rgb(255 255 255 / .16) 2px, transparent 2.5px) 11px 11px / 22px 22px,
    linear-gradient(160deg, var(--red), var(--red-dark));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1), 0 16px 30px -16px color-mix(in srgb, var(--red) 80%, transparent);
}
.reveal-cover {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 12px;
  background: var(--card); color: var(--text);
  font-size: 1rem; font-weight: 700;
  box-shadow: 0 8px 18px -8px rgb(0 0 0 / .45);
  transition: transform .15s ease;
}
@media (hover: hover) { .reveal:hover .reveal-cover { transform: translateY(-2px); } }

.reveal.shown {
  background: color-mix(in srgb, var(--gold) 9%, var(--card));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gold) 65%, transparent);
  outline: 1.5px dashed color-mix(in srgb, var(--gold) 70%, transparent);
  outline-offset: -10px;
}
.reveal-name { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.reveal-name strong {
  font-family: var(--serif); font-weight: 700; font-size: 2.4rem; line-height: 1.1;
  overflow-wrap: anywhere; text-wrap: balance;
}
.reveal-name strong.long { font-size: min(1.85rem, 8vw); }
.reveal-name strong.xlong { font-size: min(1.45rem, 6vw); }
.reveal-name small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.reveal-secret {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 5px 14px 5px 5px; border-radius: 99px;
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  color: var(--red-ink); font-size: .92rem; font-weight: 700;
}
.reveal-secret img { width: 32px; height: 32px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--gold); }
.reveal.compact .reveal-secret { margin-top: 2px; padding: 3px 11px 3px 3px; gap: 6px; font-size: .8rem; }
.reveal.compact .reveal-secret img { width: 24px; height: 24px; }
.reveal.shown::before, .reveal.shown::after {
  content: "✦"; position: absolute; color: var(--gold); line-height: 1;
}
.reveal.shown::before { top: 20px; left: 22px; font-size: 1.2rem; }
.reveal.shown::after { top: 22px; right: 24px; font-size: .9rem; } /* top corner: the bottom holds the secret pill */

.confetti {
  position: absolute; left: 50%; top: 50%;
  width: 8px; height: 12px; border-radius: 2px;
  background: var(--c); pointer-events: none;
  opacity: 0;
}

/* ---------- Draw scene (only created when motion is allowed) ---------- */
.draw-scene {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 24px; overflow: hidden; text-align: center; cursor: pointer;
  color: #fff8ef;
  background:
    radial-gradient(55% 40% at 50% 42%, rgb(255 214 120 / .16), transparent 70%),
    radial-gradient(130% 95% at 50% 40%, #0f4a32, #062218 68%, #020d08);
  animation: ds-in .25s ease both;
  -webkit-tap-highlight-color: transparent;
}
.draw-scene.out { animation: ds-out .3s ease forwards; }
/* Two layers of falling snow at different speeds. */
.draw-scene::before, .draw-scene::after {
  content: ""; position: absolute; left: 0; right: 0; top: -60px; bottom: 0; pointer-events: none;
  background: radial-gradient(circle, rgb(255 255 255 / .55) 1.6px, transparent 2.2px) 0 0 / 60px 60px;
  animation: ds-snow 2.4s linear infinite;
}
.draw-scene::after {
  background: radial-gradient(circle, rgb(255 255 255 / .3) 1px, transparent 1.6px) 17px 23px / 30px 30px;
  top: -30px; animation-duration: 3.2s; --fall: 30px;
}
.ds-stage { position: relative; z-index: 1; width: 220px; height: 220px; display: grid; place-items: center; }
.ds-rays {
  position: absolute; inset: -110px; opacity: 0; transform: scale(.3);
  transition: opacity .4s ease, transform .7s cubic-bezier(.2, 1.4, .4, 1);
  -webkit-mask: radial-gradient(circle, #000 22%, transparent 66%);
  mask: radial-gradient(circle, #000 22%, transparent 66%);
}
.ds-rays::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(rgb(255 214 120 / .3) 0 9deg, transparent 9deg 18deg);
  animation: ds-spin 14s linear infinite;
}
.draw-scene .ds-gift {
  position: relative; z-index: 1; width: 150px; height: 150px; overflow: visible;
  transform-origin: 50% 90%;
  filter: drop-shadow(0 16px 22px rgb(0 0 0 / .5));
  animation: ds-gift-in .55s cubic-bezier(.2, 1.5, .4, 1) both;
}
.draw-scene .ds-gift .box { fill: #8c1820; }
.draw-scene .ds-gift .lid { fill: #c8303a; }
.draw-scene .ds-gift .ribbon, .draw-scene .ds-gift .spark { fill: #f0c25e; }
.draw-scene .ds-gift .knot { fill: #c8962e; }
.draw-scene .ds-gift .spark { transform-box: fill-box; transform-origin: center; animation: twinkle 1.1s ease-in-out infinite; }
.draw-scene .ds-gift .lid-group {
  transform-box: fill-box; transform-origin: 50% 100%;
  transition: transform .55s cubic-bezier(.2, 1.7, .4, 1);
}
.ds-chip {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  max-width: 150px; padding: 6px 13px; border-radius: 99px;
  background: #fff8ef; color: #2a2220;
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: .92rem; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 8px 16px -8px rgb(0 0 0 / .6);
  opacity: 0;
  animation: ds-fly 1s cubic-bezier(.55, 0, .7, .45) var(--d) both;
}
.ds-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ds-chip > img { flex: none; width: 26px; height: 26px; margin: -3px 0 -3px -8px; border-radius: 50%; object-fit: cover; }
.ds-caption {
  position: relative; z-index: 1; margin-top: 14px;
  font-family: var(--serif); font-weight: 700; font-size: 1.75rem; line-height: 1.15;
  text-shadow: 0 2px 14px rgb(0 0 0 / .45);
}
.ds-sub {
  position: relative; z-index: 1; color: rgb(255 248 239 / .85);
  opacity: 0; transform: translateY(8px); transition: opacity .4s .25s, transform .4s .25s;
}
.ds-skip {
  position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom));
  font-size: .8rem; color: rgb(255 248 239 / .55);
}
.ds-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 42%, rgb(255 240 200 / .85), transparent 55%);
}
.draw-scene .confetti { width: 10px; height: 16px; }
.draw-scene.shake .ds-gift { animation: ds-shake 1.25s ease-in both; }
.draw-scene.open .ds-gift { animation: ds-bounce .6s cubic-bezier(.2, 1.5, .4, 1) both; }
.draw-scene.open .ds-gift .lid-group { transform: translate(-4px, -26px) rotate(-16deg); }
.draw-scene.open .ds-rays { opacity: 1; transform: none; }
.draw-scene.open .ds-flash { animation: ds-flash .7s ease-out; }
.draw-scene.open .ds-caption { font-size: 2.7rem; color: #ffd27a; animation: pop .55s cubic-bezier(.2, 1.5, .4, 1) both; }
.draw-scene.open .ds-sub { opacity: 1; transform: none; }

@keyframes ds-in { from { opacity: 0; } }
@keyframes ds-out { to { opacity: 0; transform: scale(1.04); } }
@keyframes ds-snow { to { transform: translateY(var(--fall, 60px)); } }
@keyframes ds-spin { to { transform: rotate(1turn); } }
@keyframes ds-gift-in { from { opacity: 0; transform: scale(.4) translateY(30px); } }
@keyframes ds-fly {
  0% { opacity: 0; transform: translate(-50%, -50%) translate(var(--sx), var(--sy)) rotate(var(--rot)) scale(.6); }
  22% { opacity: 1; transform: translate(-50%, -50%) translate(var(--sx), var(--sy)) rotate(var(--rot)) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) translate(0, 14px) rotate(0) scale(.2); }
}
@keyframes ds-shake {
  0% { transform: none; }
  10% { transform: rotate(-3deg); }
  20% { transform: rotate(3deg); }
  30% { transform: rotate(-5deg) translateY(-2px); }
  40% { transform: rotate(5deg); }
  50% { transform: rotate(-7deg) translateY(-4px) scale(1.02); }
  60% { transform: rotate(7deg) scale(1.03); }
  70% { transform: rotate(-9deg) translateY(-6px) scale(1.05); }
  80% { transform: rotate(9deg) scale(1.07); }
  90% { transform: rotate(-6deg) translateY(-8px) scale(1.09); }
  100% { transform: scale(1.1); }
}
@keyframes ds-bounce { 0% { transform: scale(1.1); } 40% { transform: scale(.92); } 100% { transform: scale(1); } }
@keyframes ds-flash { 15% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  body::before, body::after { will-change: transform; animation: snowfall 9s linear infinite; }
  body::after { animation-duration: 13s; animation-delay: -4s; }
  .screen { animation: rise .35s ease both; }
  .music-toggle:not(.off) .waves { animation: music-waves 1.2s ease-in-out infinite; }
  .quiz-opt.right, .quiz-score { animation: pop .4s cubic-bezier(.2, 1.5, .4, 1) both; }
  body[data-screen="home"] .mark { animation: float 4.5s ease-in-out infinite; }
  .pill.ok::before { animation: pulse 2s ease-out infinite; }
  .sway { display: inline-block; transform-origin: 50% 100%; animation: sway 3.2s ease-in-out infinite; }
  .reveal:not(.shown) { animation: jiggle 4s ease-in-out 1.5s infinite; }
  .reveal-name strong, .reveal-photo { animation: pop .5s cubic-bezier(.2, 1.5, .4, 1) both; }
  .reveal-secret { animation: pop .5s .3s cubic-bezier(.2, 1.5, .4, 1) both; }
  .reveal.shown::before, .reveal.shown::after { animation: twinkle 1.8s ease-in-out infinite; }
  .reveal.shown::after { animation-delay: .9s; }
  .confetti { animation: burst 1.1s cubic-bezier(.15, .7, .35, 1) forwards; }
}
@keyframes snowfall {
  0% { transform: translate(0, 0); }
  25% { transform: translate(10px, calc(var(--tile) * .25)); }
  75% { transform: translate(-10px, calc(var(--tile) * .75)); }
  100% { transform: translate(0, var(--tile)); }
}
@keyframes music-waves { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes float { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes jiggle {
  0%, 84%, 100% { transform: none; }
  88% { transform: rotate(-1.5deg) scale(1.01); }
  92% { transform: rotate(1.5deg) scale(1.01); }
  96% { transform: rotate(-.5deg); }
}
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
@keyframes twinkle { 50% { opacity: .3; transform: scale(.7); } }
@keyframes burst {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)); }
}
