:root {
  --bg: #0a0709;
  --bg-2: #14090d;
  --card: #1a0d12;
  --card-2: #231017;
  --ink: #eadfd0;
  --ink-dim: #a89a8c;
  --blood: #8a0f1c;
  --blood-bright: #c4172b;
  --oxblood: #4a0a12;
  --candle: #ffb54a;
  --candle-soft: rgba(255, 181, 74, .18);
  --line: rgba(196, 23, 43, .35);
  --display: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --head: "Cinzel", Georgia, serif;
  --body: "IM Fell English", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, #2a0d16 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ---------- atmosphere ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.moon {
  position: absolute; top: 28px; right: 8%;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6ecd2 0%, #d8c79a 60%, #a8966a 100%);
  box-shadow: 0 0 60px 20px rgba(246, 236, 210, .18), 0 0 160px 60px rgba(246, 236, 210, .08);
  opacity: .8;
}
.fog {
  position: absolute; left: -50%; width: 200%; height: 40%;
  background:
    radial-gradient(ellipse 30% 50% at 20% 60%, rgba(180, 170, 190, .10), transparent 70%),
    radial-gradient(ellipse 25% 45% at 55% 40%, rgba(180, 170, 190, .08), transparent 70%),
    radial-gradient(ellipse 30% 55% at 85% 65%, rgba(180, 170, 190, .10), transparent 70%);
  animation: drift 70s linear infinite;
}
.fog-a { bottom: 0; }
.fog-b { bottom: 18%; opacity: .7; animation-duration: 110s; animation-direction: reverse; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(25%); } }

.bat { position: absolute; color: #000; width: 46px; height: 20px; opacity: .85; left: -80px; }
.bat-1 { top: 12%; animation: fly 26s linear infinite, flap .5s ease-in-out infinite; }
.bat-2 { top: 26%; width: 32px; height: 14px; animation: fly 38s linear 9s infinite, flap .4s ease-in-out infinite; }
.bat-3 { top: 6%; width: 38px; height: 17px; animation: fly 31s linear 17s infinite, flap .45s ease-in-out infinite; }
@keyframes fly {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(30vw, 40px); }
  50%  { transform: translate(60vw, -20px); }
  75%  { transform: translate(90vw, 50px); }
  100% { transform: translate(125vw, 0); }
}
@keyframes flap { 0%, 100% { scale: 1 1; } 50% { scale: 1 .55; } }

/* ---------- layout ---------- */
.wrap {
  position: relative; z-index: 1;
  max-width: 1040px; margin: 0 auto;
  padding: 24px 16px 56px;
}
.wrap > section, .wrap > header { margin-bottom: 28px; }

h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0; line-height: 1.15; }
h2 { font-size: 1.5rem; color: var(--candle); letter-spacing: .04em; }
.eyebrow {
  font-family: var(--head); text-transform: uppercase; letter-spacing: .28em;
  font-size: .72rem; color: var(--blood-bright); margin: 0 0 8px;
}

