/* ==========================================================================
   ShuffleNames — one token system, two themes, every component, one big moment.
   Themes are driven by html[data-theme="festive"] / html[data-theme="neutral"].
   All contrast pairs below meet WCAG AA (most meet AAA); ratios noted inline.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Fonts — self-hosted (zero third-party requests is a product rule).
   Fraunces variable (wght 100-900 + optical size axis), latin subset,
   SIL Open Font License — see /assets/fonts/OFL.txt.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/assets/fonts/fraunces-latin-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.4375rem;
  --step-3: clamp(1.625rem, 1.3rem + 1.6vw, 2rem);
  --step-4: clamp(2rem, 1.5rem + 2.5vw, 2.75rem);
  --step-5: clamp(2.5rem, 1.8rem + 3.5vw, 3.6rem);

  /* Space */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;

  /* Radii */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Festive colors double as the :root fallback (reveal.html defaults festive). */
  --bg: #122019;
  --bg-wash: #16271e;
  --surface: #1b2d23;
  --surface-2: #243a2d;
  --ink: #f2e9d8;          /* on bg 13.98:1, on surface 12.05:1 */
  --ink-muted: #afc2ac;    /* on bg 8.93:1, on surface 7.70:1 */
  --accent: #e08f3c;       /* as text on bg 6.55:1 */
  --accent-hover: #eaa157; /* accent-ink on it: 8.37:1 */
  --accent-active: #ce7f30;/* accent-ink on it: 5.76:1 */
  --accent-ink: #241203;   /* on accent 7.02:1 */
  --focus: #f0c878;        /* vs bg 10.62:1 (needs 3:1) */
  --border: #33513f;       /* decorative */
  --border-input: #6b8a74; /* vs surface 3.81:1, vs surface-2 3.21:1 (UI component minimum 3:1) */
  --error: #f0b8b0;        /* on bg 9.78:1 */
  --gold: #f0c878;
  --card-face: #f2e9d8;
  --card-face-ink: #122019; /* 13.98:1 */
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --confetti-1: #f0c878;
  --confetti-2: #e08f3c;
  --confetti-3: #f2e9d8;
  --confetti-4: #7fae8e;
}

html[data-theme="festive"] {
  --bg: #122019;
  --bg-wash: #16271e;
  --surface: #1b2d23;
  --surface-2: #243a2d;
  --ink: #f2e9d8;
  --ink-muted: #afc2ac;
  --accent: #e08f3c;
  --accent-hover: #eaa157;
  --accent-active: #ce7f30;
  --accent-ink: #241203;
  --focus: #f0c878;
  --border: #33513f;
  --border-input: #6b8a74;
  --error: #f0b8b0;
  --gold: #f0c878;
  --card-face: #f2e9d8;
  --card-face-ink: #122019;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --confetti-1: #f0c878;
  --confetti-2: #e08f3c;
  --confetti-3: #f2e9d8;
  --confetti-4: #7fae8e;
}

html[data-theme="neutral"] {
  --bg: #f7f6f2;
  --bg-wash: #efeee8;
  --surface: #ffffff;
  --surface-2: #f2f1ec;
  --ink: #20242e;          /* on bg 14.35:1, on surface 15.52:1 */
  --ink-muted: #585f6e;    /* on bg 5.93:1, on surface 6.41:1 */
  --accent: #4338ca;       /* as text on surface 7.90:1 */
  --accent-hover: #3730a3; /* white on it 9.93:1 */
  --accent-active: #312b8f;
  --accent-ink: #ffffff;   /* on accent 7.90:1 */
  --focus: #4338ca;
  --border: #dcdad2;
  --border-input: #7b8598; /* vs white 3.72:1, vs surface-2 3.29:1 */
  --error: #9e2b47;        /* on bg 6.72:1, on white 7.27:1 */
  --gold: #f2b03d;
  --card-face: #ffffff;
  --card-face-ink: #20242e;
  --shadow: 0 10px 30px rgba(32, 36, 46, 0.12);
  --confetti-1: #e8618c;
  --confetti-2: #f2b03d;
  --confetti-3: #2fa36b;
  --confetti-4: #3d7bf5;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 var(--s-4);
  letter-spacing: 0.005em;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }

p {
  margin: 0 0 var(--s-4);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--accent-hover);
}

html[data-theme="neutral"] a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

[hidden] {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 66rem;
  margin-inline: auto;
  padding-inline: var(--s-4);
}

