:root {
  --bg: #10080c;
  --ink: #f4ead8;
  --muted: #b7a394;
  --gold: #e0c17a;
  --line: rgba(224, 193, 122, 0.32);
  --wine: #8e243c;
  --paper: #f3e6c8;
  --paper-ink: #2a160f;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(420px 280px at 110% -10%, rgba(224, 193, 122, 0.16), transparent 60%),
    radial-gradient(280px 220px at -10% 20%, rgba(142, 36, 60, 0.2), transparent 70%),
    linear-gradient(#140a0e, #10080c 40%, #0b0709);
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.top, main, #banner, #dock, #tabs { position: relative; z-index: 1; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
  max-width: 920px;
  margin: 0 auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.crest-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(243, 230, 200, 0.35);
}
body[data-phase="midnight"] .crest-mark,
body[data-phase="reveal"] .crest-mark { animation: flicker 2.8s infinite; }
.seal-inline {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 8px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
}
.hero {
  margin: 0 -22px 0;
}
.hero img,
.scene {
  width: 100%;
  display: block;
  object-fit: cover;
}
.hero img {
  height: min(46vw, 280px);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}
.scene {
  height: 168px;
  border-radius: 18px;
}
.how { text-align: left; background: #1a1014; border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 16px; }
.how ol { margin: 8px 0 0; padding-left: 1.25em; display: grid; gap: 8px; }
.how li { font-family: var(--serif); font-size: 18px; }
.you-now { text-align: center; padding-top: 8px; }
.you-now h2 { font-size: clamp(36px, 9vw, 56px); line-height: 0.95; margin: 0 0 6px; }
.do-this {
  text-align: center;
  background: linear-gradient(180deg, rgba(142, 36, 60, 0.34), rgba(255, 248, 236, 0.03));
  border: 1px solid rgba(224, 193, 122, 0.5);
  border-radius: 22px;
  padding: 18px 16px 16px;
}
.do-this h3 { font-size: clamp(34px, 9vw, 52px); line-height: 0.95; margin: 0 0 8px; }
.ask-box {
  text-align: left;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 16px;
  padding: 14px 14px 6px;
  margin: 12px 0;
  font-family: var(--serif);
  font-size: 18px;
}
.ask-box .kicker, .ask-box p { color: #7c1c32; }
.ask-box p:last-child { color: var(--paper-ink); }
@keyframes flicker {
  0%, 100% { filter: brightness(1); }
  45% { filter: brightness(1.15); }
  50% { filter: brightness(0.75); }
  55% { filter: brightness(1.05); }
}
.eyebrow {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 11px;
}
.phase { margin: 0; font-family: var(--serif); font-size: 18px; }
#sound {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--gold);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 12px;
}
main {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 16px 28px;
}
body.has-tabs main { padding-bottom: calc(108px + var(--safe-b)); }
body.has-dock.has-tabs main { padding-bottom: calc(176px + var(--safe-b)); }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: clamp(40px, 10vw, 68px); line-height: 0.95; margin: 8px 0; }
h2 { font-size: 32px; margin: 0 0 8px; }
h3 { font-size: 22px; margin: 0 0 6px; }
p { margin: 0 0 10px; overflow-wrap: break-word; }
summary { cursor: pointer; min-height: 44px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.error {
  background: rgba(142, 36, 60, 0.25);
  border: 1px solid rgba(196, 72, 96, 0.5);
  padding: 10px 12px;
  border-radius: 12px;
}

.wax, .ghost, .row, .letter, .tab, .tiny {
  border-radius: 14px;
}
.wax, .ghost, .tiny, .row, .letter, .tab, .seal {
  border: 0;
  text-align: left;
}
.wax {
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  text-align: center;
  color: #f8ead8;
  background: radial-gradient(circle at 30% 0%, #c44860, #7c1c32 55%, #4c101c);
  box-shadow: inset 0 0 0 1px rgba(243, 230, 200, 0.18), 0 10px 24px rgba(80, 10, 20, 0.35);
  letter-spacing: 0.03em;
}
.ghost, .tiny {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  text-align: center;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line) !important;
}
.tiny { min-height: 42px; width: auto; }
.stack { display: grid; gap: 10px; }
.stack.tight { gap: 6px; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }
input, textarea, select {
  width: 100%;
  font-size: 16px;
  background: #160d11;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
textarea { min-height: 110px; resize: vertical; }
.gate { max-width: 460px; margin: 0 auto; padding-top: 4vh; }
.invite {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--paper);
}
.code {
  font-family: var(--serif);
  font-size: clamp(52px, 16vw, 84px);
  letter-spacing: 0.18em;
  margin: 0;
  line-height: 1;
}
.hostline {
  font-size: clamp(28px, 6vw, 40px);
  font-family: var(--serif);
  margin: 0;
  word-break: break-word;
}
.qr {
  width: min(100%, 280px);
  background: var(--paper);
  padding: 10px;
  border-radius: 16px;
}
.card, .paperish {
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.04), rgba(255, 248, 236, 0.02));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.invitation {
  background:
    radial-gradient(400px 120px at 50% 0%, rgba(224, 193, 122, 0.14), transparent 60%),
    #1a1014;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 18px;
  text-align: center;
}
.invitation h2 { font-size: clamp(32px, 8vw, 46px); }
.secret {
  margin-top: 12px;
  text-align: left;
  background: #2a1016;
  border: 1px solid rgba(196, 72, 96, 0.55);
  border-radius: 16px;
  padding: 14px;
}
.person, .letter {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 12px;
  background: #180e12;
  border: 1px solid rgba(224, 193, 122, 0.16);
  color: inherit;
}
.person { grid-template-columns: 1fr; align-items: center; }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions .tiny { flex: 1; }
.mission.done { opacity: 0.72; }
.person small, .letter em { color: var(--muted); font-style: normal; font-size: 13px; }
.person.off { opacity: 0.55; }
.letter.unseen { border-color: rgba(196, 72, 96, 0.8); }
.letter[data-kind="voorwerp"] { background: #1c1610; }
.letter[data-kind="vloek"] { background: #241016; }
.kicker { color: var(--gold); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 3px 3px 16px 3px;
  padding: 22px 18px 26px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
}
.paper .kicker, .paper h2, .paper p { color: var(--paper-ink); }
.paper .kicker { color: #7c1c32; }
#banner:not([hidden]) { display: block; }
#banner {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px 8px;
}
#banner button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: #f3e6c8;
  color: #4c101c;
  font-family: var(--serif);
  font-size: 18px;
}
#dock:not([hidden]) { display: block; }
#dock {
  position: fixed;
  z-index: 6;
  left: 0; right: 0;
  bottom: calc(62px + var(--safe-b));
  padding: 8px 16px 0;
  background: linear-gradient(transparent, #10080c 30%);
}
#tabs:not([hidden]) { display: flex; }
#tabs {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(16, 8, 12, 0.94);
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  flex: 1 0 auto;
  min-height: 44px;
  min-width: 64px;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  text-align: center;
  padding: 8px;
}
.tab.on { color: var(--paper); background: rgba(224, 193, 122, 0.12); }
#overlay[hidden], #banner[hidden], #tabs[hidden], #dock[hidden] { display: none !important; }
#overlay:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 3, 4, 0.78);
  display: grid;
  place-items: end center;
  padding: 12px;
}
.sheet, .seal-screen {
  width: min(560px, 100%);
  max-height: min(92dvh, 900px);
  overflow: auto;
  background: #160d11;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 16px calc(18px + var(--safe-b));
}
.seal-screen { text-align: center; place-self: center; padding: 32px 18px; }
.seal {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  margin: 12px auto;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 68px;
  background: #2a1014;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.seal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seal:active { transform: scale(0.98); }
.shake { animation: shake 0.45s linear; }
@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
.badge-screen {
  place-self: center;
  width: min(560px, 100%);
  text-align: center;
  padding: 28px 18px;
}
.badge-screen h2 { font-size: clamp(36px, 9vw, 58px); }
#toasts {
  position: fixed;
  z-index: 40;
  left: 16px; right: 16px;
  bottom: calc(16px + var(--safe-b));
  display: grid;
  gap: 8px;
  pointer-events: none;
}
body.has-tabs #toasts { bottom: calc(126px + var(--safe-b)); }
.toast {
  justify-self: center;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 999px;
  padding: 10px 16px;
  max-width: 520px;
}
.reveal h2 { font-size: clamp(40px, 10vw, 64px); line-height: 0.95; }
.verdict { font-family: var(--serif); font-size: 22px; }
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.board li, .proofs li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(224, 193, 122, 0.16);
}
.proofs { padding-left: 18px; }
.proofs li { display: list-item; }
.split { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.row-actions { display: flex; gap: 8px; }
.choice.on { outline: 2px solid var(--gold); }
@media (min-width: 860px) {
  .lobby-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px; align-items: start; }
  .gate { padding-top: 8vh; }
}
body.vigil .top,
body.vigil #tabs,
body.vigil #banner,
body.vigil #dock { display: none !important; }
body.vigil main {
  min-height: 100dvh;
  display: block;
  max-width: 560px;
  padding: 0 0 28px;
}
.vigil-screen {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 0 22px calc(36px + env(safe-area-inset-bottom));
  text-align: center;
}
.vigil-screen .seal-inline { margin-top: -48px; }
.vigil-kicker {
  margin: 8px 0 18px;
  font-family: var(--serif);
  font-size: clamp(28px, 8vw, 44px);
  letter-spacing: 0.01em;
  line-height: 1.05;
}
.vigil-ring {
  width: min(280px, 78vw);
  height: min(280px, 78vw);
  margin: 8px auto 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(224, 193, 122, 0.5);
  box-shadow:
    0 0 0 10px rgba(142, 36, 60, 0.16),
    0 0 50px rgba(142, 36, 60, 0.28),
    inset 0 0 40px rgba(0, 0, 0, 0.45);
  animation: ember 4.8s ease-in-out infinite;
}
.remain {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(56px, 16vw, 84px);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
}
.remain-label {
  margin: 8px 0 0;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 10px;
}
.vigil-screen h1 {
  font-size: clamp(26px, 7vw, 40px);
  line-height: 1.15;
  margin: 0 0 14px;
}
.vigil-story {
  display: grid;
  gap: 12px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 18px;
}
.vigil-story p { margin: 0; }
.vigil-key { margin-top: 26px; opacity: 0.92; }
.trial {
  margin: 12px auto 0;
  display: block;
  opacity: 0.72;
}
.vigil-key input {
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(224, 193, 122, 0.4);
  border-radius: 0;
  text-align: center;
  letter-spacing: 0.24em;
  font-family: var(--serif);
  font-size: 22px;
}
@keyframes ember {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
.code-label { font-family: var(--serif); }
.code-input {
  font-family: var(--serif);
  font-size: clamp(40px, 12vw, 64px);
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 0 12px;
}
.mutter {
  margin: 18px 0 0;
  color: #c44860;
  font-family: var(--serif);
  font-style: italic;
  min-height: 1.4em;
}
#overlay.veil {
  background: #070405;
  place-items: center;
  padding: 0;
}
.safe-screen, .hold {
  width: min(520px, 100%);
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 14px;
  text-align: center;
  padding: 28px 22px calc(28px + var(--safe-b));
}
.safe-screen h2, .hold h2 { font-size: clamp(36px, 10vw, 60px); }
.hold .paper { text-align: left; }
.paper .warn { color: #7c1c32; font-family: var(--serif); }
.secret { animation: slam 0.35s ease; }
@keyframes slam {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .crest-mark, .shake, .seal, .secret, .vigil-ring { animation: none; }
}
