/* Mafia Night: film-noir theme.
   Phases recolor the whole page through body[data-phase]: night is cold moonlight and rain,
   day is warm tobacco light, the vote turns blood red. */
:root {
  --ink: #0b0a09;
  --ink-2: #15120f;
  --ink-3: #1e1a16;
  --surface: rgba(255, 238, 214, 0.045);
  --surface-2: rgba(255, 238, 214, 0.085);
  --line: rgba(255, 228, 190, 0.11);
  --line-2: rgba(255, 228, 190, 0.2);
  --text: #f2e9da;
  --muted: #b3a690;
  --faint: #776c5d;
  --paper: #e8dcc2;
  --paper-2: #d6c6a4;
  --paper-ink: #2a2018;
  --blood: #b3122e;
  --blood-hi: #e2384f;
  --blood-glow: rgba(226, 56, 79, 0.45);
  --gold: #c9a45c;
  --gold-hi: #ecd096;
  --doctor: #4fc395;
  --detective: #79a9ff;
  --villager: #d9c49c;
  --mafia: #e2384f;
  --moon: #b8cdf2;
  --accent: var(--gold);
  --accent-hi: var(--gold-hi);
  --radius: 18px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --type: 'Special Elite', 'Courier New', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation; /* no double-tap zoom on buttons; pinch zoom still works */
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ======================================================================
   Atmosphere
   ====================================================================== */
.atmo { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 55% at 50% -8%, rgba(255, 214, 160, 0.16), transparent 70%),
    radial-gradient(120% 90% at 50% 120%, rgba(179, 18, 46, 0.14), transparent 60%),
    linear-gradient(180deg, #17120e 0%, var(--ink) 70%);
  transition: opacity 1.2s;
}
.sky::after { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s; }
body[data-phase="night"] .sky::after, body[data-phase="reveal"] .sky::after {
  opacity: 1;
  background:
    radial-gradient(55% 40% at 80% 6%, rgba(160, 190, 255, 0.2), transparent 70%),
    linear-gradient(180deg, #0c1222 0%, #07090f 75%);
}
body[data-phase="day"] .sky::after, body[data-phase="dawn"] .sky::after {
  opacity: 1;
  background:
    radial-gradient(80% 50% at 50% -5%, rgba(255, 186, 102, 0.26), transparent 70%),
    linear-gradient(180deg, #24180e 0%, #120d09 75%);
}
body[data-phase="vote"] .sky::after, body[data-phase="verdict"] .sky::after {
  opacity: 1;
  background:
    radial-gradient(80% 55% at 50% -5%, rgba(226, 56, 79, 0.25), transparent 70%),
    linear-gradient(180deg, #230c0f 0%, #0e0708 75%);
}
.moon {
  position: absolute; top: calc(64px + var(--safe-top)); right: 9vw; width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #f4f7ff, #c3d2f0 55%, #8ea3cc);
  box-shadow: 0 0 60px 18px rgba(170, 196, 255, 0.22), 0 0 160px 40px rgba(150, 180, 255, 0.12);
  opacity: 0; transform: translateY(40px); transition: opacity 1.4s, transform 1.6s var(--ease-out);
}
.moon::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 64% 60%, rgba(90, 110, 150, 0.35) 0 9%, transparent 10%), radial-gradient(circle at 40% 70%, rgba(90, 110, 150, 0.25) 0 6%, transparent 7%), radial-gradient(circle at 56% 30%, rgba(90, 110, 150, 0.22) 0 5%, transparent 6%); }
body[data-phase="night"] .moon { opacity: 0.9; transform: none; }
body[data-screen="Home"] .moon { opacity: 0.55; transform: none; }

.smoke i {
  position: absolute; width: 70vmax; height: 40vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(220, 205, 185, 0.07), transparent);
  animation: drift 38s ease-in-out infinite alternate; will-change: transform;
}
.smoke i:nth-child(1) { left: -30vmax; top: 18vh; }
.smoke i:nth-child(2) { right: -34vmax; top: 48vh; animation-duration: 46s; animation-delay: -12s; }
.smoke i:nth-child(3) { left: -10vmax; bottom: -16vmax; animation-duration: 52s; animation-delay: -24s; }
@keyframes drift { to { transform: translate(24vmax, -4vmax) scale(1.15); } }
body[data-screen="Game"] .smoke i { animation-play-state: paused; }

.rain {
  position: absolute; inset: -20% 0 0; opacity: 0; transition: opacity 1.5s;
  background-image:
    repeating-linear-gradient(104deg, transparent 0 22px, rgba(190, 210, 255, 0.07) 22px 23px, transparent 23px 61px),
    repeating-linear-gradient(101deg, transparent 0 37px, rgba(190, 210, 255, 0.05) 37px 38px, transparent 38px 89px);
  background-size: 100% 260px, 100% 340px;
  animation: rain 0.9s linear infinite;
}
@keyframes rain { to { background-position: -60px 260px, -80px 340px; } }
body[data-phase="night"] .rain { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .rain, .smoke i { animation: none; } }

.skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 26vh; min-height: 140px; opacity: 0.85; }
.skyline .b { fill: #0f0d0b; }
.skyline .b2 { fill: #15120f; }
.skyline .w { fill: #f2c56b; opacity: 0; transition: opacity 1.6s; }
.skyline .w.on { opacity: 0.55; }
body[data-phase="night"] .skyline .w.on { opacity: 0.85; }
body[data-phase="day"] .skyline .w { opacity: 0 !important; }
body[data-screen="Game"] .skyline { opacity: 0.45; }

.grain {
  position: absolute; inset: 0; opacity: 0.09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.75) 100%); }

/* ======================================================================
   Base components
   ====================================================================== */
.screen { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; animation: screenIn 0.5s var(--ease-out); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } }

.card {
  background: linear-gradient(180deg, rgba(40, 33, 27, 0.82), rgba(22, 18, 15, 0.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 230, 190, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 50px; padding: 0 20px; border-radius: 14px;
  font-weight: 800; font-size: 16px; letter-spacing: 0.02em;
  transition: transform 0.15s var(--spring), filter 0.2s, opacity 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.42; pointer-events: none; }
.btn-big { height: 58px; font-size: 17px; width: 100%; border-radius: 16px; }
.btn-small { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn-primary {
  color: #fff4ea;
  background: linear-gradient(180deg, #d02340, #93091f);
  box-shadow: 0 14px 30px -12px var(--blood-glow), inset 0 1px 0 rgba(255, 200, 200, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  color: #2a1d0b;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  box-shadow: 0 12px 26px -14px rgba(201, 164, 92, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: linear-gradient(180deg, #d02340, #93091f); color: #fff; }
.btn-quiet-danger { width: 100%; height: 46px; margin-top: 8px; color: #e9909c; font-size: 15px; font-weight: 700; border-radius: 12px; }
.btn-quiet-danger:hover { background: rgba(226, 56, 79, 0.08); }
.btn-quiet-danger .ico { width: 18px; height: 18px; }
.link-btn { color: var(--muted); font-size: 15px; font-weight: 600; padding: 10px; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(255, 230, 190, 0.25); }
.link-btn.small { font-size: 13.5px; padding: 6px; }

.icon-btn { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); transition: transform 0.15s var(--spring), background 0.2s; }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.off { color: var(--faint); }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font: 13px var(--type); color: var(--muted); margin: 0 0 8px 4px; letter-spacing: 0.06em; text-transform: uppercase; }
.field input, .code-input {
  width: 100%; height: 54px; border-radius: 14px; padding: 0 16px;
  font: 700 17px var(--font); color: var(--text);
  background: rgba(0, 0, 0, 0.35); border: 1.5px solid var(--line); outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder, .code-input::placeholder { color: var(--faint); font-weight: 500; }
.field input:focus, .code-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201, 164, 92, 0.15); }

.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; } .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { opacity: 1; transform: translateY(-3px); } }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + var(--safe-top)) 14px 10px; }
.topbar-title { font: 800 19px var(--display); letter-spacing: 0.02em; }
#screenLobby .topbar { background: linear-gradient(180deg, rgba(11, 10, 9, 0.97) 70%, rgba(11, 10, 9, 0)); }

/* ======================================================================
   Home
   ====================================================================== */
