:root {
  --deep: #0B3D24;
  --deep2: #145C37;
  --mint: #7FE3B0;
  --candle: #3FCB7E;
  --ivory: #FBF8EF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--ivory);
}

body { font-family: 'Cormorant Garamond', serif; color: var(--deep); }

/* ---------- loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ivory);
  transition: opacity .4s ease;
}
#loader img { width: 120px; opacity: .85; animation: loaderPulse 1.8s ease-in-out infinite; }
#loader.hide { opacity: 0; pointer-events: none; }
@keyframes loaderPulse { 0%, 100% { opacity: .5 } 50% { opacity: .95 } }

/* ---------- stage ---------- */
#stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1536px;
  height: 864px;
  transform-origin: 50% 50%;
  opacity: 0;
  transition: opacity .4s ease;
}
#stage.ready { opacity: 1; }

#bg {
  position: absolute;
  left: -512px;
  top: -80px;
  width: 2560px;
  height: 1024px;
  transform-origin: 50% 50%;
}

#glow {
  position: absolute;
  left: 768px;
  top: 300px;
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.85), rgba(220,255,236,.35) 40%, transparent 70%);
  opacity: .55;
  animation: glowBreathe 6s ease-in-out infinite;
}
@keyframes glowBreathe { 0%, 100% { opacity: .45 } 50% { opacity: .6 } }

#rays {
  position: absolute;
  left: 768px;
  top: 300px;
  width: 1400px;
  height: 1400px;
  margin: -700px 0 0 -700px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.75) 0 6deg, rgba(255,255,255,0) 6deg 15deg);
  -webkit-mask: radial-gradient(circle, #000 0 18%, transparent 62%);
  mask: radial-gradient(circle, #000 0 18%, transparent 62%);
  opacity: 0;
  transition: opacity .6s ease;
}
body[data-state="final"] #rays { opacity: .55; animation: raySpin 60s linear infinite; }
@keyframes raySpin { to { transform: rotate(360deg) } }

#motes { position: absolute; left: 0; top: 0; width: 1536px; height: 864px; pointer-events: none; }
#confettiBurst { position: absolute; left: 0; top: 0; width: 1536px; height: 864px; pointer-events: none; }

/* ---------- candles ---------- */
#candles { position: absolute; inset: 0; pointer-events: none; }
.candle { position: absolute; }
.candle img {
  width: 30px;
  display: block;
  filter: drop-shadow(0 0 2px #FBF8EF) drop-shadow(0 0 3px #FBF8EF) drop-shadow(0 0 14px rgba(255,214,120,.9));
}
.candle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,214,120,.85), rgba(255,214,120,0) 70%);
  opacity: .5;
  animation: flame 2.6s ease-in-out infinite;
}
@keyframes flame {
  0%, 100% { opacity: .35; transform: translate(-50%, -50%) scale(.9) }
  50% { opacity: .7; transform: translate(-50%, -50%) scale(1.1) }
}
.candle.bob { animation: bob var(--bobdur, 4s) ease-in-out infinite; animation-delay: var(--bobdelay, 0s); }
@keyframes bob { 0%, 100% { transform: translateY(-6px) } 50% { transform: translateY(6px) } }
body[data-state="sorting"] .candle::after { animation-duration: 1.1s; }
#candles.flare .candle::after { box-shadow: 0 0 18px 8px rgba(255,214,120,.7); }

/* ---------- crest + ribbon ---------- */
#crest {
  position: absolute;
  left: 564px;
  top: 50px;
  width: 408px;
  height: 510px;
  transform-origin: 50% 55%;
  transition: transform .18s ease-out;
}
#crest img, #crest svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#crest img { filter: drop-shadow(0 6px 18px rgba(11,61,36,.25)); }
.ribbon-text { font-family: Cinzel, serif; font-weight: 900; font-size: 60px; fill: var(--deep); letter-spacing: 2px; }
.slot { opacity: 0; }

/* ---------- UI ---------- */
#ui { position: absolute; inset: 0; text-align: center; z-index: 6; }
.halo { text-shadow: 0 0 6px var(--ivory), 0 0 14px var(--ivory), 0 0 24px rgba(251,248,239,.9); }

