/* Blood on the Clocktower companion — worn purple grimoire, bone-white tokens, parchment pages, old gold. */

@font-face { font-family: 'Pirata One'; src: url('/fonts/pirata-one.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cardo'; src: url('/fonts/cardo-regular.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cardo'; src: url('/fonts/cardo-bold.woff') format('woff'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cardo'; src: url('/fonts/cardo-italic.woff') format('woff'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Crimson'; src: url('/fonts/crimson-regular.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Crimson'; src: url('/fonts/crimson-semibold.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Crimson'; src: url('/fonts/crimson-italic.woff') format('woff'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  /* gothic display face for titles and big headings, in the spirit of the game's own lettering */
  --gothic: 'Pirata One', 'Cardo', Georgia, serif;
  --display: 'Cardo', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --body: 'Crimson', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;

  --plum-950: #0e0819;
  --plum-900: #170e28;
  --plum-850: #1e1333;
  --plum-800: #281a42;
  --plum-700: #3a2860;
  --plum-600: #54407e;
  --plum-line: #5f4c88;
  --bone: #f0e6cf;
  --bone-soft: #c9bedf;
  --gold: #c9a24c;
  --gold-hi: #e6c47a;
  --parchment: #ece0c4;
  --parchment-deep: #dcc8a0;
  --parchment-edge: #b99a63;
  --sepia: #2c1d10;
  --sepia-soft: #6b5236;
  --crimson: #8b1a1a;
  --crimson-hi: #ad2a24;
  --blood: #6e0f0f;
  --ink-blue: #24508c;

  --townsfolk: #2f5f9e;
  --outsider: #2b7f86;
  --minion: #b45a1c;
  --demon: #9e1a2c;

  /* paper grain, drawn with SVG noise */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.38'/%3E%3C/svg%3E");
  --fibres: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .09' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .28 0 0 0 0 .12 0 0 0 .45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='.25'/%3E%3C/svg%3E");
  /* dark oak grain: long, stretched noise */
  --texture: url('/img/grimoire-purple.jpg');
  --woodgrain: linear-gradient(transparent, transparent);
}

/* Paper context: the grimoire pages (panel, dialogs, forms). */
:root, .panel, dialog.modal, .home-form, .paper {
  --bg: var(--parchment);
  --surface: #e6d7b6;
  --field: #f6eedb;
  --text: var(--sepia);
  --muted: var(--sepia-soft);
  --line: #bfa577;
  --accent: var(--crimson);
  --accent-hi: var(--crimson-hi);
  --accent-text: #f7eedb;
  --heading: #4a1220;
  --shadow: 0 1px 0 rgba(70, 45, 15, 0.25);
  color-scheme: light;
}

/* Velvet context: the town square, the top bar, the home page, night wake-ups. */
body.home, .velvet, dialog.wake-modal, .toast {
  --bg: var(--plum-800);
  --surface: var(--plum-700);
  --field: var(--plum-900);
  --text: var(--bone);
  --muted: var(--bone-soft);
  --line: var(--plum-line);
  --accent: var(--gold);
  --accent-hi: var(--gold-hi);
  --accent-text: var(--plum-950);
  --heading: var(--bone);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
body.home, .velvet { color: var(--text); }
body.phase-night .velvet, body.phase-night dialog.wake-modal {
  --bg: var(--plum-900);
  --surface: var(--plum-850);
  --field: var(--plum-950);
  --line: #43305a;
  --muted: #a99bbd;
}
/* By night the grimoire is read by candlelight. */
body.phase-night .panel, body.phase-night dialog.modal:not(.wake-modal) {
  --bg: #d8c59d;
  --surface: #cfb98d;
  --field: #e6d7b4;
  --line: #a88c5c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--plum-800);
  background-image: radial-gradient(ellipse at 50% 20%, rgba(150, 120, 210, 0.12), rgba(14, 8, 25, 0.35) 75%), var(--texture);
  background-size: cover, cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 1.08rem;
  line-height: 1.45;
}
body.phase-night { background-image: radial-gradient(ellipse at 50% 15%, rgba(60, 40, 110, 0.25), rgba(8, 4, 16, 0.72) 70%), var(--texture); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 0.5rem; color: var(--heading); }
h2 { font-size: 1.55rem; }
.home h2, .modal-title, .role-name { font-family: var(--gothic); font-weight: 400; letter-spacing: 0.01em; }
.home h2 { font-size: 1.85rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.08rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8em; word-break: break-all; }
.muted { color: var(--muted); }
.small, small { font-size: 0.9rem; }
.center { text-align: center; }
.danger { color: var(--crimson-hi); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }

/* ---------------------------------------------------------------- controls */

.btn {
  font: 600 1rem/1.15 var(--body);
  color: var(--text);
  background: color-mix(in srgb, var(--field) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(var(--accent-hi), var(--accent)); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: linear-gradient(var(--crimson-hi), var(--crimson)); border-color: var(--crimson); color: #f7eedb; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { font-size: 0.92rem; padding: 0.35rem 0.7rem; }
.btn.wide { width: 100%; }
.icon-btn {
  font: inherit; background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 6px;
  min-width: 2.2rem; height: 2.2rem; cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover { border-color: var(--line); }
.icon-btn.tiny { min-width: 1.4rem; height: 1.4rem; font-size: 0.7rem; padding: 0; }

.input {
  font: 400 1.05rem/1.3 var(--body);
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  width: 100%;
  min-width: 0;
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); font-style: italic; }
.input.narrow { width: 6rem; }
textarea.input { resize: vertical; line-height: 1.45; }
select.input { cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.75rem; }
.field > span:first-child, .field-label { font-family: var(--display); font-style: italic; font-size: 0.95rem; color: var(--muted); margin: 0; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; cursor: pointer; }
.check input { margin-top: 0.3rem; accent-color: var(--crimson); width: 1.05rem; height: 1.05rem; }
.check.inline { display: inline-flex; margin: 0; align-items: center; gap: 0.3rem; }
.check.inline input { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 0.75rem; align-items: end; }
.fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.85rem 0.25rem; margin: 0 0 0.85rem; }
.fieldset legend { font-family: var(--display); font-weight: 700; padding: 0 0.35rem; color: var(--heading); }
.form-error { color: var(--crimson-hi); min-height: 1.2em; font-size: 0.95rem; margin: 0 0 0.5rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-top: 0.4rem; }
.button-row.tight { gap: 0.2rem; margin: 0; }
.button-col { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 0.75rem; background: var(--field); }
.segmented button { font: 600 0.95rem var(--body); color: var(--text); background: transparent; border: 0; padding: 0.4rem 0.8rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--accent); color: var(--accent-text); }
.segmented.small { margin: 0; }
.segmented.small button { font-size: 0.88rem; padding: 0.3rem 0.55rem; }

.chip {
  font: 600 0.95rem var(--body); color: var(--text); background: var(--field); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; display: inline-flex; gap: 0.35rem; align-items: center; white-space: nowrap;
}
.chip.on, .chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.person { cursor: default; font-family: var(--display); font-size: 1.1rem; padding: 0.3rem 0.9rem; }
.chip .count { background: var(--crimson); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 0 0.4rem; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.callout { border-left: 3px solid var(--accent); padding: 0.5rem 0.75rem; background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 0 6px 6px 0; }
.callout.dead { border-color: var(--crimson); background: color-mix(in srgb, var(--crimson) 10%, transparent); }

/* ---------------------------------------------------------------- tokens: bone-white discs */

.token {
  --t: 56px;
  --team: #8a7048;
  position: relative;
  width: var(--t); height: var(--t);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background:
    var(--grain),
    radial-gradient(circle at 38% 30%, #fbf5e6 0%, #efe3c6 40%, #e0cca1 72%, #c4a670 92%, #a98a55 100%);
  background-size: 120px 120px, auto;
  box-shadow:
    inset 0 0 0 max(1px, calc(var(--t) * 0.02)) rgba(255, 250, 235, 0.65),
    inset 0 0 calc(var(--t) * 0.12) rgba(120, 85, 35, 0.35),
    0 calc(var(--t) * 0.04) calc(var(--t) * 0.09) rgba(0, 0, 0, 0.55),
    0 0 0 max(1px, calc(var(--t) * 0.012)) rgba(70, 45, 15, 0.55);
  color: var(--sepia);
  flex: none;
  user-select: none;
}
/* a fine inner ring, tinted by team */
.token::before {
  content: ''; position: absolute; inset: 7%; border-radius: 50%;
  border: max(1px, calc(var(--t) * 0.014)) solid color-mix(in srgb, var(--team) 55%, transparent);
  pointer-events: none;
}
.token-icon {
  font-size: calc(var(--t) * 0.42); line-height: 1;
  filter: sepia(0.25) saturate(0.9) drop-shadow(0 calc(var(--t) * 0.015) 0 rgba(60, 35, 10, 0.35));
}
.token.named .token-icon { transform: translateY(calc(var(--t) * -0.1)); font-size: calc(var(--t) * 0.38); }
.token-arc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.arc-text { font-family: var(--display); font-weight: 700; font-size: 12.5px; fill: #33210f; letter-spacing: 0.02em; }
.arc-text.evil { fill: #7d1222; }
.team-townsfolk { --team: var(--townsfolk); }
.team-outsider { --team: var(--outsider); }
.team-minion { --team: var(--minion); }
.team-demon { --team: var(--demon); }
.token-xs { --t: 26px; }
.token-sm { --t: 44px; }
.token-md { --t: 60px; }
.token-lg { --t: 86px; }
.token-xl { --t: 124px; }
.token-empty { background: transparent; box-shadow: none; border: 2px dashed var(--line); color: var(--muted); }
.token-empty::before { display: none; }
.token-life { background: var(--grain), radial-gradient(circle at 38% 30%, #efe5cf 0%, #d9c6a0 70%, #b39667 100%); background-size: 120px 120px, auto; }
.token-life::before { border-color: rgba(90, 60, 25, 0.35); }
.token-initial { font: 700 calc(var(--t) * 0.32)/1 var(--display); letter-spacing: 0.04em; color: #4a3219; }
.token-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.removable { position: relative; display: inline-flex; }
.removable .icon-btn { position: absolute; top: -6px; right: -8px; background: var(--field); border-color: var(--line); }

/* ---------------------------------------------------------------- home */

.home-wrap { max-width: 980px; margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) 1.25rem 2rem; }
.home-head { position: relative; text-align: center; padding: 2.5rem 0 2.5rem; }
.home-clock {
  position: absolute; left: 50%; top: 50%; width: min(460px, 90vw); aspect-ratio: 1; transform: translate(-50%, -52%);
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 8px color-mix(in srgb, var(--gold) 6%, transparent);
  --box: min(460px, 90vw); --ringf: 0.9; --tok: 0.08;
}
.home-clock .mark { position: absolute; left: 50%; top: 50%; width: 2px; height: 14px; margin: -7px 0 0 -1px; background: color-mix(in srgb, var(--gold) 45%, transparent); transform: rotate(var(--a)) translateY(calc(var(--box) * -0.47)); }
.home-clock .clock-hand { opacity: 0.6; height: calc(var(--box) * 0.36); }
.home-title {
  position: relative; margin: 0;
  font: 400 clamp(3.2rem, 13vw, 7.6rem)/0.92 var(--gothic); letter-spacing: 0.01em;
  color: var(--bone);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 30px rgba(20, 8, 40, 0.8);
}
.home-title .lead { display: block; font-size: 0.42em; letter-spacing: 0.06em; color: var(--bone-soft); }
.home-title .main {
  display: block;
  background: linear-gradient(180deg, #fbefc4 0%, #e6c47a 45%, #a9822f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.6)) drop-shadow(0 0 18px rgba(20, 8, 40, 0.8));
  text-shadow: none;
}
.home-lede { position: relative; max-width: 34rem; margin: 1rem auto 0; color: var(--bone-soft); font: italic 1.2rem/1.45 var(--display); }
.home-forms { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.home-form { border-radius: 6px; padding: 1.5rem 1.6rem; }
.home-form.paper, .home-form:not(.host) {
  background: var(--fibres), var(--grain), linear-gradient(160deg, #f1e6cc, #e3d0a8);
  box-shadow: inset 0 0 50px rgba(120, 80, 30, 0.3), 0 10px 30px rgba(0, 0, 0, 0.45);
  color: var(--sepia);
}
.home-form.host {
  --bg: var(--plum-800); --surface: var(--plum-700); --field: var(--plum-900); --text: var(--bone); --muted: var(--bone-soft);
  --line: var(--plum-line); --accent: var(--gold); --accent-hi: var(--gold-hi); --accent-text: var(--plum-950); --heading: var(--bone);
  color-scheme: dark;
  background: color-mix(in srgb, var(--plum-900) 60%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); color: var(--bone);
}
.code-input { font: 700 1.9rem/1 var(--display); letter-spacing: 0.35em; text-transform: uppercase; text-align: center; padding: 0.55rem; }
.home-saved { margin-top: 2rem; }
.home-saved ul { list-style: none; padding: 0; margin: 0; }
.home-saved li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.home-foot { margin-top: 3rem; color: var(--bone-soft); font-size: 0.92rem; max-width: 40rem; }
@media (max-width: 720px) { .home-forms { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- game layout */

.game { display: flex; flex-direction: column; min-height: 100vh; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 1rem; padding-top: max(0.45rem, env(safe-area-inset-top));
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  background: linear-gradient(rgba(14, 8, 25, 0.82), rgba(14, 8, 25, 0.7)), var(--texture) center / cover;
  position: sticky; top: 0; z-index: 20; color: var(--text);
}
.brand { font: 400 1.5rem var(--gothic); letter-spacing: 0.02em; color: var(--gold-hi); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7), 0 0 12px rgba(201, 162, 76, 0.35); }
.room-code { font: 700 1.05rem var(--display); letter-spacing: 0.2em; color: var(--gold-hi); background: transparent; border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); border-radius: 4px; padding: 0.15rem 0.55rem; cursor: pointer; }
.phase-pill { font: 400 1.15rem var(--display); white-space: nowrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); }
.timer.urgent { background: var(--crimson); color: #fff; border-color: var(--crimson); }
.spacer { flex: 1; }
.conn { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); }
.conn.ok { background: #5fae7d; }
.conn.bad { background: var(--crimson-hi); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.stage { flex: 1; display: flex; min-height: 0; }
.square {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; position: relative;
  background: radial-gradient(circle at 50% 48%, rgba(227, 192, 114, 0.1), transparent 55%);
}
body.phase-night .square {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(240, 230, 207, 0.7), transparent),
    radial-gradient(1px 1px at 72% 12%, rgba(240, 230, 207, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 88% 64%, rgba(240, 230, 207, 0.5), transparent),
    radial-gradient(1px 1px at 30% 82%, rgba(240, 230, 207, 0.45), transparent),
    radial-gradient(1px 1px at 55% 30%, rgba(240, 230, 207, 0.3), transparent),
    radial-gradient(1px 1px at 8% 60%, rgba(240, 230, 207, 0.35), transparent),
    radial-gradient(circle at 50% 48%, rgba(160, 170, 230, 0.08), transparent 55%);
}
.circle-host { width: min(100%, calc(100vh - 7rem)); max-width: 860px; }
.pause-banner {
  color: var(--bone);
  display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; justify-content: center; text-align: center;
  background: color-mix(in srgb, var(--plum-950) 80%, transparent); border: 1px solid var(--gold); border-radius: 6px;
  padding: 0.5rem 0.9rem; margin-bottom: 0.5rem; font-family: var(--display); font-style: italic; z-index: 6;
}

/* the grimoire page */
.panel {
  width: 450px; flex: none; display: flex; flex-direction: column; min-height: 0; color: var(--text);
  background-color: var(--bg);
  background-image: var(--fibres), var(--grain);
  box-shadow: inset 0 0 70px rgba(110, 72, 25, 0.35), -8px 0 30px rgba(0, 0, 0, 0.4);
  border-left: 3px double color-mix(in srgb, var(--parchment-edge) 80%, transparent);
}
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; flex: none; }
.tab {
  font: 400 1.08rem var(--display); color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 0.7rem 0.85rem 0.55rem; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 0.35rem; align-items: center;
}
.tab.active { color: var(--heading); border-bottom-color: var(--crimson); font-weight: 700; }
.tab .badge { background: var(--crimson); color: #fff; border-radius: 999px; font: 600 0.75rem var(--body); padding: 0 0.42rem; line-height: 1.4; }
.panes { flex: 1; overflow-y: auto; min-height: 0; }
.pane { padding: 1rem 1.1rem; }
#pane-town, #pane-chat { height: 100%; padding: 0; }
.pane-section { padding: 0 0 1rem; margin-bottom: 1rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.pane-section:last-child { border-bottom: 0; }
.summary-heading { cursor: pointer; font: 700 1.2rem var(--display); color: var(--heading); margin-bottom: 0.5rem; }

@media (max-width: 900px) {
  .game { height: auto; }
  .stage { flex-direction: column; }
  .square { padding: 0.5rem 0.5rem 0; }
  .circle-host { width: min(100%, 64vh); }
  .panel { width: 100%; border-left: 0; border-top: 3px double var(--parchment-edge); box-shadow: inset 0 0 70px rgba(110, 72, 25, 0.35); }
  .tabs { position: sticky; top: 2.9rem; background-color: var(--bg); background-image: var(--grain); z-index: 10; }
  .panes { overflow: visible; }
  #pane-town, #pane-chat { height: 70vh; }
  .brand { display: none; }
  .topbar { gap: 0.5rem; padding-left: 0.75rem; padding-right: 0.75rem; }
}

/* ---------------------------------------------------------------- the clock */

.clock { position: relative; width: 100%; aspect-ratio: 1 / 1; --box: 600px; --tok: 0.15; --ringf: 0.7; }
.clock-rim {
  position: absolute; inset: calc((100% - var(--ring, 70%)) / 2); border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent);
  box-shadow:
    0 0 0 calc(var(--box) * 0.01) color-mix(in srgb, var(--gold) 8%, transparent),
    inset 0 0 0 calc(var(--box) * 0.01) color-mix(in srgb, var(--gold) 8%, transparent);
}
.clock-marks .mark, .home-clock .mark { pointer-events: none; }
.clock-marks .mark {
  position: absolute; left: 50%; top: 50%; width: 2px; height: calc(var(--box) * 0.022); margin: calc(var(--box) * -0.011) 0 0 -1px;
  background: color-mix(in srgb, var(--gold) 55%, transparent);
  transform: rotate(var(--a)) translateY(calc(var(--box) * var(--ringf) * -0.5 + var(--box) * var(--tok) * 0.72));
}
.clock-hand {
  position: absolute; left: 50%; top: 50%; z-index: 2; width: max(3px, calc(var(--box) * 0.007));
  height: calc(var(--box) * var(--ringf) * 0.5 - var(--box) * var(--tok) * 0.68);
  background: linear-gradient(to top, transparent 0 46%, color-mix(in srgb, var(--gold) 70%, transparent) 46%, var(--gold-hi));
  border-radius: 3px;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(var(--angle, 0deg));
  transition: transform var(--tick, 600ms) cubic-bezier(0.3, 0.85, 0.35, 1.04), opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
}
.clock-hand.shown { opacity: 1; }
.clock-hand.no-anim { transition: none; }
.clock-hand-tip {
  position: absolute; left: 50%; top: calc(var(--box) * -0.03); transform: translateX(-50%);
  border-left: calc(var(--box) * 0.016) solid transparent; border-right: calc(var(--box) * 0.016) solid transparent;
  border-bottom: calc(var(--box) * 0.034) solid var(--gold-hi);
}

.dial {
  position: absolute; left: 50%; top: 50%; z-index: 3; transform: translate(-50%, -50%);
  width: calc(var(--box) * (var(--ringf) - var(--tok) * 1.9)); max-width: 70%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: calc(var(--box) * 0.006);
  pointer-events: none;
}
.dial-title, .dial-sub { text-shadow: 0 0 4px var(--bg), 0 0 8px var(--bg), 0 0 16px var(--bg); }
.dial-title { font: 400 clamp(1.6rem, calc(var(--box) * 0.085), 4rem)/1.05 var(--gothic); letter-spacing: 0.01em; color: var(--bone); }
.dial-sub { font: italic clamp(0.85rem, calc(var(--box) * 0.026), 1.15rem)/1.35 var(--display); color: var(--muted); max-width: 24ch; }
.orb { --orb: calc(var(--box) * 0.095); width: var(--orb); height: var(--orb); border-radius: 50%; margin-bottom: calc(var(--box) * 0.012); flex: none; }
.orb-night { box-shadow: inset calc(var(--orb) * -0.24) calc(var(--orb) * -0.1) 0 0 var(--bone); transform: rotate(-20deg); filter: drop-shadow(0 0 calc(var(--orb) * 0.25) rgba(240, 230, 207, 0.35)); }
.orb-day { background: radial-gradient(circle, var(--gold-hi) 0 50%, transparent 52%); box-shadow: 0 0 0 calc(var(--orb) * 0.09) color-mix(in srgb, var(--gold-hi) 20%, transparent), 0 0 calc(var(--orb) * 0.7) color-mix(in srgb, var(--gold-hi) 45%, transparent); }
.orb-lobby { border: calc(var(--orb) * 0.05) solid color-mix(in srgb, var(--gold) 60%, transparent); box-shadow: inset 0 0 0 calc(var(--orb) * 0.12) color-mix(in srgb, var(--gold) 12%, transparent); }
.orb-over { border: calc(var(--orb) * 0.1) double var(--gold); }

.seats { position: absolute; inset: 0; z-index: 4; }
.seat {
  position: absolute; width: calc(var(--box) * var(--tok)); height: calc(var(--box) * var(--tok));
  transform: translate(-50%, -50%);
  padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit;
  border-radius: 50%;
}
.seat .token { --t: calc(var(--box) * var(--tok)); transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.6s ease; }
.seat:hover .token { transform: scale(1.04); }
.seat-under {
  position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px; width: max-content; max-width: calc(var(--box) * 0.25);
  pointer-events: none;
}
.seat-name {
  font: 700 clamp(0.8rem, calc(var(--box) * 0.028), 1.15rem)/1.15 var(--display);
  text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
  padding: 0.05em 0.45em; border-radius: 3px; color: var(--bone);
  background: color-mix(in srgb, var(--plum-950) 70%, transparent);
}
.seat-name .you { font-weight: 400; font-style: italic; color: var(--bone-soft); }
.seat-sub, .seat-guess { font: italic clamp(0.66rem, calc(var(--box) * 0.02), 0.85rem)/1.2 var(--display); color: var(--bone-soft); white-space: nowrap; }
.seat-sub.danger { color: #ff9aa6; }
.seat-guess { color: var(--gold-hi); background: color-mix(in srgb, var(--plum-950) 60%, transparent); padding: 0 0.35em; border-radius: 3px; }
.seat-reminders { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: calc(var(--box) * 0.25); }
.reminder {
  font: 600 clamp(0.6rem, calc(var(--box) * 0.018), 0.78rem)/1.25 var(--body); padding: 0 0.4em; border-radius: 999px;
  background: var(--grain), #e9dcbd; background-size: 120px; border: 1px solid #a88a55; white-space: nowrap; color: var(--sepia);
}
.reminder.big { font-size: 0.9rem; padding: 0.15rem 0.2rem 0.15rem 0.55rem; display: inline-flex; align-items: center; gap: 0.25rem; }
.reminder-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.4rem; }

.seat-badges { position: absolute; top: -8%; right: -14%; display: flex; gap: 2px; z-index: 3; pointer-events: none; }
.seat-badges > span { font-size: calc(var(--box) * var(--tok) * 0.26); line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.ghostvote { color: var(--bone); }
.ghostvote.spent { color: var(--bone-soft); opacity: 0.6; }
.hand.locked.no { color: var(--bone-soft); font-weight: 700; }
.block-badge { color: #ff8090; }

.seat.me .token { box-shadow: 0 0 0 calc(var(--box) * 0.007) var(--gold-hi), 0 0 calc(var(--box) * 0.03) rgba(227, 192, 114, 0.5), 0 calc(var(--t) * 0.04) calc(var(--t) * 0.09) rgba(0, 0, 0, 0.55); }
.seat.offline .seat-name { opacity: 0.55; }
.seat.offline::after { content: ''; position: absolute; bottom: 4%; left: 4%; width: 14%; height: 14%; border-radius: 50%; background: #7b6d86; border: 2px solid var(--bg); z-index: 3; }
.seat.nominee .token { box-shadow: 0 0 0 calc(var(--box) * 0.008) var(--crimson-hi), 0 0 calc(var(--box) * 0.05) rgba(200, 40, 60, 0.75); }
.seat.nominator .token { outline: 2px dashed var(--gold-hi); outline-offset: calc(var(--box) * 0.006); }
.seat.on-block .token { box-shadow: 0 0 0 calc(var(--box) * 0.01) var(--crimson), 0 0 calc(var(--box) * 0.04) rgba(200, 40, 60, 0.6); }
.seat.under-hand .token { transform: scale(1.1); }
.seat.dead .token { filter: grayscale(0.7) brightness(0.62) sepia(0.2); }
.seat.dead::before {
  content: ''; position: absolute; left: 16%; right: 16%; top: -14%; height: 78%; z-index: 2; pointer-events: none;
  background: linear-gradient(#0c0610 40%, #2b1a38);
  clip-path: polygon(50% 0, 70% 8%, 84% 30%, 92% 62%, 100% 100%, 50% 90%, 0 100%, 8% 62%, 16% 30%, 30% 8%);
  opacity: 0.94;
}

/* vote bar (players) */
.votebar {
  position: sticky; bottom: 0.75rem; z-index: 15; width: min(100%, 640px);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  background: var(--plum-900); border: 1px solid var(--crimson-hi); border-radius: 8px; padding: 0.7rem 0.9rem; margin-top: 0.75rem;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--crimson) 35%, transparent), 0 8px 24px rgba(0, 0, 0, 0.45);
}
.vote-text { display: flex; flex-direction: column; }
.vote-text strong { font: 700 1.35rem var(--display); }
.vote-text span { color: var(--muted); font-style: italic; }
.vote-btn { font-size: 1.1rem; padding: 0.75rem 1.2rem; }
.vote-btn.raised { background: linear-gradient(var(--crimson-hi), var(--crimson)); border-color: var(--crimson-hi); color: #fff; }
.vote-locked { font-weight: 600; }

/* ---------------------------------------------------------------- chat (on the parchment) */

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-channels { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); flex: none; scrollbar-width: thin; }
.chip.channel.whisper:not(.active) { border-style: dashed; }
.chip-select { width: auto; padding: 0.2rem 0.5rem; font-size: 0.92rem; border-radius: 999px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; min-height: 0; }
.chat-list .empty { color: var(--muted); text-align: center; margin: auto; max-width: 26ch; font-style: italic; }
.msg { display: grid; grid-template-columns: 1fr auto; gap: 0 0.5rem; max-width: 92%; }
.msg-who { font: 700 0.95rem var(--display); grid-column: 1; color: var(--heading); }
.msg-text { grid-column: 1 / -1; background: color-mix(in srgb, var(--field) 85%, transparent); border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 2px 10px 10px 10px; padding: 0.4rem 0.7rem; overflow-wrap: anywhere; }
.msg time { grid-column: 2; grid-row: 1; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; align-self: end; }
.msg.mine { align-self: flex-end; }
.msg.mine .msg-text { background: color-mix(in srgb, var(--crimson) 12%, var(--field)); border-radius: 10px 2px 10px 10px; }
.msg.system { align-self: center; max-width: 100%; grid-template-columns: 1fr; text-align: center; }
.msg.system .msg-text { background: transparent; border: 0; font: italic 1.08rem/1.35 var(--display); padding: 0.1rem 0.5rem; color: var(--muted); }
.msg.system time { display: block; grid-column: 1; grid-row: auto; text-align: center; font-size: 0.72rem; opacity: 0.85; }
.chat-notice { margin: 0; padding: 0.5rem 0.75rem; font-style: italic; color: var(--muted); border-top: 1px solid var(--line); }
.chat-compose { display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem; border-top: 1px solid var(--line); flex: none; padding-bottom: max(0.6rem, env(safe-area-inset-bottom)); }
.pane .chat-compose { border-top: 0; padding: 0; }

/* ---------------------------------------------------------------- player panes */

.my-role { display: flex; gap: 1rem; align-items: flex-start; }
.role-name { font: 700 1.7rem/1.1 var(--display); margin: 0 0 0.2rem; color: var(--heading); }
.role-team { color: color-mix(in srgb, var(--team, var(--muted)) 85%, #000); font: italic 1.05rem var(--display); margin-bottom: 0.4rem; }
.velvet .role-team, .wake-modal .role-team { color: color-mix(in srgb, var(--team, var(--muted)) 50%, #fff); }
.role-ability { font-size: 1.1rem; }
.learned { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.learned > li { border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.8rem; background: color-mix(in srgb, var(--field) 50%, transparent); }
.learned-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.3rem; }
.script summary { cursor: pointer; font: 700 1.2rem var(--display); color: var(--heading); }
.script-team h4 { margin-top: 0.9rem; border-bottom: 1px solid var(--line); padding-bottom: 0.2rem; }
.script-team:nth-of-type(n+3) h4 { color: var(--crimson); }
.script-role { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 0.55rem; }
.script-role strong { font-family: var(--display); }
.script-role p { margin: 0; font-size: 0.98rem; color: var(--muted); }
.notes { min-height: 9rem; background-image: repeating-linear-gradient(transparent 0 1.43em, color-mix(in srgb, var(--line) 45%, transparent) 1.43em calc(1.43em + 1px)); background-attachment: local; }
.sheet { display: flex; flex-direction: column; gap: 0.6rem; }
.sheet-row { border-bottom: 1px dashed var(--line); padding-bottom: 0.6rem; }
.sheet-row.dead .sheet-name { text-decoration: line-through; text-decoration-color: var(--crimson); }
.sheet-name { font: 700 1.1rem var(--display); margin-bottom: 0.3rem; }
.sheet-editor { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem; align-items: center; }
.sheet-editor .input:last-child { grid-column: 1 / -1; }
.sheet-editor .field-label { grid-column: 1 / -1; }
.record { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.record > li { border-left: 3px solid var(--crimson); padding-left: 0.7rem; }
.record p { margin: 0.15rem 0; }
.record-noms { margin: 0.2rem 0; padding-left: 1.1rem; }
.record-noms li { margin-bottom: 0.25rem; }
.record-voters { display: block; }
details.round { margin-bottom: 0.5rem; }
details.round summary { cursor: pointer; font: 700 1.05rem var(--display); margin-bottom: 0.3rem; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.45rem; margin: 0.5rem 0 0.25rem; }
.pick {
  font: 700 1.1rem var(--display); color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.65rem 0.5rem; cursor: pointer;
}
.pick.dead { color: var(--muted); font-style: italic; }
.pick[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.seat-menu .sheet-editor { margin-top: 0.75rem; }

/* info shown at night */
.info { display: flex; flex-direction: column; gap: 0.6rem; }
.info-text { font: italic 1.2rem/1.4 var(--display); margin: 0; }
.info-players, .info-roles { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.info-number { font: 700 4.8rem/1 var(--display); color: var(--accent); }
.info-yesno { font: 700 3.6rem/1 var(--display); }
.info-yesno.yes { color: #6cc08c; }
.info-yesno.no { color: #ff7d8d; }
.panel .info-yesno.yes, dialog.modal:not(.wake-modal) .info-yesno.yes { color: #2f7a4a; }
.panel .info-yesno.no, dialog.modal:not(.wake-modal) .info-yesno.no { color: var(--crimson); }
.info-group { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.info-label { font: italic 1.05rem var(--display); margin: 0 0 0.4rem; }
.grimoire-snap table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.grimoire-snap th, .grimoire-snap td { text-align: left; padding: 0.3rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grimoire-snap th { font-family: var(--display); }
.grimoire-snap td .token { vertical-align: middle; margin-right: 0.35rem; }
.grimoire-snap tr.is-dead td { color: var(--muted); }

/* ---------------------------------------------------------------- dialogs */

dialog.modal {
  width: min(560px, 94vw); max-height: 90vh; padding: 0; border: 0; border-radius: 4px;
  background-color: var(--bg); background-image: var(--fibres), var(--grain); color: var(--text);
  box-shadow: inset 0 0 60px rgba(110, 72, 25, 0.35), 0 0 0 1px #8f7344, 0 0 0 5px color-mix(in srgb, var(--parchment-edge) 40%, transparent), 0 30px 70px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column;
}
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: rgba(10, 4, 18, 0.7); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 1rem 1.15rem 0.4rem; }
.modal-title { margin: 0; font-size: 1.6rem; }
.modal-body { padding: 0.25rem 1.15rem 0.75rem; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1.15rem 1rem; border-top: 1px solid var(--line); }
.builder-modal { width: min(680px, 96vw); }
dialog.wake-modal {
  background: radial-gradient(ellipse at 50% 0%, rgba(80, 55, 140, 0.6), rgba(14, 8, 25, 0.88) 70%), var(--texture) center / cover;
  box-shadow: 0 0 0 1px var(--gold), 0 0 0 6px color-mix(in srgb, var(--gold) 18%, transparent), 0 30px 70px rgba(0, 0, 0, 0.7);
}
.wake-modal .modal-title { font-size: 2.3rem; font-weight: 400; color: var(--bone); }
.wake-kicker { color: var(--muted); font: italic 1rem var(--display); margin-bottom: 0.6rem; }
.wake-instruction { font-family: var(--display); font-weight: 700; margin-top: 0.75rem; }
.gameover-modal .modal-title { font-size: 2.9rem; font-weight: 400; }
.gameover-modal.good .modal-title { color: var(--ink-blue); }
.gameover-modal.evil .modal-title { color: var(--crimson); }
.gameover-reason { font: italic 1.2rem var(--display); }

.reveal-modal .modal-body { padding-top: 0.5rem; }
.reveal-card { position: relative; perspective: 1200px; min-height: 360px; margin-bottom: 0.75rem; }
.reveal-back, .reveal-front {
  position: absolute; inset: 0; border-radius: 4px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.9s cubic-bezier(0.3, 1.2, 0.4, 1);
}
.reveal-back { background: radial-gradient(ellipse at 50% 30%, rgba(80, 55, 140, 0.5), rgba(14, 8, 25, 0.85)), var(--texture) center / cover; border: 1px solid var(--gold); display: flex; align-items: center; justify-content: center; --orb: 90px; --bone: #f0e6cf; }
.reveal-back .orb-night { --box: 900px; }
.reveal-front {
  transform: rotateY(180deg); padding: 1.25rem;
  background: var(--fibres), var(--grain), linear-gradient(160deg, #f3e9d1, #e2cfa6);
  box-shadow: inset 0 0 50px rgba(110, 72, 25, 0.35), 0 0 0 1px #8f7344;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.3rem;
}
.reveal-card.flipped .reveal-back { transform: rotateY(-180deg); }
.reveal-card.flipped .reveal-front { transform: rotateY(0deg); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--plum-900); color: var(--bone); border: 1px solid var(--gold); padding: 0.55rem 1rem; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); transition: opacity 0.3s ease, transform 0.3s ease; text-align: center; }
.toast.error { border-color: var(--crimson-hi); background: #3a0f1a; }
.toast.leaving { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- storyteller panes */

.alerts { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.alert { border-radius: 4px; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-left-width: 4px; background: color-mix(in srgb, var(--field) 70%, transparent); margin-bottom: 0.75rem; }
.alert p { margin: 0 0 0.25rem; }
.alert.warn { border-left-color: var(--minion); }
.alert.end { border-left-color: var(--crimson); }
.alert.info { border-left-color: var(--townsfolk); }
.pause-row { margin: 0 0 1rem; }
.invite { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.75rem; }
.invite-code { font: 400 3rem/1 var(--gothic); letter-spacing: 0.3em; color: var(--crimson); }
.invite-link { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.steps { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.step { display: flex; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px dashed var(--line); }
.step:last-child { border-bottom: 0; }
.step.done { opacity: 0.5; }
.step.special .step-head strong { font-weight: 400; font-style: italic; }
.step-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--crimson); margin-top: 0.2rem; }
.step-body { flex: 1; min-width: 0; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.step-head strong { font-family: var(--display); font-size: 1.15rem; color: var(--heading); }
.step-icon { font-size: 1.1rem; }
.step-player { font-weight: 600; display: inline-flex; gap: 0.25rem; align-items: center; }
.step-player::before { content: '—'; color: var(--muted); margin-right: 0.15rem; }
.step-text { font-size: 0.98rem; color: var(--muted); margin: 0.15rem 0 0.2rem; font-style: italic; }
.flag { font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 0 0.45rem; border: 1px solid currentColor; }
.flag.drunk { color: var(--outsider); }
.flag.poisoned { color: #4f7a1f; }
.flag.dead { color: var(--crimson); }
.flags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.wakes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.wake-row { border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.75rem; background: color-mix(in srgb, var(--field) 45%, transparent); }
.wake-row.closed { opacity: 0.55; }
.wake-row-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; margin-bottom: 0.25rem; }
.wake-row .info-number { font-size: 2rem; }
.wake-row .info-yesno { font-size: 1.6rem; }
.wake-row .info-text { font-size: 1rem; }
.wake-row .token-lg { --t: 50px; }
.wake-choice { font-weight: 600; color: var(--crimson); }
.vote-box { border: 1px solid var(--crimson); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--crimson) 25%, transparent); border-radius: 6px; padding: 0.7rem 0.85rem; margin: 0.75rem 0; }
.vote-box.done { border-color: var(--line); box-shadow: none; }
.noms { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.noms li { display: flex; flex-direction: column; gap: 0.15rem; border-bottom: 1px dashed var(--line); padding-bottom: 0.5rem; }
.end-game summary { cursor: pointer; font-style: italic; color: var(--muted); }
.team-block h4 .count { font-family: var(--body); font-size: 0.92rem; font-weight: 600; }
.count.ok { color: #2f7a4a; }
.count.off { color: var(--minion); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 0.4rem; }
.role-pick {
  display: flex; align-items: center; gap: 0.4rem; font: 600 0.95rem/1.1 var(--body); color: var(--text); text-align: left;
  background: color-mix(in srgb, var(--field) 60%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem 0.4rem; cursor: pointer; min-width: 0;
}
.role-pick > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.role-pick .token { --t: 32px; }
.role-pick:not(.on) .token { filter: grayscale(0.85); opacity: 0.55; }
.role-pick.on { border-color: var(--team); box-shadow: inset 0 0 0 1px var(--team); background: var(--field); }
.problems { margin: 0 0 0.5rem; padding-left: 1.2rem; color: var(--minion); }
.ok-text { color: #2f7a4a; font-weight: 600; }
.bluffs { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 0.4rem; align-items: center; }
@media (max-width: 520px) { .bluffs { grid-template-columns: 1fr; } }
.players { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.player-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.player-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-no { color: var(--muted); font-variant-numeric: tabular-nums; width: 1.4rem; text-align: right; font-family: var(--display); }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #9c8c76; flex: none; }
.dot.on { background: #3f9a62; }
.grim-table { list-style: none; padding: 0; margin: 0 0 0.75rem; display: flex; flex-direction: column; gap: 0.55rem; }
.grim-row { border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.6rem; background: color-mix(in srgb, var(--field) 50%, transparent); }
.grim-row.dead { opacity: 0.75; }
.grim-row.dead .grim-who strong { text-decoration: line-through; text-decoration-color: var(--crimson); }
.grim-who { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.35rem; }
.grim-who strong { font-family: var(--display); font-size: 1.08rem; flex: 1; }
.grim-controls { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.grim-controls select.input { width: auto; flex: 1 1 10rem; }
.watching { margin-top: 0.5rem; }
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.98rem; }
.log li { display: flex; flex-direction: column; }
.log-meta { font: italic 0.82rem var(--display); color: var(--muted); }
.seat-panel .button-row { margin-bottom: 0.9rem; }
.seat-panel-top { display: flex; gap: 0.8rem; align-items: flex-start; margin-bottom: 0.75rem; }
.seat-panel-top .role-name { font-size: 1.4rem; }
.suggestion { border: 1px dashed var(--accent); border-radius: 6px; padding: 0.5rem 0.7rem; margin-bottom: 0.85rem; display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }
.suggestion p { margin: 0; font-style: italic; }
.alert.warn p { margin: 0; }
.builder .alert { margin-bottom: 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- chat: who am I talking to? */

.chat-channels { flex-wrap: nowrap; scroll-snap-type: x proximity; }
.chip.channel { scroll-snap-align: center; }
.chip.channel.is-dead { text-decoration: line-through; text-decoration-color: var(--crimson); }
.chat-to {
  display: flex; align-items: center; gap: 0.35rem; padding: 0.35rem 0.5rem; flex: none;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--chan, var(--accent)) 14%, transparent);
  border-left: 5px solid var(--chan, var(--accent));
}
.chat-to-label { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.45rem; overflow: hidden; }
.chat-to-label strong { font: 700 1.05rem/1.2 var(--display); color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-to-kicker { font: italic 0.85rem var(--display); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.chat-to .icon-btn { border-color: var(--line); background: var(--field); min-width: 2.4rem; }
.chat-to.flash { animation: chat-to-flash 0.7s ease; }
@keyframes chat-to-flash { 0% { background: color-mix(in srgb, var(--chan, var(--accent)) 55%, transparent); } 100% { background: color-mix(in srgb, var(--chan, var(--accent)) 14%, transparent); } }
.chat.chan-public { --chan: #9a7a2e; }
.chat.chan-private { --chan: var(--crimson); }
.chat.chan-whisper { --chan: var(--outsider); }
.chat .chat-compose .input { border-color: color-mix(in srgb, var(--chan, var(--line)) 70%, var(--line)); border-width: 2px; }
.chat .chat-send { white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(color-mix(in srgb, var(--chan) 80%, #fff), var(--chan)); border-color: var(--chan); color: #fbf3e2; }
.chat-divider { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0 0.1rem; color: var(--muted); font: italic 0.85rem var(--display); }
.chat-divider::before, .chat-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- reminders: chips, tray, brush */

.rem-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.rem-chip {
  --team: #8a7048;
  display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer;
  font: 600 0.9rem/1.1 var(--body); color: var(--sepia);
  background: var(--grain), #eadcbc; background-size: 120px; border: 1px solid #a88a55; border-left: 4px solid var(--team);
  border-radius: 999px; padding: 0.38rem 0.7rem 0.38rem 0.5rem; min-height: 2.2rem;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}
.rem-chip:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--team) 45%, transparent); }
.rem-chip:active { transform: scale(0.96); }
.rem-chip.on { background: var(--crimson); color: #fbf3e2; border-color: var(--crimson-hi); box-shadow: 0 0 0 2px color-mix(in srgb, var(--crimson-hi) 40%, transparent); }
.rem-chip.custom { border-style: dashed; border-left-width: 1px; font-style: italic; }
.rem-icon { font-size: 1rem; line-height: 1; }
.rem-count { background: var(--sepia); color: #f4ead2; border-radius: 999px; font-size: 0.72rem; padding: 0.05rem 0.4rem; }
.rem-chip.on .rem-count { background: #fbf3e2; color: var(--crimson); }
.reminder.team-townsfolk, .rem-chip.team-townsfolk { --team: var(--townsfolk); }
.reminder.team-outsider, .rem-chip.team-outsider { --team: var(--outsider); }
.reminder.team-minion, .rem-chip.team-minion { --team: var(--minion); }
.reminder.team-demon, .rem-chip.team-demon { --team: var(--demon); }
.reminder[class*="team-"] { border-left: 3px solid var(--team); }

.rem-tray {
  position: relative; z-index: 4; width: min(100%, 860px); margin-top: 0.5rem; padding: 0.5rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: 8px;
  background: color-mix(in srgb, var(--plum-950) 70%, transparent);
}
.tray-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.tray-hint { margin: 0; font: italic 0.95rem var(--display); color: var(--muted); flex: 1; min-width: 12rem; }
.tray-hint.active { color: var(--bone); font-style: normal; }
.tray-hint.active strong { color: var(--gold-hi); }
.rem-tray .rem-chips { margin-top: 0.45rem; }
.clock.brushing .seat { cursor: copy; }
.clock.brushing .seat .token { outline: 2px dashed color-mix(in srgb, var(--gold-hi) 55%, transparent); outline-offset: 3px; }
.clock.brushing .seat.brush-on .token { outline: 3px solid var(--crimson-hi); box-shadow: 0 0 0 calc(var(--box) * 0.006) var(--crimson-hi), 0 0 calc(var(--box) * 0.04) rgba(200, 40, 40, 0.8); }

/* ---------------------------------------------------------------- the night curtain (painted by curtain.js) */

.curtain { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.curtain[data-state="down"] { pointer-events: auto; }
.curtain-canvas { position: absolute; inset: 0; display: block; }
.curtain-text {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
  text-align: center; padding: 1rem; opacity: 0; transform: translateY(8px); transition: opacity 0.9s ease, transform 0.9s ease;
}
.curtain-title { font: 400 clamp(2.8rem, 9vw, 6rem)/1 var(--gothic); color: var(--gold-hi); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 0, 0, 0.9); }
.curtain-sub { font: italic clamp(1rem, 2.6vw, 1.35rem)/1.35 var(--display); color: #f1e2c4; max-width: 26ch; text-shadow: 0 1px 8px rgba(0, 0, 0, 1); }
.curtain[data-state="down"] .curtain-text { opacity: 1; transform: none; transition-delay: 1.4s; }

/* fixes after visual check */
.rem-tray { z-index: 6; }
.rem-tray:not(:has(.rem-chips)) { width: auto; align-self: flex-start; background: transparent; border-color: transparent; padding: 0; }
body.is-st .circle-host { width: min(100%, calc(100vh - 6rem - var(--tray-h, 0px))); min-width: min(100%, 300px); }
.chat .chat-compose .input { flex: 1; min-width: 0; }
.chat .chat-send { flex: none; max-width: 55%; }

/* ---------------------------------------------------------------- token art */

.token.has-art .token-art {
  position: absolute; left: 12%; top: 12%; width: 76%; height: 76%; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 calc(var(--t) * 0.012) 0 rgba(60, 35, 10, 0.25));
}
.token.has-art.named .token-art { left: 17%; top: 6%; width: 66%; height: 66%; }
.token.has-art.token-xs .token-art { left: 6%; top: 6%; width: 88%; height: 88%; }
.token.token-full { background: none; box-shadow: 0 calc(var(--t) * 0.04) calc(var(--t) * 0.1) rgba(0, 0, 0, 0.55); }
.token.token-full::before { display: none; }
.token-full-img { width: 100%; height: 100%; border-radius: 50%; display: block; pointer-events: none; }
.arc-text { paint-order: stroke; stroke: rgba(246, 236, 214, 0.85); stroke-width: 2.2px; stroke-linejoin: round; }
img.rem-icon { width: 1.5rem; height: 1.5rem; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.rem-chip.on img.rem-icon { box-shadow: 0 0 0 2px #fbf3e2; }
.seat-rem-icon { width: 1.25em; height: 1.25em; border-radius: 50%; vertical-align: -0.3em; margin-right: 0.25em; }
span.seat-rem-icon { width: auto; height: auto; }

/* ---------------------------------------------------------------- cut-out character symbols */

.token-glyph { --t: 40px; display: inline-flex; width: var(--t); height: var(--t); flex: none; align-items: center; justify-content: center; vertical-align: middle; }
.token-glyph-xs { --t: 28px; }
.token-glyph-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.role-pick .token-glyph { --t: 34px; }
.role-pick:not(.on) .token-glyph { filter: grayscale(0.85); opacity: 0.55; }
.step-icon-img { width: 1.9em; height: 1.9em; object-fit: contain; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.seat-guess-icon { width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: -0.35em; margin-right: 0.2em; }

/* ---------------------------------------------------------------- character picker */

.role-picker { display: flex; align-items: center; gap: 0.5rem; text-align: left; cursor: pointer; min-height: 2.75rem; padding-top: 0.3rem; padding-bottom: 0.3rem; }
.role-picker .role-icon { width: 2rem; height: 2rem; object-fit: contain; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.role-icon-none { display: inline-block; width: 2rem; height: 2rem; border-radius: 50%; border: 2px dashed var(--line); flex: none; }
.role-picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-picker-label.placeholder { color: var(--muted); font-style: italic; }
.role-picker-caret { color: var(--muted); margin-left: auto; }
.role-picker[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.role-menu {
  position: fixed; z-index: 3000; display: flex; flex-direction: column; overflow: hidden;
  background-color: var(--parchment); background-image: var(--fibres), var(--grain); color: var(--sepia);
  border: 1px solid #8f7344; border-radius: 8px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.role-menu-search { margin: 0.5rem; width: auto; flex: none; }
.role-menu-list { overflow-y: auto; padding: 0 0.35rem 0.5rem; overscroll-behavior: contain; }
.role-menu-group { font: italic 700 0.85rem var(--display); text-transform: uppercase; letter-spacing: 0.08em; padding: 0.55rem 0.5rem 0.2rem; color: color-mix(in srgb, var(--team, var(--muted)) 85%, #000); border-bottom: 1px solid var(--line); margin-bottom: 0.15rem; }
.role-menu-group.team-townsfolk { --team: var(--townsfolk); }
.role-menu-group.team-outsider { --team: var(--outsider); }
.role-menu-group.team-minion { --team: var(--minion); }
.role-menu-group.team-demon { --team: var(--demon); }
.role-option {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; cursor: pointer;
  font: 600 1.02rem/1.15 var(--body); color: var(--sepia); background: transparent; border: 0; border-radius: 6px; padding: 0.3rem 0.5rem;
}
.role-option .role-icon { width: 2.3rem; height: 2.3rem; object-fit: contain; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.role-option:hover, .role-option:focus-visible { background: color-mix(in srgb, var(--crimson) 12%, transparent); outline: none; }
.role-option.on { background: var(--crimson); color: #fbf3e2; }
.role-option.on .role-icon { filter: drop-shadow(0 0 2px rgba(255, 245, 225, 0.9)); }
.role-menu-empty { padding: 0.5rem; }

/* ---------------------------------------------------------------- group chats */

.chat.chan-group { --chan: #4f7a3a; }
.chip.new-group { border-style: dashed; font-style: italic; }
.chat-invites:empty { display: none; }
.chat-invites { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, #4f7a3a 12%, transparent); flex: none; }
.chat-invite { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.chat-group-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); flex: none; }
.group-members { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 0; }
.chip.small-chip { font-size: 0.85rem; padding: 0.1rem 0.55rem; font-family: var(--body); }
.chip.pending { opacity: 0.65; border-style: dashed; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.35rem 0.75rem; }
.pick-person { padding: 0.3rem 0; }
.manage-list { display: flex; flex-direction: column; gap: 0.5rem; }
.manage-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; border-bottom: 1px dashed var(--line); padding-bottom: 0.45rem; }
.manage-row strong, .manage-row > span:first-child { flex: 1; min-width: 7rem; }

/* ---------------------------------------------------------------- personal drawing layer */

.draw-canvas { position: absolute; inset: 0; z-index: 4; pointer-events: none; touch-action: none; }
.draw-canvas.active { pointer-events: auto; cursor: crosshair; }
.draw-canvas.active[data-tool="text"] { cursor: text; }
.draw-canvas.active[data-tool="erase"] { cursor: not-allowed; }
.draw-bar { position: absolute; right: 0.6rem; top: 0.6rem; z-index: 7; display: flex; align-items: center; gap: 0.3rem; flex-direction: row-reverse; }
.draw-tools { display: none; align-items: center; gap: 0.25rem; padding: 0.25rem 0.35rem; border-radius: 999px; background: color-mix(in srgb, var(--plum-950) 85%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.draw-bar.open .draw-tools { display: flex; }
.draw-btn { min-width: 2rem; height: 2rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); background: color-mix(in srgb, var(--plum-950) 85%, transparent); color: var(--bone); font: 700 1rem/1 var(--body); cursor: pointer; padding: 0 0.45rem; }
.draw-btn.on { border-color: var(--gold-hi); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold-hi) 40%, transparent); }
.draw-toggle { font-size: 1.1rem; box-shadow: inset 0 -3px 0 var(--ink, #5cd36b); }
.draw-toggle[aria-pressed="true"] { background: var(--gold); color: var(--plum-950); }
.draw-btn.swatch { min-width: 1.6rem; width: 1.6rem; height: 1.6rem; padding: 0; background: var(--ink); border: 2px solid rgba(0, 0, 0, 0.5); }
.draw-btn.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--ink); }
.draw-sep { width: 1px; height: 1.4rem; background: color-mix(in srgb, var(--gold) 35%, transparent); margin: 0 0.15rem; }
.draw-text-input { position: absolute; z-index: 8; transform: translateY(-50%); font: 700 1.3rem 'Pirata One', serif; background: rgba(10, 4, 18, 0.75); border: 1px dashed currentColor; border-radius: 4px; padding: 0.1rem 0.35rem; min-width: 8rem; outline: none; }
@media (max-width: 900px) { .draw-bar { top: 0.4rem; right: 0.4rem; } .draw-tools { flex-wrap: wrap; max-width: 70vw; border-radius: 14px; } }

/* fixes from the bug-hunt pass */
.bluffs { grid-template-columns: 1fr; }
.bluffs > .btn { justify-self: start; }
.grim-controls .role-picker { flex: 1 1 12rem; width: auto; }

/* ---- test players */
.test-badge { font-size: .8rem; padding: .15rem .5rem; border-radius: 999px; border: 1px dashed #e6c47a; color: #e6c47a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.test-list { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .35rem; }
.test-list li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.test-list .test-name { flex: 1 1 8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.test-actions select { width: auto; }
.btn.ghost.danger { background: transparent; color: var(--crimson); border-color: var(--crimson); }

/* ---- characters shown as information (bluffs, "this character is in play"…) */
.info-roles { align-items: flex-start; }
.role-card { margin: 0; width: 6.2rem; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; text-align: center; }
.role-card-icon { width: 5rem; height: 5rem; object-fit: contain; display: grid; place-items: center; font-size: 2.6rem; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.role-card figcaption { font: 400 1.2rem/1.1 var(--gothic); letter-spacing: 0.02em; color: var(--ink, #2a1c14); overflow-wrap: anywhere; }
.role-card.team-townsfolk figcaption, .role-card.team-outsider figcaption { color: #1f4f8a; }
.role-card.team-minion figcaption, .role-card.team-demon figcaption { color: #8b1a1a; }
.wake-modal .role-card.team-townsfolk figcaption, .wake-modal .role-card.team-outsider figcaption { color: #8fc0ff; }
.wake-modal .role-card.team-minion figcaption, .wake-modal .role-card.team-demon figcaption { color: #ff8a8a; }
.learned > li > .btn { margin-top: 0.5rem; position: relative; z-index: 1; }

/* reminder tray: grouped by character, compact, never scrolls */
.rem-groups { display: flex; flex-wrap: wrap; gap: 0.3rem 0.45rem; margin-top: 0.45rem; align-items: center; }
.rem-group { --team: #8a7048; display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.2rem 0.15rem 0.15rem; border-radius: 999px; background: color-mix(in srgb, var(--team) 22%, transparent); border: 1px solid color-mix(in srgb, var(--team) 55%, transparent); }
.rem-group.team-townsfolk { --team: var(--townsfolk); }
.rem-group.team-outsider { --team: var(--outsider); }
.rem-group.team-minion { --team: var(--minion); }
.rem-group.team-demon { --team: var(--demon); }
.rem-group.general { background: transparent; border-color: transparent; }
.rem-group-icon { width: 1.75rem; height: 1.75rem; object-fit: contain; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.rem-groups .rem-chip { font-size: 0.8rem; min-height: 1.75rem; padding: 0.2rem 0.55rem; border-left-width: 1px; gap: 0.25rem; }
.rem-groups img.rem-icon { width: 1.2rem; height: 1.2rem; }
@media (max-width: 900px) {
  body.is-st .circle-host { width: min(100%, 64vh); }
  body.is-st.phase-night .square { padding-top: 2.8rem; } /* keep the top seats clear of the curtain's valance */
}

/* hand-picked characters waiting for the deal */
.seat.queued .token { opacity: 0.6; outline: 2px dashed color-mix(in srgb, var(--gold-hi) 70%, transparent); outline-offset: 3px; }
.queued-tag { font: italic 0.75rem var(--display); color: var(--gold); border: 1px dashed currentColor; border-radius: 999px; padding: 0 0.4rem; }

/* reminder tray v3: a docked, easy-to-read bottom window across the town square */
.rem-tray {
  width: 100%; max-width: none; margin-top: 0.6rem; padding: 0.6rem 0.8rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent); border-radius: 10px;
  background: linear-gradient(color-mix(in srgb, var(--plum-950) 92%, transparent), color-mix(in srgb, var(--plum-950) 82%, transparent));
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 color-mix(in srgb, var(--gold) 25%, transparent);
}
.rem-tray .tray-toggle { font-size: 1rem; padding: 0.4rem 0.8rem; }
.rem-tray .tray-hint { font-size: 1.02rem; }
.rem-groups { gap: 0.45rem 0.6rem; margin-top: 0.6rem; }
.rem-group { gap: 0.3rem; padding: 0.2rem 0.3rem 0.2rem 0.25rem; }
.rem-group-icon { width: 2.4rem; height: 2.4rem; }
.rem-groups .rem-chip { font-size: 0.98rem; min-height: 2.35rem; padding: 0.3rem 0.8rem; }
.rem-groups img.rem-icon { width: 1.5rem; height: 1.5rem; }
.rem-count { font-size: 0.8rem; }
/* the reminders sitting on each seat, a touch larger too */
.seat-reminders { max-width: calc(var(--box) * 0.3); gap: 3px; }
.seat-reminders .reminder { font-size: clamp(0.74rem, calc(var(--box) * 0.021), 0.92rem); padding: 0.05em 0.45em; }
.seat-rem-icon { width: 1.4em; height: 1.4em; }

/* ---- chat v3: conversation list beside the open conversation */
#pane-town, #pane-chat { container-type: inline-size; }
.chat { display: grid; grid-template-columns: minmax(8.5rem, 36%) 1fr; grid-template-rows: minmax(0, 1fr); height: 100%; min-height: 0; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-threads { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; padding: 0.4rem; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--field) 35%, transparent); scrollbar-width: thin; }
.thread {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.35rem; width: 100%; text-align: left;
  padding: 0.45rem 0.4rem; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--ink, inherit); cursor: pointer; font: inherit;
}
.thread:hover { background: color-mix(in srgb, var(--field) 70%, transparent); }
.thread.active { background: var(--field); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: inset 3px 0 0 var(--accent); }
.thread-icon { font-size: 1.05rem; line-height: 1; }
.thread-body { display: flex; flex-direction: column; min-width: 0; }
.thread-name { font: 700 0.95rem/1.2 var(--display); color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-last { font-size: 0.8rem; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread.has-unread .thread-name { color: var(--crimson); }
.thread.has-unread .thread-last { color: var(--ink, inherit); font-weight: 600; }
.thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.thread-time { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.thread .count { background: var(--crimson); color: #fbf3e2; border-radius: 999px; font-size: 0.72rem; font-weight: 700; padding: 0.05rem 0.42rem; }
.thread.is-dead .thread-name { text-decoration: line-through; text-decoration-color: var(--crimson); }
.thread.whisper .thread-icon, .thread.group .thread-icon { opacity: 0.9; }
.thread-actions { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.35rem; padding-top: 0.45rem; border-top: 1px dashed var(--line); }
.thread-select { font-size: 0.85rem; padding: 0.35rem 0.4rem; }
.thread-new { border: 1px dashed var(--line); background: transparent; border-radius: 7px; padding: 0.4rem; font: italic 0.88rem var(--display); color: var(--heading); cursor: pointer; }
/* narrow panels: the list sits on top as a short scrolling strip */
@container (max-width: 19rem) {
  .chat { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .chat-threads { border-right: 0; border-bottom: 1px solid var(--line); max-height: 9.5rem; }
}
@supports not (container-type: inline-size) { .chat { grid-template-columns: 1fr; } }

/* ---- two adjustable side panels around the town square */
.panel { position: relative; width: 440px; }
.panel-left { order: 0; border-left: 0; border-right: 3px double color-mix(in srgb, var(--parchment-edge) 80%, transparent); box-shadow: inset 0 0 70px rgba(110, 72, 25, 0.35), 8px 0 30px rgba(0, 0, 0, 0.4); }
.square { order: 1; }
.panel-right { order: 2; }
.panel[hidden] { display: none; }
.tabs-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); flex: none; }
.tabs-row .tabs { flex: 1; min-width: 0; border-bottom: 0; }
.layout-btn { flex: none; align-self: center; margin: 0 0.35rem; border-color: transparent; background: transparent; color: var(--muted); font-size: 1.15rem; }
.layout-btn:hover { color: var(--heading); border-color: var(--line); }
.tab[draggable="true"] { cursor: pointer; }
body.dragging-tab .panel { outline: 2px dashed transparent; outline-offset: -6px; transition: outline-color 0.15s; }
body.dragging-tab .panel.drop-here { outline-color: var(--gold); }
.panel-grip { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; touch-action: none; }
.panel-right .panel-grip { left: -4px; }
.panel-left .panel-grip { right: -4px; }
.panel-grip:hover, .panel-grip:active { background: color-mix(in srgb, var(--gold) 35%, transparent); }
@media (max-width: 900px) {
  .panel, .panel-left, .panel-right { width: 100% !important; border-right: 0; }
  .square { order: 0; }
  .panel-left { order: 1; }
  .panel-right { order: 2; }
  .panel-grip { display: none; }
  .tabs-row { position: sticky; top: 2.9rem; background-color: var(--bg); background-image: var(--grain); z-index: 10; }
  .tabs-row .tabs { position: static; }
}
/* panels give way on smaller screens so the town square keeps at least ~480px */
@media (min-width: 901px) {
  .panel { max-width: max(250px, calc((100vw - 480px) / 2)); min-width: 250px; }
  .square { min-width: 0; overflow: hidden; }
}
.rem-tray { box-sizing: border-box; max-width: 100%; }
.rem-group { flex-wrap: wrap; max-width: 100%; }
@container (max-width: 19rem) { .chat-threads { max-height: 40%; } }
.music-btn.off { opacity: 0.45; filter: grayscale(1); }