.home-wrap { width: 100%; max-width: 420px; margin: 0 auto; padding: calc(34px + var(--safe-top)) 18px calc(30px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; flex: 1; }
.logo { width: 140px; height: 76px; margin-bottom: 6px; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.8)); animation: hatIn 1s var(--ease-out); }
.logo-hat { width: 100%; height: 100%; }
@keyframes hatIn { from { opacity: 0; transform: translateY(-24px) rotate(-8deg); } }
.brand { margin: 0; font: 900 64px/0.9 var(--display); letter-spacing: 0.08em; text-align: center; color: var(--text); text-shadow: 0 4px 0 #000, 0 0 40px rgba(226, 56, 79, 0.25); }
.brand-sub { display: block; margin-top: 8px; font: italic 700 18px var(--display); letter-spacing: 0.3em; color: var(--blood-hi); text-shadow: none; }
.brand-sub::before, .brand-sub::after { content: ""; display: inline-block; width: 0.9em; height: 2px; background: currentColor; vertical-align: middle; }
.brand-sub::before { margin-right: 0.6em; }
.brand-sub::after { margin-left: 0.3em; }
.tagline { margin: 14px 0 24px; font: 15px var(--type); color: var(--muted); text-align: center; letter-spacing: 0.02em; }
.home-card { width: 100%; padding: 22px 18px 18px; }
.home-card.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; font: 13px var(--type); color: var(--faint); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.code-input { flex: 1; min-width: 0; font: 22px var(--type); letter-spacing: 0.28em; text-align: center; text-transform: uppercase; }
.code-input::placeholder { letter-spacing: 0.2em; font-family: var(--type); font-size: 18px; }
.join-row .btn { height: 54px; padding: 0 22px; }
.form-msg { min-height: 20px; margin: 10px 2px 0; font-size: 14px; font-weight: 600; color: #f28a98; text-align: center; }
.form-msg.ok { color: var(--muted); }
.form-msg:empty { min-height: 0; margin: 0; }
.app-footer { margin-top: auto; padding-top: 22px; font: 12.5px var(--type); color: var(--faint); }
.app-footer .icon { color: var(--blood-hi); }

/* Cross-promo: other AppDoodle games. Home and game over only, never during play. */
.more-games { width: 100%; display: flex; align-items: center; gap: 14px; margin-top: 6px; padding: 12px 16px; border-radius: 14px; background: linear-gradient(180deg, rgba(40, 33, 27, 0.82), rgba(22, 18, 15, 0.88)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); color: var(--text); text-decoration: none; text-align: left; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
.more-games:hover { border-color: var(--line-2); }
.more-games:active { transform: scale(0.98); }
.more-games > .ico:first-child { width: 26px; height: 26px; color: var(--gold); }
.more-games-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.more-games-text b { font-size: 15px; }
.more-games-text small { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.more-games-go { width: 18px; height: 18px; color: var(--muted); }
.finish-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 4px; font-size: 14px; font-weight: 600; color: var(--gold-hi); text-decoration: none; }
.finish-more .ico { width: 16px; height: 16px; }
.app-footer a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255, 230, 190, 0.3); }

.resume { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; margin-bottom: 18px; border-radius: 14px; background: rgba(201, 164, 92, 0.12); border: 1px solid rgba(201, 164, 92, 0.35); }
.resume-info { flex: 1; }
.resume-label { font-size: 13px; color: var(--gold-hi); font-weight: 700; }
.resume-code { font: 20px var(--type); letter-spacing: 0.2em; }

.invite { text-align: center; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--line-2); }
.invite-label { font: 13px var(--type); text-transform: uppercase; letter-spacing: 0.14em; color: var(--blood-hi); }
.invite-code { font: 34px var(--type); letter-spacing: 0.24em; margin: 4px 0 10px; }
.invite-seats { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; min-height: 30px; }
.invite-seats .av { width: 30px; height: 30px; font-size: 13px; }
.invite-status { font-size: 14px; color: var(--muted); }
.invite-status.bad { color: #f2a1ac; }
.invite-alt { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 14px; }
#inviteWatchBtn { margin-top: 10px; }

/* ======================================================================
   Avatars
   ====================================================================== */
.av {
  --c: #777;
  position: relative; width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font: 800 21px var(--display); color: #fff8ef; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 70%, #fff 30%), var(--c) 55%, color-mix(in srgb, var(--c) 55%, #000 45%));
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 0 3.5px color-mix(in srgb, var(--c) 50%, transparent), 0 10px 20px -8px rgba(0, 0, 0, 0.9);
}
.av .presence { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: #3ccf7f; border: 2.5px solid var(--ink-2); }
.av.offline .presence { background: #6c645a; }
.av.big { width: 64px; height: 64px; font-size: 26px; }

/* ======================================================================
   Lobby
   ====================================================================== */
.lobby-wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 4px 16px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.code-card { padding: 18px 16px 16px; text-align: center; position: relative; overflow: hidden; }
.code-card::before { content: 'CASE NO.'; position: absolute; top: 12px; left: 16px; font: 11px var(--type); color: var(--faint); letter-spacing: 0.1em; }
.code-label { font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); }
.room-code { display: block; margin: 4px auto 12px; font: 44px var(--type); letter-spacing: 0.24em; padding-left: 0.24em; color: var(--paper); text-shadow: 0 0 22px rgba(236, 208, 150, 0.25); }
.code-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.qr-box { width: 180px; height: 180px; margin: 14px auto 2px; padding: 10px; background: var(--paper); border-radius: 12px; }
.qr-box svg { width: 100%; height: 100%; }
.qr-box svg rect { fill: var(--paper); }
.qr-box svg path { fill: var(--paper-ink); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 4px 0; }
.section-head h2 { margin: 0; font: 800 22px var(--display); }
.section-head .count { font: 15px var(--type); color: var(--muted); margin-left: 6px; }
.section-note { font-size: 13px; color: var(--gold-hi); font-weight: 700; }

.lobby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.l-seat {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  animation: seatIn 0.45s var(--spring) both;
}
.l-seat.me { border-color: rgba(201, 164, 92, 0.45); background: rgba(201, 164, 92, 0.08); }
.l-seat .name { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.l-seat .tag { font: 10.5px var(--type); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-hi); }
.l-seat .tag.dim { color: var(--faint); }
.l-seat.empty { border-style: dashed; background: transparent; color: var(--faint); justify-content: center; }
.l-seat.empty .av { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 230, 190, 0.18); color: var(--faint); font-family: var(--font); font-weight: 400; text-shadow: none; }
.l-seat .remove { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; color: var(--faint); }
.l-seat .remove:hover { background: rgba(226, 56, 79, 0.15); color: var(--blood-hi); }
.l-seat .remove .ico { width: 15px; height: 15px; }
@keyframes seatIn { from { opacity: 0; transform: scale(0.85) translateY(8px); } }

.mix-card { padding: 16px; }
.mix-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mix-title { font: 13px var(--type); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.mix { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mix-item { --rc: var(--villager); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 14px; background: color-mix(in srgb, var(--rc) 9%, transparent); border: 1px solid color-mix(in srgb, var(--rc) 28%, transparent); transition: opacity 0.3s; }
.mix-item.zero { opacity: 0.35; }
.mix-item .ico { width: 26px; height: 26px; color: var(--rc); }
.mix-item b { font: 900 22px/1 var(--display); }
.mix-item span { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.mix-times { display: flex; justify-content: center; gap: 14px; margin-top: 12px; font: 12.5px var(--type); color: var(--faint); flex-wrap: wrap; }
.mix-times span { display: inline-flex; align-items: center; gap: 5px; }
.mix-times .ico { width: 14px; height: 14px; }

.settings { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-2); display: flex; flex-direction: column; gap: 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-label { font-weight: 700; font-size: 15px; }
.set-label small { display: block; font-weight: 500; font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); flex: none; }
.seg button { min-width: 42px; height: 34px; padding: 0 10px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); transition: background 0.2s, color 0.2s; }
.seg button.on { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1d0b; }
.seg button:disabled { opacity: 0.3; }
.toggle { position: relative; width: 50px; height: 30px; border-radius: 99px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line-2); transition: background 0.25s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.25s var(--spring), background 0.25s; }
.toggle.on { background: rgba(201, 164, 92, 0.35); border-color: var(--gold); }
.toggle.on::after { transform: translateX(20px); background: var(--gold-hi); }

.lobby-actions { margin-top: 4px; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; height: 56px; color: var(--muted); font-weight: 600; border-radius: 16px; border: 1px dashed var(--line-2); }

/* ======================================================================
   Game
   ====================================================================== */
#screenGame { height: calc(100vh - var(--chat-h, 0px)); height: calc(100dvh - var(--chat-h, 0px)); min-height: 0; }
#screenLobby { padding-bottom: var(--chat-h, 0px); }
.game-top { background: linear-gradient(180deg, rgba(11, 10, 9, 0.9), rgba(11, 10, 9, 0)); }
.phase-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 12px; border-radius: 99px;
  font: 800 16px var(--display); letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line-2);
}
.phase-ico .ico { width: 19px; height: 19px; }
body[data-phase="night"] .phase-ico { color: var(--moon); }
body[data-phase="day"] .phase-ico, body[data-phase="dawn"] .phase-ico { color: #ffc46b; }
body[data-phase="vote"] .phase-ico, body[data-phase="verdict"] .phase-ico { color: var(--blood-hi); }

.timer { position: relative; width: 46px; height: 46px; display: grid; place-items: center; font: 800 12.5px var(--font); font-variant-numeric: tabular-nums; }
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .t-track { fill: rgba(0, 0, 0, 0.45); stroke: rgba(255, 230, 190, 0.12); stroke-width: 3; }
.timer .t-fill { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke 0.3s; }
.timer.low .t-fill { stroke: var(--blood-hi); }
.timer.low { color: #ff9eab; animation: tick 1s infinite; }
.timer.paused { opacity: 0.5; }
.timer.hidden { visibility: hidden; }
@keyframes tick { 50% { transform: scale(1.08); } }

.stage { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 14px 18px; width: 100%; max-width: 640px; margin: 0 auto; }
.prompt { text-align: center; padding: 6px 6px 14px; }
.prompt-title { margin: 4px 0 6px; font: 900 28px/1.08 var(--display); letter-spacing: 0.01em; text-wrap: balance; }

/* the round at a glance: Night, Morning, Talk, Vote */
.steps { list-style: none; margin: 0 auto 10px; padding: 0; display: flex; justify-content: center; align-items: center; gap: 4px; }
.steps[hidden] { display: none; }
.steps li { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 99px; font: 700 11.5px var(--font); letter-spacing: 0.02em; color: var(--faint); border: 1px solid transparent; transition: all 0.3s; }
.steps li .ico { width: 13px; height: 13px; }
.steps li + li::before { content: ''; width: 8px; height: 1px; margin: 0 6px 0 -9px; background: var(--line-2); }
.steps li.done { color: var(--muted); }
.steps li.now { color: var(--ink); background: var(--accent); box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 70%, transparent); }
@media (max-width: 360px) { .steps li { padding: 0 7px; font-size: 10.5px; } .steps li .ico { display: none; } }

/* a big picture of what you do now: knife, heart, cuffs, Zzz */
.prompt-hero { width: 58px; height: 58px; margin: 0 auto 2px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 72%); border: 1.5px solid color-mix(in srgb, var(--accent) 50%, transparent); animation: heroIn 0.5s var(--spring) both; }
.prompt-hero[hidden] { display: none; }
.prompt-hero .ico { width: 30px; height: 30px; stroke-width: 1.8; }
@keyframes heroIn { from { transform: scale(0.6); opacity: 0; } }
body.sleeping .prompt-hero { animation: heroIn 0.5s var(--spring) both, snooze 3.4s ease-in-out infinite; }
@keyframes snooze { 50% { transform: translateY(-4px) rotate(-6deg); } }

