:root {
  --navy: #272154;
  --night: #0b0824;
  --purple: #8060ed;
  --yellow: #f8bf2e;
  --orange: #f86e36;
  --ink: #f3efff;
  --ink-soft: rgba(243, 239, 255, 0.72);
  --panel: rgba(18, 13, 48, 0.5);
  --panel-edge: rgba(169, 139, 255, 0.22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: Roboto, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#scene:active { cursor: grabbing; }

/* ---- the greeting ---- */

.greeting {
  position: fixed;
  top: max(env(safe-area-inset-top), clamp(18px, 5.2vh, 60px));
  left: 0;
  right: 0;
  padding: 0 16px;
  text-align: center;
  pointer-events: none;
}

.greeting h1 {
  margin: 0;
  font-weight: 400;
}

.merry {
  display: block;
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(2.5rem, 6.4vw, 6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  padding: 0 0.1em 0.08em;
  background: linear-gradient(180deg, #fffaf0 5%, #ffe6ad 48%, #f8bf2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 22px rgba(248, 191, 46, 0.38)) drop-shadow(0 1px 2px rgba(11, 8, 36, 0.6));
}

.from {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 0.35em;
  font-size: clamp(1rem, 1.9vw, 1.6rem);
  font-weight: 400;
  color: var(--ink-soft);
  text-shadow: 0 1px 12px rgba(11, 8, 36, 0.8);
}

.from .mark {
  height: 1.5em;
  width: auto;
  margin-left: 0.15em;
  filter: drop-shadow(0 0 10px rgba(128, 96, 237, 0.55));
}

.wordmark {
  font-weight: 700;
  font-size: 1.35em;
  letter-spacing: -0.01em;
  color: #fff;
}

/* ---- panels ---- */

.moments, .spirit {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom), clamp(14px, 3.2vh, 32px));
  pointer-events: none;
}

.moments {
  left: clamp(14px, 2.4vw, 36px);
  width: min(360px, calc(100vw - 28px));
}

.moments ul {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.moments li {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--ink);
  animation: moment-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.moments li::before {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone, var(--yellow));
  box-shadow: 0 0 10px 2px var(--tone, var(--yellow));
}
.moments li.special {
  border-color: color-mix(in srgb, var(--tone) 60%, transparent);
  background: rgba(38, 28, 84, 0.72);
  font-weight: 500;
}
.moments li:nth-child(2) { opacity: 0.74; }
.moments li:nth-child(3) { opacity: 0.48; }
.moments li:nth-child(4) { opacity: 0.24; }

@keyframes moment-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
}

.spirit {
  right: clamp(14px, 2.4vw, 36px);
  width: min(300px, calc(100vw - 28px));
  padding: 14px 16px 12px;
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.spirit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spirit-title {
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8c89a0;
}
.status[data-kind='live']::before {
  background: #5ee6a0;
  box-shadow: 0 0 8px 1px #5ee6a0;
  animation: beat 1.8s ease-in-out infinite;
}
.status[data-kind='demo']::before { background: var(--yellow); }

@keyframes beat {
  50% { opacity: 0.35; }
}

.meter {
  height: 6px;
  margin: 10px 0 9px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#spirit-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--purple), var(--orange) 60%, var(--yellow));
  transform-origin: left center;
  transform: scaleX(0.02);
  transition: transform 0.6s ease-out;
  box-shadow: 0 0 12px rgba(248, 191, 46, 0.6);
}

.count + .count { margin-top: 3px; }
.count {
  margin: 0;
  font-size: 0.76rem;
  color: var(--ink-soft);
}
.count strong {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---- controls ---- */

.controls {
  position: fixed;
  top: max(env(safe-area-inset-top), 14px);
  right: clamp(12px, 2vw, 28px);
  display: flex;
  gap: 8px;
}

.controls button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--panel-edge);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.controls button:hover { color: #fff; border-color: rgba(169, 139, 255, 0.6); }
.controls button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.controls button[aria-pressed='true'] { color: var(--night); background: var(--yellow); border-color: var(--yellow); }
.controls svg { width: 18px; height: 18px; fill: currentColor; }

.controls .initials {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.controls button.signed-in { color: var(--night); background: var(--yellow); border-color: var(--yellow); }
.controls button.signed-in svg { display: none; }

/* ---- team sign-in ---- */

.account-panel {
  position: fixed;
  top: calc(max(env(safe-area-inset-top), 14px) + 48px);
  right: clamp(12px, 2vw, 28px);
  width: min(300px, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  background: rgba(18, 13, 48, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(5, 3, 20, 0.5);
  font-size: 0.86rem;
  line-height: 1.45;
}
.account-panel h2 { margin: 0 0 6px; font-size: 1rem; font-weight: 500; }
.account-panel p { margin: 0 0 12px; color: var(--ink-soft); }
.account-panel .muted { font-size: 0.8rem; }
.account-panel form { display: grid; gap: 8px; margin-top: 12px; }
.account-panel label { display: grid; gap: 4px; font-size: 0.76rem; color: var(--ink-soft); }
.account-panel input {
  padding: 8px 10px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
}
.account-panel input:focus-visible, .button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--yellow);
  border-radius: 999px;
  background: var(--yellow);
  color: var(--night);
  font: inherit;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button.quiet { background: transparent; border-color: var(--panel-edge); color: var(--ink); }
.button.quiet:hover { border-color: rgba(169, 139, 255, 0.6); }

/* ---- what signed-in visitors see: the detail behind each moment ---- */

.team .moments { width: min(390px, calc(100vw - 28px)); pointer-events: auto; }
.team .moments li {
  align-items: flex-start;
  padding: 7px 8px 7px 12px;
  border-radius: 14px;
  font-size: 0.82rem;
}
.team .moments li::before { margin-top: 0.42em; }
.team .moments li:nth-child(n) { opacity: 1; }
.team .moments li:nth-child(4) { opacity: 0.8; }
.team .moments li:nth-child(5) { opacity: 0.55; }
.team .moments:hover li { opacity: 1; }
.moments .what { flex: 1; min-width: 0; }
.moments .scheme { font-weight: 700; }
.moments .meta { display: block; margin-top: 1px; font-size: 0.74rem; color: var(--ink-soft); }
.moments a.open {
  flex: none;
  align-self: center;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: color 0.2s, background 0.2s;
}
.moments a.open:hover, .moments a.open:focus-visible { color: var(--night); background: var(--yellow); outline: none; }
.moments a.open svg { width: 15px; height: 15px; fill: currentColor; }

/* A word above the house a moment came from. */
.tags { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.tags span {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(22, 16, 58, 0.8);
  border: 1px solid var(--panel-edge);
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
  animation: tag-rise 2.6s ease-out forwards;
}
.tags b { color: var(--yellow); font-weight: 700; }
@keyframes tag-rise {
  0% { opacity: 0; margin-top: 8px; }
  12% { opacity: 1; margin-top: 0; }
  75% { opacity: 1; }
  100% { opacity: 0; margin-top: -26px; }
}

/* ---- arrival ---- */

.veil {
  position: fixed;
  inset: 0;
  background: var(--night);
  pointer-events: none;
  transition: opacity 2.4s ease-out;
}
.ready .veil { opacity: 0; }

.greeting, .moments, .spirit, .controls, .tags {
  opacity: 0;
  transition: opacity 1.6s ease-out 1.2s, transform 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) 1.2s;
}
.greeting { transform: translateY(-10px); }
.ready .greeting, .ready .moments, .ready .spirit, .ready .controls, .ready .tags {
  opacity: 1;
  transform: none;
}

@media (max-width: 640px) {
  .spirit { width: min(210px, 52vw); padding: 10px 12px; }
  .moments { width: calc(100vw - min(210px, 52vw) - 40px); }
  .moments li { font-size: 0.74rem; padding: 6px 10px; }
  .moments li:nth-child(n + 3) { display: none; }
  .team .moments { width: calc(100vw - 28px); bottom: calc(max(env(safe-area-inset-bottom), 14px) + 96px); }
  .team .moments li:nth-child(n + 4) { display: none; }
  .team .moments li:nth-child(3) { display: flex; }
  .count { font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .moments li { animation: none; }
  .tags span { animation-duration: 2.6s; animation-timing-function: step-end; }
  .veil, .greeting, .moments, .spirit, .controls { transition-duration: 0.01s; transition-delay: 0s; }
}