@media (min-width: 640px) {
  .container {
    padding-inline: var(--s-6);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

section {
  margin-block: var(--s-7);
}

/* --------------------------------------------------------------------------
   3. Buttons
   -------------------------------------------------------------------------- */

.btn,
.btn-ghost {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--r-m);
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease,
    transform 90ms ease;
}

.btn {
  padding: 0.7em 1.4em;
  color: var(--accent-ink);
  background-color: var(--accent);
  border: 2px solid transparent;
}

.btn:hover {
  background-color: var(--accent-hover);
  color: var(--accent-ink);
}

.btn:active {
  background-color: var(--accent-active);
  transform: translateY(1px);
}

.btn-ghost {
  padding: 0.45em 0.9em;
  color: var(--accent);
  background-color: transparent;
  border: 2px solid var(--border-input);
}

.btn-ghost:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
  background-color: var(--surface-2);
}

.btn-ghost:active {
  transform: translateY(1px);
}

/* Copy feedback — app.js adds .copied and swaps the label for ~1.5s */
.btn.copied,
.btn-ghost.copied {
  background-color: var(--surface-2);
  color: var(--ink);
  border-color: var(--border-input);
}

.btn-big {
  font-size: var(--step-1);
  padding: 0.8em 1.8em;
}

/* --------------------------------------------------------------------------
   4. Forms
   -------------------------------------------------------------------------- */

label {
  display: block;
  font-weight: 600;
  font-size: var(--step--1);
  margin-bottom: var(--s-1);
}

input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background-color: var(--surface);
  border: 2px solid var(--border-input);
  border-radius: var(--r-m);
  padding: 0.55em 0.75em;
  width: 100%;
}

html[data-theme="neutral"] input,
html[data-theme="neutral"] select,
html[data-theme="neutral"] textarea {
  background-color: var(--surface);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline-offset: 1px;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

textarea {
  min-height: 5.5em;
  resize: vertical;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.1em) 50%, calc(100% - 0.75em) 50%;
  background-size: 0.35em 0.35em;
  background-repeat: no-repeat;
  padding-right: 2.2em;
}

.field {
  margin-bottom: var(--s-4);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: end;
}

.field-row > .field {
  flex: 1 1 12rem;
  margin-bottom: 0;
}

.field-row > .btn,
.field-row > .btn-ghost {
  flex: 0 0 auto;
}

/* Add-name form: input + button side by side, stacking at narrow widths */
#name-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: end;
}

#name-form .field {
  flex: 1 1 14rem;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   5. Messages, cards, notes
   -------------------------------------------------------------------------- */

.error {
  color: var(--error);
  font-weight: 600;
  margin-block: var(--s-3);
}

.note {
  color: var(--ink-muted);
  font-size: var(--step--1);
  margin-block: var(--s-3);
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  padding: var(--s-5);
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .card {
    padding: var(--s-6);
  }
}

/* --------------------------------------------------------------------------
   6. Header / hero
   -------------------------------------------------------------------------- */

.site-header {
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.brand svg {
  width: 1.6em;
  height: 1.6em;
  flex: 0 0 auto;
}

.header-link {
  font-size: var(--step--1);
}

.hero {
  padding-block: var(--s-7) var(--s-6);
  background-color: var(--bg-wash);
  margin-block: 0;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  max-width: 22ch;
  margin-bottom: var(--s-4);
}

.hero .subhead {
  font-size: var(--step-1);
  color: var(--ink-muted);
  max-width: 54ch;
}

.hero .hero-cta {
  margin-top: var(--s-5);
}

/* --------------------------------------------------------------------------
   7. Tool: names, exclusions, results
   -------------------------------------------------------------------------- */

#name-list,
#exclusion-list,
#link-list {
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.name-item,
.exclusion-item,
.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: var(--s-2) var(--s-3);
}

.name-label {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.name-actions,
.link-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

.name-item.is-duplicate {
  border: 2px solid var(--error);
}

.name-item.is-duplicate .name-label::after {
  content: " — duplicate";
  color: var(--error);
  font-weight: 600;
  font-size: var(--step--1);
}

.name-edit {
  flex: 1 1 8rem;
  width: auto;
}

.exclusion-item span {
  font-weight: 600;
}

.link-item {
  padding: var(--s-3);
}

.link-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-1);
  overflow-wrap: anywhere;
}

#results h2 {
  margin-bottom: var(--s-2);
}

#results > .card > p:first-of-type,
.results-caveat {
  color: var(--ink-muted);
}

#copy-all {
  margin-top: var(--s-5);
}

#draw-button {
  margin-top: var(--s-4);
}

.tool-block {
  margin-block: var(--s-6);
}

.tool-block:first-of-type {
  margin-top: 0;
}

/* --------------------------------------------------------------------------
   8. How it works / steps
   -------------------------------------------------------------------------- */

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-4);
}