/* my to-do line: your turn, done, nothing to do */
.todo { margin: 12px auto 0; max-width: 400px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 14px; font-weight: 700; font-size: 14.5px; line-height: 1.3; text-align: left; animation: rise 0.4s var(--ease-out) both; }
.todo[hidden] { display: none; }
.todo .todo-ico { flex: none; font-size: 17px; display: grid; place-items: center; }
.todo .todo-ico .ico { width: 18px; height: 18px; stroke-width: 3; }
.todo b { color: inherit; }
.todo[data-kind="todo"] { color: #2a1a06; background: linear-gradient(180deg, #ffd793, #f0b553); box-shadow: 0 8px 22px -10px rgba(255, 190, 90, 0.8); animation: rise 0.4s var(--ease-out) both, nudge 2.2s 0.6s ease-in-out infinite; }
.todo[data-kind="urgent"] { color: #fff; background: linear-gradient(180deg, #ef4b62, #b3122e); box-shadow: 0 8px 22px -8px var(--blood-glow); animation: nudge 0.8s ease-in-out infinite; }
.todo[data-kind="done"] { color: #b9f5da; background: rgba(79, 195, 149, 0.14); border: 1px solid rgba(79, 195, 149, 0.45); }
.todo[data-kind="rest"] { color: var(--muted); background: rgba(255, 230, 190, 0.05); border: 1px dashed var(--line-2); font-weight: 600; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: scale(1.025); } }

/* nothing to do tonight: the city sleeps on this phone */
body.sleeping .grid { opacity: 0.5; filter: saturate(0.4) brightness(0.8); transition: opacity 0.6s, filter 0.6s; }
body.sleeping .prompt-title { color: #cfdaf2; }
body.sleeping .prompt { position: relative; }
body.sleeping .prompt::after { content: 'z  z  Z'; position: absolute; top: 34px; left: calc(50% + 30px); font: 800 15px var(--display); color: var(--moon); opacity: 0; animation: zzz 3.2s ease-in-out infinite; pointer-events: none; white-space: pre; }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 8px) scale(0.8); } 30% { opacity: 0.9; } 100% { opacity: 0; transform: translate(14px, -22px) scale(1.15); } }
.prompt-text { margin: 0 auto; max-width: 34ch; font-size: 14.5px; line-height: 1.45; color: var(--muted); text-wrap: pretty; }
.prompt-text b { color: var(--text); }
.prompt-progress { margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; font: 12.5px var(--type); color: var(--faint); letter-spacing: 0.04em; }
.prompt-progress:empty { display: none; }
.prompt-progress .bar { width: 90px; height: 4px; border-radius: 4px; background: rgba(255, 230, 190, 0.1); overflow: hidden; }
.prompt-progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s var(--ease-out); }