/* ---------- hero ---------- */
.hero { text-align: center; padding-top: 40px; position: relative; isolation: isolate; }
/* painted backdrop: castle on the hill; the painting has its own moon */
.hero::before {
  content: ""; position: absolute; z-index: -1; inset: -24px -50vw 0; left: 50%; right: auto; width: 100vw; transform: translateX(-50%);
  background:
    linear-gradient(180deg, rgba(10, 7, 9, .55) 0%, rgba(10, 7, 9, .35) 40%, rgba(10, 7, 9, .85) 85%, var(--bg) 100%),
    url("/art/hero-sm.webp") center 30% / cover no-repeat;
  /* fade out instead of ending on a hard line against the page gradient */
  bottom: -80px;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
}
@media (min-width: 701px) { .hero::before { background-image: linear-gradient(180deg, rgba(10, 7, 9, .55) 0%, rgba(10, 7, 9, .3) 40%, rgba(10, 7, 9, .85) 85%, var(--bg) 100%), url("/art/hero.webp"); } }
.moon { display: none; }
.hero h1 {
  font-family: var(--display); font-weight: 900;
  font-size: clamp(2rem, 9vw, 4.25rem);
  color: #f4e6d0;
  text-shadow: 0 0 18px var(--candle-soft), 0 2px 0 #000, 0 0 40px rgba(196, 23, 43, .45);
  overflow-wrap: anywhere;
  animation: flicker 6s infinite;
}
@keyframes flicker {
  0%, 100% { text-shadow: 0 0 18px var(--candle-soft), 0 2px 0 #000, 0 0 40px rgba(196, 23, 43, .45); }
  47% { text-shadow: 0 0 24px rgba(255, 181, 74, .3), 0 2px 0 #000, 0 0 46px rgba(196, 23, 43, .5); }
  50% { text-shadow: 0 0 10px rgba(255, 181, 74, .1), 0 2px 0 #000, 0 0 30px rgba(196, 23, 43, .35); }
  53% { text-shadow: 0 0 26px rgba(255, 181, 74, .32), 0 2px 0 #000, 0 0 48px rgba(196, 23, 43, .5); }
}
.when {
  font-family: var(--head); font-size: 1.15rem; margin: 22px 0 12px; color: var(--candle);
  letter-spacing: .05em;
}
.notes { list-style: none; padding: 0; margin: 0; color: var(--ink-dim); font-style: italic; }
.notes li { margin: 2px 0; }

.invite {
  background: linear-gradient(180deg, rgba(74, 10, 18, .35), rgba(20, 9, 13, .6));
  border: 1px solid var(--line); border-radius: 6px; padding: 22px 18px;
}
.invite h2 { margin-bottom: 10px; }
.invite p { margin: 0 0 12px; }
.invite p:last-child { margin-bottom: 0; }
.invite em { color: var(--blood-bright); font-style: italic; }

/* ---------- panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 20px 18px; box-shadow: 0 0 30px rgba(0, 0, 0, .5), inset 0 0 40px rgba(74, 10, 18, .25);
}
.panel[hidden] { display: none; }
.panel h2 { margin-bottom: 12px; }
.panel label { display: block; font-family: var(--head); font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 6px; }
.panel input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: #0d0609; color: var(--ink);
  border: 1px solid #4a2a30; border-radius: 4px;
  font: inherit; font-size: 1.1rem;
}
.panel input:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; border-color: var(--candle); }
.hint { color: var(--ink-dim); font-style: italic; margin: 10px 0 0; }
.hint.warn { color: var(--candle); }

.me { border-color: var(--blood-bright); box-shadow: 0 0 36px rgba(196, 23, 43, .25), inset 0 0 40px rgba(74, 10, 18, .35); }
.me .coming { font-size: 1.2rem; margin: 0 0 14px; }
.me .coming strong { font-family: var(--head); color: var(--candle); }
.me .btn-row { justify-content: flex-start; }
.closed { text-align: center; }
.closed p { margin: 0; color: var(--ink-dim); }

/* ---------- buttons ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.btn {
  min-height: 48px; padding: 10px 20px;
  font-family: var(--head); font-weight: 700; letter-spacing: .08em; font-size: .9rem; text-transform: uppercase;
  color: #fff; background: linear-gradient(180deg, var(--blood-bright), var(--blood));
  border: 1px solid #e0485a; border-radius: 4px; cursor: pointer;
  box-shadow: 0 2px 0 #2a0409, 0 0 18px rgba(196, 23, 43, .3);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible { outline: 2px solid var(--candle); outline-offset: 2px; }
.btn.ghost { background: transparent; border-color: #5a3a40; color: var(--ink); box-shadow: none; }

/* ---------- gallery ---------- */
.gallery-h { text-align: center; margin-bottom: 6px; }
.status-line { text-align: center; color: var(--ink-dim); font-style: italic; margin: 0 0 18px; min-height: 1.5em; }
.gallery { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .gallery { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  width: 100%; margin: 0; padding: 20px 18px 18px;
  background: linear-gradient(170deg, var(--card-2), var(--card) 60%);
  color: var(--ink); font: inherit;
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--blood-bright), transparent);
}
button.card { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .2s, box-shadow .2s, border-color .2s; }
button.card:hover { transform: translateY(-3px); border-color: var(--candle); box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 26px var(--candle-soft); }
button.card:active { transform: translateY(0); }
button.card:focus-visible { outline: 2px solid var(--candle); outline-offset: 3px; }
.card h3 { font-size: 1.3rem; color: #f4e6d0; }
.card .ctitle { font-family: var(--head); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--blood-bright); margin: 4px 0 12px; }
.card .flavor { font-style: italic; color: var(--candle); margin: 0 0 10px; }
.card .blurb { margin: 0 0 16px; color: var(--ink); font-size: 1rem; flex: 1; }
.card .badge {
  align-self: flex-start; font-family: var(--head); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; border: 1px solid;
  overflow-wrap: anywhere; max-width: 100%;
}
.card.available .badge { color: #9fe0a8; border-color: #3f8a4c; background: rgba(63, 138, 76, .12); }
.card .portrait {
  display: block; width: calc(100% + 36px); height: auto; max-width: none; margin: -20px -18px 14px; aspect-ratio: 4 / 3;
  object-fit: cover; object-position: 50% 18%; background: #140c10;
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent); mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.card .seal { position: absolute; top: 12px; right: 12px; width: 72px; height: 72px; transform: rotate(-12deg); filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .7)); pointer-events: none; }
.card.taken > :not(.seal) { opacity: .6; filter: grayscale(.7); }
.card.taken .badge { color: var(--ink-dim); border-color: #4a3a3e; background: rgba(0, 0, 0, .3); }
.card.mine { opacity: 1; filter: none; border-color: var(--candle); box-shadow: 0 0 30px var(--candle-soft); }
.card.mine .badge { color: var(--candle); border-color: var(--candle); background: var(--candle-soft); }
.card.picking button.card { cursor: pointer; }
.card.locked { opacity: .85; }

/* ---------- dialog / toast ---------- */
dialog {
  width: min(92vw, 440px); padding: 24px 20px; color: var(--ink);
  background: linear-gradient(170deg, #2a1119, #12080b); border: 1px solid var(--blood-bright); border-radius: 8px;
  box-shadow: 0 0 60px rgba(196, 23, 43, .35), 0 20px 60px #000;
}
dialog::backdrop { background: rgba(5, 2, 3, .82); }
dialog h3 { font-size: 1.5rem; color: var(--candle); margin-bottom: 10px; }
dialog p { margin: 0 0 14px; }
.error { color: #ff7a88; font-style: italic; margin: 0 0 12px; }
.error[hidden] { display: none; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 440px; margin: 0 auto; padding: 14px 18px; border-radius: 6px;
  background: #2a1119; border: 1px solid var(--blood-bright); color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .7); text-align: center;
}
.toast[hidden] { display: none; }

.foot { text-align: center; color: var(--ink-dim); font-style: italic; margin-top: 40px; }

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

/* ---------- buttons on parchment: wax seal + ink-ruled ---------- */
.panel .btn-row, dialog .btn-row { justify-content: center; gap: 14px; margin-top: 6px; }
.panel .btn, dialog .btn {
  min-height: 48px; padding: 10px 26px; border-radius: 3px;
  font-family: var(--head); font-weight: 700; letter-spacing: .12em; font-size: .85rem;
  color: #f3e3c4; text-shadow: 0 -1px 0 rgba(0, 0, 0, .45);
  background: radial-gradient(ellipse at 50% 30%, #8e1a26 0%, #6a0f1a 55%, #4a0811 100%);
  border: 1px solid #3a060d;
  box-shadow: inset 0 1px 0 rgba(255, 210, 190, .18), inset 0 -2px 4px rgba(0, 0, 0, .35), 0 2px 3px rgba(60, 30, 10, .45);
  filter: none;
}
.panel .btn:hover, dialog .btn:hover { background: radial-gradient(ellipse at 50% 30%, #9c1f2c 0%, #741220 55%, #520a14 100%); filter: none; }
.panel .btn:focus-visible, dialog .btn:focus-visible { outline: 2px solid var(--p-red, #7a1020); outline-offset: 3px; }
.panel .btn.ghost, dialog .btn.ghost {
  color: var(--p-ink, #2b1a10); text-shadow: none;
  background: transparent; border: 3px double #6b4a2e; box-shadow: none;
}
.panel .btn.ghost:hover, dialog .btn.ghost:hover { background: rgba(107, 74, 46, .1); }
@media (max-width: 520px) {
  .panel .btn-row, dialog .btn-row { flex-direction: column; align-items: stretch; }
  dialog .btn-row { flex-direction: column-reverse; }   /* primary action on top */
}
.me, .closed { text-align: center; }
.me .hint { text-align: center; }

/* ---------- toast as parchment ---------- */
.toast {
  background: url("/art/parchment.webp") center / 512px repeat, #e6d2a8;
  color: #2b1a10; border: 0; border-radius: 2px;
  box-shadow: inset 0 0 24px rgba(120, 75, 30, .45), 0 10px 30px rgba(0, 0, 0, .8);
}

/* Available badge in candle-gold rather than off-palette green */
.card.available .badge { color: var(--candle); border-color: rgba(255, 181, 74, .55); background: rgba(255, 181, 74, .08); }

/* ---------- claimed section ---------- */
#taken-section { margin-top: 48px; }
#taken-section[hidden] { display: none; }
.taken-gallery .blurb { display: none; }   /* compact: name, title, tagline, who */
.all-claimed { grid-column: 1 / -1; text-align: center; font-style: italic; color: var(--ink-dim); margin: 0; }
@media (min-width: 960px) { .taken-gallery { grid-template-columns: repeat(4, 1fr); } }

/* ---------- parchment scrolls: invite, panels, confirm dialog ----------
   One generated scroll per form factor (art-src/scroll.py), drawn with border-image so the rolls and
   torn edges keep their shape while the box grows. Slice values come from scroll.py's output. */
.invite, .panel, dialog {
  --p-ink: #2b1a10; --p-dim: #5a3f28; --p-red: #7a1020;
  position: relative;
  background: none; border-radius: 0; box-shadow: none;
  color: var(--p-ink);
  border-style: solid;
  border-width: 39px 33px 35px 34px;
  border-image: url("/art/scroll-mobile.webp") 117 100 107 104 fill / 39px 33px 35px 34px stretch;
  padding: 18px 14px;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .6));
}
@media (min-width: 701px) {
  .invite, .panel, dialog {
    border-width: 50px 62px 48px 62px;
    border-image: url("/art/scroll-web.webp") 104 129 99 130 fill / 50px 62px 48px 62px stretch;
    padding: 20px 30px;
  }
}
.wrap > .invite, .wrap > .panel { margin: 0 0 32px; }
.invite::before, .invite::after, .panel::before, .panel::after, dialog::before, dialog::after { content: none; }
.me { filter: drop-shadow(0 0 22px rgba(255, 181, 74, .3)) drop-shadow(0 12px 18px rgba(0, 0, 0, .6)); }
dialog { overflow: visible; text-align: center; width: min(calc(100vw - 24px), 480px); }

.invite h2, .panel h2 { color: var(--p-red); text-align: center; text-shadow: none; }
.invite em { color: var(--p-red); font-weight: 700; }
.panel label { color: var(--p-dim); }
.panel input {
  background: rgba(255, 248, 228, .5); color: var(--p-ink);
  border: 1px solid #8a6a48; box-shadow: inset 0 1px 3px rgba(80, 50, 20, .25);
}
.panel input::placeholder { color: #876c50; }
.panel input:focus-visible { outline-color: var(--p-red); border-color: var(--p-red); }
.panel .hint { color: var(--p-dim); }
.panel .hint.warn { color: #8a3b00; font-weight: 700; }
.me .coming strong { color: var(--p-red); }
.closed p { color: var(--p-dim); }
dialog .eyebrow { color: var(--p-dim); }
dialog h3 { color: var(--p-red); }
dialog .error { color: #9a1020; font-weight: 700; }

/* name field inside the confirm scroll (monster-first RSVP) */
.confirm-name { text-align: left; margin: 0 0 14px; }
.confirm-name[hidden] { display: none; }
.confirm-name label { display: block; font-family: var(--head); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--p-dim); margin-bottom: 6px; }
.confirm-name input {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; font-size: 1.1rem; border-radius: 3px;
  background: rgba(255, 248, 228, .5); color: var(--p-ink);
  border: 1px solid #8a6a48; box-shadow: inset 0 1px 3px rgba(80, 50, 20, .25);
}
.confirm-name input::placeholder { color: #876c50; }
.confirm-name input:focus-visible { outline: 2px solid var(--p-red); outline-offset: 2px; border-color: var(--p-red); }

/* Center short rows instead of leaving them hugging the left edge */
.gallery { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.gallery > .card { flex: 0 1 100%; }
@media (min-width: 640px) { .gallery > .card { flex-basis: calc((100% - 16px) / 2); } }
@media (min-width: 960px) {
  .gallery > .card { flex-basis: calc((100% - 32px) / 3); }
  .taken-gallery > .card { flex-basis: calc((100% - 48px) / 4); }
}
dialog { padding-top: 26px; }