@media (min-width: 720px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.steps li {
  counter-increment: step;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  padding: var(--s-5);
}

.steps li::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1em;
  height: 2.1em;
  border-radius: 50%;
  background-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: var(--s-3);
}

.steps h3 {
  margin-bottom: var(--s-2);
}

.steps p {
  margin: 0;
  color: var(--ink-muted);
}

/* Tiny confetti-dot ornament (used sparingly; decorative only) */
.dot-row {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}

.dot-row i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-row i:nth-child(1) { background-color: var(--confetti-1); }
.dot-row i:nth-child(2) { background-color: var(--confetti-2); }
.dot-row i:nth-child(3) { background-color: var(--confetti-3); }
.dot-row i:nth-child(4) { background-color: var(--confetti-4); }

/* --------------------------------------------------------------------------
   9. FAQ
   -------------------------------------------------------------------------- */

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  background-color: var(--surface);
  margin-bottom: var(--s-3);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--step-1);
  font-family: var(--font-display);
  padding: var(--s-4) var(--s-5);
  list-style-position: outside;
}

.faq-item summary:hover {
  color: var(--accent);
}

.faq-item[open] summary {
  border-bottom: 1px solid var(--border);
}

.faq-item .faq-answer {
  padding: var(--s-4) var(--s-5);
}

.faq-item .faq-answer p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: var(--s-8);
  padding-block: var(--s-6);
  border-top: 1px solid var(--border);
  background-color: var(--bg-wash);
  color: var(--ink-muted);
  font-size: var(--step--1);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4) var(--s-6);
  align-items: center;
  justify-content: space-between;
}

.site-footer nav {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--ink-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   11. Reveal page — layout
   -------------------------------------------------------------------------- */

#reveal-root {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-6) var(--s-4);
  gap: var(--s-5);
}

#reveal-greeting {
  color: var(--ink-muted);
  font-size: var(--step-1);
  margin: 0;
}

#reveal-button {
  font-size: var(--step-1);
  padding: 0.85em 2em;
}

#reveal-error {
  max-width: 34ch;
}

#reveal-result {
  background-color: var(--card-face);
  color: var(--card-face-ink);
  border-radius: var(--r-l);
  padding: var(--s-6) var(--s-6) var(--s-5);
  box-shadow: var(--shadow);
  max-width: min(26rem, 92vw);
  width: 100%;
}

.reveal-kicker {
  font-size: var(--step-0);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: var(--s-2);
}

#receiver-name {
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 700;
  line-height: 1.1;
  /* Neutralize the global h1 letter-spacing now that this is a heading;
     margin and font-size are already pinned here. */
  letter-spacing: normal;
  margin: 0 0 var(--s-4);
  overflow-wrap: anywhere;
}

#receiver-name:focus {
  outline: none;
}

#reveal-details {
  margin: 0;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-1) var(--s-4);
  border-top: 1px solid rgba(0, 0, 0, 0.14);
  padding-top: var(--s-4);
  font-size: var(--step--1);
}

#reveal-details:empty {
  display: none;
}

#reveal-details dt {
  font-weight: 700;
}

#reveal-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   12. Reveal stage — the hat, drawn in CSS
   -------------------------------------------------------------------------- */

#reveal-stage {
  position: relative;
  width: min(280px, 80vw);
  height: 240px;
  margin-inline: auto;
}

.stage-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.hat {
  position: relative;
  width: 200px;
  height: 150px;
  transform-origin: 50% 90%;
  z-index: 3; /* the hat (and its own stacking context) sits above the parked card */
  animation: hat-sway 3.4s ease-in-out infinite;
}

/* Crown */
.hat-crown {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: 118px;
  height: 112px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface) 70%);
  border: 2px solid var(--border-input);
  border-bottom: none;
  border-radius: 12px 12px 4px 4px;
  z-index: 3;
}

/* Band */
.hat-band {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  width: 118px;
  height: 22px;
  background-color: var(--gold);
  z-index: 4;
}

/* Brim */
.hat-brim {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 200px;
  height: 38px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface) 70%);
  border: 2px solid var(--border-input);
  border-radius: 50%;
  z-index: 5;
}

/* The drawn card: hidden inside the crown, rises on reveal.
   z-index 2 keeps it behind the crown until it clears the top edge. */
.draw-card {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%) translateY(0) rotate(0deg);
  width: 96px;
  height: 120px;
  background-color: var(--card-face);
  color: var(--card-face-ink);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.draw-card-face {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  opacity: 0.55;
}

