:root {
  --bg: #EEF1EA; --fg: #1E2233; --card: #FFFFFF; --line: #CCD2C4; --muted: #5B6170; --blood: #C93A2A;
  --display: "Bowlby One", "Arial Black", Impact, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Gaegu", "Comic Sans MS", "Comic Neue", cursive;
  --role-bad: #C93A2A; --role-town: #2E6FB0; --role-neutral: #8B3FC9; --role-wolf: #8A5A2B; --role-fire: #D9631A; --role-witch: #2F8F5B;
  color-scheme: light;
}
/* the whole app flips to ink blue at night */
body.night {
  --bg: #151B36; --fg: #E6E8F4; --card: #222A4D; --line: #38416B; --muted: #A3A9C9; --blood: #E0533F;
  --role-bad: #FF7A66; --role-town: #8FB8F0; --role-neutral: #C9A0F0; --role-wolf: #D8AE80; --role-fire: #F5A55A; --role-witch: #7FD3A6;
  color-scheme: dark;
}
body { transition: background-color .4s, color .4s; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 17px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }

.screen { min-height: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center { justify-content: center; }
.center-text { text-align: center; }
.spacer { flex: 1; }
.bar { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.bar a { color: inherit; }
.logo { font-family: var(--display); font-weight: 400; font-size: 64px; line-height: 1; margin: 0; text-align: center; }
.title { font-size: 22px; font-weight: 700; margin: 0; line-height: 1.2; }
.label { font-size: 14px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.err { color: var(--blood); min-height: 1.4em; margin: 0; text-align: center; font-weight: 700; }
.or { text-align: center; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

.btn { display: block; width: 100%; border: 2px solid var(--fg); background: var(--fg); color: var(--bg); padding: 14px; border-radius: 14px; font-weight: 700; font-size: 17px; }
.btn.ghost { background: transparent; color: var(--fg); }
.btn.small { width: auto; padding: 8px 14px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .35; cursor: default; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; font-size: 15px; }

.codeinput { width: 100%; text-align: center; font-family: var(--display); font-size: 40px; letter-spacing: .35em; padding: 10px 0 10px .35em; border: 2px solid var(--fg); border-radius: 14px; background: var(--card); text-transform: uppercase; }
.codeinput::placeholder { color: var(--line); }
.textinput { width: 100%; font-family: var(--hand); font-size: 30px; font-weight: 700; padding: 8px 14px; border: 2px solid var(--fg); border-radius: 14px; background: var(--card); }

.codeline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bigcode { font-family: var(--display); font-size: 40px; letter-spacing: .12em; line-height: 1; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; padding: 4px; border-radius: 12px; text-align: left; }
.prow.away { opacity: .5; }
.nm { font-family: var(--hand); font-size: 26px; font-weight: 700; line-height: 1; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: var(--line); white-space: nowrap; }
.av { width: 48px; height: 48px; border-radius: 12px; flex: none; }
img.av { background: #fff; border: 3px solid; object-fit: cover; }
.dotav { display: grid; place-items: center; color: #fff; font-family: var(--hand); font-weight: 700; font-size: 26px; text-transform: uppercase; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--fg); background: var(--card); font-family: var(--hand); font-size: 22px; font-weight: 700; line-height: 1; }

#huePicker { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#huePicker[hidden] { display: none; }
.huegrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.huebtn { aspect-ratio: 1; border-radius: 50%; border: 0; color: #fff; font-family: var(--hand); font-weight: 700; font-size: 18px; text-transform: uppercase; }
.huebtn:disabled { opacity: .3; cursor: default; }
.huebtn.on { outline: 3px solid var(--fg); outline-offset: 2px; }

.drawscreen { gap: 12px; }
.pad { width: 100%; aspect-ratio: 1; border-radius: 16px; background: #fff; border: 2px solid var(--line); touch-action: none; display: block; }
.swatches { display: flex; justify-content: space-between; gap: 8px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(0,0,0,.18); }
.sw.on { outline: 3px solid var(--fg); outline-offset: 3px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--fg); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 10px 4px; font-weight: 700; }
.seg button.on { background: var(--fg); color: var(--bg); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#banner { position: fixed; top: 0; left: 0; right: 0; padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px; background: var(--blood); color: #fff; text-align: center; font-weight: 700; font-size: 14px; z-index: 10; }


.tight { gap: 6px; }
.btn.red { background: var(--blood); border-color: var(--blood); color: #fff; }
.btn.chosen { outline: 3px solid var(--fg); outline-offset: 3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card.accuse, .accuse { flex-direction: row; align-items: center; gap: 12px; }
.card.claim { border: 2px solid var(--blood); }
.ghostcard { font-size: 15px; display: block; }
.headline { font-family: var(--display); font-weight: 400; font-size: 38px; line-height: 1.05; margin: 0; text-wrap: balance; }
.headline.red { color: var(--blood); }
.bigline { font-size: 21px; font-weight: 700; margin: 0; }

.av.big { width: 64px; height: 64px; }
.av.huge { width: 140px; height: 140px; border-radius: 22px; align-self: center; font-size: 64px; }
/* dead: a big red cross over the face */
.avx { position: relative; display: inline-flex; flex: none; }
.avx > .av { filter: grayscale(.7); opacity: .7; }
.avx::before, .avx::after { content: ""; position: absolute; left: -8%; top: 50%; width: 116%; height: 14%; min-height: 5px; margin-top: -7%; background: #D62F1E; border-radius: 4px; box-shadow: 0 0 0 1.5px #fff; }
.avx::before { transform: rotate(45deg); }
.avx::after { transform: rotate(-45deg); }
.avx:has(.huge) { align-self: center; }


.pgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; }
.pcell { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; min-width: 0; }
.pcell .av { width: 56px; height: 56px; }
.pcell .tag { font-size: 10px; padding: 2px 6px; }
.pname { font-family: var(--hand); font-size: 20px; font-weight: 700; line-height: 1; overflow-wrap: anywhere; }
.pcell.dead .pname { opacity: .6; }
.prow.dead { opacity: .55; }

.picklist { display: flex; flex-direction: column; gap: 8px; }
.pickrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 10px 6px 6px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); text-align: left; }
.pickrow.sel { border-color: var(--fg); box-shadow: 0 0 0 2px var(--fg) inset; }
body.night .pickrow.sel { border-color: #F0C64A; box-shadow: 0 0 0 2px #F0C64A inset; }
.pickrow:disabled { opacity: .35; cursor: default; }

/* role cards: only visible while held */
.rolecard { border-radius: 18px; border: 2px dashed var(--line); background: var(--card); min-height: 260px; display: grid; place-items: center; padding: 18px; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; }
.rolecard-hidden { font-weight: 700; color: var(--muted); text-align: center; }
.rolecard-shown, .peek-card { display: none; flex-direction: column; gap: 8px; }
.rolecard.held { border: 2px solid #F0C64A; place-items: stretch; }
.rolecard.held .rolecard-hidden, .peek.held .peek-hint { display: none; }
.rolecard.held .rolecard-shown, .peek.held .peek-card { display: flex; }
.rolecard p, .peek p { margin: 0; }
.rolename { font-family: var(--display); font-size: 36px; line-height: 1; }
body.night .rolename { color: #F0C64A; }
.peek { border: 2px dashed var(--line); border-radius: 14px; padding: 10px 14px; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; cursor: pointer; }
.peek-hint { text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.peek.held { border-style: solid; background: var(--card); }

.votes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.votes > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vh { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.vh.yes { color: var(--blood); }
.voter { display: flex; align-items: center; gap: 6px; font-family: var(--hand); font-size: 21px; font-weight: 700; line-height: 1; }
.voter i { width: 12px; height: 12px; border-radius: 50%; flex: none; }

.mini { border: 2px dashed var(--line); border-radius: 16px; padding: 28px 16px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.mini p { margin: 0; }

.step { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.step.muted { color: var(--muted); }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper b { min-width: 1.5em; text-align: center; font-variant-numeric: tabular-nums; font-size: 19px; }
.stepper button { width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--fg); background: transparent; font-weight: 700; font-size: 20px; line-height: 1; }
.stepper button:disabled { opacity: .3; }
.tog { width: 48px; height: 28px; border-radius: 14px; background: var(--line); border: 0; position: relative; flex: none; padding: 0; }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.tog.on { background: var(--fg); }
.tog.on::after { left: 23px; background: var(--bg); }
.seg button:disabled { opacity: .35; }
.chip.on { background: var(--fg); color: var(--bg); }
span.chip { font-size: 19px; padding: 6px 12px; }
button.prow.mine { outline: 2px dashed var(--line); }
.timer { font-variant-numeric: tabular-nums; color: var(--fg); }

/* ghost whispers */
.whisper { font-family: var(--hand); font-size: 32px; font-weight: 700; line-height: 1.05; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { height: 48px; border-radius: 12px; border: 2px dashed var(--line); display: grid; place-items: center; font-family: var(--hand); font-size: 24px; font-weight: 700; }
.slot.f { border-style: solid; border-color: #F0C64A; color: #F0C64A; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-family: var(--hand); font-size: 23px; font-weight: 700; line-height: 1; }
.tile.used { opacity: .3; }
.link:disabled { opacity: .5; text-decoration: none; cursor: default; }
.whispercard { border: 2px solid var(--fg); animation-name: fadeout; animation-timing-function: ease-in; animation-fill-mode: forwards; }
@keyframes fadeout { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats .card { gap: 2px; }
.stats b { font-size: 17px; }
/* ghost role guesses */
.tray { gap: 8px; }
.rchip { border: 2px solid transparent; border-radius: 999px; padding: 7px 12px; font-weight: 700; font-size: 15px; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.rchip small { font-weight: 400; opacity: .85; }
.rchip.on { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg) inset; }
.rchip.out { opacity: .35; }
.rchip.dragging { position: fixed; z-index: 20; pointer-events: none; transform: translate(-50%, -120%); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
/* role colours go by team */
.team-mafia { --tc: var(--role-bad); }
.team-werewolf { --tc: var(--role-wolf); }
.team-arsonist { --tc: var(--role-fire); }
.team-witch { --tc: var(--role-witch); }
.team-town { --tc: var(--role-town); }
.team-neutral { --tc: var(--role-neutral); }
.tag[class*="team-"] { background: var(--tc); color: #fff; }
body.night .tag[class*="team-"] { color: #151B36; }
.rolename[class*="team-"] { color: var(--tc); }
.rchip[class*="team-"] { background: var(--tc); }
body.night .rchip[class*="team-"] { color: #151B36; }
.tag.guess { border: 1.5px dashed currentColor; font-size: 10px; padding: 2px 6px; cursor: pointer; }
.tag.guess.empty { background: transparent; color: var(--muted); cursor: default; }
button.tag { font-family: inherit; }
.pcell.droppable { border-radius: 12px; padding: 4px 2px; cursor: pointer; }
.pcell.droppable.over { outline: 3px solid var(--fg); background: var(--card); }
@media (prefers-reduced-motion: reduce) { #toast, body, .tog::after { transition: none; } }

/* multi-pick night steps and the arsonist */
.steps { display: flex; gap: 8px; }
.steps span { flex: 1; text-align: center; font-weight: 700; padding: 6px 0; border-radius: 10px; border: 2px solid var(--line); }
.steps span.on { border-color: #F0C64A; color: #F0C64A; }
.steps span.done { background: var(--line); }
.seg.seg2 { grid-template-columns: 1fr 1fr; }
.btn.fire { background: #E0662A; border-color: #E0662A; color: #fff; }

/* role pool chips: in = team colour with a tick, out = faded and dashed */
.pchip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 2px dashed var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 15px; }
.pchip.on { border: 2px solid var(--tc); background: var(--tc); color: #fff; }
.pchip.on::before { content: ""; width: 5px; height: 10px; border: solid currentColor; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -2px); }
