/* Mafia: a night room round one table. Calm motion only (slow fades and glides, one card flip, no bounce), big
   targets (48px and up), AA contrast. Transforms and opacity for anything that moves. */
:root {
  --night: #0D0720; --deep: #120A2A; --card: #1C1238; --card2: #251847; --line: rgba(185, 140, 255, 0.22);
  --ink: #1A1033; --sun: #FFD60A; --gum: #FF3D8B; --mint: #00D6A3; --lilac: #B98CFF; --sky: #4CC9F0; --ember: #FFB13B; --red: #E8262E;
  --muted: rgba(255, 255, 255, 0.74); --ease: cubic-bezier(0.22, 0.61, 0.36, 1); --slow: 1.4s;
  --tile: 96px; --bar: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--night); color: #fff; font: 600 16px/1.45 Figtree, system-ui, sans-serif; }
body { min-height: 100dvh; overscroll-behavior: none; }
a { color: var(--sun); }
h1, h2, h3 { font-family: 'Bagel Fat One', Figtree, sans-serif; font-weight: 400; margin: 0; line-height: 1.02; letter-spacing: 0.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.screen { position: relative; z-index: 1; min-height: 100dvh; }
.center { display: grid; place-items: center; padding: 24px 16px; }

/* --- the sky behind everything --- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(120% 70% at 50% -10%, #2B1766 0%, rgba(43, 23, 102, 0) 60%), radial-gradient(60% 45% at 50% 58%, rgba(255, 177, 59, 0.13), rgba(255, 177, 59, 0) 70%), var(--night); }
.wash { position: absolute; inset: 0; opacity: 0; transition: opacity 2.2s var(--ease); }
.wash--night { background: radial-gradient(90% 60% at 72% 8%, rgba(120, 170, 255, 0.24), rgba(0, 0, 0, 0) 60%), linear-gradient(180deg, #0A1238 0%, #0B0F2E 55%, #070A1F 100%); }
.wash--day { background: radial-gradient(110% 55% at 50% 108%, rgba(255, 177, 59, 0.42), rgba(255, 61, 139, 0.12) 45%, rgba(0, 0, 0, 0) 75%), linear-gradient(180deg, #2A1650 0%, #3A1B55 45%, #4A2050 100%); }
body[data-phase='night'] .wash--night { opacity: 1; }
body:is([data-phase='dawn'], [data-phase='day'], [data-phase='vote'], [data-phase='verdict']) .wash--day { opacity: 1; }
.stars { position: absolute; inset: 0 0 30% 0; opacity: 0.35; transition: opacity 2.2s var(--ease); }
.stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; animation: twinkle 5s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.25; } }
body[data-phase='night'] .stars { opacity: 1; }
body:is([data-phase='day'], [data-phase='vote'], [data-phase='verdict']) .stars { opacity: 0.08; }
.moon { position: absolute; top: 13%; left: 9%; width: 64px; height: 64px; border-radius: 50%; background: #F4F1FF; box-shadow: inset -14px -6px 0 0 #C9D3FF; opacity: 0; transform: translateY(20px); transition: opacity 2.2s var(--ease), transform 2.2s var(--ease); filter: drop-shadow(0 0 40px rgba(180, 200, 255, 0.55)); }
body[data-phase='night'] .moon { opacity: 0.95; transform: none; }
.skyline { position: absolute; left: 0; right: 0; bottom: 0; height: 26vh; color: #170F38; opacity: 0.85; transition: color 2.2s var(--ease); }
.skyline svg { width: 100%; height: 100%; display: block; }
body[data-phase='night'] .skyline { color: #0C1336; }
body:is([data-phase='day'], [data-phase='vote'], [data-phase='verdict'], [data-phase='dawn']) .skyline { color: #2B1240; }
.grain { position: absolute; inset: -50%; opacity: 0.07; 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%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% 45%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%); }

/* --- home --- */
#home { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.htop { display: flex; justify-content: space-between; align-items: center; padding: 18px 0; }
.brand { text-decoration: none; font-family: 'Bagel Fat One', sans-serif; font-size: 30px; color: var(--sun); line-height: 1; }
.brand span { display: block; font: 900 11px Figtree, sans-serif; letter-spacing: 0.3em; text-transform: uppercase; color: #fff; }
.pill { text-decoration: none; color: #fff; padding: 12px 18px; border-radius: 999px; border: 2px solid var(--line); font-weight: 900; min-height: 48px; display: inline-flex; align-items: center; }
.hero { text-align: center; display: grid; justify-items: center; }
.hero-table { position: relative; width: min(360px, 86vw); aspect-ratio: 1.25; margin: 10px 0 14px; }
.ht-table { position: absolute; inset: 22% 16%; border-radius: 50%; background: radial-gradient(60% 60% at 50% 40%, #4A2C8A, #24144F 75%); box-shadow: 0 0 0 8px #2C1A5C, 0 0 80px rgba(255, 177, 59, 0.28), inset 0 -16px 30px rgba(0, 0, 0, 0.4); }
.hero-table span { --r: calc(var(--a) * 60deg - 90deg); position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; display: grid; place-items: center; font: 900 18px Figtree; color: var(--ink);
  background: var(--c); box-shadow: 0 0 0 4px rgba(13, 7, 32, 0.9), 0 0 0 7px var(--c), 0 10px 24px rgba(0, 0, 0, 0.45);
  transform: translate(calc(cos(var(--r)) * 44cqw), calc(sin(var(--r)) * 30cqw)); opacity: 0; animation: seatIn 1.2s var(--ease) forwards; animation-delay: calc(var(--a) * 0.12s + 0.2s); }
.hero-table { container-type: inline-size; }
@keyframes seatIn { from { opacity: 0; } to { opacity: 1; } }
.ht-mark { position: absolute; left: 50%; top: 50%; width: 92px; height: 92px; transform: translate(-50%, -50%); filter: drop-shadow(0 8px 24px rgba(255, 61, 139, 0.45)); }
.ht-mark svg { width: 100%; height: 100%; }
.kicker { margin: 12px 0 6px; color: var(--lilac); font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; }
.title { font-size: clamp(76px, 22vw, 136px); color: var(--gum); text-shadow: 0 0 40px rgba(255, 61, 139, 0.4), 0 6px 0 #5A0B2E; }
.title span { display: inline-block; opacity: 0; transform: translateY(14px); animation: rise 1.4s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.lede { color: var(--muted); font-size: 18px; max-width: 42ch; margin: 10px auto 22px; opacity: 0; animation: rise 1.4s 0.5s var(--ease) forwards; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.signin { display: grid; gap: 14px; padding: 20px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); max-width: 460px; }
.signin p { margin: 0; color: var(--muted); }
.signin .btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.note { background: rgba(255, 214, 10, 0.12); border: 1px solid rgba(255, 214, 10, 0.4); padding: 12px 16px; border-radius: 16px; margin: 0 0 8px; }
.how { list-style: none; padding: 0; margin: 40px 0 0; display: grid; gap: 12px; }
.how li { background: rgba(28, 18, 56, 0.86); border: 1px solid var(--line); border-radius: 24px; padding: 18px 18px 16px; display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; }
.how b { grid-row: span 2; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--gum); color: #fff; font-family: 'Bagel Fat One', sans-serif; font-size: 22px; }
.how h3 { font-size: 22px; align-self: end; }
.how p { margin: 4px 0 0; color: var(--muted); }
.safety { margin-top: 18px; padding: 20px; border-radius: 24px; background: rgba(0, 214, 163, 0.08); border: 1px solid rgba(0, 214, 163, 0.35); }
.safety h3 { font-size: 20px; color: var(--mint); }
.safety ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.foot { margin-top: 30px; color: rgba(255, 255, 255, 0.6); font-size: 14px; text-align: center; }

/* --- buttons, cards, forms --- */
.btn { appearance: none; border: 0; min-height: 52px; padding: 0 26px; border-radius: 999px; background: var(--sun); color: var(--ink); font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.6); transition: transform 0.25s var(--ease), opacity 0.25s, background-color 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: rgba(255, 255, 255, 0.04); color: #fff; border: 2px solid var(--line); box-shadow: none; }
.btn.gum { background: var(--gum); color: #fff; }
.btn.mint { background: var(--mint); }
.btn.on { background: var(--mint); color: var(--ink); }
.btn.small { min-height: 48px; padding: 0 18px; font-size: 15px; }
.btn.wide { width: 100%; }
.card { width: 100%; max-width: 440px; background: rgba(28, 18, 56, 0.94); border: 1px solid var(--line); border-radius: 28px; padding: 24px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.card h2 { font-size: 32px; }
.card p { margin: 0; color: var(--muted); }
.card p b { color: #fff; }
label { display: grid; gap: 6px; font-weight: 800; }
input { width: 100%; min-height: 52px; border-radius: 16px; border: 2px solid var(--line); background: var(--deep); color: #fff; padding: 0 14px; font: 800 18px Figtree, sans-serif; }
input:focus { outline: none; border-color: var(--lilac); }
#f-code { text-transform: uppercase; letter-spacing: 0.3em; }
.err { color: #FF9EC4; min-height: 1.2em; margin: 0; font-weight: 800; }
.cam-card { justify-items: center; text-align: center; }
.cam-preview { position: relative; width: 168px; height: 168px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 35%, #3A2370, #1A0F3D); box-shadow: 0 0 0 5px var(--sun), 0 0 0 12px rgba(255, 214, 10, 0.16), 0 20px 50px rgba(0, 0, 0, 0.5); }
.cam-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-ini { position: absolute; inset: 0; display: grid; place-items: center; font: 400 56px 'Bagel Fat One'; color: var(--sun); }
.cam-preview.live .cam-ini { display: none; }

/* --- the game screen --- */
#game { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.bar { display: flex; align-items: center; gap: 8px; min-height: var(--bar); padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); z-index: 3; }
/* Inside the Funn app its own close button sits top left: leave it room. */
body.in-app .bar, body.in-app .htop { padding-left: 72px; }
.htop { padding-top: max(18px, env(safe-area-inset-top)); }
.chip { min-height: 48px; border-radius: 16px; border: 1px solid var(--line); background: rgba(18, 10, 42, 0.72); backdrop-filter: blur(8px); padding: 4px 12px; display: grid; align-content: center; text-align: left; line-height: 1.1; }
.chip small { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--lilac); font-weight: 900; }
.chip b { font: 400 20px 'Bagel Fat One'; letter-spacing: 0.12em; color: var(--sun); }
.role-chip { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 14px; }
.role-chip svg { width: 30px; height: 30px; }
.bar-tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.bar { min-width: 0; }
@media (max-width: 599px) { .moon { width: 42px; height: 42px; top: 76px; left: 14px; box-shadow: inset -9px -4px 0 0 #C9D3FF; } #t-voice, #t-sound { display: none; } .role-chip span { display: none; } .role-chip { padding: 4px 8px; } .chip.code { padding: 4px 10px; } }
.tool { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: rgba(18, 10, 42, 0.72); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 0; transition: background-color 0.3s; }
.tool svg { width: 22px; height: 22px; }
.tool[aria-pressed='false'] { background: rgba(232, 38, 46, 0.22); border-color: rgba(255, 120, 140, 0.5); }
.tool .dot { position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--gum); box-shadow: 0 0 0 2px var(--night); }
.room { position: relative; display: grid; grid-template-columns: 1fr; min-height: 0; }
.stage { position: relative; min-height: 0; margin: 0 8px; }

/* The table: a warm pool of light on dark wood-felt. */
.table { position: absolute; left: 50%; top: var(--hy, 50%); width: var(--tw, 60%); height: var(--th, 60%); transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(70% 70% at 50% 35%, #4B2D8C 0%, #2C1863 55%, #1B0E45 100%);
  box-shadow: 0 0 0 10px #2A185A, 0 0 0 12px rgba(185, 140, 255, 0.25), 0 30px 90px rgba(0, 0, 0, 0.6), inset 0 -24px 50px rgba(0, 0, 0, 0.45); transition: filter 2.2s var(--ease); }
.pool { position: absolute; inset: -12%; border-radius: 50%; background: radial-gradient(50% 50% at 50% 45%, rgba(255, 214, 10, 0.26), rgba(255, 177, 59, 0.08) 55%, rgba(255, 177, 59, 0) 72%); mix-blend-mode: screen; transition: opacity 2.2s var(--ease); }
body[data-phase='night'] .pool { opacity: 0.18; }
body[data-phase='night'] .table { filter: hue-rotate(-25deg) saturate(0.7) brightness(0.8); }

.seats { position: absolute; inset: 0; }
.seat { position: absolute; left: 0; top: 0; width: var(--tile); display: grid; justify-items: center; gap: 6px; transform: translate(calc(var(--x) - 50%), calc(var(--y) - var(--tile) / 2)); transition: transform 1.2s var(--ease), opacity 1s; }
.ring { position: relative; width: var(--tile); height: var(--tile); border-radius: 50%; padding: 0; border: 0; background: radial-gradient(circle at 50% 35%, #3A2370, #160C38); box-shadow: 0 0 0 4px var(--hue), 0 0 0 9px color-mix(in srgb, var(--hue) 20%, transparent), 0 14px 34px rgba(0, 0, 0, 0.55); overflow: visible; transition: box-shadow 0.6s var(--ease), transform 0.6s var(--ease); }
.ring .clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.ring video { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 1.4s var(--ease), transform 1.4s var(--ease), opacity 0.6s; }
.seat.me video { transform: scaleX(-1); }
.ring .ini { position: absolute; inset: 0; display: grid; place-items: center; font: 400 calc(var(--tile) * 0.36) 'Bagel Fat One'; color: var(--hue); }
.ring.has-video .ini { opacity: 0; }
.ring::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; border: 3px solid var(--hue); opacity: 0; pointer-events: none; }
.seat.speaking .ring::after { animation: speak 1.8s ease-in-out infinite; }
@keyframes speak { 0%, 100% { opacity: 0.85; transform: scale(1); } 50% { opacity: 0.25; transform: scale(1.07); } }
.pill { max-width: calc(var(--tile) + 40px); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; background: rgba(13, 7, 32, 0.84); border: 1px solid color-mix(in srgb, var(--hue) 45%, transparent); font-size: 13px; font-weight: 900; white-space: nowrap; }
.pill b { overflow: hidden; text-overflow: ellipsis; }
/* A small stage (a 320 px phone, a phone on its side): faces in rows, not round the table (js/mafia-layout.js). */
.stage.rows .seat { gap: 4px; }
.stage.rows .seat .pill { max-width: var(--name, 60px); min-height: 0; padding: 2px 6px 2px 5px; gap: 4px; font-size: 11px; }
.stage.rows .seat .pill i { width: 6px; height: 6px; }
.stage.rows .hub { gap: 3px; }
.stage.rows .hub-kicker { display: none; }
.stage.rows .timer { width: 58px; }
.stage.rows .timer b { font-size: 17px; }
.stage.rows .hub .code-big { font-size: 34px; }
.pill i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--hue); font-style: normal; }
.seat.away .pill i { background: rgba(255, 255, 255, 0.3); }
.tag { position: absolute; z-index: 2; left: 50%; bottom: -6px; transform: translateX(-50%); padding: 2px 9px; border-radius: 999px; font: 900 11px Figtree; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; background: var(--sun); color: var(--ink); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.tag.host { background: var(--lilac); }
.tag.gum { background: var(--gum); color: #fff; }
.tag.mint { background: var(--mint); }
.tag.sky { background: var(--sky); }
.icons { position: absolute; top: -4px; right: -4px; display: flex; gap: 3px; z-index: 2; }
.icons span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(13, 7, 32, 0.9); border: 1px solid var(--line); }
.icons svg { width: 14px; height: 14px; }
.seat .warn { position: absolute; inset: 12%; display: grid; place-items: center; text-align: center; font-size: 10px; font-weight: 800; line-height: 1.15; color: var(--muted); }

/* Tappable (a pick or a vote): a soft lift on hover, a ring of the action's colour when chosen. */
.seat.can .ring { cursor: pointer; }
.seat.can .ring:hover { transform: translateY(-3px); }
.seat.can .ring:focus-visible { outline: 3px solid #fff; outline-offset: 8px; }
.seat.chosen .ring { box-shadow: 0 0 0 4px var(--act), 0 0 0 12px color-mix(in srgb, var(--act) 30%, transparent), 0 0 46px color-mix(in srgb, var(--act) 60%, transparent); }
.cross { position: absolute; inset: -16px; pointer-events: none; color: var(--gum); opacity: 0; transform: rotate(-30deg) scale(1.15); transition: opacity 0.8s var(--ease), transform 1s var(--ease); }
.cross svg { width: 100%; height: 100%; }
.seat.aimed .cross { opacity: 1; transform: none; }
.cross b { position: absolute; right: 2px; top: 2px; min-width: 24px; height: 24px; border-radius: 12px; background: var(--gum); color: #fff; font: 900 13px/24px Figtree; text-align: center; }

/* Night: faces blur and dim; out players grey. */
body[data-phase='night'] .ring video, body[data-phase='deal'] .ring video { filter: blur(14px) saturate(0.5) brightness(0.65); transform: scale(1.2); }
body[data-phase='night'] .seat.me video, body[data-phase='deal'] .seat.me video { transform: scaleX(-1) scale(1.2); }
body[data-phase='night'] .ring { box-shadow: 0 0 0 4px color-mix(in srgb, var(--hue) 55%, #3A4A8A), 0 14px 34px rgba(0, 0, 0, 0.6); }
body[data-phase='night'] .seat.chosen .ring { box-shadow: 0 0 0 4px var(--act), 0 0 0 12px color-mix(in srgb, var(--act) 30%, transparent), 0 0 46px color-mix(in srgb, var(--act) 60%, transparent); }
.seat.out .ring { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.22), 0 14px 34px rgba(0, 0, 0, 0.5); }
.seat.out video, .seat.out .ini { filter: grayscale(1) brightness(0.5) !important; }
.seat.out .pill { opacity: 0.7; border-color: rgba(255, 255, 255, 0.2); }
.seat.out .pill i { background: rgba(255, 255, 255, 0.3); }
.stamp { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-14deg); padding: 3px 12px; border: 3px solid rgba(255, 255, 255, 0.85); border-radius: 10px; font: 400 calc(var(--tile) * 0.2) 'Bagel Fat One'; letter-spacing: 0.06em; color: #fff; background: rgba(13, 7, 32, 0.4); }

/* The middle of the table. */
.hub { position: absolute; left: 50%; top: var(--hy, 50%); transform: translate(-50%, -50%); width: var(--hw, 46%); display: grid; justify-items: center; text-align: center; gap: 6px; pointer-events: none; }
.hub > * { pointer-events: auto; }
.hub-kicker { margin: 0; font: 900 12px Figtree; letter-spacing: 0.2em; text-transform: uppercase; color: var(--lilac); }
.hub-title { font-size: clamp(26px, 5.4vmin, 52px); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45); }
body[data-phase='night'] .hub-title { color: #CFE0FF; }
body:is([data-phase='day'], [data-phase='dawn']) .hub-title { color: var(--sun); }
body[data-phase='vote'] .hub-title { color: var(--gum); }
.hub-sub { margin: 0; color: var(--muted); font-size: 15px; max-width: 30ch; }
@media (max-width: 599px) { .hub-sub { font-size: 13px; } .hub-kicker { font-size: 11px; } .hub-title { font-size: 24px; } }
.hub .code-big { font: 400 clamp(36px, 8vmin, 64px) 'Bagel Fat One'; letter-spacing: 0.16em; color: var(--sun); text-shadow: 0 0 30px rgba(255, 214, 10, 0.35); }
.timer { position: relative; width: clamp(76px, 15vmin, 140px); aspect-ratio: 1; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.t-bg { fill: rgba(13, 7, 32, 0.5); stroke: rgba(255, 255, 255, 0.12); stroke-width: 7; }
.t-fg { fill: none; stroke: var(--sun); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100; transition: stroke-dashoffset 0.3s linear, stroke 1s; }
body[data-phase='night'] .t-fg { stroke: #9DB8FF; }
body[data-phase='vote'] .t-fg { stroke: var(--gum); }
.timer b { position: absolute; inset: 0; display: grid; place-items: center; font: 400 clamp(20px, 4.4vmin, 38px) 'Bagel Fat One'; }

/* Vote chips flying to their target. */
.flyers { position: absolute; inset: 0; pointer-events: none; }
.fly { position: absolute; left: 0; top: 0; width: 26px; height: 26px; margin: -13px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px rgba(13, 7, 32, 0.9), 0 6px 14px rgba(0, 0, 0, 0.5); font: 900 11px/26px Figtree; color: var(--ink); text-align: center; transition: transform 1.1s var(--ease), opacity 0.6s; }
.count { position: absolute; z-index: 3; top: -10px; left: -10px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px; background: var(--gum); color: #fff; font: 400 18px/34px 'Bagel Fat One'; text-align: center; box-shadow: 0 0 0 3px var(--night); transition: transform 0.5s var(--ease); }

/* The dock: the narrator's caption and what you can do now. */
.dock { position: relative; z-index: 3; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); display: grid; gap: 10px; justify-items: center; }
.caption { margin: 0; max-width: 60ch; text-align: center; font-size: 16px; font-weight: 700; color: #fff; min-height: 1.45em; padding: 8px 16px; border-radius: 16px; background: rgba(13, 7, 32, 0.6); backdrop-filter: blur(6px); transition: opacity 0.8s var(--ease); }
.caption:empty { opacity: 0; }
.caption.fade { opacity: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.actions .hint { color: var(--muted); font-weight: 800; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(13, 7, 32, 0.7); border: 1px solid var(--line); }
.seg button { min-height: 44px; min-width: 52px; border-radius: 999px; border: 0; background: transparent; font-weight: 900; }
.seg button[aria-pressed='true'] { background: var(--lilac); color: var(--ink); }
.notes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* Chat: a drawer on phones, a column on laptops. */
.side { position: fixed; z-index: 6; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); display: grid; grid-template-rows: auto 1fr auto auto; gap: 8px; padding: 14px; background: rgba(18, 10, 42, 0.97); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform 0.7s var(--ease); }
body.chat-open .side { transform: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h3 { font-size: 22px; }
.chat { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat li { padding: 8px 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border-left: 4px solid var(--hue, var(--lilac)); }
.chat li b { display: block; font-size: 12px; color: var(--hue, var(--lilac)); }
.chat li.mafia { background: rgba(255, 61, 139, 0.12); }
.chat li.out { background: rgba(255, 255, 255, 0.03); color: var(--muted); }
.chat li.chat-empty { border: 0; background: none; margin: auto 0; text-align: center; color: var(--muted); font-size: 14px; padding: 20px 10px; }
.chat-empty b { display: block; font: 400 22px 'Bagel Fat One'; color: var(--lilac); margin-bottom: 6px; }
.chat li.sys { border: 0; background: none; text-align: center; color: var(--muted); font-size: 13px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { min-height: 48px; font-size: 16px; }
@media (min-width: 1000px) {
  .room { grid-template-columns: 1fr 340px; }
  .side { position: relative; transform: none; inset: auto; width: auto; margin: 0 12px 12px 0; border-radius: 24px; border: 1px solid var(--line); background: rgba(18, 10, 42, 0.78); backdrop-filter: blur(10px); }
  .close-side, .chat-tool { display: none; }
}

/* --- overlays --- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; align-content: center; gap: 18px; padding: 24px 16px; background: rgba(7, 4, 20, 0.78); backdrop-filter: blur(10px); animation: fadeIn 0.8s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.card3d { position: relative; width: min(300px, 78vw); aspect-ratio: 0.68; perspective: 1400px; cursor: pointer; }
.card3d .face { position: absolute; inset: 0; border-radius: 28px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform 1.1s var(--ease); box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6); overflow: hidden; }
.card3d .back { background: radial-gradient(70% 50% at 50% 45%, rgba(255, 61, 139, 0.32), rgba(255, 61, 139, 0) 70%), repeating-linear-gradient(45deg, rgba(185, 140, 255, 0.09) 0 2px, transparent 2px 22px), repeating-linear-gradient(-45deg, rgba(185, 140, 255, 0.09) 0 2px, transparent 2px 22px), linear-gradient(160deg, #2E1868, #1A0D44); border: 3px solid var(--lilac); display: grid; place-items: center; }
.card3d .back::before { content: ''; position: absolute; inset: 14px; border-radius: 18px; border: 2px dashed rgba(185, 140, 255, 0.35); }
.back-art { display: grid; justify-items: center; gap: 10px; }
.back-art .moon-mark { width: 120px; height: 120px; border-radius: 50%; background: #F4F1FF; box-shadow: inset -26px -10px 0 0 #C9D3FF, 0 0 60px rgba(200, 210, 255, 0.45); }
.back-art h3 { font-size: 46px; color: var(--gum); text-shadow: 0 4px 0 #4A0A28; }
.back-art small { font: 900 12px Figtree; letter-spacing: 0.3em; text-transform: uppercase; color: var(--sun); }
.back-art span { font-weight: 900; letter-spacing: 0.04em; margin-top: 10px; padding: 10px 18px; border-radius: 999px; background: rgba(13, 7, 32, 0.6); border: 1px solid var(--line); }
.card3d .front { transform: rotateY(180deg); background: radial-gradient(90% 60% at 50% 30%, color-mix(in srgb, var(--rc) 35%, #1C1238), #140A30 75%); border: 3px solid var(--rc); display: grid; align-content: center; justify-items: center; text-align: center; gap: 10px; padding: 22px; }
.card3d.flipped .back { transform: rotateY(-180deg); }
.card3d.flipped .front { transform: rotateY(0); }
.front .mark { width: 46%; filter: drop-shadow(0 12px 30px color-mix(in srgb, var(--rc) 55%, transparent)); }
.front .mark svg { width: 100%; height: auto; }
.front .card-side { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); padding: 5px 14px; border-radius: 999px; font: 900 11px Figtree; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink); background: var(--rc); white-space: nowrap; }
.front .corner { position: absolute; width: 34px; opacity: 0.5; }
.front .corner svg { width: 100%; height: auto; }
.front .corner.tl { left: 16px; top: 14px; } .front .corner.br { right: 16px; top: 14px; }
.front small { font: 900 12px Figtree; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.front h2 { font-size: clamp(40px, 12vw, 56px); color: var(--rc); }
.front p { margin: 0; color: #fff; font-size: 16px; }
.front .team { margin-top: 4px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 61, 139, 0.16); font-weight: 800; font-size: 14px; }
.role-note { margin: 0; color: var(--muted); text-align: center; }

.end { align-content: start; overflow-y: auto; background: radial-gradient(80% 50% at 50% 10%, color-mix(in srgb, var(--wc) 30%, transparent), rgba(7, 4, 20, 0.92) 70%); padding-top: max(40px, 8vh); }
.end-kicker { margin: 0; font: 900 13px Figtree; letter-spacing: 0.24em; text-transform: uppercase; color: var(--lilac); }
.end-title { font-size: clamp(56px, 15vw, 128px); color: var(--wc); text-align: center; text-shadow: 0 0 50px color-mix(in srgb, var(--wc) 45%, transparent), 0 6px 0 rgba(0, 0, 0, 0.5); opacity: 0; transform: translateY(18px); animation: rise 1.6s 0.2s var(--ease) forwards; }
.end-line { margin: 0; max-width: 40ch; text-align: center; color: var(--muted); font-size: 18px; }
.lineup { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 980px; }
.lineup li { width: 132px; padding: 16px 10px 14px; border-radius: 22px; background: rgba(28, 18, 56, 0.92); border: 1px solid var(--line); display: grid; justify-items: center; gap: 8px; text-align: center; opacity: 0; transform: translateY(16px); animation: rise 0.9s var(--ease) forwards; animation-delay: calc(0.4s + var(--i) * 0.08s); }
.lineup li.win { border-color: var(--wc); box-shadow: 0 0 0 1px var(--wc), 0 16px 40px rgba(0, 0, 0, 0.4); }
.lineup .av { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--hue); color: var(--ink); font: 400 24px 'Bagel Fat One'; }
.lineup li.dead .av { filter: grayscale(0.8) brightness(0.7); }
.lineup b { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px; border-radius: 999px; background: color-mix(in srgb, var(--rc) 20%, transparent); color: var(--rc); font: 900 11px Figtree; letter-spacing: 0.06em; text-transform: uppercase; }
.badge svg { width: 22px; height: 22px; }
@media (max-width: 599px) {
  .end { gap: 12px; padding-top: 32px; }
  .lineup { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .lineup li { width: auto; grid-template-columns: 44px 1fr auto; justify-items: start; align-items: center; text-align: left; padding: 8px 12px 8px 8px; border-radius: 18px; gap: 12px; }
  .lineup .av { width: 44px; height: 44px; font-size: 18px; }
  .end-line { font-size: 16px; }
}
.end-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; padding-bottom: 24px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; background: var(--c); opacity: 0.9; animation: drift var(--d) linear var(--w) infinite; }
@keyframes drift { to { transform: translate(var(--dx), 110vh) rotate(540deg); } }

.sheet-wrap { align-content: end; padding: 0; }
.sheet { width: min(480px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 28px 28px 0 0; padding: 22px 18px max(22px, env(safe-area-inset-bottom)); display: grid; gap: 10px; animation: slideUp 0.7s var(--ease); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { font-size: 26px; }
.sheet-actions { display: grid; gap: 10px; }
.sheet p { margin: 0; color: var(--muted); }
/* --- face props (js/mafia-face.js places them; they glide, never snap) --- */
.seat .pill { position: relative; z-index: 2; } /* a name always reads over a hanging chain */
.ring .props, .props-preview .props { position: absolute; inset: 0; z-index: 1; pointer-events: none; transition: opacity 1.4s var(--ease), filter 1.4s var(--ease); }
.props.mirror { transform: scaleX(-1); }
.props .prop { position: absolute; left: 0; top: 0; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45)); animation: fadeIn 0.9s var(--ease); will-change: transform; }
.props .prop svg { display: block; width: 100%; height: 100%; }
body[data-phase='night'] .ring .props, body[data-phase='deal'] .ring .props { opacity: 0; }
.seat.out .props { opacity: 0.55; filter: grayscale(1); }
.props-sheet { gap: 14px; }
.props-head { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.props-preview { position: relative; width: 104px; height: 104px; border-radius: 50%; margin: 6px; background: radial-gradient(circle at 50% 35%, #3A2370, #160C38); box-shadow: 0 0 0 4px var(--hue, var(--sun)), 0 0 0 9px color-mix(in srgb, var(--hue, var(--sun)) 20%, transparent); }
.props-preview .clip { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.props-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0; transition: opacity 0.6s; }
.props-preview.has-video video { opacity: 1; }
.props-preview .ini { position: absolute; inset: 0; display: grid; place-items: center; font: 400 38px 'Bagel Fat One'; color: var(--hue, var(--sun)); }
.props-preview.has-video .ini { opacity: 0; }
.props-name { font: 900 15px Figtree; color: var(--sun) !important; }
.props-note { font-size: 13px; }
.props-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.prop-btn { aspect-ratio: 1; min-height: 52px; border-radius: 18px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 45%, rgba(214, 196, 255, 0.34), rgba(185, 140, 255, 0.08) 72%); display: grid; place-items: center; padding: 8px; color: var(--muted); transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease), box-shadow 0.4s var(--ease); }
.prop-btn svg { width: 100%; height: 100%; max-height: 40px; }
.prop-btn:hover { border-color: rgba(185, 140, 255, 0.6); }
.prop-btn[aria-pressed='true'] { background: radial-gradient(circle at 50% 45%, rgba(255, 230, 120, 0.45), rgba(255, 214, 10, 0.12) 72%); border-color: var(--sun); box-shadow: 0 0 0 2px var(--sun), 0 0 24px rgba(255, 214, 10, 0.25); }
.prop-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.props-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --- the out: a ghost of themselves (see-through, grey, a small ghost mark) --- */
.ring .ghost { position: absolute; z-index: 2; left: -6px; top: -6px; width: calc(var(--tile) * 0.3); min-width: 20px; max-width: 34px; opacity: 0; transform: translateY(4px); transition: opacity 1.2s var(--ease), transform 1.2s var(--ease); pointer-events: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5)); }
.ring .ghost svg { display: block; width: 100%; height: auto; }
.seat.out .ring .ghost { opacity: 0.95; transform: none; }
.seat.out .ring .clip { opacity: 0.62; transition: opacity 1.2s var(--ease); }
.seat.out .ring .clip::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 50% 38%, rgba(230, 225, 255, 0.22), rgba(150, 140, 220, 0.18) 70%); pointer-events: none; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 12px 18px; border-radius: 16px; background: var(--card2); border: 1px solid var(--line); font-weight: 800; max-width: 90vw; text-align: center; animation: fadeIn 0.5s var(--ease); }

@media (min-width: 1000px) {
  :root { --bar: 76px; }
  .bar { padding: 12px 20px; }
  .caption { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.2s !important; }
  .confetti, .stars i { display: none; }
  .title span, .lede, .end-title, .lineup li, .hero-table span { opacity: 1; transform: none; }
  .hero-table span { transform: translate(calc(cos(var(--r)) * 44cqw), calc(sin(var(--r)) * 30cqw)); }
}
