/* ==========================================================================
   Karácsonyi ajándékhúzó – design tokens first, then components.
   ========================================================================== */

:root {
  /* palette */
  --fenyo-sotet: #0F3D2E;
  --fenyo: #1B5E20;
  --piros: #C62828;
  --piros-sotet: #8E1B1B;
  --arany: #D4A017;
  --arany-vilagos: #F2C94C;
  --krem: #FFF8E7;
  --ho: #FFFFFF;
  --tinta: #2B1B17;
  --hiba: #B3261E;

  /* derived (kept next to the palette so it can be tuned in one place) */
  --mezo-keret: #7A6A4A;          /* form borders: 3:1+ on cream */
  --tinta-halk: #5A4640;          /* secondary text on cream, AA */
  --arany-halvany: rgba(212, 160, 23, 0.16);
  --sarga-sav: #FFD54F;

  /* type */
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-script: 'Great Vibes', 'Brush Script MT', cursive;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-title: 28px;
  --fs-name: 48px;
  --fs-body: 16px;
  --fs-small: 14px;

  /* shape */
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.28);
  --content: 720px;
  --tap: 44px;
}

@media (min-width: 720px) {
  :root {
    --fs-title: 36px;
    --fs-name: 64px;
    --fs-body: 17px;
  }
}

/* ---------- fonts (self-hosted, OFL; latin + latin-ext covers ő and ű) ---------- */

@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/playfair-display-latin-ext-700.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/playfair-display-latin-700.woff2') format('woff2');
  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;
}
@font-face {
  font-family: 'Great Vibes';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/great-vibes-latin-ext-400.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Great Vibes';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/great-vibes-latin-400.woff2') format('woff2');
  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;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-latin-ext-400.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-latin-400.woff2') format('woff2');
  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;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/nunito-latin-ext-700.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/nunito-latin-700.woff2') format('woff2');
  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;
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ho);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(27, 94, 32, 0.55), transparent 60%),
    radial-gradient(ellipse at 50% 110%, rgba(142, 27, 27, 0.18), transparent 55%),
    var(--fenyo-sotet);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0; }
h1 { font-size: var(--fs-title); }
h2 { font-size: calc(var(--fs-title) * 0.8); }
h3 { font-size: 20px; }
p { margin: 0 0 0.75em; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }

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

[hidden] { display: none !important; }

/* visible focus on light and dark surfaces: dark inner ring + gold outer ring */
:focus-visible {
  outline: 2px solid var(--fenyo-sotet);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--arany-vilagos);
  border-radius: 6px;
}
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .draw-btn:focus-visible {
  border-radius: var(--radius-btn);
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--krem); color: var(--tinta);
  padding: 10px 16px; border-radius: 8px; font-weight: 700;
}
.skip-link:focus { top: 8px; }

.icon { display: inline-flex; width: 1.3em; height: 1.3em; flex: none; vertical-align: middle; }
.icon svg { width: 100%; height: 100%; }

/* ---------- decoration: snow ---------- */

.snow {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
}
.flake {
  position: absolute; top: -12px; left: var(--x);
  width: var(--s); height: var(--s);
  animation: fall var(--d) linear var(--dl) infinite;
  will-change: transform;
}
.flake i {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--ho);
  opacity: var(--o);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
  animation: sway var(--sw) ease-in-out var(--dl) infinite alternate;
}
@keyframes fall { from { transform: translateY(-5vh); } to { transform: translateY(108vh); } }
@keyframes sway { from { transform: translateX(-14px); } to { transform: translateX(14px); } }

/* ---------- decoration: garland ---------- */