/* role accents: what the current action looks like */
/* night: one moonlit accent for every role, so phones side by side look alike */
body[data-act="night"] { --accent: var(--moon); --accent-hi: #e3ecff; }
body[data-act="mafia"] { --accent: var(--mafia); --accent-hi: #ff8b9a; }
body[data-act="doctor"] { --accent: var(--doctor); --accent-hi: #a7f0d1; }
body[data-act="detective"] { --accent: var(--detective); --accent-hi: #c4dbff; }
body[data-act="villager"] { --accent: var(--villager); --accent-hi: #fff0cf; }
body[data-act="vote"] { --accent: var(--blood-hi); --accent-hi: #ff9eab; }
body[data-act="day"] { --accent: #ffc46b; --accent-hi: #ffe0ae; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pc {
  --c: #777;
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 4px 11px; border-radius: 16px; min-height: 124px;
  background: linear-gradient(180deg, rgba(42, 35, 29, 0.72), rgba(22, 18, 15, 0.8));
  border: 1px solid var(--line);
  transition: transform 0.18s var(--spring), border-color 0.2s, box-shadow 0.25s, background 0.25s, opacity 0.3s, filter 0.4s;
  animation: seatIn 0.4s var(--spring) both;
}
.pc .name { font-weight: 800; font-size: 14px; max-width: 100%; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc .sub { font: 10.5px var(--type); letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); min-height: 13px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; }
.pc .sub.you { color: var(--gold-hi); }
.pc.pickable { cursor: pointer; }
.pc.pickable:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pc.pickable:active { transform: scale(0.95); }
.pc.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 22%, #241d18), color-mix(in srgb, var(--accent) 8%, #16120f));
  box-shadow: 0 0 0 1px var(--accent), 0 12px 34px -10px color-mix(in srgb, var(--accent) 70%, transparent);
  transform: translateY(-2px);
}
.pc.selected .av { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 0 4px var(--accent), 0 0 24px 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.pc.blocked { opacity: 0.4; }
.pc.dim { opacity: 0.55; }
.pc .mark, .pc .votes, .pc .accuse-count, .pc .ready-tick, .pc .badge, .pc .ready-mini { z-index: 2; }
.pc .mark {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: #10131c; background: var(--accent);
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: markIn 0.35s var(--spring);
}
.pc .mark .ico { width: 15px; height: 15px; stroke-width: 2.4; }
@keyframes markIn { from { transform: scale(0) rotate(-40deg); } }
.pc .badge { position: absolute; top: 7px; left: 7px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.pc .badge .ico { width: 13px; height: 13px; stroke-width: 2.4; }
.badge.fam { background: rgba(201, 164, 92, 0.16); color: var(--gold-hi); border: 1px solid rgba(201, 164, 92, 0.45); }
.badge.ismafia { background: var(--blood); color: #fff; box-shadow: 0 0 12px var(--blood-glow); }
.badge.clean { background: rgba(79, 195, 149, 0.2); color: #9ff0cc; border: 1px solid rgba(79, 195, 149, 0.5); }
.badge.sus { background: rgba(217, 196, 156, 0.14); color: var(--villager); border: 1px solid rgba(217, 196, 156, 0.4); }
.pc .sub.fam { color: var(--gold-hi); }
.pc .sub.ismafia { color: #ff9eab; font-weight: 700; }
.pc .sub.clean { color: #9ff0cc; }
/* a teammate's pick (mafia view): their little faces in the top-left corner */
.pc .picks { position: absolute; top: 7px; left: 7px; z-index: 2; display: flex; }
.pc .picks .av { width: 22px; height: 22px; font-size: 10px; margin-right: -5px; box-shadow: 0 0 0 1.5px #000; }
.pc .ready-tick { position: absolute; top: 7px; right: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 196, 107, 0.2); color: #ffc46b; border: 1px solid rgba(255, 196, 107, 0.5); animation: markIn 0.35s var(--spring); }
.pc .ready-tick .ico { width: 13px; height: 13px; stroke-width: 3; }

/* votes on a card */
.pc .votes { position: absolute; top: 7px; right: 7px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 99px; display: grid; place-items: center; font: 900 14px var(--display); background: var(--blood); color: #fff; box-shadow: 0 4px 14px -2px var(--blood-glow); animation: markIn 0.35s var(--spring); }
.pc .voters { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; max-width: 100%; padding: 0 6px; min-height: 16px; }
.pc .voters .av { width: 16px; height: 16px; font-size: 8.5px; box-shadow: 0 0 0 1px #000; }
.pc.leading { border-color: rgba(226, 56, 79, 0.6); }

/* dead */
.pc.dead { background: rgba(10, 9, 8, 0.6); border-style: dashed; }
.pc.dead .av { background: radial-gradient(circle at 35% 30%, #6b645c, #3a3530 60%, #1c1916); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6); color: #8c8379; }
.pc.dead .av::after { content: ''; position: absolute; inset: -5px; background: linear-gradient(45deg, transparent 45.5%, var(--blood-hi) 45.5% 54.5%, transparent 54.5%), linear-gradient(-45deg, transparent 45.5%, var(--blood-hi) 45.5% 54.5%, transparent 54.5%); opacity: 0.9; filter: drop-shadow(0 0 4px var(--blood-glow)); }
.pc.dead .name { color: var(--faint); text-decoration: line-through; text-decoration-color: rgba(226, 56, 79, 0.6); }
.pc .fate { font: 9.5px var(--type); letter-spacing: 0.05em; color: var(--faint); text-transform: uppercase; }
.role-stamp {
  --rc: var(--villager);
  display: inline-block; padding: 2px 7px; border-radius: 4px; transform: rotate(-4deg);
  font: 10.5px var(--type); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--rc); border: 1.5px solid var(--rc);
}
.role-stamp[data-role="mafia"], .role-chip[data-role="mafia"] { --rc: var(--mafia); }
.role-stamp[data-role="doctor"], .role-chip[data-role="doctor"] { --rc: var(--doctor); }
.role-stamp[data-role="detective"], .role-chip[data-role="detective"] { --rc: var(--detective); }

/* the detective's notes / extra info under the grid */
/* role notes look the same for every role (neutral paper), only the words differ */
.notes { margin-top: 16px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px dashed var(--line-2); }
.notes h4 { margin: 0 0 8px; font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); }
.notes ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.notes li { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; }
.notes li span:first-child { color: var(--faint); font: 12px var(--type); }
.notes li b { flex: 1; }
.notes .verdict-m { color: #ff9eab; font-weight: 800; }
.notes .verdict-c { color: #9ff0cc; font-weight: 800; }


.paused-banner, .dead-banner { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 8px; padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.paused-banner { background: rgba(201, 164, 92, 0.12); border: 1px solid rgba(201, 164, 92, 0.35); color: var(--gold-hi); font-weight: 800; }
.dead-banner { background: rgba(0, 0, 0, 0.45); border: 1px dashed rgba(255, 230, 190, 0.2); color: var(--muted); text-align: left; justify-content: flex-start; }
.dead-banner .skull { width: 28px; height: 28px; color: var(--blood-hi); }
.dead-banner b { color: var(--text); }
body.is-dead .grid { filter: saturate(0.55); }

/* bottom dock */
.dock { display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(12px + var(--safe-bottom)); background: linear-gradient(0deg, rgba(11, 10, 9, 0.96) 55%, rgba(11, 10, 9, 0)); }
.dock > * { position: relative; }
@media (min-width: 680px) { .dock { padding-left: max(14px, calc(50% - 320px)); padding-right: max(14px, calc(50% - 320px)); } }
.id-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px 0 12px; border-radius: 16px; flex: none;
  background: linear-gradient(180deg, #e9ddc3, #cdbb94); color: var(--paper-ink);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.9), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  touch-action: none; transition: transform 0.15s var(--spring);
}
.id-btn:active, .id-btn.holding { transform: scale(0.95); }
.id-btn .fp { width: 26px; height: 26px; color: #6b4a2a; }
.id-btn.holding .fp { color: var(--blood); }
.id-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.id-label { font: 800 14.5px var(--display); }
.id-hint { font: 10.5px var(--type); letter-spacing: 0.05em; opacity: 0.7; }
.dock-actions { flex: 1; display: flex; gap: 8px; justify-content: flex-end; min-width: 0; }
.dock-actions .btn { height: 56px; flex: 1; max-width: 260px; padding: 0 14px; font-size: 15px; }
.dock-actions .btn.on { background: linear-gradient(180deg, #ffd793, #e0a350); color: #2a1a06; }
.dock-note { flex: 1; text-align: right; font: 13px var(--type); color: var(--faint); line-height: 1.3; }
.dock-note b { color: var(--text); font-family: var(--font); }
.dock-note.job { display: flex; align-items: center; justify-content: flex-end; gap: 10px; text-align: left; font-size: 12.5px; }
.dock-note.job .ico { flex: none; width: 34px; height: 34px; padding: 7px; border-radius: 50%; color: var(--ink); background: var(--accent); stroke-width: 2.2; }
.dock-note.job.pending { color: var(--accent-hi); font-size: 13px; }
.dock-note.job.pending > :first-child { font-size: 22px; }

/* ======================================================================
   Role cards (reveal, peek, rules)
   ====================================================================== */
.role-card {
  --rc: var(--villager);
  position: relative; width: 100%; height: 100%; border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 22px 18px;
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--rc) 22%, transparent), transparent 70%),
    linear-gradient(180deg, #2a231d, #120f0c);
  border: 1px solid color-mix(in srgb, var(--rc) 45%, transparent);
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.35), inset 0 0 0 7px color-mix(in srgb, var(--rc) 25%, transparent);
  text-align: center;
}
.role-card[data-role="mafia"] { --rc: var(--mafia); }
.role-card[data-role="doctor"] { --rc: var(--doctor); }
.role-card[data-role="detective"] { --rc: var(--detective); }
.role-card .rc-team { font: 12px var(--type); letter-spacing: 0.22em; text-transform: uppercase; color: var(--rc); }
.role-card .rc-art { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; color: var(--rc); background: radial-gradient(circle, color-mix(in srgb, var(--rc) 20%, transparent), transparent 70%); border: 1.5px solid color-mix(in srgb, var(--rc) 50%, transparent); }
.role-card .rc-art .ico { width: 56px; height: 56px; stroke-width: 1.5; }
.role-card .rc-name { font: 900 38px/1 var(--display); letter-spacing: 0.02em; }
.role-card .rc-power { font-size: 14px; line-height: 1.45; color: var(--muted); max-width: 30ch; }
.role-card .rc-goal { font: 12.5px/1.4 var(--type); color: var(--text); opacity: 0.8; max-width: 32ch; padding-top: 8px; border-top: 1px dashed color-mix(in srgb, var(--rc) 35%, transparent); }
.role-card .rc-how { list-style: none; margin: 2px 0 0; padding: 10px 0 0; width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 6px; border-top: 1px dashed color-mix(in srgb, var(--rc) 35%, transparent); text-align: left; }
.role-card .rc-how li { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; font-weight: 700; line-height: 1.3; color: var(--text); }
.role-card .rc-how span { flex: none; width: 46px; font: 11px var(--type); text-transform: uppercase; letter-spacing: 0.12em; color: var(--rc); }
.role-card .rc-team-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.role-card .rc-team-list span { padding: 4px 10px; border-radius: 99px; font-weight: 800; font-size: 13px; background: rgba(226, 56, 79, 0.15); border: 1px solid rgba(226, 56, 79, 0.4); color: #ffc2ca; }

.reveal { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom)); background: radial-gradient(90% 60% at 50% 30%, rgba(30, 40, 70, 0.55), transparent 75%), rgba(5, 6, 10, 0.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fadeIn 0.5s; }
.reveal-inner { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.reveal-kicker { font: 14px var(--type); text-transform: uppercase; letter-spacing: 0.25em; color: var(--muted); }
.dossier { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 56vh; perspective: 1200px; touch-action: none; cursor: pointer; }
.dossier-back, .dossier-front { position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform 0.55s var(--ease-out); }
.dossier-back {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--paper-ink);
  background:
    linear-gradient(180deg, transparent 0 18%, rgba(0, 0, 0, 0.06) 18% 18.6%, transparent 18.6%),
    radial-gradient(120% 90% at 30% 10%, #efe3c8, #cdb88e 70%, #b39a6c);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9), inset 0 0 40px rgba(110, 80, 40, 0.35);
}
.dossier-back::before { content: ''; position: absolute; top: -12px; left: 18px; width: 38%; height: 26px; border-radius: 10px 10px 0 0; background: #d9c69e; }
.stamp { font: 26px var(--type); letter-spacing: 0.16em; text-transform: uppercase; color: var(--blood); border: 3px solid var(--blood); padding: 4px 12px; border-radius: 6px; transform: rotate(-9deg); opacity: 0.85; mix-blend-mode: multiply; }
.dossier-seal { width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #d6324b, #8e0a20); color: #ffd9de; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4), inset 0 -4px 8px rgba(0, 0, 0, 0.3); animation: sealPulse 2s ease-in-out infinite; }
.dossier-seal .ico { width: 46px; height: 46px; stroke-width: 1.6; }
@keyframes sealPulse { 50% { box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4), 0 0 0 12px rgba(214, 50, 75, 0.15), inset 0 -4px 8px rgba(0, 0, 0, 0.3); } }
.dossier-hint { font: 800 16px var(--display); text-align: center; line-height: 1.35; }
.dossier-hint small { font: 12px var(--type); opacity: 0.7; }
.dossier-front { transform: rotateY(180deg); }
.dossier.open .dossier-back { transform: rotateY(-180deg); }
.dossier.open .dossier-front { transform: rotateY(0); }
.reveal-progress { font: 13px var(--type); color: var(--faint); min-height: 18px; text-align: center; }

.peek { position: fixed; inset: 0; z-index: 56; display: grid; place-items: center; padding: 24px; background: rgba(5, 5, 6, 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; animation: fadeIn 0.15s; }
.peek-card { width: min(320px, 82vw); aspect-ratio: 3 / 4; animation: peekIn 0.3s var(--spring); }
@keyframes peekIn { from { transform: translateY(40px) scale(0.9); opacity: 0; } }

/* ======================================================================
   Cinematics (phase changes)
   ====================================================================== */
.cine { position: fixed; inset: 0; z-index: 52; display: grid; place-items: center; padding: 24px; cursor: pointer; animation: cineIn 0.6s ease both; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cine.out { animation: cineOut 0.5s ease forwards; }
@keyframes cineIn { from { opacity: 0; } }
@keyframes cineOut { to { opacity: 0; } }
.cine[data-kind="night"] { background: radial-gradient(80% 55% at 50% 30%, rgba(40, 60, 110, 0.5), transparent 70%), rgba(4, 5, 11, 0.95); }
.cine[data-kind="day"] { background: radial-gradient(90% 60% at 50% 30%, rgba(255, 180, 90, 0.25), transparent 70%), rgba(16, 10, 5, 0.95); }
.cine[data-kind="dawn"] { background: radial-gradient(90% 60% at 50% 80%, rgba(255, 150, 70, 0.3), transparent 70%), rgba(16, 9, 5, 0.95); }
.cine[data-kind="vote"], .cine[data-kind="verdict"] { background: radial-gradient(80% 60% at 50% 35%, rgba(150, 15, 35, 0.42), transparent 70%), rgba(10, 4, 5, 0.95); }
.cine-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; max-width: 380px; }
.cine-kicker { font: 13px var(--type); letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); animation: rise 0.8s 0.15s var(--ease-out) both; }
.cine-title { margin: 0; font: 900 48px/1 var(--display); letter-spacing: 0.01em; animation: rise 0.9s 0.3s var(--ease-out) both; text-wrap: balance; }
.cine-title em { font-style: italic; color: var(--blood-hi); }
.cine-text { margin: 0; font-size: 16px; line-height: 1.5; color: var(--muted); animation: rise 0.9s 0.55s var(--ease-out) both; text-wrap: balance; }
.cine-text b { color: var(--text); }
.cine-art { animation: rise 1s var(--ease-out) both; }
.cine-job { --rc: var(--moon); width: 112px; height: 112px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; color: var(--rc); background: radial-gradient(circle, color-mix(in srgb, var(--rc) 26%, transparent), transparent 70%); border: 2px solid color-mix(in srgb, var(--rc) 55%, transparent); box-shadow: 0 0 60px -10px color-mix(in srgb, var(--rc) 60%, transparent); }
.cine-job .ico { width: 58px; height: 58px; stroke-width: 1.6; }
.cine-job[data-role="mafia"] { --rc: var(--mafia); }
.cine-job[data-role="doctor"] { --rc: var(--doctor); }
.cine-job[data-role="detective"] { --rc: var(--detective); }
.cine-job[data-role="day"] { --rc: #ffc46b; }
.cine-job[data-role="villager"] { width: auto; height: auto; border: 0; background: none; box-shadow: none; }
.cine-steps { list-style: none; margin: 4px auto 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; max-width: 300px; animation: rise 0.9s 0.55s var(--ease-out) both; }
.cine-steps li { display: flex; align-items: center; gap: 12px; font-size: 16px; color: var(--text); }
.cine-steps li > b:first-child { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 900 14px var(--display); color: #2a1a06; background: #ffc46b; }
.cine-judge { margin-top: 4px; font-weight: 800; }
.cine-judge.good { color: #9ff0cc; }
.cine-judge.bad { color: #ffb3bd; }
.cine-moon { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle at 38% 38%, #f4f7ff, #c3d2f0 55%, #8ea3cc); box-shadow: 0 0 80px 24px rgba(170, 196, 255, 0.3); animation: moonRise 1.6s var(--ease-out) both; }
@keyframes moonRise { from { transform: translateY(80px); opacity: 0; } }
.cine-sun { width: 130px; height: 65px; border-radius: 130px 130px 0 0; background: radial-gradient(circle at 50% 100%, #fff1c9, #ffb259 45%, #e3622c); box-shadow: 0 0 90px 30px rgba(255, 160, 80, 0.35); animation: moonRise 1.6s var(--ease-out) both; }
.cine-victim { position: relative; margin-bottom: 14px; }
.cine-victim .av { width: 108px; height: 108px; font-size: 44px; filter: grayscale(1) brightness(0.8); animation: victim 1.2s 0.2s var(--ease-out) both; }
.cine-victim .slash { position: absolute; inset: -10px; pointer-events: none; }
.cine-victim .slash i { position: absolute; left: 50%; top: 50%; width: 140%; height: 6px; margin-left: -70%; border-radius: 4px; background: var(--blood-hi); box-shadow: 0 0 18px var(--blood-glow); transform: rotate(45deg) scaleX(0); animation: slash 0.35s 0.9s var(--ease-out) forwards; }
.cine-victim .slash i + i { transform: rotate(-45deg) scaleX(0); animation-delay: 1.1s; }
@keyframes slash { to { transform: rotate(var(--r, 45deg)) scaleX(1); } }
.cine-victim .slash i + i { --r: -45deg; }
@keyframes victim { from { filter: grayscale(0) brightness(1); transform: scale(1.15); } }
.cine-stamp { animation: stampIn 0.45s 1.5s var(--spring) both; }
.cine-stamp .role-stamp { font-size: 16px; padding: 6px 14px; border-width: 2.5px; }
@keyframes stampIn { from { opacity: 0; transform: scale(2.2) rotate(-12deg); } }
.cine-private { margin-top: 10px; padding: 12px 16px; border-radius: 14px; background: rgba(255, 230, 190, 0.07); border: 1px dashed var(--line-2); font-size: 15px; animation: rise 0.8s 1.8s var(--ease-out) both; }
.cine-private .lbl { display: block; font: 11.5px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); margin-bottom: 4px; }
.cine-private .lbl .ico { width: 14px; height: 14px; margin: -2px 6px 0 0; vertical-align: middle; }
.cine-private.good { border: 1px solid rgba(79, 195, 149, 0.55); background: rgba(79, 195, 149, 0.1); }
.cine-private.bad { border: 1px solid rgba(226, 56, 79, 0.6); background: rgba(226, 56, 79, 0.12); }
.cine-private .is-m { color: #ff9eab; font-weight: 900; }
.cine-private .is-c { color: #9ff0cc; font-weight: 900; }
.cine-gavel .ico { width: 84px; height: 84px; color: var(--blood-hi); stroke-width: 1.5; animation: gavel 0.9s 0.2s var(--ease-out) both; transform-origin: 80% 80%; }
@keyframes gavel { 0% { transform: rotate(-35deg); opacity: 0; } 60% { transform: rotate(8deg); opacity: 1; } 100% { transform: rotate(0); } }
.cine-tap { position: absolute; bottom: calc(26px + var(--safe-bottom)); left: 0; right: 0; text-align: center; font: 12px var(--type); color: var(--faint); letter-spacing: 0.14em; text-transform: uppercase; animation: fadeIn 1s 2s both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ======================================================================
   Finish
   ====================================================================== */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(5, 4, 4, 0.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fadeIn 0.3s; }
.finish { overflow-y: auto; align-items: start; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.finish[data-winner="mafia"] { background: radial-gradient(90% 60% at 50% 0%, rgba(160, 15, 35, 0.5), rgba(6, 3, 4, 0.96) 70%); }
.finish[data-winner="town"] { background: radial-gradient(90% 60% at 50% 0%, rgba(201, 164, 92, 0.35), rgba(8, 6, 4, 0.96) 70%); }
.finish-card { width: 100%; max-width: 480px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; animation: rise 0.7s var(--ease-out); }
.finish-emblem { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px; }
.finish-emblem .ico { width: 64px; height: 64px; stroke-width: 1.4; }
.finish[data-winner="mafia"] .finish-emblem { color: var(--blood-hi); background: radial-gradient(circle, rgba(226, 56, 79, 0.25), transparent 70%); border: 1.5px solid rgba(226, 56, 79, 0.5); }
.finish[data-winner="town"] .finish-emblem { color: var(--gold-hi); background: radial-gradient(circle, rgba(236, 208, 150, 0.22), transparent 70%); border: 1.5px solid rgba(236, 208, 150, 0.5); }
.finish-kicker { font: 13px var(--type); letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); }
.finish h2 { margin: 0; font: 900 40px/1.05 var(--display); text-wrap: balance; }
.finish-sub { margin: 4px 0 14px; color: var(--muted); font-size: 15px; }
.finish-sub b.won { color: var(--gold-hi); }
.finish-sub b.lost { color: #ff9eab; }
.finish-list { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 18px; }
.f-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; animation: seatIn 0.45s var(--spring) both; }
.f-row.winner { border-color: rgba(236, 208, 150, 0.35); }
.f-row.dead .av { filter: grayscale(1) brightness(0.7); }
.f-row .av { width: 36px; height: 36px; font-size: 15px; }
.f-row .f-name { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-row .f-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-top: 3px; }
.f-row .f-meta .role-stamp { transform: none; font-size: 9.5px; padding: 1px 5px; }
.f-row .f-fate { font: 10px var(--type); color: var(--faint); white-space: nowrap; }
.f-row > div { min-width: 0; }
.finish-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.finish-row { display: flex; gap: 10px; }
.finish-row .btn { flex: 1; }

/* ======================================================================
   Sheets, dialogs, toasts, banners
   ====================================================================== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); animation: fadeIn 0.25s; }
.sheet { position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; padding: 10px 14px calc(18px + var(--safe-bottom)); border-radius: 24px 24px 0 0; background: linear-gradient(180deg, #2a231d, #17130f); border: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.6); animation: sheetUp 0.35s var(--ease-out); display: flex; flex-direction: column; gap: 4px; max-height: 88vh; overflow-y: auto; }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 230, 190, 0.22); margin: 0 auto 10px; flex: none; }
.sheet-item { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 14px; border-radius: 14px; font-weight: 700; font-size: 15.5px; text-align: left; }
.sheet-item:hover, .sheet-item:active { background: var(--surface-2); }
.sheet-item.danger { color: #ff8b9a; }
.sheet-item .state { margin-left: auto; font: 12px var(--type); color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.sheet h3 { font: 900 26px var(--display); margin: 0 6px 10px; }
.sheet-host { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 2px 10px; margin-bottom: 4px; border-bottom: 1px dashed var(--line-2); }
.sheet-host:empty { display: none; }
.sheet-host .host-label { grid-column: 1 / -1; font: 11.5px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); padding: 0 4px; }
.sheet-host button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 74px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.sheet-host button:disabled { opacity: 0.35; }
.sheet-host button .ico { width: 22px; height: 22px; color: var(--gold-hi); }
.sheet .btn { margin-top: 10px; }

.case-list { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.case-round { font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); margin: 12px 0 4px; }
.case-round:first-child { margin-top: 0; }
.case-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.case-item .av { width: 30px; height: 30px; font-size: 13px; }
.case-item .ci-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); flex: none; }
.case-item .ci-ico .ico { width: 16px; height: 16px; }
.case-item .txt { flex: 1; color: var(--muted); }
.case-item .txt b { color: var(--text); }
.case-empty { color: var(--faint); font: 14px var(--type); padding: 10px 0 4px; }

.rules-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.rr { --rc: var(--villager); display: flex; gap: 10px; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--rc) 8%, transparent); border: 1px solid color-mix(in srgb, var(--rc) 25%, transparent); }
.rr[data-role="mafia"] { --rc: var(--mafia); } .rr[data-role="doctor"] { --rc: var(--doctor); } .rr[data-role="detective"] { --rc: var(--detective); }
.rr .ico { width: 26px; height: 26px; color: var(--rc); }
.rr b { display: block; font: 800 16px var(--display); margin-bottom: 2px; }
.rr span { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.rules-steps { margin: 0; padding: 0 4px 0 22px; display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.rules-steps b { color: var(--text); }
.rules-steps em { color: var(--gold-hi); font-style: normal; font-weight: 700; }
.rules-note { margin: 12px 4px 0; font: 13px var(--type); color: var(--faint); }

.dialog-overlay { z-index: 80; }
.dialog { width: 100%; max-width: 360px; padding: 22px 20px 18px; animation: pop 0.3s var(--spring); }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.dialog h3 { margin: 0 0 6px; font: 800 22px var(--display); }
.dialog p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }
.choice-actions { display: flex; flex-direction: column; gap: 8px; }

.toasts { position: fixed; z-index: 70; left: 0; right: 0; top: calc(64px + var(--safe-top)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px 16px 10px 10px; border-radius: 14px; font-size: 14.5px; font-weight: 600; background: rgba(26, 21, 17, 0.96); border: 1px solid var(--line-2); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.9); animation: toastIn 0.4s var(--spring); }
.toast.out { animation: toastOut 0.3s ease-in forwards; }
.toast .t-ico { font-size: 18px; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.92); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(0.95); } }

.conn-banner { position: fixed; z-index: 75; top: calc(8px + var(--safe-top)); left: 50%; transform: translate(-50%, -160%); display: flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; background: #3b2d0a; color: #ffd98a; border: 1px solid rgba(255, 200, 80, 0.4); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transition: transform 0.4s var(--spring); white-space: nowrap; }
.conn-banner.show { transform: translate(-50%, 0); }
.conn-banner .conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffc248; animation: blink 0.9s infinite; }
.conn-banner.offline { background: #3d1218; color: #ffb3bb; border-color: rgba(255, 90, 106, 0.45); }
.conn-banner.offline .conn-dot { background: var(--blood-hi); }
@keyframes blink { 50% { opacity: 0.3; } }
body.disconnected .grid, body.disconnected .dock { opacity: 0.5; pointer-events: none; }

.sound-pill { position: fixed; z-index: 45; left: 50%; bottom: calc(92px + var(--safe-bottom) + var(--chat-h, 0px)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px 0 12px; border-radius: 999px; font-size: 14px; font-weight: 800; color: #2a1d0b; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); box-shadow: 0 10px 26px -8px rgba(0, 0, 0, 0.8); animation: pillIn 0.4s var(--spring); white-space: nowrap; }
.sound-pill .ico { width: 18px; height: 18px; }
@keyframes pillIn { from { opacity: 0; transform: translate(-50%, 10px) scale(0.9); } }

.splash { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: radial-gradient(90% 60% at 50% 30%, #1d1712, var(--ink)); }
.spinner-hat { width: 54px; height: 54px; border-radius: 50%; border: 3px solid rgba(255, 230, 190, 0.12); border-top-color: var(--blood-hi); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.splash-text { color: var(--muted); font: 15px var(--type); }

.watch-chip { margin-left: 6px; font: 12px var(--type); color: var(--muted); }

@media (max-width: 360px) {
  .brand { font-size: 54px; }
  .prompt-title { font-size: 26px; }
  .grid { gap: 8px; }
  .pc { min-height: 116px; }
  .av { width: 46px; height: 46px; font-size: 19px; }
  .id-text .id-hint { display: none; }
  .cine-title { font-size: 40px; }
}
@media (min-height: 800px) { .pc { min-height: 132px; } }

/* big rooms (10-16): smaller cards so most of the table fits on one phone screen */
.grid.compact { gap: 8px; }
.grid.compact .pc { min-height: 104px; padding: 10px 3px 8px; gap: 5px; border-radius: 14px; }
.grid.compact .pc > .av { width: 42px; height: 42px; font-size: 18px; }
.grid.compact .pc > .av .presence { width: 11px; height: 11px; }
.grid.compact .pc .name { font-size: 13px; }
.grid.compact .pc .mark, .grid.compact .pc .votes { width: 22px; height: 22px; min-width: 22px; top: 5px; right: 5px; font-size: 12px; }
.grid.compact .pc .badge { width: 20px; height: 20px; top: 5px; left: 5px; }
.grid.compact .pc .picks { bottom: 30px; }
@media (min-width: 480px) { .grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 600px) { .grid.crowd { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* moon tucked into the corner on phones, so it never sits behind the heading */
@media (max-width: 560px) {
  body[data-screen="Game"] .moon { top: calc(58px + var(--safe-top)); right: -22px; width: 58px; height: 58px; }
  body[data-phase="night"] .moon { opacity: 0.55; }
}
/* short phones (iPhone SE, landscape-ish): tighten the header and cards */
@media (max-height: 700px) {
  .prompt { padding: 4px 6px 10px; }
  .prompt-title { font-size: 25px; margin: 4px 0; }
  .prompt-text { font-size: 13.5px; }
  .pc { min-height: 108px; padding: 10px 4px 9px; }
  .dossier { max-height: 50vh; }
  .cine-title { font-size: 40px; }
  .home-wrap { padding-top: calc(18px + var(--safe-top)); }
  .logo { width: 110px; height: 60px; }
  .brand { font-size: 52px; }
  .tagline { margin: 10px 0 16px; }
}
/* the dock never squeezes its buttons into two lines */
.dock-actions .btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) {
  .dock { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .id-btn { padding: 0 10px; height: 52px; }
  .id-btn .fp { width: 22px; height: 22px; }
  .id-label { font-size: 13px; }
  .dock-actions .btn { height: 52px; font-size: 14px; padding: 0 10px; }
  .dock-actions .btn .ico { display: none; }
  .phase-pill { font-size: 14.5px; padding: 0 12px 0 10px; }
}

/* ======================================================================
   Interaction: chat, accusations, reactions, last will, files, guide
   ====================================================================== */
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.topbar-title small { font: 11.5px var(--type); color: var(--gold); letter-spacing: 0.08em; margin-top: 2px; }
.topbar-title small:empty { display: none; }
.icon-btn.exit-btn { color: #ff9eab; border-color: rgba(226, 56, 79, 0.35); background: rgba(226, 56, 79, 0.08); width: 42px; padding: 0; justify-content: center; }
.chat-btn { position: relative; }
.chat-btn .unread { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; display: grid; place-items: center; font: 800 11px var(--font); color: #fff; background: var(--blood-hi); border: 2px solid var(--ink); animation: markIn 0.35s var(--spring); }

/* first time in the lobby */
.guide-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; text-align: left; font-size: 13.5px; line-height: 1.35; color: var(--muted); background: linear-gradient(90deg, rgba(201, 164, 92, 0.16), rgba(201, 164, 92, 0.05)); border: 1px solid rgba(201, 164, 92, 0.35); animation: seatIn 0.5s var(--spring) both; }
.guide-banner b { color: var(--gold-hi); font-size: 14.5px; }
.guide-banner .gb-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 900 18px var(--display); color: #2a1d0b; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); }
.guide-banner .ico { margin-left: auto; color: var(--gold); }

/* the beginner's tip line */
.hint { margin: 16px auto 0; max-width: 380px; display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 12px; text-align: left; font-size: 13px; line-height: 1.4; color: var(--text); background: rgba(255, 230, 190, 0.06); border: 1px dashed var(--line-2); animation: rise 0.5s 0.2s var(--ease-out) both; }
.hint-ico { flex: none; }

/* chat button in the dock + the preview bubble */
.chat-fab { flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); transition: transform 0.15s var(--spring); }
.chat-fab:active { transform: scale(0.92); }
.chat-fab .ico { width: 24px; height: 24px; }
.dock { position: relative; }
.chat-peek { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 2px); margin: 0 auto; max-width: 420px; display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 9px; border-radius: 16px; background: rgba(32, 26, 21, 0.97); border: 1px solid var(--line-2); box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.9); cursor: pointer; animation: toastIn 0.35s var(--spring); }
.chat-peek.out { animation: toastOut 0.3s ease-in forwards; }
.chat-peek .av { width: 32px; height: 32px; font-size: 14px; }
.chat-peek div { min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; }
.chat-peek b { font-size: 12.5px; color: var(--gold-hi); }
.chat-peek span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

/* chat dock: a sticky panel at the bottom on phones, a full-height column on the right on wide screens */
.chat-dock {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #241d18, #14110e); border-top: 1px solid var(--line-2);
  box-shadow: 0 -16px 40px -8px rgba(0, 0, 0, 0.7);
}
.chat-dock .chat-body { display: none; flex: 1; min-height: 0; flex-direction: column; gap: 8px; }
.chat-dock.open { height: min(46dvh, 460px); padding: 10px 12px calc(10px + var(--safe-bottom)); border-radius: 20px 20px 0 0; }
.chat-dock.open .chat-body { display: flex; }
.chat-dock.open .chat-bar { display: none; }
.chat-bar { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 16px calc(8px + var(--safe-bottom)); text-align: left; }
.chat-bar > .ico { color: var(--gold); }
.chat-bar .cb-text { flex: 1; min-width: 0; display: flex; gap: 7px; align-items: baseline; font-size: 14px; overflow: hidden; white-space: nowrap; }
.chat-bar .cb-text b { flex: none; font-size: 13px; }
.chat-bar .cb-text span { overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.chat-bar .cb-text .sys { font: 13px var(--type); color: var(--faint); }
.chat-bar .cb-chev { color: var(--faint); }
.chat-bar .unread { position: static; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; font: 800 11px var(--font); color: #fff; background: var(--blood-hi); }
body.has-chat .chat-btn { display: none; }
body.has-chat .dock { padding-bottom: 10px; }
.chat-head { display: flex; align-items: center; gap: 8px; min-height: 38px; }
.chat-head .icon-btn { margin-left: auto; width: 38px; height: 38px; flex: none; }
.chat-title { font: 800 16px var(--display); color: var(--gold-hi); padding-left: 4px; }
@media (min-width: 1000px) {
  .chat-dock, .chat-dock.open { left: auto; top: 0; width: 360px; height: 100vh; height: 100dvh; padding: calc(12px + var(--safe-top)) 14px calc(14px + var(--safe-bottom)); border-top: 0; border-left: 1px solid var(--line-2); border-radius: 0; box-shadow: -16px 0 40px -12px rgba(0, 0, 0, 0.7); }
  .chat-dock .chat-body { display: flex; }
  .chat-dock .chat-bar, .chat-collapse { display: none; }
  body.has-chat .screen { margin-right: 360px; }
  body.has-chat .dock { padding-bottom: calc(12px + var(--safe-bottom)); }
  body.has-chat .toasts, body.has-chat .sheet { right: 360px; }
  body.has-chat .sheet { left: 0; }
}
.chat-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chat-tabs button { position: relative; height: 36px; padding: 0 13px; border-radius: 99px; font-weight: 700; font-size: 13.5px; white-space: nowrap; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.chat-tabs button.on { color: #2a1d0b; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-color: transparent; }
.chat-tabs button i { position: absolute; top: -5px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; font: 800 10px/17px var(--font); font-style: normal; color: #fff; background: var(--blood-hi); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.chat-list[data-ch="family"] { background: radial-gradient(100% 60% at 50% 0%, rgba(226, 56, 79, 0.06), transparent); }
.chat-list[data-ch="dead"] { background: radial-gradient(100% 60% at 50% 0%, rgba(160, 170, 190, 0.06), transparent); }
.chat-empty { margin: auto; text-align: center; color: var(--faint); font: 14px var(--type); padding: 20px; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.msg.new { animation: msgIn 0.3s var(--spring); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.msg .av { width: 28px; height: 28px; font-size: 12px; }
.msg .bubble { padding: 8px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.38; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.msg .bubble b { display: block; font-size: 12px; margin-bottom: 1px; }
.msg.mine { align-self: flex-end; }
.msg.mine .bubble { border-radius: 16px 16px 4px 16px; background: linear-gradient(180deg, rgba(201, 164, 92, 0.3), rgba(201, 164, 92, 0.18)); border-color: rgba(201, 164, 92, 0.4); }
.msg.sys { align-self: center; max-width: 92%; text-align: center; font: 12.5px var(--type); color: var(--muted); padding: 4px 10px; border-radius: 99px; background: rgba(0, 0, 0, 0.3); }
.chat-quick, .chat-react { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none; padding: 0 1px; }
.chat-quick::-webkit-scrollbar, .chat-react::-webkit-scrollbar, .chat-tabs::-webkit-scrollbar { display: none; }
.chat-quick button { flex: none; height: 34px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.chat-react button { flex: none; width: 42px; height: 40px; border-radius: 12px; font-size: 21px; background: var(--surface); border: 1px solid var(--line); transition: transform 0.15s var(--spring); }
.chat-react button:active { transform: scale(1.25); }
.chat-form { display: flex; gap: 8px; flex: none; }
.chat-form input { flex: 1; min-width: 0; height: 48px; border-radius: 14px; padding: 0 14px; font: 600 16px var(--font); color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1.5px solid var(--line); outline: none; }
.chat-form input:focus { border-color: var(--gold); }
.chat-send { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #2a1d0b; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); }
.chat-blocked { flex: none; padding: 12px; border-radius: 14px; text-align: center; font: 13.5px var(--type); color: var(--muted); background: rgba(0, 0, 0, 0.3); border: 1px dashed var(--line-2); }

/* floating reactions */
.reactions { position: fixed; inset: 0; z-index: 58; pointer-events: none; overflow: hidden; }
.float-react { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; animation: floatUp 2.2s var(--ease-out) forwards; }
.float-react span { font-size: 40px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6)); }
.float-react small { font: 800 10.5px var(--font); padding: 1px 7px; border-radius: 99px; background: rgba(0, 0, 0, 0.6); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.4); } 15% { opacity: 1; transform: translate(-50%, -70%) scale(1.15); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -260%) scale(1); } }

/* accusations on cards */
.pc .accuse-count { position: absolute; top: 7px; right: 7px; height: 24px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center; font: 800 12px var(--font); color: #2a1a06; background: linear-gradient(180deg, #ffd793, #e0a350); box-shadow: 0 4px 12px -2px rgba(224, 163, 80, 0.6); }
.pc .voters.accusers .av { box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(224, 163, 80, 0.6); }
.pc .ready-mini { position: absolute; top: 34px; right: 9px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: #ffc46b; background: rgba(255, 196, 107, 0.15); }
.pc .ready-mini .ico { width: 11px; height: 11px; stroke-width: 3; }
.bump { animation: bump 0.45s var(--spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
.pc.leading .av { animation: lead 1.1s ease-in-out infinite; }
@keyframes lead { 50% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(226, 56, 79, 0.75), 0 0 22px 4px var(--blood-glow); } }

/* away (connection lost) */
.pc.away .av { opacity: 0.45; filter: grayscale(0.7); }
.pc.away .sub { color: #e9b26a; }

/* role card tips */
.role-card .rc-tips { margin: 2px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; text-align: left; max-width: 32ch; }
.role-card .rc-tips li { position: relative; padding-left: 18px; font-size: 12.5px; line-height: 1.38; color: var(--muted); }
.role-card .rc-tips li::before { content: '›'; position: absolute; left: 4px; color: var(--rc); font-weight: 900; }
.peek-card { aspect-ratio: auto; min-height: min(426px, 70vh); }
.peek-card .role-card { min-height: inherit; }
.peek.tappable { pointer-events: auto; cursor: pointer; }

/* last will in the morning / verdict cinematic */
.cine-will { margin-top: 6px; max-width: 320px; padding: 10px 14px; border-radius: 6px; font: 14px/1.45 var(--type); color: var(--paper-ink); background: linear-gradient(180deg, #e9ddc3, #d3c09b); transform: rotate(-1.5deg); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.8); animation: rise 0.8s 1.9s var(--ease-out) both; text-align: left; }
.cine-will .lbl { display: block; font: 11px var(--type); letter-spacing: 0.14em; text-transform: uppercase; color: #7a5a30; margin-bottom: 3px; }

/* sheets: will, player file, remove */
.sheet-note { margin: -4px 6px 12px; color: var(--muted); font-size: 14px; line-height: 1.45; }
#willInput { width: 100%; resize: none; padding: 14px; border-radius: 14px; font: 16px/1.5 var(--type); color: var(--paper-ink); background: linear-gradient(180deg, #ece1c8, #d9c7a2); border: 0; outline: none; user-select: text; -webkit-user-select: text; }
.will-count { text-align: right; font: 12px var(--type); color: var(--faint); margin: 4px 4px 0; }
.file-head { display: flex; align-items: center; gap: 14px; padding: 4px 6px 14px; }
.file-head h3 { margin: 0; }
.file-head h3 small { font: 13px var(--font); color: var(--faint); }
.file-head .av.gone { filter: grayscale(1) brightness(0.7); }
.file-status { font: 13px var(--type); color: var(--muted); margin-top: 3px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 6px; border-top: 1px solid var(--line); font-size: 14.5px; }
.file-row > span:first-child { color: var(--faint); font: 12.5px var(--type); text-transform: uppercase; letter-spacing: 0.08em; }
.file-row .verdict-m { color: #ff9eab; } .file-row .verdict-c { color: #9ff0cc; }
.file-will { margin: 10px 2px 2px; padding: 14px; border-radius: 8px; color: var(--paper-ink); background: linear-gradient(180deg, #e9ddc3, #d3c09b); }
.file-will .lbl { font: 11px var(--type); letter-spacing: 0.14em; text-transform: uppercase; color: #7a5a30; }
.file-will p { margin: 6px 0 0; font: 15px/1.5 var(--type); white-space: pre-wrap; }
.file-will p.none { opacity: 0.6; }
.remove-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.remove-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.remove-row .av { width: 40px; height: 40px; font-size: 16px; }
.remove-row span { flex: 1; display: flex; flex-direction: column; }
.remove-row small { color: var(--faint); font: 12px var(--type); }
.remove-row em { font-style: normal; font-weight: 800; font-size: 13px; color: #ff8b9a; }
.sheet-host button.wide { grid-column: 1 / -1; height: 48px; flex-direction: row; }
.sheet-host button.wide .ico { color: #ff8b9a; width: 18px; height: 18px; }
.sheet-item .ico-emoji { width: 20px; text-align: center; font-size: 17px; }

/* town name setting */
.town-row { flex-wrap: wrap; }
.town-input { display: flex; gap: 6px; flex: 1 1 180px; max-width: 260px; }
.town-input input { flex: 1; min-width: 0; height: 40px; border-radius: 11px; padding: 0 12px; font: 600 16px var(--font); color: var(--text); background: rgba(0, 0, 0, 0.35); border: 1.5px solid var(--line); outline: none; }
.town-input input:focus { border-color: var(--gold); }
.town-input button { width: 40px; height: 40px; border-radius: 11px; font-size: 19px; background: var(--surface-2); border: 1px solid var(--line); }

/* case file wills */
.case-will { display: block; margin-top: 4px; font: 12.5px/1.4 var(--type); color: var(--muted); }

/* finish particles */
.particles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.finish-card { position: relative; z-index: 1; }

/* how to play */
.guide { display: flex; flex-direction: column; gap: 18px; padding: 0 4px; }
.guide h4 { margin: 0 0 8px; font: 12.5px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); }
.guide p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.guide p b, .guide li b { color: var(--text); }
.g-roles { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 480px) { .g-roles { grid-template-columns: 1fr 1fr; } }
.g-role { --rc: var(--villager); padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--rc) 7%, transparent); border: 1px solid color-mix(in srgb, var(--rc) 28%, transparent); }
.g-role[data-role="mafia"] { --rc: var(--mafia); } .g-role[data-role="doctor"] { --rc: var(--doctor); } .g-role[data-role="detective"] { --rc: var(--detective); }
.g-role-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.g-role-head .ico { width: 28px; height: 28px; color: var(--rc); }
.g-role-head b { display: block; font: 800 17px var(--display); }
.g-role-head span { font: 11px var(--type); color: var(--rc); letter-spacing: 0.1em; text-transform: uppercase; }
.g-role p { font-size: 13.5px; }
.g-role ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.g-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.g-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.45; color: var(--muted); }
.g-steps li > span { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: var(--surface-2); color: var(--gold-hi); }
.g-steps li b { display: block; color: var(--text); font-size: 15px; }
.g-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.game-top { display: grid; grid-template-columns: 1fr auto 1fr; }
.game-top .timer { justify-self: end; }

/* small phones: the invite buttons stay on one line */
@media (max-width: 380px) {
  .code-actions { gap: 6px; }
  .code-actions .btn { padding: 0 10px; gap: 6px; }
  .room-code { font-size: 38px; }
}

/* narrow phones: the card button shrinks to its fingerprint so two action buttons fit */
@media (max-width: 400px) {
  .id-btn { width: 56px; padding: 0; justify-content: center; }
  .id-text { display: none; }
  .dock-actions .btn { font-size: 14.5px; padding: 0 10px; }
}

/* lobby: news of people walking in drops in at the bottom, so the room code stays readable */
body[data-screen="Lobby"] .toasts { top: auto; bottom: calc(24px + var(--safe-bottom)); flex-direction: column-reverse; }

/* a town chat message previewed as a tappable toast (over the prompt, never over the player cards) */
.toast.chat-toast { pointer-events: auto; cursor: pointer; padding: 8px 14px 8px 8px; }
.chat-toast .av { width: 30px; height: 30px; font-size: 13px; flex: none; }
.chat-toast .ct-body { min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; font-weight: 500; }
.chat-toast .ct-body b { font-size: 12.5px; color: var(--gold-hi); }
.chat-toast .ct-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

/* private notes inside the hold-to-peek card (detective notebook, the Family, tonight's picks) */
.role-card .rc-notes { width: 100%; max-width: 30ch; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px dashed color-mix(in srgb, var(--rc) 40%, transparent); text-align: left; }
.role-card .rc-notes h5 { margin: 0 0 6px; font: 11px var(--type); letter-spacing: 0.16em; text-transform: uppercase; color: var(--rc); }
.role-card .rc-notes ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.role-card .rc-notes li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.role-card .rc-notes li small { color: var(--faint); font: 11.5px var(--type); }
.role-card .rc-notes .verdict-m { color: #ff9eab; font-weight: 800; }
.role-card .rc-notes .verdict-c { color: #9ff0cc; font-weight: 800; }
.role-card .rc-night { font: 12.5px/1.4 var(--type); color: var(--rc); max-width: 30ch; }
.peek-card { max-height: calc(100vh - 48px); }
.peek-card .role-card { justify-content: safe center; overflow-y: auto; }

/* replay ("How it happened") */
.case-list.replay { gap: 10px; }
.rp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.rp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: var(--surface); border: 1px solid var(--line-2); }
.rp-chip .ico { width: 14px; height: 14px; }
.rp-chip.doc { color: var(--doctor); }
.rp-chip.det { color: var(--detective); }
.rp-chip.maf { color: #ff9eab; }
.rp-chip.inn { color: var(--villager); }
.rp-round { padding: 12px 12px 10px; border-radius: 16px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); animation: rise 0.5s var(--ease-out) both; }
.rp-round.night { background: linear-gradient(180deg, rgba(40, 52, 90, 0.28), rgba(0, 0, 0, 0.25)); }
.rp-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font: 12px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); }
.rp-head .ico { width: 15px; height: 15px; }
.rp-line { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 14px; color: var(--muted); line-height: 1.4; }
.rp-ico { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); font-size: 13px; }
.rp-ico .ico { width: 14px; height: 14px; }
.rp-sub { display: block; font: 11.5px var(--type); color: var(--faint); margin-top: 2px; }
.rp-name { color: var(--text); }
.rp-name[data-role="mafia"] { color: #ff9eab; }
.rp-name[data-role="doctor"] { color: #8fe3c0; }
.rp-name[data-role="detective"] { color: #a9c8ff; }
.rp-tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font: 800 11px var(--font); letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 1px; }
.rp-tag.save { background: linear-gradient(180deg, #ffd793, #e0a350); color: #2a1a06; box-shadow: 0 0 14px rgba(255, 196, 107, 0.45); }
.rp-tag.maf { background: var(--blood); color: #fff; }
.rp-tag.clean { background: rgba(79, 195, 149, 0.2); color: #9ff0cc; border: 1px solid rgba(79, 195, 149, 0.5); }
.rp-tag.inn { background: rgba(217, 196, 156, 0.16); color: var(--villager); border: 1px solid rgba(217, 196, 156, 0.4); }
.rp-out { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; font-size: 14px; font-weight: 600; background: var(--surface); }
.rp-out .ico { width: 16px; height: 16px; flex: none; }
.rp-out.dead { color: #ffb3bd; background: rgba(179, 18, 46, 0.14); }
.rp-out.caught { color: #9ff0cc; background: rgba(79, 195, 149, 0.12); }
.rp-out.calm { color: var(--muted); }
.rp-vote { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.rp-vote.out .rp-count { background: var(--blood); color: #fff; }
.rp-count { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; font-weight: 800; font-size: 12.5px; background: var(--surface-2); }
.rp-voters { display: flex; margin-left: auto; }
.rp-voters .av { width: 22px; height: 22px; font-size: 10px; margin-left: -5px; box-shadow: 0 0 0 1.5px #000; }
.rp-meta { font: 12px var(--type); color: var(--faint); padding: 2px 0; }

/* a tied vote: the tied players on the stand, everyone else steps back */
.pc.stand { border-color: rgba(255, 196, 107, 0.6); box-shadow: 0 0 0 1px rgba(255, 196, 107, 0.35), 0 10px 30px -12px rgba(255, 196, 107, 0.45); }
.pc.offstand { opacity: 0.5; filter: saturate(0.6); }
.pc.speaking { animation: speak 1.4s ease-in-out infinite !important; border-color: #ffd793; }
.pc.speaking .av { box-shadow: 0 0 0 3px #ffd793, 0 0 22px rgba(255, 215, 147, 0.7); }
@keyframes speak { 50% { box-shadow: 0 0 0 2px rgba(255, 215, 147, 0.6), 0 0 34px -4px rgba(255, 196, 107, 0.7); } }
.cine-stand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 10px; animation: rise 0.6s var(--ease-out) both; }
.cine-stand .av { width: 64px; height: 64px; font-size: 26px; box-shadow: 0 0 0 3px rgba(255, 215, 147, 0.7), 0 0 30px rgba(255, 196, 107, 0.45); }
.cine-stand .vs { font: 900 italic 20px var(--display); color: var(--gold-hi); }
.pc.speaking::after { content: '🎙 Speaking'; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 3; padding: 2px 8px; border-radius: 99px; white-space: nowrap; font: 800 10.5px var(--font); letter-spacing: 0.04em; text-transform: uppercase; color: #2a1a06; background: linear-gradient(180deg, #ffd793, #e0a350); }

/* the Family's night picks: agreed / leaning / split */
.fam-status { margin-top: 8px; padding: 6px 10px; border-radius: 10px; font-size: 13px; line-height: 1.35; color: var(--muted); background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); text-align: left; }
.fam-status b { color: var(--text); }
.fam-status.agree { color: #9ff0cc; border-color: rgba(79, 195, 149, 0.45); background: rgba(79, 195, 149, 0.1); }
.fam-status.toss { color: #ffc46b; border-color: rgba(255, 196, 107, 0.45); background: rgba(255, 196, 107, 0.08); }
.prompt-text .fam-status { display: inline-block; margin-top: 10px; }

/* secret ballots turned over on the verdict screen */
.ballots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 340px; margin: 14px auto 10px; }
.ballot { position: relative; width: 52px; height: 68px; perspective: 600px; }
.ballot .b-back, .ballot .b-front { position: absolute; inset: 0; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform 0.45s var(--ease-out); }
.ballot .b-back { background: radial-gradient(120% 90% at 30% 10%, #efe3c8, #cdb88e 70%, #b39a6c); color: #7a5a30; font: 900 24px var(--display); box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.8); }
.ballot .b-front { transform: rotateY(180deg); background: linear-gradient(180deg, #2a231d, #17130f); border: 1px solid rgba(255, 196, 107, 0.45); }
.ballot.flipped .b-back { transform: rotateY(-180deg); }
.ballot.flipped .b-front { transform: rotateY(0); }
.ballot .av { width: 30px; height: 30px; font-size: 13px; }
.ballot small { max-width: 48px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 700; color: var(--text); }
.ballot .b-skip { font: 11px var(--type); text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); }
.b-tally { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; min-height: 22px; font-size: 14px; color: var(--muted); }
.b-tally b { color: var(--text); }
.b-tally .lead, .b-tally .lead b { color: #ff9eab; }

/* ======================================================================
   Live faces and voices
   ====================================================================== */
.media-bar { display: flex; justify-content: center; gap: 8px; margin: 2px 0 12px; }
/* eyes and mouths are closed at night: no camera buttons pushing the players down */
body[data-phase="night"] #mediaGame, body[data-phase="reveal"] #mediaGame { display: none; }
#mediaLobby { margin: 0; }
.media-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 11px; border-radius: 99px; font-size: 13.5px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--line-2); transition: background 0.2s, color 0.2s, transform 0.15s var(--spring); }
.media-btn:active { transform: scale(0.94); }
.media-btn .ico { width: 18px; height: 18px; }
.media-btn.on { color: #0f2a1d; background: linear-gradient(180deg, #8ff0bf, #3ccf7f); border-color: transparent; }
.media-btn.on.held { color: var(--moon); background: rgba(184, 205, 242, 0.12); border-color: rgba(184, 205, 242, 0.35); }

/* a face fills the avatar: the card grows a video tile */
.has-face > .av { width: calc(100% - 10px); height: auto; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; font-size: 0; }
.grid.compact .has-face > .av { width: calc(100% - 8px); height: auto; }
.has-face > .av .face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; background: #000; }
.has-face > .av .face.mine { transform: scaleX(-1); }
.has-face > .av .presence { z-index: 1; right: 5px; bottom: 5px; }
.pc.dead.has-face > .av .face { filter: grayscale(1) brightness(0.6); }
.pc.dead.has-face > .av::after { z-index: 1; inset: 0; }
.pc.has-face .picks { z-index: 3; }
.l-seat.has-face { padding-top: 6px; }
.pc.has-face { padding-top: 6px; }
.talking > .av { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 0 4.5px #3ccf7f, 0 0 22px 2px rgba(60, 207, 127, 0.55) !important; transition: box-shadow 0.12s; }

/* narrator voice picker */
.voice-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.voice-row { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 14px; border-radius: 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); }
.voice-row .vr-name { font-weight: 800; font-size: 15px; }
.voice-row .vr-lang { grid-row: 2; font: 11.5px var(--type); color: var(--faint); letter-spacing: 0.05em; }
.voice-row .ico { grid-row: 1 / 3; grid-column: 2; color: var(--muted); }
.voice-row.on { border-color: rgba(201, 164, 92, 0.6); background: rgba(201, 164, 92, 0.12); }
.voice-row.on .ico { color: var(--gold-hi); }
.sheet-note.small { font-size: 12.5px; }

/* ======================================================================
   Narrator subtitles: a typed strip of old paper, pinned with tape, above the dock
   ====================================================================== */
.subs {
  position: fixed; z-index: 58; left: 50%; bottom: calc(var(--chat-h, 0px) + var(--safe-bottom) + 80px);
  width: min(calc(100vw - 32px), 460px); transform: translateX(-50%) rotate(-1deg);
  pointer-events: none; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.75));
  animation: subsIn 0.45s var(--spring) both;
}
.subs[hidden] { display: none; }
.subs.out { animation: subsOut 0.45s ease both; }
@keyframes subsIn { from { opacity: 0; transform: translateX(-50%) translateY(14px) rotate(-3deg); } }
@keyframes subsOut { to { opacity: 0; transform: translateX(-50%) translateY(10px) rotate(0deg); } }
/* during the card reveal (and over the end screen) the strip waits at the top, out of the way */
body[data-phase="reveal"] .subs, .finish:not([hidden]) ~ .subs { bottom: auto; top: calc(var(--safe-top) + 22px); }
.subs-paper {
  position: relative; padding: 13px 18px 11px;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(120, 80, 30, 0.18), transparent 55%),
    radial-gradient(90% 80% at 100% 100%, rgba(110, 70, 25, 0.22), transparent 60%),
    repeating-linear-gradient(0deg, rgba(90, 60, 30, 0.05) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #f1e6cc, #ddc9a0);
  color: #2b1f14;
}
.subs-paper p { margin: 0; min-height: 1.4em; font: 15px/1.4 var(--type); letter-spacing: 0.01em; text-wrap: pretty; }
.subs-paper p.typing::after { content: ''; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; background: #b3122e; animation: caret 0.7s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
/* a red rubber stamp in the corner */
.subs-tag {
  position: absolute; z-index: 2; top: -11px; left: 16px; padding: 2px 8px 1px; transform: rotate(-4deg);
  font: 11px var(--type); letter-spacing: 0.22em; text-transform: uppercase; color: #b3122e;
  background: #efe2c4; border: 1.5px solid #b3122e; border-radius: 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
/* a strip of tape holding it down */
.subs::after {
  content: ''; position: absolute; z-index: 2; top: -9px; right: 22px; width: 64px; height: 20px; transform: rotate(5deg);
  background: rgba(240, 230, 200, 0.55); border-left: 1px dashed rgba(0, 0, 0, 0.08); border-right: 1px dashed rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
@media (prefers-reduced-motion: reduce) { .subs, .subs.out { animation: none; } }
/* over a big story screen it drops to the bottom edge, under the story, above "Tap to continue" */
.cine:not([hidden]) ~ .subs { bottom: calc(var(--safe-bottom) + 58px); }
/* while it's up, the player grid can scroll clear of it */
body.subs-on .stage { padding-bottom: 84px; }

/* ======================================================================
   Tonight's story (lobby), the scene picker, cover jobs, story quotes
   ====================================================================== */
.scene-card { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; position: relative; overflow: hidden;
  background: radial-gradient(120% 120% at 0% 0%, rgba(201, 164, 92, 0.14), transparent 60%), var(--surface); }
.scene-card[hidden] { display: none; }
.scene-card.rolled { animation: sceneRoll 0.5s var(--spring); }
@keyframes sceneRoll { 0% { transform: rotateX(0); } 50% { transform: rotateX(80deg); opacity: 0.4; } 100% { transform: rotateX(0); } }
.sc-emoji { flex: none; width: 54px; height: 54px; display: grid; place-items: center; font-size: 30px; border-radius: 16px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-2); }
.sc-body { flex: 1; min-width: 0; }
.sc-kicker { font: 11px var(--type); text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); }
.sc-name { margin-top: 2px; font: 800 18px/1.2 var(--display); }
.sc-name span { font: 600 13.5px var(--font); color: var(--muted); }
.sc-blurb { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.sc-roll { flex: none; width: 58px; height: 58px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 22px; background: var(--surface-2); border: 1px solid var(--line-2); transition: transform 0.15s var(--spring); }
.sc-roll small { font: 9.5px var(--type); letter-spacing: 0.04em; color: var(--muted); }
.sc-roll:active { transform: scale(0.92) rotate(-8deg); }

.scene-row { flex-direction: column; align-items: stretch; }
.scene-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.scene-pick button { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 8px; border-radius: 10px; font-weight: 700; font-size: 12.5px; color: var(--muted); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-pick button span { font-size: 16px; }
.scene-pick button.on { color: #2a1d0b; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-color: transparent; }

.pc .sub { text-transform: none; letter-spacing: 0.02em; font-size: 11px; }
.pc .sub.you { text-transform: uppercase; letter-spacing: 0.07em; font-size: 10.5px; }
.role-card .rc-cover { font: 12.5px/1.35 var(--type); color: var(--muted); padding: 5px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.3); border: 1px dashed color-mix(in srgb, var(--rc) 35%, transparent); }
.role-card .rc-cover b { color: var(--text); font-family: var(--font); }

/* the narrator's line on a story screen: a quote on old paper */
.cine-quote { margin: 6px auto 0; max-width: 34ch; padding: 10px 14px; font: italic 15px/1.45 var(--font); color: #e9dcc0; border-left: 3px solid var(--gold); background: rgba(255, 230, 190, 0.06); border-radius: 0 10px 10px 0; text-align: left; animation: rise 0.9s 0.9s var(--ease-out) both; }
.finish-story { margin: -6px auto 14px; max-width: 36ch; font: italic 14.5px/1.45 var(--font); color: #e9dcc0; }
.finish-story[hidden] { display: none; }
