:root {
  --ink: #160d19;
  --plum: #3f174b;
  --violet: #7c3aed;
  --ember: #ff7a1a;
  --gold: #f6c96c;
  --cream: #fff7e8;
  --mist: #c6b4da;
  --panel: rgba(26, 13, 31, 0.92);
  --line: rgba(246, 201, 108, 0.28);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% -10%, rgba(124, 58, 237, 0.28), transparent 33rem),
    linear-gradient(180deg, #09070d 0%, #180b1d 45%, #0a070d 100%);
  font-family: "Nunito", system-ui, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.night-sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.72) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(246,201,108,.55) 0 1px, transparent 1.7px);
  background-position: 0 0, 29px 41px;
  background-size: 67px 67px, 113px 113px;
  opacity: .14;
  z-index: -1;
}

.page-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 18px auto 70px;
}

.hero {
  position: relative;
  width: min(100%, 720px);
  height: auto;
  aspect-ratio: 1;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.hero-entry {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #100914;
  cursor: pointer;
}
.hero-entry:focus-visible { outline: 4px solid #c99cff; outline-offset: -7px; }
.hero-entry::after {
  content: "";
  position: absolute;
  left: 89%;
  top: 52%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,178,72,.34);
  box-shadow: 0 0 18px 7px rgba(255,126,28,.34);
  animation: entry-ember 2.4s ease-in-out infinite;
  pointer-events: none;
}
.hero-entry.opened::after { display: none; }
.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .8s ease, filter .8s ease;
}
.hero-entry:hover .hero-image { transform: scale(1.012); filter: brightness(1.04); }
.mini-label {
  margin: 0 0 .4rem;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}
h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  line-height: .95;
}
.cast-button, .refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  padding: .78rem 1.25rem;
  background: linear-gradient(135deg, #8b3cf1, #4a1760);
  color: white;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(75, 23, 96, .44), inset 0 1px rgba(255,255,255,.2);
  cursor: pointer;
}
.cast-button:hover:not(:disabled), .refresh-button:hover { transform: translateY(-2px); filter: brightness(1.12); }

.countdown-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.1rem;
  align-items: center;
  margin: 20px 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(0,0,0,.28);
}
.moon { font-size: 2.4rem; color: var(--gold); filter: drop-shadow(0 0 12px rgba(246,201,108,.6)); }
.countdown-panel h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.countdown { display: flex; gap: .55rem; }
.countdown span {
  display: grid;
  min-width: 64px;
  padding: .45rem .5rem;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  text-align: center;
  color: var(--mist);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.countdown strong { color: var(--cream); font-size: 1.25rem; line-height: 1.1; }

.fog-reveal {
  position: relative;
  min-height: 430px;
  margin: 28px 0;
  overflow: hidden;
  border: 1px solid rgba(198,180,218,.22);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 22%, rgba(124,58,237,.22), transparent 28%),
    linear-gradient(145deg, #110a16, #28112f 55%, #0b0810);
  box-shadow: var(--shadow), inset 0 0 80px rgba(0,0,0,.5);
  touch-action: none;
  cursor: crosshair;
}
.fog-reveal.summoned { animation: vault-summon .8s cubic-bezier(.2,.8,.2,1) both; }
.fog-reveal canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
.fog {
  position: absolute;
  inset: -30%;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse, rgba(188,160,215,.36), transparent 55%),
    radial-gradient(ellipse at 70% 40%, rgba(103,60,133,.42), transparent 50%);
  filter: blur(14px);
  animation: fog-drift 14s ease-in-out infinite alternate;
  transition: opacity 1s ease;
}
.fog-reveal.awake .fog { opacity: .08; }
.swipe-invitation {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 5;
  margin: 0;
  transform: translate(-50%,-50%);
  white-space: nowrap;
  color: rgba(255,247,232,.82);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity .6s ease;
}
.fog-reveal.awake .swipe-invitation { opacity: 0; }
.reveal-copy {
  position: absolute;
  inset: 35px 24px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.reveal-copy p {
  margin: .16rem 0;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(5px);
  color: #f8eacc;
  font: 700 clamp(1.5rem, 4.7vw, 3.4rem)/1.12 "Cormorant Garamond", Georgia, serif;
  transition: opacity .8s ease, transform .8s ease, filter .8s ease;
}
.reveal-copy p.revealed { opacity: 1; transform: none; filter: none; }
.reveal-copy strong { color: var(--gold); text-shadow: 0 0 20px rgba(246,201,108,.45); }

.vault-section {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 360px);
  gap: 2rem;
  align-items: center;
  padding: clamp(1.3rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(33,15,40,.97), rgba(12,8,16,.97));
  box-shadow: var(--shadow);
}
.vault-section.summoned { animation: vault-summon .9s cubic-bezier(.2,.8,.2,1) both; }
.vault-copy h2, .guardian-copy h2, .results-heading h2, .closing-card h2 { font-size: clamp(2.7rem, 7vw, 5rem); }
.vault-door {
  position: relative;
  width: min(100%, 280px);
  aspect-ratio: .68;
  justify-self: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}