.garland {
  position: relative; z-index: 2;
  height: 64px;
  background: url('../assets/garland-tile.svg') repeat-x top center / auto 34px;
  pointer-events: none;
}
.bulb {
  position: absolute; top: 20px;
  width: 12px; height: 15px;
  border-radius: 50% 50% 55% 55% / 45% 45% 55% 55%;
  animation: twinkle 3s ease-in-out infinite;
}
.bulb::before {
  content: ''; position: absolute; left: 50%; top: -9px;
  width: 2px; height: 10px; margin-left: -1px; background: var(--arany);
}
.bulb.gold { background: radial-gradient(circle at 35% 30%, #fff6c9, var(--arany-vilagos) 55%, var(--arany)); box-shadow: 0 0 10px 3px rgba(242, 201, 76, 0.65); }
.bulb.red { background: radial-gradient(circle at 35% 30%, #ffb3b3, var(--piros) 60%, var(--piros-sotet)); box-shadow: 0 0 10px 3px rgba(198, 40, 40, 0.65); }
.bulb:nth-child(1) { left: 5%; } .bulb:nth-child(2) { left: 15%; top: 26px; } .bulb:nth-child(3) { left: 25%; }
.bulb:nth-child(4) { left: 36%; top: 26px; } .bulb:nth-child(5) { left: 47%; } .bulb:nth-child(6) { left: 58%; top: 26px; }
.bulb:nth-child(7) { left: 69%; } .bulb:nth-child(8) { left: 80%; top: 26px; } .bulb:nth-child(9) { left: 91%; }
.bulb:nth-child(3n+1) { animation-delay: -0.4s; } .bulb:nth-child(3n+2) { animation-delay: -1.5s; } .bulb:nth-child(3n) { animation-delay: -2.4s; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 45% { opacity: 0.45; } 70% { opacity: 0.9; } }

/* ---------- layout ---------- */

.site { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.page { width: 100%; max-width: var(--content); margin: 0 auto; padding: 8px 16px 32px; flex: 1; }

.site-header { text-align: center; padding: 8px 0 4px; }
.site-header h1 { color: var(--arany-vilagos); overflow-wrap: anywhere; }
.site-header .kicker { font-size: var(--fs-small); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ho); opacity: 0.85; margin-bottom: 4px; }

.divider {
  display: flex; align-items: center; gap: 10px; margin: 12px auto;
  max-width: 260px; color: var(--arany-vilagos);
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--arany); }
.divider .icon { width: 18px; height: 18px; }

.site-footer {
  position: relative; z-index: 1;
  max-width: var(--content); width: 100%; margin: 0 auto;
  padding: 8px 16px 28px;
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; justify-content: center;
  font-size: var(--fs-small);
}
.foot-btn {
  background: none; border: 0; color: var(--ho); cursor: pointer;
  min-height: var(--tap); padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: underline; text-decoration-color: var(--arany); text-underline-offset: 4px;
  font-size: var(--fs-small);
}
.foot-btn:hover { color: var(--arany-vilagos); }
.foot-sep { color: var(--arany); }

.switch-label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none;
  width: 48px; height: 28px; margin: 0; flex: none; cursor: pointer;
  border-radius: 14px; border: 2px solid var(--arany);
  background: rgba(255, 255, 255, 0.12); position: relative;
  transition: background 150ms;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--ho); transition: transform 150ms;
}
.switch:checked { background: var(--fenyo); }
.switch:checked::after { transform: translateX(20px); }
.card .switch { background: #e6dcc3; border-color: var(--mezo-keret); }
.card .switch:checked { background: var(--fenyo); border-color: var(--fenyo); }

/* ---------- cards ---------- */

.card {
  position: relative;
  color: var(--tinta);
  background:
    url('../assets/star.svg') top 8px left 8px / 12px 12px no-repeat,
    url('../assets/star.svg') top 8px right 8px / 12px 12px no-repeat,
    url('../assets/star.svg') bottom 8px left 8px / 12px 12px no-repeat,
    url('../assets/star.svg') bottom 8px right 8px / 12px 12px no-repeat,
    var(--krem);
  border: 1px solid var(--arany);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px 20px;
  margin: 16px 0;
}
.card h2 { margin-bottom: 6px; }
.card .lead { color: var(--tinta-halk); }
.card .small, .small { font-size: var(--fs-small); }
.muted { color: var(--tinta-halk); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; min-width: var(--tap); padding: 0 22px;
  border: 2px solid transparent; border-radius: var(--radius-btn);
  font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
  transition: background 150ms, border-color 150ms, transform 150ms, color 150ms;
}
.btn-primary { background: var(--piros); color: var(--ho); }
.btn-primary:hover { background: var(--piros-sotet); }
.btn-primary:active { background: var(--piros-sotet); transform: translateY(1px); }
.btn-secondary { background: transparent; border-color: var(--arany); color: var(--tinta); }
.on-dark .btn-secondary, .btn-secondary.on-dark { color: var(--ho); }
.btn-secondary:hover { background: var(--arany-halvany); }
.btn-danger { background: var(--hiba); color: var(--ho); }
.btn-small { min-height: var(--tap); padding: 0 14px; font-size: var(--fs-small); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary:disabled:hover { background: var(--piros); }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.btn-row.spread { justify-content: space-between; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  background: transparent; border: 1px solid var(--arany); border-radius: 50%;
  color: var(--tinta); cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.icon-btn .icon { width: 22px; height: 22px; }
.icon-btn:hover:not(:disabled) { background: var(--arany-halvany); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.danger { color: var(--hiba); }

/* ---------- forms ---------- */

.field { margin: 0 0 16px; }
.field label, .field .label { display: block; font-weight: 700; margin-bottom: 4px; }
.hint { font-size: var(--fs-small); color: var(--tinta-halk); margin: 4px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .row2 { grid-template-columns: 2fr 1fr; } .row2.even { grid-template-columns: 1fr 1fr; } }

input[type='text'], input[type='date'], input[type='number'], select, textarea {
  width: 100%; min-height: 48px; padding: 8px 12px;
  background: var(--ho); color: var(--tinta);
  border: 2px solid var(--mezo-keret); border-radius: 10px;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.4; }
select { appearance: auto; }
input[aria-invalid='true'], select[aria-invalid='true'] { border-color: var(--hiba); background: #fff5f4; }

.error {
  display: flex; gap: 6px; align-items: flex-start;
  margin: 6px 0 0; color: var(--hiba); font-size: var(--fs-small); font-weight: 700;
}
.error .icon { width: 18px; height: 18px; margin-top: 1px; }

.inline-form { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.inline-form .grow { flex: 1 1 200px; min-width: 0; }

/* ---------- notices ---------- */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--krem); color: var(--tinta);
  border-left: 6px solid var(--piros); border-radius: 0 12px 12px 0;
  padding: 12px 14px; margin: 14px 0;
  box-shadow: var(--shadow-card);
}
.notice .icon { color: var(--piros); width: 24px; height: 24px; margin-top: 1px; }
.notice.ok { border-left-color: var(--fenyo); }
.notice.ok .icon { color: var(--fenyo); }
.notice p { margin: 0; }
.notice strong { display: block; }
.storage-bar {
  background: var(--sarga-sav); color: var(--tinta);
  padding: 10px 16px; font-size: var(--fs-small); font-weight: 700;
  position: relative; z-index: 3; text-align: center;
}

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 60; max-width: min(92vw, 520px);
  background: var(--krem); color: var(--tinta);
  border: 1px solid var(--arany); border-radius: 12px;
  padding: 10px 16px; box-shadow: var(--shadow-card); font-weight: 700;
  animation: toast-in 200ms ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- stepper ---------- */

.stepper { list-style: none; margin: 8px 0 4px; padding: 0; display: flex; position: relative; }
.stepper::before {
  content: ''; position: absolute; left: 12%; right: 12%; top: 6px; height: 2px;
  background: var(--arany); opacity: 0.8;
}
.step { flex: 1; display: flex; justify-content: center; position: relative; }
.step-btn {
  background: none; border: 0; cursor: pointer; padding: 0 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: var(--tap); min-height: var(--tap); color: var(--ho);
  font-size: var(--fs-small); font-weight: 400;
}
.step-btn:disabled { cursor: not-allowed; }
.step-btn svg { width: 28px; height: 36px; overflow: visible; transition: transform 150ms; }
.step .b-ball { stroke: var(--arany-vilagos); stroke-width: 2; fill: var(--fenyo-sotet); }
.step.done .b-ball { fill: var(--arany); stroke: var(--arany); }
.step.current .b-ball { fill: var(--piros); stroke: var(--arany-vilagos); }
.step.current svg { transform: scale(1.3); transform-origin: top center; margin-bottom: 8px; }
.step.current .step-name { font-weight: 700; color: var(--arany-vilagos); }
.step.locked .step-btn { opacity: 0.75; }
.step-name { display: block; }
.step-lock { width: 14px; height: 14px; margin-left: 3px; }

/* ---------- step views ---------- */

.view-enter { animation: slide-in 250ms ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

.view-title { margin-bottom: 6px; }
.view-title:focus { outline: none; box-shadow: none; }

/* ---------- participants ---------- */

.people-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.unit { display: grid; gap: 4px; position: relative; }
.unit.couple { padding-left: 18px; }
.unit.couple::before {
  content: ''; position: absolute; left: 6px; top: 26px; bottom: 26px; width: 3px;
  background: var(--arany); border-radius: 2px;
}
.unit.couple .ring {
  position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; padding: 2px; border-radius: 50%;
  background: var(--krem); color: var(--tinta); border: 1px solid var(--arany);
  display: flex; z-index: 1;
}
.unit.couple .ring .icon { width: 100%; height: 100%; }

.person {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center;
  background: var(--ho); border: 1px solid #e3d6b0; border-radius: 12px; padding: 8px 10px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  background: var(--piros); color: var(--ho); text-transform: uppercase;
}
.avatar.c1 { background: var(--fenyo); }
.avatar.c2 { background: var(--arany); color: var(--tinta); }
.person-name { font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.person-actions { display: flex; gap: 6px; }
.person-extra { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding-top: 4px; border-top: 1px dashed #e3d6b0; }
.person-extra label { font-size: var(--fs-small); color: var(--tinta-halk); display: inline-flex; align-items: center; gap: 8px; }
.person-extra select { min-height: var(--tap); width: auto; max-width: 100%; padding: 4px 8px; font-size: var(--fs-small); }
.person .edit-form { grid-column: 2 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.person .edit-form .grow { flex: 1 1 140px; min-width: 0; }

.list-foot {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px;
}
.counter { font-weight: 700; }
.counter.ok { color: var(--fenyo); }
.link-btn {
  background: none; border: 0; cursor: pointer; padding: 0 4px; min-height: var(--tap);
  color: var(--tinta); font-weight: 700; text-decoration: underline;
  text-decoration-color: var(--arany); text-underline-offset: 4px;
}

/* ---------- exclusions ---------- */

.excl-list { display: grid; gap: 10px; margin-top: 14px; }
.excl-card { background: var(--ho); border: 1px solid #e3d6b0; border-radius: 12px; }
.excl-card summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 6px 12px;
}
.excl-card summary::-webkit-details-marker { display: none; }
.excl-card summary .icon-chevron { transition: transform 150ms; margin-left: auto; }
.excl-card[open] summary .icon-chevron { transform: rotate(90deg); }
.excl-card .badge {
  font-size: var(--fs-small); color: var(--tinta-halk);
}
.excl-card .badge.has { color: var(--piros-sotet); font-weight: 700; }
.excl-body { padding: 4px 12px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px; border-radius: 22px;
  background: var(--krem); border: 2px solid var(--arany); color: var(--tinta);
  font-weight: 700; cursor: pointer; transition: background 150ms, color 150ms;
  overflow-wrap: anywhere; text-align: left;
}
.chip:hover { background: #ffefc2; }
.chip[aria-pressed='true'] { background: var(--piros); border-color: var(--piros); color: var(--ho); }
.chip[aria-pressed='true'] .chip-name { text-decoration: line-through; }
.chip[aria-pressed='true']:hover { background: var(--piros-sotet); }
.chip.locked { background: var(--fenyo-sotet); border-color: var(--fenyo-sotet); color: var(--ho); cursor: default; }
.chip .icon { width: 18px; height: 18px; }

.matrix-wrap { overflow-x: auto; margin: 14px -4px 0; padding: 4px; }
.matrix { border-collapse: separate; border-spacing: 2px; }
.matrix th { font-weight: 700; font-size: 13px; padding: 0 2px; }
.matrix thead th { vertical-align: bottom; }
.matrix thead th span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 116px; overflow: hidden; text-overflow: ellipsis; }
.matrix tbody th { text-align: right; white-space: nowrap; padding-right: 8px; position: sticky; left: 0; background: var(--krem); }
.cell {
  width: 30px; height: 30px; border-radius: 6px; padding: 0; cursor: pointer;
  border: 1px solid var(--mezo-keret); background: var(--ho); color: var(--ho);
  display: inline-flex; align-items: center; justify-content: center;
}
.cell .icon { width: 18px; height: 18px; }
.cell[aria-pressed='true'] { background: var(--piros); border-color: var(--piros); }
.cell:disabled { cursor: default; background: #ece4cc; border-color: #d8ccaa; color: var(--tinta-halk); }
.cell.pair:disabled { background: var(--fenyo-sotet); border-color: var(--fenyo-sotet); color: var(--ho); }
.only-wide { display: none; }
@media (min-width: 900px) { .only-wide { display: inline-flex; } }
.view-toggle { display: flex; gap: 8px; margin-top: 10px; }

.status-bar {
  position: sticky; bottom: 8px; z-index: 4; margin: 16px 0 0;
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--krem); color: var(--tinta);
  border: 1px solid var(--arany); border-left: 6px solid var(--fenyo);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow-card);
}
.status-bar.bad { border-left-color: var(--piros); }
.status-bar .icon { width: 24px; height: 24px; color: var(--fenyo); }
.status-bar.bad .icon { color: var(--piros); }
.status-bar p { margin: 0; font-weight: 700; }

/* ---------- draw ---------- */

.draw-stage { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 4px; }
.draw-btn {
  width: 190px; height: 190px; border-radius: 50%; cursor: pointer; margin: 18px 0;
  background: radial-gradient(circle at 35% 30%, #e24a4a, var(--piros) 55%, var(--piros-sotet));
  border: 6px solid var(--arany);
  box-shadow: 0 0 0 4px rgba(212, 160, 23, 0.35), 0 12px 28px rgba(0, 0, 0, 0.4);
  color: var(--ho); font-family: var(--font-display); font-weight: 700; font-size: 32px;
  transition: transform 150ms, box-shadow 150ms;
}
.draw-btn:hover:not(:disabled) { transform: scale(1.04); }
.draw-btn:active:not(:disabled) { transform: translateY(2px) scale(0.99); }
.draw-btn:disabled { filter: grayscale(0.7) brightness(0.8); cursor: not-allowed; }
.draw-facts { color: var(--tinta-halk); }

.draw-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 61, 46, 0.95);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  color: var(--ho);
}
.sack-wrap { position: relative; width: 200px; height: 210px; animation: sack-shake 1.5s ease-in-out forwards; }
.sack-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.nc {
  position: absolute; left: 50%; top: 40%;
  min-width: 78px; max-width: 120px; padding: 6px 10px; margin-left: -50px;
  background: var(--krem); color: var(--tinta); border: 1px solid var(--arany); border-radius: 6px;
  font-size: 13px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; animation: nc-swirl 1.5s ease-in-out var(--dl) forwards;
}
@keyframes nc-swirl {
  0% { opacity: 0; transform: translate(var(--x0), var(--y0)) rotate(var(--r0)) scale(1); }
  12% { opacity: 1; }
  45% { opacity: 1; transform: translate(var(--x1), var(--y1)) rotate(calc(var(--r0) * -1)) scale(1); }
  72% { opacity: 1; transform: translate(0, -60px) rotate(0) scale(0.8); }
  88% { opacity: 1; transform: translate(0, 30px) rotate(0) scale(0.4); }
  100% { opacity: 0; transform: translate(0, 50px) scale(0); }
}
@keyframes sack-shake {
  0%, 55% { transform: none; }
  60% { transform: rotate(-4deg); } 66% { transform: rotate(4deg); } 72% { transform: rotate(-3deg); }
  78% { transform: rotate(3deg); } 84%, 100% { transform: none; }
}
.spark {
  position: absolute; left: 50%; top: 30%; width: var(--sz); height: var(--sz); margin: -8px;
  color: var(--arany-vilagos); opacity: 0;
  animation: spark-burst 0.55s ease-out 0.95s forwards;
}
.spark svg { width: 100%; height: 100%; }
@keyframes spark-burst {
  0% { opacity: 1; transform: translate(0, 0) scale(0.3) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); }
}
.draw-overlay p { margin-top: 18px; font-family: var(--font-display); font-size: 20px; }

/* ---------- links ---------- */

.id-badge {
  display: inline-block; padding: 2px 12px; border-radius: 20px;
  border: 1px solid var(--arany); background: var(--ho); font-weight: 700; letter-spacing: 0.06em;
}
.link-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.link-row { background: var(--ho); border: 1px solid #e3d6b0; border-radius: 12px; padding: 10px 12px; }
.link-top { display: flex; align-items: center; gap: 10px; }
.link-top .person-name { flex: 1; }
.link-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.sent-label { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; font-size: var(--fs-small); margin-left: auto; }
.sent-label input { width: 22px; height: 22px; accent-color: var(--fenyo); }
.link-row.is-sent .person-name { color: var(--fenyo); }
.share-menu { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e3d6b0; }
.copy-fallback { margin-top: 8px; }
.copy-fallback input { font-size: 13px; }

.result-card {
  position: relative; text-align: center; color: var(--tinta); overflow: hidden;
  background:
    linear-gradient(90deg, transparent calc(50% - 16px), var(--arany) calc(50% - 16px), var(--arany-vilagos) 50%, var(--arany) calc(50% + 16px), transparent calc(50% + 16px)),
    linear-gradient(0deg, transparent calc(50% - 16px), var(--arany) calc(50% - 16px), var(--arany-vilagos) 50%, var(--arany) calc(50% + 16px), transparent calc(50% + 16px)),
    var(--krem);
  border: 1px solid var(--arany); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); margin: 16px 0; padding: 20px;
}
.result-lock { color: var(--tinta); background: var(--krem); border: 1px solid var(--arany); border-radius: 14px; padding: 14px 16px; display: inline-block; max-width: 100%; }
.result-lock .icon-star { width: 30px; height: 30px; color: var(--arany); }
.result-open { background: none; padding: 0; text-align: left; }
.result-open-wrap { text-align: left; background: var(--krem); border-radius: 12px; }
.result-table { list-style: none; margin: 12px 0; padding: 0; border: 1px solid var(--arany); border-radius: 12px; overflow: hidden; }
.result-table li { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 8px 12px; background: var(--krem); }
.result-table li:nth-child(even) { background: #f6e8bd; }
.result-table .arrow { color: var(--tinta); font-weight: 700; }
.result-table .to { font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.result-table .from { overflow-wrap: anywhere; }

/* ---------- dialogs ---------- */

dialog {
  width: min(92vw, 520px); max-height: 88vh; overflow: auto;
  padding: 22px 20px; color: var(--tinta);
  background: var(--krem); border: 1px solid var(--arany); border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
dialog::backdrop { background: rgba(5, 25, 18, 0.72); }
dialog h2 { margin-bottom: 8px; }
dialog .help-sec h3 { margin: 16px 0 4px; font-size: 18px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 2px solid var(--mezo-keret); border-radius: 10px; margin: 8px 0; cursor: pointer; min-height: var(--tap); background: var(--ho); }
.radio-card:has(input:checked) { border-color: var(--fenyo); background: #eef6ea; }
.radio-card input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--fenyo); flex: none; }
.radio-card.disabled { opacity: 0.6; cursor: not-allowed; }
.dialog-section { padding: 14px 0; border-top: 1px solid #e3d6b0; }
.dialog-section:first-of-type { border-top: 0; }
.drop-zone { border: 2px dashed var(--mezo-keret); border-radius: 12px; padding: 14px; text-align: center; background: var(--ho); }
.drop-zone.over { border-color: var(--piros); background: #fff1ef; }
.check-row { display: flex; gap: 10px; align-items: center; min-height: var(--tap); cursor: pointer; }
.check-row input { width: 22px; height: 22px; accent-color: var(--fenyo); }

/* ---------- reveal ---------- */

.reveal-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.reveal-main { flex: 1; width: 100%; max-width: var(--content); margin: 0 auto; padding: 8px 16px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.reveal-main h1 { color: var(--ho); margin-top: 4px; overflow-wrap: anywhere; }
.reveal-event { color: var(--arany-vilagos); margin: 4px 0 0; font-weight: 700; }

.stage { position: relative; width: min(100%, 440px); height: 300px; margin: 14px auto 0; transition: height 0.5s ease; }
.stage.open { height: var(--stage-open, 520px); }
.gift-btn {
  position: absolute; left: 50%; bottom: 0; margin-left: -120px; z-index: 2;
  width: 240px; height: 250px; padding: 0; background: none; border: 0; cursor: pointer;
  animation: bob 3s ease-in-out infinite;
}
.stage.open .gift-btn { animation: none; cursor: default; }
.gift-svg { width: 100%; height: 100%; overflow: visible; }
.gift-lid { transition: transform 0.75s cubic-bezier(0.5, 0, 0.9, 0.4) 0.3s, opacity 0.45s ease 0.6s; }
.gift-bow .bow-left, .gift-bow .bow-right, .gift-bow .bow-tail { transition: transform 0.4s ease; transform-origin: 120px 84px; }
.stage.open .gift-lid { transform: translate(-30px, -170px) rotate(-18deg); opacity: 0; }
.stage.open .bow-left { transform: rotate(-30deg) translate(-10px, 0); }
.stage.open .bow-right { transform: rotate(30deg) translate(10px, 0); }
.stage.open .bow-tail { transform: scale(0.8) translateY(6px); }
.gift-btn:hover:not(:disabled) .gift-svg { filter: brightness(1.08); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.reveal-card {
  position: absolute; left: 50%; bottom: 82px; z-index: 1; width: min(92vw, 380px);
  transform: translate(-50%, 200px) scale(0.55); opacity: 0; visibility: hidden;
  padding: 26px 20px 66px; margin: 0;
  transition: transform 0.3s ease, opacity 0.25s ease, visibility 0s linear 0.3s;
}
.stage.open .reveal-card {
  transform: translate(-50%, 0) scale(1); opacity: 1; visibility: visible;
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.25, 1) 0.65s, opacity 0.5s ease 0.65s, visibility 0s;
}
.reveal-card .you { margin: 0; font-size: var(--fs-small); text-transform: uppercase; letter-spacing: 0.08em; color: var(--tinta-halk); }
.drawn-name {
  font-family: var(--font-script); font-weight: 400; font-size: var(--fs-name); line-height: 1.1;
  color: var(--piros-sotet); margin: 6px 0 12px; overflow-wrap: anywhere;
}
.drawn-name.long { font-size: calc(var(--fs-name) * 0.7); }
.drawn-name.xlong { font-size: calc(var(--fs-name) * 0.52); }
.facts { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; text-align: left; }
.facts li { display: flex; gap: 8px; align-items: baseline; border-top: 1px solid #e3d6b0; padding-top: 4px; overflow-wrap: anywhere; }
.facts .k { font-size: var(--fs-small); color: var(--tinta-halk); min-width: 86px; flex: none; }
.facts .v { font-weight: 700; }
.card-id { font-size: 12px; color: var(--tinta-halk); margin: 6px 0 0; }

.reveal-hint { margin-top: 12px; font-size: 18px; font-weight: 700; color: var(--ho); }
.stage.open ~ .reveal-hint { display: none; }
.reveal-actions { margin-top: 14px; min-height: 52px; }
.reveal-contact { margin: 18px 0 0; font-size: var(--fs-small); color: var(--ho); max-width: 440px; }
.reveal-contact strong { color: var(--arany-vilagos); }

.confetti {
  position: absolute; left: 50%; top: 56%; width: var(--sz); height: var(--sz); margin: calc(var(--sz) / -2);
  color: var(--c); opacity: 0; z-index: 3; pointer-events: none;
  animation: confetti 2s cubic-bezier(0.15, 0.7, 0.35, 1) var(--dl) forwards;
}
.confetti svg { width: 100%; height: 100%; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(0.4); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); }
}

.error-page { max-width: 460px; margin: 28px auto; text-align: center; }
.error-page .icon-gift { width: 72px; height: 72px; color: var(--arany); margin-bottom: 8px; }

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .snow, .confetti, .spark { display: none !important; }
  .bulb, .gift-btn { animation: none; }
  .view-enter { animation: fade-in 250ms ease-out; }
  .toast { animation: none; }
  .stage { transition: none; }
  .gift-lid, .gift-bow .bow-left, .gift-bow .bow-right, .gift-bow .bow-tail { transition: opacity 0.3s ease; transform: none !important; }
  .stage.open .gift-lid { opacity: 0; }
  .reveal-card { transform: translate(-50%, 0) scale(1); transition: opacity 0.3s ease, visibility 0s linear 0.3s; }
  .stage.open .reveal-card { transition: opacity 0.3s ease, visibility 0s; }
  .excl-card summary .icon-chevron { transition: none; }
  .draw-btn, .btn { transition: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media print { .snow, .garland { display: none; } }