.whisper {
  position: absolute;
  width: 360px;
  font-size: 28px;
  font-style: italic;
  font-weight: 600;
  opacity: 0;
  z-index: 7;
  padding: 18px 30px;
  box-sizing: border-box;
  background: radial-gradient(closest-side, rgba(251,248,239,.92), rgba(251,248,239,.75) 60%, rgba(251,248,239,0));
  transition: opacity .5s ease;
}
#whisperL { left: 170px; top: 300px; text-align: right; }
#whisperR { left: 1006px; top: 250px; text-align: left; }

#headline {
  position: absolute;
  left: 0; right: 0; top: 576px;
  height: 56px;
  line-height: 56px;
  font-size: 40px;
  font-style: italic;
  font-weight: 600;
  transition: opacity .3s ease;
}
#headline.verdict {
  font-family: 'Cinzel Decorative', serif;
  font-style: normal;
  font-weight: 900;
  font-size: 58px;
  letter-spacing: 3px;
  color: var(--deep);
}

#sub {
  position: absolute;
  left: 0; right: 0; top: 632px;
  font-size: 22px;
  font-style: italic;
  font-weight: 600;
}

#btn {
  position: absolute;
  left: 618px; top: 677px;
  width: 300px; height: 62px;
  border: 3px solid var(--mint);
  border-radius: 999px;
  background: linear-gradient(#145C37, #0B3D24);
  color: var(--ivory);
  font: 700 24px Cinzel, serif;
  letter-spacing: 4px;
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(11,61,36,.25), 0 8px 24px rgba(11,61,36,.35), 0 0 30px rgba(127,227,176,.6);
}
#btn:disabled { cursor: default; opacity: .82; box-shadow: 0 0 0 4px rgba(11,61,36,.2), 0 8px 24px rgba(11,61,36,.25); }
#btn:focus-visible { outline: 3px solid var(--candle); outline-offset: 4px; }
#btn.pulse { animation: btnPulse 3s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(11,61,36,.25), 0 8px 24px rgba(11,61,36,.35), 0 0 22px rgba(127,227,176,.45) }
  50% { box-shadow: 0 0 0 4px rgba(11,61,36,.25), 0 8px 24px rgba(11,61,36,.35), 0 0 44px rgba(127,227,176,.9) }
}

#links {
  position: absolute;
  left: 0; right: 0; top: 766px;
  height: 40px;
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .4s ease, transform .4s ease, visibility 0s linear .4s;
}
#links.show { opacity: 1; pointer-events: auto; visibility: visible; transform: none; transition: opacity .4s ease, transform .4s ease, visibility 0s; }
#links a, #links .ca {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--ivory);
  border: 2px solid var(--deep);
  font: 700 15px Cinzel, serif;
  letter-spacing: 2px;
  color: var(--deep);
  text-decoration: none;
  cursor: pointer;
}
#links .ca { background: var(--mint); }
#links a:focus-visible, #links .ca:focus-visible { outline: 3px solid var(--candle); outline-offset: 3px; }

#toast {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--deep);
  color: var(--ivory);
  font: 700 14px Cinzel, serif;
  letter-spacing: 2px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .25s ease;
}
#toast.show { opacity: 1; }

/* ---------- header ---------- */
#hdr {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  font-family: Cinzel, serif;
  color: var(--deep);
  z-index: 30;
}
#brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(251,248,239,.92);
  border: 2px solid var(--deep);
  box-shadow: 0 4px 14px rgba(11,61,36,.18);
}
#brand img { height: 40px; display: block; }
#brand .wordmark { font-weight: 900; font-size: clamp(16px, 1.4vw, 22px); letter-spacing: 3px; }
.chip {
  font: 700 clamp(11px, .85vw, 13px) Cinzel, serif;
  letter-spacing: 2px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(251,248,239,.88);
  border: 2px solid var(--deep);
  white-space: nowrap;
}
#hud { display: flex; gap: 10px; align-items: center; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #stage { opacity: 1; }
}
