:root {
  color-scheme: light;
  --paper: #f8f5ef;
  --white: #fffdfa;
  --ink: #242b25;
  --muted: #5d645b;
  --line: #e4ded3;
  --wine: #852839;
  --wine-dark: #6c1c2c;
  --green: #28483c;
  --serif: Georgia, 'Times New Roman', serif;
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: default; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #a33d50; outline-offset: 3px; }
.shell { width: min(1112px, calc(100% - 64px)); margin-inline: auto; }

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-content { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 16px; }
.wordmark { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; font: bold 1.34rem/1 var(--serif); letter-spacing: -.045em; }
.brand-period { color: var(--wine); }
.gift-mark { display: grid; place-items: center; width: 33px; height: 33px; margin-right: 10px; border-radius: 9px; background: var(--wine); color: #fff5e7; position: relative; }
.gift-mark i { position: relative; width: 15px; height: 12px; border: 1.5px solid currentColor; border-radius: 1px; margin-top: 5px; background: linear-gradient(to right, transparent calc(50% - .6px), currentColor calc(50% - .6px) calc(50% + .6px), transparent calc(50% + .6px)); }
.gift-mark i::before, .gift-mark i::after { content: ''; position: absolute; top: -6px; width: 6px; height: 5px; border: 1.2px solid currentColor; }
.gift-mark i::before { left: 1px; border-radius: 4px 4px 0 4px; transform: rotate(17deg); }
.gift-mark i::after { right: 1px; border-radius: 4px 4px 4px 0; transform: rotate(-17deg); }
.header-actions { display: flex; align-items: center; gap: 4px; margin-right: -10px; }
.help-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .875rem; font-weight: 650; white-space: nowrap; }
.help-button:hover { background: var(--paper); color: var(--wine-dark); }
.help-symbol { display: inline-grid; place-items: center; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%; font-size: .68rem; line-height: 1; }

.hero { display: grid; align-items: center; isolation: isolate; position: relative; overflow: hidden; min-height: 315px; margin-top: 29px; border-radius: 21px; background: #791f31; color: #fff3dc; }
.hero-art { position: absolute; z-index: -1; inset: 0 0 0 36%; background: radial-gradient(ellipse at 74% 45%, #a2414b, transparent 70%); }
.hero-art::before { content: ''; position: absolute; inset: 0; background: url('gifts.webp') 66% 51% / cover no-repeat; }
.hero-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #791f31 0%, #791f31 5%, #791f3100 39%); }
.hero-content { padding: 35px 0 40px clamp(28px, 5.6vw, 66px); }
.hero-content .hero-label { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; color: #f6d6a1; font-size: .75rem; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
.hero-label span { font-size: 1rem; }
.hero h1 { font: bold clamp(3.2rem, 6.3vw, 5.75rem)/.99 var(--serif); letter-spacing: -.066em; }
.hero-content > p:last-child { max-width: 320px; margin-top: 18px; color: #f6ded7; font-size: 1.04rem; line-height: 1.55; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.61fr) minmax(0, 1fr); align-items: start; gap: 22px; margin-top: 24px; }
.setup-column, .sidebar { display: grid; gap: 16px; min-width: 0; }
.card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 17px; background: var(--white); box-shadow: 0 2px 4px #441a0b06; }
.guest-card { container-type: inline-size; }
.card-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 20px; }
.card h2, .help-dialog h2 { font: bold 1.77rem/1.13 var(--serif); letter-spacing: -.045em; }
.card-heading p, .draw-card > p { color: var(--muted); margin-top: 5px; font-size: .96rem; }
.count { display: inline-flex; align-items: center; min-height: 29px; margin-top: 2px; padding: 2px 10px; border-radius: 20px; background: #edf1e8; color: var(--green); font-size: .81rem; font-weight: 700; white-space: nowrap; }
.field-label, .guest-labels { color: #383c35; font-size: .875rem; font-weight: 680; }
.optional { margin-left: 5px; color: var(--muted); font-size: .78rem; font-weight: 450; }
input:is([type=text], [type=url]), select, textarea { display: block; width: 100%; min-width: 0; min-height: 43px; padding: 8px 10px; border: 1px solid #ded7cb; border-radius: 8px; background-color: #fffefa; color: var(--ink); font-size: .94rem; font-weight: 500; }
input:is([type=text], [type=url])::placeholder, textarea::placeholder { color: #74796f; opacity: 1; }
#game-name { margin-top: 5px; }
.exchange-name-hint { margin: 5px 0 17px; color: var(--muted); font-size: .85rem; }
select { appearance: none; padding-right: 25px; background-image: linear-gradient(45deg, transparent 50%, #5e645b 50%), linear-gradient(135deg, #5e645b 50%, transparent 50%); background-position: calc(100% - 13px) 53%, calc(100% - 9px) 53%; background-size: 4px 4px; background-repeat: no-repeat; text-overflow: ellipsis; }
select:disabled { opacity: 1; background-color: #f7f5ef; color: #74756d; }
.guest-labels, .guest-row { display: grid; grid-template-columns: 37px minmax(0, 1fr) minmax(130px, .95fr) 74px 30px; gap: 8px; align-items: center; }
.guest-labels { margin-bottom: 6px; }
.guest-labels span:first-child { grid-column: 2; }
.guest-list { display: grid; gap: 8px; }
.theme-icon { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 9px; background: var(--theme-swatch, #f7e9df); font-size: 1.08rem; }
.guest-theme { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-width: 0; min-height: 43px; padding: 8px 10px; border: 1px solid #ded7cb; border-radius: 8px; background: #fffefa; color: var(--ink); text-align: left; font-size: .94rem; font-weight: 500; }
.guest-theme:hover { border-color: #b4a898; background: #f9f6ef; }
.selected-theme { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-picker-mark { width: 12px; height: 12px; flex: 0 0 12px; color: var(--green); background: radial-gradient(circle, currentColor 1.45px, transparent 1.65px) 0 0 / 6px 6px; }
.icon-button { display: grid; place-items: center; min-width: 30px; min-height: 34px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #69665f; font-size: 1.28rem; line-height: 1; }
.icon-button:hover { background: #f9ebe8; color: var(--wine-dark); }
.outline-button, .primary-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 1px solid #ddd4c5; border-radius: 8px; background: var(--white); color: var(--green); font-size: .9rem; font-weight: 700; line-height: 1.35; }
.outline-button span { color: inherit; font-size: 1.17rem; line-height: 1; }
.outline-button:hover:not(:disabled) { background: #eff2ec; border-color: #c1c9bc; }
.outline-button:disabled { color: #6f7267; background: #f7f5ef; }
.guest-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.preview-guest { width: 74px; min-height: 43px; padding-inline: 5px; }
.exchange-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.exchange-fields input, .exchange-fields textarea { margin-top: 5px; }
.exchange-fields textarea { resize: vertical; min-height: 68px; }
.exchange-wide { grid-column: 1 / -1; }

.rules-card .card-heading { margin-bottom: 16px; }
.rule-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.rule-fields select { margin-top: 5px; }
.both-ways { display: flex; align-items: center; gap: 8px; margin: 11px 0 12px; color: var(--muted); font-size: .88rem; cursor: pointer; }
.both-ways input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.rule-note { margin-top: 12px; color: var(--muted); font-size: .84rem; }
.rule-list { display: grid; gap: 5px; margin: 12px 0 0; padding: 0; list-style: none; }
.rule-item { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 2px 4px 2px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); font-size: .88rem; overflow-wrap: anywhere; }
.rule-item button { flex: 0 0 29px; min-height: 29px; }
.draw-card { background: #f4ecdc; border-color: #eadcc3; }
.draw-card > div { display: flex; align-items: center; gap: 7px; }
.draw-sparkle { color: var(--wine); font-size: 1.25rem; }
.primary-button { min-height: 44px; padding-inline: 16px; border-color: transparent; background: var(--wine); color: #fff9ef; }
.primary-button:hover { background: var(--wine-dark); }
.primary-button:disabled { opacity: .75; }
.primary-button span { font-size: 1.17rem; line-height: 1; }
.draw-card .primary-button { width: 100%; margin-top: 13px; }
.draw-card .draw-status { margin-top: 10px; color: var(--wine-dark); font-size: .9rem; font-weight: 650; }
.backup-card summary { cursor: pointer; font-weight: 700; }
.backup-card p { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.delivery-card { margin-top: 22px; }
.delivery-card .card-heading { margin-bottom: 13px; }
.local-notice { margin-bottom: 10px; padding: 10px 12px; border-radius: 8px; background: #f4ecdc; color: #59422b; font-size: .88rem; }
.delivery-note { color: var(--muted); font-size: .875rem; }
.delivery-list { margin: 0; padding: 0; list-style: none; }
.delivery-item { display: grid; grid-template-columns: 37px minmax(85px, .6fr) minmax(130px, 1.35fr) auto; gap: 10px; align-items: center; padding-block: 9px; border-bottom: 1px solid var(--line); }
.delivery-item:last-child { border: 0; padding-bottom: 0; }
.delivery-name { overflow-wrap: anywhere; }
.delivery-item input { font-size: .85rem; color: var(--muted); }
.delivery-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.delivery-actions .outline-button { min-width: 83px; }
.site-footer { display: flex; justify-content: center; align-items: baseline; gap: 7px; padding: 19px 0 23px; color: var(--muted); text-align: center; font-size: .84rem; }
.lock-mark { position: relative; display: inline-block; flex: 0 0 9px; width: 9px; height: 8px; border: 1px solid currentColor; border-radius: 2px; }
.lock-mark::before { content: ''; position: absolute; left: 1px; right: 1px; top: -5px; height: 5px; border: 1px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.help-dialog { width: min(470px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); color: var(--ink); box-shadow: 0 20px 70px #24161d36; }
.help-dialog::backdrop { background: #24161d75; }
.dialog-close { position: absolute; top: 11px; right: 11px; }
.help-dialog ol { display: grid; gap: 9px; padding-left: 23px; }
.help-dialog p { margin-top: 15px; color: var(--muted); }
.help-dialog .primary-button { margin-top: 17px; }
.dialog-fields { display: grid; gap: 10px; margin-top: 12px; }
.dialog-fields :is(input, select, textarea) { margin-top: 4px; }
.dialog-fields .primary-button { justify-self: start; margin-top: 0; }
.form-status:empty { display: none; }
.help-dialog .form-status { margin: 0; color: var(--wine-dark); }

.preview-dialog { width: min(565px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--white); color: var(--ink); box-shadow: 0 20px 70px #24161d36; }
.preview-dialog::backdrop { background: #24161d75; }
.preview-header { position: sticky; z-index: 2; top: 0; padding: 16px 47px 15px 18px; background: var(--white); }
.preview-header h2 { font: bold 1.43rem/1.15 var(--serif); letter-spacing: -.03em; }
.preview-header p { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.theme-picker { width: min(820px, calc(100% - 24px)); }
.theme-picker-header { border-bottom: 1px solid var(--line); }
.theme-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.theme-filters button { min-height: 34px; padding: 5px 10px; border-radius: 20px; }
.theme-filters button[aria-pressed=true] { background: var(--green); color: var(--white); border-color: var(--green); }
.theme-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 15px; background: var(--paper); }
.theme-option { display: grid; gap: 6px; grid-template-rows: auto 1fr; min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--ink); text-align: left; }
.theme-option:hover { border-color: #b4a898; }
.theme-option[aria-pressed=true] { border-color: var(--wine); box-shadow: inset 0 0 0 1px var(--wine); }
.theme-option-name { align-self: center; padding: 2px 5px 5px; font-size: .86rem; font-weight: 700; line-height: 1.3; }
.theme-sample { display: grid; min-height: 69px; place-items: center; padding: 8px; border-radius: 8px; }
.theme-sample-icon { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, var(--theme-paper)); border-radius: 11px; background: var(--theme-paper); box-shadow: 0 2px 8px #17131948; font-size: 1.45rem; transition: transform .16s ease-out; }
.theme-option:hover .theme-sample-icon { transform: translateY(-2px) rotate(-6deg); }

.reveal-page { --theme-bg: #742438; --theme-paper: #fff0db; --theme-ink: #371b24; --theme-accent: #a72f46; display: grid; min-height: 100dvh; place-items: center; padding: 30px 16px; overflow: hidden; color: var(--theme-ink); }
.reveal-page, .theme-sample { background-color: var(--theme-bg); background-image: radial-gradient(circle at 28% 25%, #ffffff17 0, #ffffff00 49%), var(--theme-texture, radial-gradient(circle, #ffffff37 1px, transparent 1.6px)); background-size: auto, var(--theme-tile, 28px 28px); }
[data-theme-pattern=stripes] { --theme-texture: repeating-linear-gradient(130deg, transparent 0 13px, #ffffff18 13px 19px); --theme-tile: auto; }
[data-theme-pattern=checks] { --theme-texture: conic-gradient(#ffffff18 25%, transparent 0 50%, #ffffff18 0 75%, transparent 0); --theme-tile: 24px 24px; }
[data-theme-pattern=rings] { --theme-texture: radial-gradient(circle, transparent 5px, #ffffff29 5.5px 6.5px, transparent 7px); }
[data-theme-pattern=aurora] { --theme-texture: linear-gradient(138deg, transparent 18%, #50f9c744 49%, #bf8bf74d 65%, transparent 78%); --theme-tile: auto; }
.reveal-card { position: relative; width: min(100%, 555px); padding: clamp(24px, 5.5vw, 47px); border: 1px solid #ffffff85; border-radius: 24px; background: var(--theme-paper); box-shadow: 0 20px 55px #1a101443; text-align: center; overflow: hidden; }
.reveal-card::before, .reveal-card::after { content: '✦'; position: absolute; top: 70px; color: var(--theme-accent); opacity: .32; font-size: 2rem; pointer-events: none; }
.reveal-card::before { left: 9%; }
.reveal-card::after { right: 9%; top: 133px; font-size: 1.45rem; }
.reveal-meta { position: relative; z-index: 1; color: var(--theme-accent); font-size: clamp(.9rem, 2.7vw, 1.02rem); font-weight: 750; letter-spacing: .065em; overflow-wrap: anywhere; }
.reveal-symbol { line-height: 1; font-size: clamp(3.8rem, 12vw, 5.6rem); margin: 25px 0 17px; }
.reveal-match-label { margin: 0 0 5px; color: var(--theme-accent); font-size: .88rem; font-weight: 700; }
.reveal-card :is(h1, h3) { margin: 0; font: bold clamp(2.4rem, 7vw, 4.1rem)/1.04 var(--serif); letter-spacing: -.055em; overflow-wrap: anywhere; }
.reveal-copy { margin: 12px auto 0; max-width: 34ch; }
.reveal-button { margin-top: 22px; background: var(--theme-accent); color: var(--theme-paper); }
.reveal-button:hover { background: var(--theme-ink); }
.reveal-card.is-open .reveal-symbol { animation: unwrap .55s cubic-bezier(.18, .9, .38, 1.4) both; }
.reveal-card.is-open :is(h1, h3) { animation: appear .42s ease-out both; }
.reveal-card a { color: var(--theme-accent); font-weight: 700; text-underline-offset: 3px; }
.reveal-home { display: block; margin-top: 12px; }
.reveal-details { margin-top: 27px; padding-top: 18px; border-top: 1px solid color-mix(in srgb, var(--theme-ink) 24%, transparent); text-align: left; }
.reveal-details :is(h2, h4) { margin: 0 0 11px; font: bold 1.35rem/1.2 var(--serif); letter-spacing: -.025em; }
.reveal-details dl { display: grid; gap: 11px; margin: 0; }
.reveal-details dt { color: var(--theme-accent); font-size: .875rem; font-weight: 700; }
.reveal-details dd { margin: 1px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.preview-stage { min-height: 0; padding: clamp(12px, 4vw, 30px); }
.preview-stage .reveal-card { padding: clamp(16px, 4vw, 32px); }
@keyframes unwrap { from { transform: scale(.5) rotate(-15deg); opacity: .4; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes appear { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 830px) {
  .shell { width: calc(100% - 36px); }
  .workspace { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
  .card { padding: 18px; }
}

@media (max-width: 650px) {
  .shell { width: calc(100% - 28px); }
  .header-content { min-height: 57px; }
  .hero { margin-top: 14px; min-height: 305px; grid-template-rows: 1fr; align-items: end; border-radius: 16px; }
  .hero-art { inset: 0 0 0 18%; }
  .hero-art::before { background-position: 74% 48%; }
  .hero-art::after { background: linear-gradient(0deg, #791f31 1%, #791f31e8 29%, #791f3100 77%), linear-gradient(90deg, #791f31 0%, #791f3100 40%); }
  .hero-content { padding: 24px 18px 23px; }
  .hero h1 { font-size: clamp(2.8rem, 12.5vw, 4.25rem); }
  .hero-content .hero-label { margin-bottom: 6px; }
  .hero-content > p:last-child { margin-top: 9px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 13px; }
  .setup-column, .sidebar { gap: 12px; }
  .delivery-card { margin-top: 12px; }
  .delivery-item { grid-template-columns: 37px minmax(0, 1fr) auto; gap: 5px 8px; }
  .delivery-item input { grid-column: 2 / 4; grid-row: 2; }
  .delivery-actions { grid-column: 3; grid-row: 1; }
  .delivery-actions .outline-button { min-width: 0; padding-inline: 8px; }
  input:is([type=text], [type=url]), select, textarea { font-size: 1rem; }
  .guest-theme { font-size: 1rem; }
  .theme-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer { align-items: baseline; }
}

@media (max-width: 460px) {
  .help-label { display: none; }
  .delivery-item { grid-template-columns: 37px minmax(0, 1fr); }
  .delivery-item input { grid-column: 2; }
  .delivery-actions { grid-column: 2; grid-row: 3; }
  .theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
}

@container (max-width: 410px) {
  .guest-labels { display: none; }
  .guest-row { grid-template-columns: 32px minmax(0, 1fr) 74px; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .guest-row .guest-name { grid-column: 1 / 3; grid-row: 1; }
  .guest-row .remove-guest { grid-column: 3; grid-row: 1; justify-self: end; }
  .guest-row .theme-icon { grid-column: 1; grid-row: 2; width: 32px; height: 35px; }
  .guest-row .guest-theme { grid-column: 2; grid-row: 2; }
  .guest-row .preview-guest { grid-column: 3; grid-row: 2; }
}

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