:root {
  --bg: #121015; --panel: #1d1922; --panel2: #262130; --line: #3a3244;
  --ink: #efe6d8; --muted: #9a90a3; --blood: #c0262f; --blood2: #8e1b22;
  --gold: #c9a35a; --green: #5fa36b; --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; min-height: 100vh; background: transparent; }
/* Mistvale at night behind every screen: the moon rising over the rooftops in the fog (art/backgrounds, option A).
   A fixed layer rather than background-attachment: fixed, which iPhones ignore. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--bg) url(/img/bg.svg) center bottom / cover no-repeat; pointer-events: none; }
h1, h2, h3, .display { font-family: Cinzel, Georgia, serif; letter-spacing: .04em; margin: 0; }
h1 { font-size: 34px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
#app { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(120px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
/* Phones with a notch or Dynamic Island: content stays clear of it and of the home bar; the background still fills the screen. */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

button, .btn {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; min-height: 46px;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--blood); border-color: var(--blood); color: #fff; }
button.gold { background: var(--gold); border-color: var(--gold); color: #1a1408; }
button.ghost { background: transparent; }
button.full { width: 100%; }
button.chip { min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: 14px; }
button.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
input {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; width: 100%; min-height: 46px;
}
input.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; font-size: 22px; }
label.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: 40px; color: var(--ink); }
.hero .logo { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; border-radius: var(--radius); }
/* The living logo (public/logo.js): everything moves slowly and only a little. */
.logo-anim { aspect-ratio: 900 / 420; }
.logo-anim .bell { transform-box: view-box; transform-origin: 450px 113.5px; animation: lgBell 7s ease-in-out infinite alternate; }
.logo-anim .fog-a { animation: lgFogA 70s ease-in-out infinite alternate; }
.logo-anim .fog-b { animation: lgFogB 52s ease-in-out infinite alternate; }
.logo-anim .bird { transform-box: view-box; }
.logo-anim .b1 { animation: lgFly1 46s linear infinite; animation-delay: -16s; }
.logo-anim .b2 { animation: lgFly2 58s linear infinite; animation-delay: -12s; }
.logo-anim .b3 { animation: lgFly3 72s linear infinite; animation-delay: -55s; }
.logo-anim .wings { transform-box: fill-box; transform-origin: center; animation: lgFlap .9s ease-in-out infinite alternate; }
.logo-anim .b2 .wings { animation-duration: 1.1s; }
.logo-anim .b3 .wings { animation-duration: 1.3s; }
.logo-anim .flicker { opacity: 0; animation: lgFlicker 9s infinite; }
.logo-anim .f2 { animation-duration: 13s; animation-delay: -4s; }
.logo-anim .f3 { animation-duration: 11s; animation-delay: -7s; }
@keyframes lgBell { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes lgFogA { from { transform: translateX(-80px); } to { transform: translateX(80px); } }
@keyframes lgFogB { from { transform: translateX(70px); opacity: .6; } to { transform: translateX(-70px); opacity: 1; } }
@keyframes lgFly1 { from { transform: translate(-30px, 98px); } to { transform: translate(930px, 66px); } }
@keyframes lgFly2 { from { transform: translate(930px, 58px); } to { transform: translate(-30px, 84px); } }
@keyframes lgFly3 { from { transform: translate(-30px, 140px); } to { transform: translate(930px, 112px); } }
@keyframes lgFlap { from { transform: scaleY(1); } to { transform: scaleY(.25); } }
@keyframes lgFlicker { 0%, 40%, 72%, 100% { opacity: 0; } 46% { opacity: .35; } 52% { opacity: .08; } 58% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .logo-anim * { animation: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hero .subtitle { font-family: Cinzel, Georgia, serif; color: var(--gold); letter-spacing: .12em; text-transform: uppercase; font-size: 14px; margin-top: 4px; }
.story { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 4px 2px 16px; }
.story p { margin: 0 0 10px; }
.overlay .story { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; color: var(--ink); }
.credits h3 { margin-bottom: 8px; }
.credits p { font-size: 13px; color: var(--muted); margin: 0 0 10px; overflow-wrap: anywhere; }
.story .tagline { color: var(--ink); font-weight: 600; text-align: center; margin: 14px 0 0; }
.sigil { font-size: 44px; line-height: 1; margin-bottom: 8px; }

.roomcode { font-family: Cinzel, serif; font-size: 44px; letter-spacing: .25em; text-align: center; color: var(--gold); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 200px; height: 200px; margin: 10px auto; display: flex; align-items: center; justify-content: center; }
.qr img, .qr svg { width: 100%; height: 100%; }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: #555; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag.gm { color: var(--gold); border-color: var(--gold); }
.tag.dead { color: var(--blood); border-color: var(--blood); }
.tag.speak { color: #fff; background: var(--blood); border-color: var(--blood); }
.dead-name { text-decoration: line-through; color: var(--muted); }

.role-card { border-radius: var(--radius); padding: 18px; text-align: center; border: 1px solid var(--line); }
.role-card.monster { background: linear-gradient(160deg, #3a0d12, #1d1922); border-color: var(--blood); }
.role-card.hunter { background: linear-gradient(160deg, #1d2a22, #1d1922); border-color: var(--green); }
.role-card.gm { background: linear-gradient(160deg, #3a2f17, #1d1922); border-color: var(--gold); }
.role-card.thrall { background: linear-gradient(160deg, #2a1230, #1d1922); border-color: #8a4a9a; }
.role-card.vanhelsing { background: linear-gradient(160deg, #142838, #1d1922); border-color: #5a8db0; }
.role-card .display { font-size: 26px; }
.role-card { overflow: hidden; }
.role-card .role-pic { display: block; width: calc(100% + 36px); height: auto; margin: -18px -18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }

/* minmax(0, 1fr): a long word ("Slaughterhouse") must never widen a column past the screen */
.cards { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.card {
  border-radius: 12px; padding: 10px 8px; border: 1px solid var(--line); background: var(--panel2); text-align: left;
  min-height: 64px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; line-height: 1.25; min-width: 0;
}
.card .pic { flex: none; width: 40px; height: 40px; }
/* Name and category sit together, centred beside the picture. A name with a word too long for the card is
   shrunk to fit by fitCardNames() in app.js; only if it still won't fit does the word break, with a hyphen. */
.card .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.card .name.break { overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
/* Small phones: a little more room for the card names */
@media (max-width: 420px) { .panel { padding: 12px; } .card { gap: 6px; } .card .pic { width: 36px; height: 36px; } }
.card .cat { font-size: 11px; color: var(--muted); font-weight: 500; }
.card.weapon { border-left: 4px solid #8b8fa3; }
.card.lair { border-left: 4px solid #6b8f6f; }
button.card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.card.solution { border-color: var(--blood); box-shadow: 0 0 0 2px var(--blood) inset; }

.topbar { position: sticky; top: 0; z-index: 5; background: rgba(18, 16, 21, .9); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: calc(10px + env(safe-area-inset-top)) 0 10px; margin-top: calc(-1 * env(safe-area-inset-top)); border-bottom: 1px solid var(--line); margin-bottom: 12px; min-height: 58px; }
.timer { flex: none; font-family: Cinzel, serif; font-size: 30px; font-variant-numeric: tabular-nums; color: var(--gold); }
.timer.low { color: var(--blood); }
.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tabs button { flex: 1; min-height: 40px; padding: 8px; }
.tabs button.on { background: var(--ink); color: var(--bg); }

.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile.fixed { border-color: var(--gold); }
.tile.new { box-shadow: 0 0 0 2px var(--blood) inset; }
.tile h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile h3 .ticon { flex: none; width: 32px; height: 32px; }
.opts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.opt { font-size: 13px; font-weight: 600; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; position: relative; color: var(--ink); }
.opt.marked { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.opt .ord { position: absolute; top: -7px; right: -5px; background: var(--blood); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 6px; }
button.opt { cursor: pointer; }

.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); width: min(528px, calc(100% - 32px)); z-index: 6; box-shadow: 0 8px 30px rgba(0,0,0,.6); }
.overlay { position: fixed; inset: 0; background: #0b090d; z-index: 20; overflow: auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.overlay .inner { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top)); z-index: 30; background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.6); }
.toast.bad { border-color: var(--blood); }
.banner { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); background: var(--panel2); }
.banner.dead { border-color: var(--blood); background: #2a0f13; }
.banner.speak { border-color: var(--gold); }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.log li.death { color: #ff8a8f; }
.log li.win { color: var(--gold); }
.log li.phase { color: var(--muted); font-style: italic; }
.result { text-align: center; padding: 24px 12px; border-radius: var(--radius); }
.result.hunters { background: linear-gradient(160deg, #1d2a22, #121015); border: 1px solid var(--green); }
.result.monster { background: linear-gradient(160deg, #3a0d12, #121015); border: 1px solid var(--blood); }
.result h1 { font-size: 30px; }

/* hints */
.tile.removed { opacity: .45; filter: grayscale(1); }
.timer.paused { color: var(--muted); }
.countdown { padding-top: 24px; }
.countdown-num { font-family: Cinzel, serif; font-size: 72px; line-height: 1.1; color: var(--gold); }
.countdown .story { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; color: var(--ink); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fade-in 1s ease-out both; }
.card-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-bottom: 4px; }
.tag.sus { color: var(--gold); border-color: var(--gold); }
.qmarks { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--gold); }
button.card.qmine, .card.qmarked { border-color: var(--gold); }
button.card.qmine { box-shadow: 0 0 0 2px var(--gold) inset; }
.tip { font-size: 15px; font-weight: 600; color: var(--gold); margin-bottom: 6px; }
.secret { font-weight: 700; color: var(--gold); margin-bottom: 0; }

/* the "time for the hunt" button pulses */
.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192,38,47,.7); } 50% { box-shadow: 0 0 0 14px rgba(192,38,47,0); } }

/* a hunt playing out on every phone */
.overlay.hunt { display: flex; align-items: center; background: #0b090d; }
.overlay.hunt .inner { width: 100%; }
.hunt-who h1 { font-size: 40px; color: var(--gold); }
.hunt-who .display { font-size: 22px; }
.hunt-guess .cards { margin: 10px 0 6px; }
.hunt-result { border-radius: var(--radius); padding: 18px; }
.hunt-result h1 { font-size: 44px; }
.hunt-result.right { background: #1d2a22; border: 1px solid var(--green); }
.hunt-result.wrong { background: #3a0d12; border: 1px solid var(--blood); }
.enter { animation: enter .5s ease-out; }
@keyframes enter { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }/* The lobby tutorial (public/tutorial.js). */
.tut-list { margin: 0; padding-left: 20px; }
.tut-list li + li { margin-top: 10px; }
.overlay.tutorial .role-card { text-align: left; }
.overlay.tutorial .role-card .display { text-align: center; margin-bottom: 6px; }
/* Lobby: big games are urged to add the Thrall. */
.suggest { border: 1px solid var(--blood); background: #2a0f13; border-radius: var(--radius); padding: 10px 12px; }
.suggest-note { font-size: 14px; margin-bottom: 8px; }
.suggest .chip { border-color: var(--blood); box-shadow: 0 0 0 2px var(--blood); }
/* Kalei Games page (public/kalei.js) */
.kg-card { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kg-icon { width: 64px; height: 64px; border-radius: 14px; flex: none; }
.kg-name { font-weight: 700; }
.kg-get { flex: none; font-weight: 700; color: #1b1b1b; background: var(--gold); border-radius: 999px; padding: 8px 18px; text-decoration: none; }
/* Host Unlock box in the host's lobby */
.unlock { border-color: var(--gold, #c9a45c); }
.unlock.on { font-size: 14px; }