/* Confetti pieces: parked at the hat mouth, invisible until the reveal. */
.confetti {
  position: absolute;
  left: 50%;
  top: 108px;
  width: 0;
  height: 0;
  z-index: 6;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  left: -5px;
  top: -7px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
}

.confetti span:nth-child(4n + 1) { background-color: var(--confetti-1); }
.confetti span:nth-child(4n + 2) { background-color: var(--confetti-2); }
.confetti span:nth-child(4n + 3) { background-color: var(--confetti-3); }
.confetti span:nth-child(4n + 4) { background-color: var(--confetti-4); }

/* Per-piece trajectories */
.confetti span:nth-child(1)  { --cx: -120px; --cy: -150px; --cr: 340deg;  --cd: 0.90s; }
.confetti span:nth-child(2)  { --cx: 95px;   --cy: -170px; --cr: -280deg; --cd: 0.94s; }
.confetti span:nth-child(3)  { --cx: -60px;  --cy: -195px; --cr: 420deg;  --cd: 0.98s; }
.confetti span:nth-child(4)  { --cx: 140px;  --cy: -120px; --cr: -360deg; --cd: 0.92s; }
.confetti span:nth-child(5)  { --cx: -155px; --cy: -95px;  --cr: 300deg;  --cd: 1.00s; }
.confetti span:nth-child(6)  { --cx: 30px;   --cy: -210px; --cr: -430deg; --cd: 0.96s; }
.confetti span:nth-child(7)  { --cx: 115px;  --cy: -185px; --cr: 380deg;  --cd: 1.04s; }
.confetti span:nth-child(8)  { --cx: -95px;  --cy: -175px; --cr: -310deg; --cd: 0.90s; }
.confetti span:nth-child(9)  { --cx: 165px;  --cy: -80px;  --cr: 450deg;  --cd: 1.02s; }
.confetti span:nth-child(10) { --cx: -35px;  --cy: -220px; --cr: -390deg; --cd: 0.98s; }
.confetti span:nth-child(11) { --cx: 70px;   --cy: -200px; --cr: 320deg;  --cd: 1.06s; }
.confetti span:nth-child(12) { --cx: -140px; --cy: -130px; --cr: -420deg; --cd: 0.94s; }

/* --------------------------------------------------------------------------
   13. Reveal choreography — everything moves ONLY under body.revealed
   Timeline: 0s settle → 0.35s the pull → 0.9s confetti → 1.15s result pops in
   -------------------------------------------------------------------------- */

body.revealed .hat {
  animation: hat-settle 0.6s var(--ease-out) both;
}

body.revealed .draw-card {
  animation: card-pull 0.9s 0.35s var(--ease-pop) both;
}

body.revealed .confetti span {
  animation: confetti-burst var(--cd) 0.9s cubic-bezier(0.15, 0.6, 0.35, 1) both;
}

body.revealed #reveal-result {
  animation: result-pop 0.55s 1.15s var(--ease-pop) both;
}

@keyframes hat-sway {
  0%, 100% { transform: rotate(-1.6deg); }
  50% { transform: rotate(1.6deg); }
}

@keyframes hat-settle {
  0% { transform: rotate(0deg) scale(1); }
  30% { transform: rotate(-3deg) scale(1.03, 0.97); }
  60% { transform: rotate(2deg) scale(0.98, 1.02); }
  100% { transform: rotate(0deg) scale(1); }
}

@keyframes card-pull {
  0% {
    transform: translateX(-50%) translateY(0) rotate(0deg);
    opacity: 1;
  }
  70% {
    transform: translateX(-50%) translateY(-135px) rotate(-6deg);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-120px) rotate(-4deg);
    opacity: 1;
  }
}

@keyframes confetti-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--cx), var(--cy)) rotate(var(--cr));
  }
}

@keyframes result-pop {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --------------------------------------------------------------------------
   14. Reduced motion — every animation and transition dies, idle included.
   The result appears instantly; the card and confetti stay put.
   -------------------------------------------------------------------------- */

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

  .hat,
  body.revealed .hat,
  body.revealed .draw-card,
  body.revealed #reveal-result {
    animation: none !important;
  }

  body.revealed .confetti {
    display: none;
  }

  body.revealed .draw-card {
    transform: translateX(-50%) translateY(-120px) rotate(-4deg);
  }
}

/* --------------------------------------------------------------------------
   15. Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .link-item,
  .name-item {
    flex-direction: column;
    align-items: stretch;
  }

  .link-actions,
  .name-actions {
    justify-content: flex-start;
  }

  .link-actions .btn,
  .link-actions .btn-ghost {
    flex: 1 1 auto;
  }

  #reveal-stage {
    height: 210px;
  }
}