.door-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 3px solid #916238;
  border-radius: 140px 140px 14px 14px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 2px, transparent 2px 34px),
    linear-gradient(90deg, #180e16, #3c202d 50%, #150c14);
  box-shadow: inset 0 0 0 9px #25131d, inset 0 0 0 12px rgba(246,201,108,.38), 0 20px 45px rgba(0,0,0,.52);
  transform-origin: left center;
  transition: transform 1.2s cubic-bezier(.2,.8,.2,1), filter .25s ease;
}
.vault-door:hover .door-face { filter: brightness(1.12); }
.vault-door.knock .door-face { animation: door-knock .25s ease; }
.vault-door.open .door-face { transform: rotateY(-108deg); }
.door-moon { font-size: 5.4rem; color: var(--gold); filter: drop-shadow(0 0 16px rgba(246,201,108,.55)); }
.door-ring { position: absolute; right: 28px; top: 58%; width: 40px; height: 50px; border: 5px solid #c99a50; border-radius: 50%; }
.door-light { position: absolute; inset: 12px; z-index: -1; background: #ff8a2a; filter: blur(22px); opacity: .8; }
.door-instruction { position: absolute; left: 50%; bottom: -2.4rem; transform: translateX(-50%); color: var(--gold); font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.knock-status { grid-column: 2; margin: .7rem 0 0; text-align: center; color: var(--mist); }

.ballot-section, .results-section, .closing-card {
  margin-top: 32px;
  padding: clamp(1.2rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.guardian-wrap { display: grid; grid-template-columns: minmax(180px, 330px) 1fr; gap: 1.5rem; align-items: center; }
.guardian-wrap img { width: 100%; max-height: 390px; object-fit: contain; filter: drop-shadow(0 24px 30px rgba(0,0,0,.35)); }
.rules-card, .compatibility-card {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  margin: 1.2rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(246,201,108,.3);
  border-radius: 18px;
  background: rgba(246,201,108,.075);
}
.compatibility-card {
  margin: 0 0 1.5rem;
  border-color: rgba(178,108,255,.34);
  background: rgba(124,58,237,.1);
}
.rules-card > span, .compatibility-card > span { font-size: 1.7rem; }
.rules-card p, .compatibility-card p { margin: 0; }

.selection-sticky {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.1rem;
  padding: .75rem 1rem;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 18px;
  background: rgba(14,8,18,.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 28px rgba(0,0,0,.26);
}
.selection-sticky > div:first-child { display: grid; }
.selection-sticky span { color: var(--mist); font-size: .8rem; }
.selection-sticky strong { color: var(--gold); }
.candle-row { display: flex; gap: 10px; }
.candle-row i { position: relative; display: block; width: 13px; height: 30px; border-radius: 4px; background: #5c465f; transition: background .3s ease; }
.candle-row i::before { content: ""; position: absolute; left: 2px; top: -13px; width: 9px; height: 15px; border-radius: 60% 40% 60% 40%; background: #37293a; transform: rotate(8deg); transition: .3s; }
.candle-row i.lit { background: #fff0c4; }
.candle-row i.lit::before { background: #ff9c2f; box-shadow: 0 0 16px 6px rgba(255,130,31,.52); }

fieldset { min-width: 0; padding: 0; border: 0; }
.guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.guide-card {
  position: relative;
  display: flex;
  min-height: 250px;
  flex-direction: column;
  gap: .45rem;
  overflow: hidden;
  padding: 1.2rem;
  border: 1px solid rgba(198,180,218,.22);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.018)),
    #160d1b;
  cursor: pointer;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.guide-card:hover { transform: translateY(-4px); border-color: rgba(246,201,108,.55); }
.guide-card:has(input:focus-visible) { outline: 3px solid #c99cff; outline-offset: 3px; }
.guide-card:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(246,201,108,.12), 0 14px 34px rgba(0,0,0,.34); transform: translateY(-4px); }
.guide-card input { position: absolute; opacity: 0; pointer-events: none; }
.card-glow { position: absolute; inset: auto -30% -50% 20%; height: 70%; border-radius: 50%; background: var(--card-accent, #7c3aed); filter: blur(60px); opacity: .12; transition: opacity .3s; }
.guide-card:has(input:checked) .card-glow { opacity: .38; }
.guide-icon { position: relative; font-size: 2.2rem; }
.guide-category { position: relative; color: var(--gold); font-size: .67rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.guide-title { position: relative; color: #fff7e8; font: 700 1.48rem/1.05 "Cormorant Garamond", Georgia, serif; }
.guide-description { position: relative; color: #d3c7d8; font-size: .84rem; line-height: 1.45; }
.choice-mark { position: absolute; top: .8rem; right: .8rem; display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; color: transparent; transition: .25s; }
.guide-card:has(input:checked) .choice-mark { color: #24132a; border-color: var(--gold); background: var(--gold); transform: rotate(-8deg) scale(1.08); }
.guide-card.mystery {
  grid-column: span 3;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-color: rgba(255,122,26,.48);
  background:
    radial-gradient(circle at 50% 120%, rgba(255,122,26,.28), transparent 50%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 2px, transparent 2px 12px),
    #160d1b;
}
.guide-card.mystery .guide-icon { font-size: 3.5rem; animation: mystery-pulse 2.4s ease-in-out infinite; }
.guide-card.mystery .guide-title { font-size: 2rem; color: #ffd58e; }

.submit-wrap { display: grid; justify-items: center; margin-top: 1.4rem; text-align: center; }
.form-message { min-height: 1.6rem; margin: 0 0 .4rem; color: #ffd58e; font-weight: 800; }
.cast-button { min-width: min(100%, 310px); border: 1px solid rgba(246,201,108,.45); background: linear-gradient(135deg, #8a3917, #6e1d52 52%, #371349); }
.cast-button:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.45); }
.privacy-note { max-width: 650px; margin: .9rem 0 0; color: #ab9bb2; font-size: .75rem; }

.results-heading { display: flex; gap: 1.4rem; align-items: end; justify-content: space-between; }
.results-heading > div { max-width: 720px; }
.refresh-button { flex: none; padding: .65rem .9rem; border-color: rgba(198,180,218,.25); background: rgba(124,58,237,.22); }
.total-ballots { color: var(--gold); font-weight: 900; }
.results-list { display: grid; gap: .72rem; margin: 1.2rem 0 0; padding: 0; list-style: none; }
.result-row { position: relative; overflow: hidden; padding: .78rem .9rem; border: 1px solid rgba(255,255,255,.09); border-radius: 15px; background: rgba(255,255,255,.035); }
.result-row.winner { border-color: rgba(246,201,108,.5); }
.result-bar { position: absolute; inset: 0 auto 0 0; width: var(--result-width); background: linear-gradient(90deg, rgba(124,58,237,.42), rgba(255,122,26,.26)); transition: width .9s cubic-bezier(.2,.8,.2,1); }
.result-copy { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .8rem; align-items: center; }
.result-name { font-weight: 900; }
.result-stat { color: #ffe2a8; font-size: .82rem; font-weight: 800; text-align: right; }

.closing-card { position: relative; overflow: hidden; text-align: center; background: radial-gradient(circle at 50% 0, rgba(124,58,237,.24), transparent 55%), var(--panel); }
.closing-pumpkin { display: block; margin-bottom: .4rem; font-size: 3.5rem; filter: drop-shadow(0 0 18px rgba(255,122,26,.55)); }
.closing-card p { max-width: 760px; margin: 1rem auto 0; }
.signature { color: var(--gold); font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.25rem; font-weight: 700; }

.bat-layer { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.flying-bat { position: absolute; left: -5rem; font-size: var(--bat-size, 2rem); animation: bat-flight var(--bat-speed, 2.4s) ease-in forwards; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes fog-drift { to { transform: translate3d(7%, -4%, 0) scale(1.06); } }
@keyframes entry-ember {
  0%, 100% { opacity: .28; transform: scale(.72); }
  50% { opacity: 1; transform: scale(1.18); }
}
@keyframes door-knock { 35% { transform: translateX(-5px) rotate(-.6deg); } 70% { transform: translateX(4px) rotate(.4deg); } }
@keyframes mystery-pulse { 50% { transform: scale(1.08) rotate(-4deg); filter: drop-shadow(0 0 15px rgba(255,122,26,.8)); } }
@keyframes vault-summon {
  from { opacity: 0; transform: translateY(34px) scale(.98); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes bat-flight { to { transform: translate(calc(100vw + 10rem), var(--bat-rise, -35vh)) rotate(var(--bat-turn, 18deg)); } }

@media (max-width: 820px) {
  .countdown-panel { grid-template-columns: auto 1fr; }
  .countdown { grid-column: 1 / -1; justify-content: center; }
  .vault-section { grid-template-columns: 1fr; text-align: center; }
  .knock-status { grid-column: 1; }
  .guardian-wrap { grid-template-columns: 1fr; text-align: center; }
  .guardian-wrap img { max-height: 300px; }
  .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-card.mystery { grid-column: span 2; }
  .results-heading { align-items: stretch; flex-direction: column; }
  .refresh-button { align-self: flex-start; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 16px, 1120px); margin-top: 8px; }
  .hero { border-radius: 22px; }
  .countdown-panel { padding: .9rem; }
  .countdown { gap: .3rem; }
  .countdown span { min-width: 0; flex: 1; padding: .38rem .2rem; font-size: .56rem; }
  .fog-reveal { min-height: 390px; }
  .swipe-invitation { font-size: .62rem; letter-spacing: .1em; }
  .ballot-section, .results-section, .closing-card { padding: 1rem; border-radius: 22px; }
  .selection-sticky { top: 4px; }
  .guide-grid { grid-template-columns: 1fr; }
  .guide-card, .guide-card.mystery { grid-column: 1; min-height: 0; }
  .result-copy { grid-template-columns: 1fr; gap: .18rem; }
  .result-stat { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behaviour: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .fog, .fog-reveal canvas, .swipe-invitation { display: none; }
  .reveal-copy p { opacity: 1; transform: none; filter: none; }
}
