:root {
  --bg: #06070b;
  --ink: #f4eee7;
  --ink-soft: rgba(244, 238, 231, 0.7);
  --ink-faint: rgba(244, 238, 231, 0.56); /* the faintest text that still reads (4.5:1) */
  --line: rgba(244, 238, 231, 0.12);
  --line-strong: rgba(244, 238, 231, 0.26);
  --panel: rgba(11, 13, 20, 0.74);
  --warm: #ffc9b5;
  --me: #ff9fb6;
  --them: #8fc8ff;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* The page scrolls like any other: the top bar first, the dock at the bottom of the
   screen when there's room and below it when there isn't. The stage, the words of a
   moment, history and joining stay fixed over it. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Top bar */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 32px);
  transition: opacity 0.8s ease;
}

.brand {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: 0.01em;
}

.presence {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  font-size: 14px;
  color: var(--ink-soft);
}

.person {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.person > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--me);
  box-shadow: 0 0 12px var(--me);
}

.them .dot {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--ink-faint);
}

.presence.together .them .dot {
  background: var(--them);
  box-shadow: 0 0 12px var(--them);
}

.thread {
  flex: none;
  width: 40px;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--ink-faint) 0 3px, transparent 3px 7px);
}

.presence.together .thread {
  background: linear-gradient(90deg, var(--me), var(--them));
  animation: thread 2.6s ease-in-out infinite;
}

@keyframes thread {
  50% {
    opacity: 0.4;
  }
}

.ghost {
  flex: none;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  color: var(--ink-soft);
  transition: border-color 0.2s, color 0.2s;
}

.ghost:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

.actions {
  display: flex;
  flex: none;
  gap: 10px;
}

.count:not(:empty) {
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(244, 238, 231, 0.12);
  font-size: 12px;
}

/* What plays over the stage */

.caption,
.letter {
  position: fixed;
  left: 50%;
  top: 13vh;
  z-index: 1;
  width: min(calc(100vw - 32px), 720px);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(20px, 2.4vw, 26px);
  color: var(--ink-soft);
  transition: opacity 1s ease;
}

.letter {
  transition: opacity 1.4s ease;
}

.caption.show,
.letter.show {
  opacity: 1;
}

.words {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1.25;
  text-shadow: 0 0 24px rgba(6, 7, 11, 0.9);
}

.letter.long .words {
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.35;
}

.words .bit {
  color: var(--ink-faint);
}

.signature {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  color: var(--ink-soft);
}

/* The dock where moments are chosen */

.dock {
  position: relative;
  z-index: 2;
  width: min(calc(100vw - 32px), 760px);
  margin: auto auto max(20px, env(safe-area-inset-bottom));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

body.playing .dock {
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
}

body.playing .topbar {
  opacity: 0.3;
}

.dock-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
}

.text-input {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.2s;
}

.text-input::placeholder {
  color: var(--ink-faint);
}

.text-input:focus {
  outline: none;
  border-color: var(--warm);
}

.note {
  display: block;
}

.moments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.moment {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}

.moment:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-2px);
}

.moment canvas {
  display: block;
  width: 100%;
  height: 112px;
}

.moment-text {
  display: block;
  padding: 12px 16px 16px;
}

.moment-title {
  display: block;
  font-family: var(--serif);
  font-size: 23px;
}

.moment-line {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-faint);
}

/* On their birthday: one more moment, just for today */

#them-name.birthday::after {
  content: " · birthday today";
  color: var(--warm);
}

.special {
  margin-top: 14px;
}

.moment-special {
  flex-direction: row;
  width: 100%;
  border-color: rgba(255, 201, 181, 0.45);
  background: rgba(255, 201, 181, 0.05);
}

.moment-special:hover {
  border-color: rgba(255, 201, 181, 0.7);
  background: rgba(255, 201, 181, 0.09);
}

.moment-special canvas {
  flex: none;
  width: 44%;
  height: 128px;
}

