:root {
  --paper: #f6f1ea;
  --card: #ffffff;
  --ink: #2b2622;
  --muted: #7a706a;
  --line: #e6ddd2;
  --red: #b3262d;
  --red-dark: #8f1d23;
  --green: #2f6b4f;
  --green-soft: #e8f2ec;
  --gold: #c9973a;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 12% 8%, rgba(179, 38, 45, 0.06), transparent 40%),
    radial-gradient(circle at 90% 0%, rgba(47, 107, 79, 0.07), transparent 40%),
    var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a { color: var(--red); }

h1, h2 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.35rem; }

code { font-family: var(--mono); background: var(--paper); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.92em; }

.site-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
}
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { display: inline-block; transform: rotate(-8deg); }

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 32px 20px 48px; flex: 1; }

.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px; }

.hero { text-align: center; margin: 16px auto 36px; max-width: 620px; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(43, 38, 34, 0.04), 0 8px 24px -12px rgba(43, 38, 34, 0.12);
}
.cards .card { margin-bottom: 0; }
.cards .card:first-child { border-top: 5px solid var(--red); }
.cards .card:last-child { border-top: 5px solid var(--green); }
.card-narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card-launch { border: 2px dashed var(--gold); background: #fffdf8; }
.center { text-align: center; }
.big-emoji { font-size: 3rem; line-height: 1; margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--muted); margin: 0 0 6px; }

/* forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; }

input, textarea {
  font: inherit;
  font-weight: 400;
  color: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.15); }
input.is-invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(179, 38, 45, 0.12); }
textarea { resize: vertical; margin: 6px 0 10px; }
.code-input { font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }

.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s;
}
.btn:hover { background: #255a42; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--red); border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper); }
.btn-small { padding: 6px 12px; font-size: 0.9rem; background: #fff; color: var(--green); }
.btn-small:hover { background: var(--green-soft); }
.btn-big { padding: 14px 26px; font-size: 1.1rem; }

.btn-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-icon:hover { background: #fbeaea; color: var(--red); }

.alert { padding: 12px 16px; border-radius: 10px; margin: 0 0 16px; }
.alert ul, ul.alert { margin: 6px 0 0; padding-left: 20px; }
ul.alert { padding-left: 32px; }
.alert-error { background: #fbeaea; color: var(--red-dark); }
.alert-ok { background: var(--green-soft); color: #22503b; }
.alert-info { background: #fff6e0; color: #6b5115; word-break: break-all; }

.recover { margin: 28px auto 0; max-width: 520px; text-align: center; color: var(--muted); }
.recover summary { cursor: pointer; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; }

/* admin */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.title-input {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  margin-left: -9px;
}
.title-input:hover { border-color: var(--line); }

.badge { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 10px; border-radius: 999px; }
.badge-draft { background: #f1ebe3; color: var(--muted); }
.badge-live { background: var(--red); color: #fff; }

.save-status { font-size: 0.85rem; color: var(--muted); }
.save-status.is-saved { color: var(--green); }
.save-status.is-error { color: var(--red); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.rule-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rule-row { display: flex; gap: 6px; align-items: center; }
.rule-row::before { content: "❄"; color: var(--gold); margin-right: 4px; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.count { font-family: var(--sans); font-size: 0.85rem; background: var(--paper); color: var(--muted); padding: 2px 10px; border-radius: 999px; vertical-align: middle; }

.table-wrap { overflow-x: auto; margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 6px 6px; }
td { padding: 4px 6px; vertical-align: middle; }
.participants td:first-child, .participants th:first-child { padding-left: 0; }
.participants tbody tr + tr td { border-top: 1px solid #f3eee7; }
.participants input { padding: 8px 10px; min-width: 140px; }
.participants form { margin: 0; }

.pill { display: inline-block; font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; background: #f1ebe3; color: var(--muted); white-space: nowrap; }
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-bad { background: #fbeaea; color: var(--red); cursor: help; }

.bulk { margin-top: 16px; }
.bulk summary { cursor: pointer; color: var(--green); font-weight: 600; font-size: 0.92rem; }

.tool-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tool-row form { margin: 0; }

.pairs td { padding: 10px 6px; border-top: 1px solid #f3eee7; font-size: 1.05rem; }
.pairs .arrow { color: var(--muted); white-space: nowrap; text-align: center; }

/* participant */
.reveal-box {
  text-align: center;
  background: var(--green-soft);
  border: 2px dashed var(--green);
  border-radius: var(--radius);
  padding: 24px 16px;
  margin: 16px 0 24px;
}
.giftee { display: block; font-family: var(--serif); font-size: clamp(1.8rem, 6vw, 2.6rem); color: var(--green); margin-top: 6px; }

.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 20px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; }

.rules { padding-left: 0; list-style: none; margin: 0 0 24px; }
.rules li { padding: 6px 0 6px 28px; position: relative; }
.rules li::before { content: "❄"; color: var(--gold); position: absolute; left: 4px; }

.confirm { text-align: center; margin: 24px 0 16px; }
.confirm .alert { text-align: left; }

@media (max-width: 640px) {
  .participants thead { display: none; }
  .participants, .participants tbody { display: block; }
  .participants tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
  }
  .participants tbody tr + tr { border-top: 1px solid #f3eee7; }
  .participants tbody tr + tr td { border-top: 0; }
  .participants td { padding: 0; }
  .participants td:nth-child(1), .participants td:nth-child(2) { flex: 1 1 100%; }
  .participants input { min-width: 0; }
  .participants td:last-child { margin-left: auto; }
  .table-wrap { overflow: visible; }
}

@media (max-width: 560px) {
  .wrap { padding: 20px 14px 40px; }
  .card { padding: 18px; }
  .inline-form { flex-direction: column; }
}