.moment-special .moment-text {
  align-self: center;
}

.badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 9px;
  border: 1px solid rgba(255, 201, 181, 0.45);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm);
}

.hint {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
  overflow-wrap: anywhere;
}

/* The room's history, like a conversation */

.history {
  position: fixed;
  top: 76px;
  right: clamp(16px, 3vw, 32px);
  bottom: 20px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  transition: opacity 0.6s ease;
}

body.playing .history {
  opacity: 0;
  pointer-events: none;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 20px;
}

.history-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 23px;
}

.close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
}

.close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.history-thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 8px 16px 18px;
  overflow-y: auto;
  list-style: none;
}

.bubble {
  max-width: 86%;
  padding: 10px 14px 9px;
  border: 1px solid color-mix(in srgb, var(--who) 40%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--who) 7%, transparent);
}

.bubble.mine {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.bubble.theirs {
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.bubble-title {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
}

.bubble-note {
  margin: 5px 0 6px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bubble-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-faint);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--warm);
}

.link-button:hover {
  text-decoration: underline;
}

.history-empty {
  margin: 0;
  padding: 0 20px 22px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* Joining */

.join {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: safe center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(6, 7, 11, 0.5);
}

.join-card {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.join-card h2 {
  margin: 0 0 26px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.1;
}

.field {
  display: block;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.field-note {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.error {
  margin: -6px 0 14px;
  font-size: 13px;
  color: #ffb0a8;
}

.characters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.character {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.character:hover {
  border-color: var(--line-strong);
}

.character input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.character canvas {
  display: block;
  width: 100%;
  height: 104px;
}

.character-name {
  display: block;
  padding: 8px 14px 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.character:has(input:checked) {
  border-color: var(--warm);
  background: rgba(255, 201, 181, 0.06);
}

.character:has(input:checked) .character-name {
  color: var(--ink);
}

.character:has(input:focus-visible) {
  outline: 2px solid var(--warm);
  outline-offset: 3px;
}

.error:empty {
  display: none;
}

.swatches {
  display: flex;
  gap: 12px;
}

.swatch {
  position: relative;
  cursor: pointer;
}

.swatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.2s;
}

.swatch input:checked + .swatch-dot {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c);
}

.swatch input:focus-visible + .swatch-dot {
  outline: 2px solid var(--warm);
  outline-offset: 6px;
}

.primary {
  width: 100%;
  margin-top: 6px;
  padding: 13px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  font-size: 15px;
  transition: background 0.2s;
}

.primary:hover {
  background: #fff;
}

@media (max-width: 600px) {
  .brand,
  .thread {
    display: none;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .presence {
    padding: 7px 12px;
    font-size: 13px;
  }

  .ghost {
    padding: 7px 12px;
    font-size: 13px;
  }

  .history {
    inset: 12px;
    width: auto;
  }

  .dock {
    padding: 16px;
    border-radius: 20px;
  }

  .dock-title {
    font-size: 22px;
  }

  .moments {
    grid-template-columns: 1fr 1fr;
  }

  .moment canvas {
    height: 96px;
  }

  .moment-line {
    display: none;
  }
}

/* Shorter laptop screens: smaller cards, so the dock usually fits without scrolling. */
@media (min-width: 601px) and (max-height: 780px) {
  .dock {
    padding: 18px 20px;
  }

  .dock-title {
    margin-bottom: 10px;
    font-size: 23px;
  }

  .moments {
    margin-top: 10px;
  }

  .moment canvas {
    height: 84px;
  }

  .moment-special canvas {
    height: 96px;
  }

  .moment-text {
    padding: 9px 14px 11px;
  }

  .moment-title {
    font-size: 20px;
  }
}

/* For people who've asked their device for less motion: no hover lift, no pulsing
   thread, quicker fades. (The stage drops its drifting rain and firework flashes, and
   notes appear without flickering bits.) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.2s !important;
  }

  .moment:hover {
    transform: none;
  }
}
