/* Mafia Stage components. Every component works in both directions (logical properties only) and in both registers.
   Class prefix ms-. State classes is-*. Variant classes ms-x--variant. */

/* =========================================================
   Mark and wordmark
   ========================================================= */
.ms-brand { display: inline-flex; align-items: center; gap: var(--space-2); }
.ms-mark { width: 28px; height: 28px; flex: none; }              /* never mirrors, never recoloured except the band */
.ms-wordmark { font-family: var(--font-body-en); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; color: var(--ink); direction: ltr; white-space: nowrap; }
.ms-wordmark--fa { font-family: var(--font-body-fa); font-weight: 600; direction: rtl; }

/* =========================================================
   Top nav
   ========================================================= */
.ms-topnav {
  height: var(--topnav);
  display: flex; align-items: center; gap: var(--space-5);
  padding-inline: var(--space-4);
}
.ms-topnav--chrome { background: var(--smoke); box-shadow: 0 1px 0 var(--edge-colour); }
.ms-topnav__links { display: flex; align-items: center; gap: var(--space-4); margin-inline-start: var(--space-3); }
.ms-topnav__link {
  position: relative; display: inline-flex; align-items: center; height: var(--topnav);
  color: var(--dim); font-size: var(--size-body-s); font-weight: var(--weight-medium);
  transition: color var(--dur-quick) var(--ease-standard);
}
.ms-topnav__link:hover, .ms-topnav__link:focus-visible { color: var(--ink); }
.ms-topnav__link[aria-current="page"] { color: var(--ink); }
.ms-topnav__link[aria-current="page"]::after { content: ""; position: absolute; inset-inline: 0; inset-block-end: 0; height: 2px; background: var(--spotlight); border-radius: 2px 2px 0 0; }
.ms-topnav__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-3); }

/* =========================================================
   Side rail
   ========================================================= */
.ms-rail {
  width: var(--rail); padding-block: var(--space-2);
  display: flex; flex-direction: column; align-items: stretch; gap: var(--space-1);
  background: var(--smoke); box-shadow: 1px 0 0 var(--edge-colour);
}
[dir="rtl"] .ms-rail { box-shadow: -1px 0 0 var(--edge-colour); }
.ms-rail__item {
  position: relative; height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--dim); font-size: var(--size-micro); font-weight: var(--weight-medium); line-height: 1;
  border-radius: var(--radius-s);
  transition: color var(--dur-quick) var(--ease-standard), background-color var(--dur-quick) var(--ease-standard);
}
.ms-rail__item svg { width: 22px; height: 22px; }
.ms-rail__item:hover, .ms-rail__item:focus-visible { color: var(--ink); background: var(--haze); }
.ms-rail__item[aria-current="page"] { color: var(--ink); }
.ms-rail__item[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: 0; inset-block: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--spotlight); }
[dir="rtl"] .ms-rail__item[aria-current="page"]::before { border-radius: 3px 0 0 3px; }
.ms-rail__item .ms-badge--count { position: absolute; inset-block-start: 6px; inset-inline-end: 10px; }
.ms-rail__spacer { flex: 1; }

/* =========================================================
   Buttons
   ========================================================= */
.ms-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-m); padding-inline: var(--space-4);
  border-radius: var(--radius-m);
  font-size: var(--size-body-s); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  color: var(--ink);
  transition: background-color var(--dur-quick) var(--ease-standard), color var(--dur-quick) var(--ease-standard), box-shadow var(--dur-quick) var(--ease-standard), filter var(--dur-quick) var(--ease-standard);
  user-select: none;
}
.ms-btn svg { width: 18px; height: 18px; flex: none; }
.ms-btn:disabled, .ms-btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.ms-btn--primary { background: var(--spotlight); color: var(--on-spotlight); }
.ms-btn--primary:hover:not(:disabled) { filter: brightness(1.07); }
.ms-btn--primary:active:not(:disabled) { background: var(--spotlight-deep); filter: none; }
.ms-btn--go { background: var(--go); color: var(--on-go); font-weight: var(--weight-strong); }
.ms-btn--go:hover:not(:disabled) { filter: brightness(1.07); }
.ms-btn--go:active:not(:disabled) { background: var(--go-deep); filter: none; }
.ms-btn--secondary { box-shadow: var(--edge-strong); }
.ms-btn--secondary:hover:not(:disabled) { background: var(--haze); }
.ms-btn--secondary:active:not(:disabled) { background: var(--mist); }
.ms-btn--ghost { color: var(--dim); }
.ms-btn--ghost:hover:not(:disabled) { color: var(--ink); background: var(--haze); }
.ms-btn--destructive { color: var(--danger); box-shadow: inset 0 0 0 1px rgb(255 106 74 / 0.35); }
.ms-btn--destructive:hover:not(:disabled) { background: rgb(255 106 74 / 0.10); box-shadow: inset 0 0 0 1px var(--danger); }
.ms-btn--destructive:active:not(:disabled) { background: rgb(255 106 74 / 0.18); }
/* stage size: pills, bigger, bolder */
.ms-btn--stage { height: var(--control-l); padding-inline: var(--space-5); border-radius: var(--radius-pill); font-size: var(--size-body); font-weight: var(--weight-strong); }
.ms-btn--s { height: 32px; padding-inline: var(--space-3); font-size: var(--size-caption); border-radius: var(--radius-s); }
.ms-btn--icon { width: var(--control-m); padding: 0; }
.ms-btn--icon.ms-btn--stage { width: var(--control-l); }
.ms-btn.is-loading { color: transparent !important; pointer-events: none; }
.ms-btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--stage) transparent var(--stage) var(--stage); animation: ms-spin 800ms linear infinite; }
.ms-btn--secondary.is-loading::after, .ms-btn--ghost.is-loading::after { border-color: var(--ink) transparent var(--ink) var(--ink); }
.ms-btn--destructive.is-loading::after { border-color: var(--danger) transparent var(--danger) var(--danger); }
@keyframes ms-spin { to { transform: rotate(360deg); } }

/* =========================================================
   Vote button: the one go action during a seat's five seconds
   ========================================================= */
.ms-vote {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-l); min-width: 200px; padding-inline: var(--space-5);
  border-radius: var(--radius-pill);
  background: var(--go); color: var(--on-go);
  font-size: var(--size-body); font-weight: var(--weight-strong); line-height: 1; white-space: nowrap;
  transition: background-color var(--dur-quick) var(--ease-standard), color var(--dur-quick) var(--ease-standard), box-shadow var(--dur-quick) var(--ease-standard);
}
.ms-vote__window {           /* the closing window: the elapsed part darkens from the end edge, so the bright part is the time left */
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: calc((1 - var(--p, 1)) * 100%);
  background: rgb(0 0 0 / 0.32);
  transition: width 1s linear;
  pointer-events: none;
}
.ms-vote svg { width: 18px; height: 18px; flex: none; }
.ms-vote > span { position: relative; }
.ms-vote:hover:not(:disabled) { filter: brightness(1.07); }
.ms-vote:active:not(:disabled) { background: var(--go-deep); }
.ms-vote.is-voted { background: transparent; color: var(--ink); box-shadow: var(--ring-ink); }
.ms-vote.is-voted .ms-vote__window { display: none; }
.ms-vote.is-closed, .ms-vote:disabled { background: var(--haze); color: var(--faint); cursor: not-allowed; }
.ms-vote.is-closed .ms-vote__window { display: none; }
.ms-vote--pulse { background: transparent; color: var(--ink); box-shadow: var(--edge-strong); }   /* manual mode: hold while the God counts */
.ms-vote--pulse.is-holding { box-shadow: var(--glow-spotlight); color: var(--spotlight); }

/* =========================================================
   Text input
   ========================================================= */
.ms-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ms-field__label { font-size: var(--size-caption); color: var(--dim); font-weight: var(--weight-medium); }
.ms-field__help { font-size: var(--size-caption); color: var(--faint); }
.ms-field__error { font-size: var(--size-caption); color: var(--danger); }
.ms-input {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--control-m); padding-inline: var(--space-3);
  border-radius: var(--radius-m);
  background: rgb(243 236 223 / 0.06);
  box-shadow: var(--edge);
  color: var(--ink);
  transition: box-shadow var(--dur-quick) var(--ease-standard), background-color var(--dur-quick) var(--ease-standard);
}
.ms-input input, .ms-input textarea { flex: 1; min-width: 0; background: none; border: 0; outline: none; height: 100%; padding: 0; color: var(--ink); font-size: var(--size-body-s); }
.ms-input input::placeholder { color: var(--faint); }
.ms-input svg { width: 18px; height: 18px; color: var(--dim); flex: none; }
.ms-input:hover { box-shadow: var(--edge-strong); }
.ms-input:focus-within { box-shadow: var(--ring-focus); background: rgb(243 236 223 / 0.04); }
.ms-input.is-error { box-shadow: inset 0 0 0 1px var(--danger); }
.ms-input.is-error:focus-within { box-shadow: 0 0 0 2px var(--stage), 0 0 0 4px var(--danger); }
.ms-input.is-disabled { opacity: 0.4; pointer-events: none; }
.ms-input--stage { height: var(--control-l); border-radius: var(--radius-pill); padding-inline: var(--space-5); background: var(--smoke); }
.ms-input--stage input { font-size: var(--size-body); }
.ms-input--textarea { height: auto; min-height: 96px; align-items: flex-start; padding-block: var(--space-2); }
.ms-input--textarea textarea { resize: vertical; line-height: var(--leading-body); min-height: 80px; }

/* =========================================================
   Pill (filter, segmented choice) and badge (status)
   ========================================================= */
.ms-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding-inline: 14px;
  border-radius: var(--radius-pill);
  background: rgb(243 236 223 / 0.06);
  color: var(--ink); font-size: var(--size-body-s); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  transition: background-color var(--dur-quick) var(--ease-standard), color var(--dur-quick) var(--ease-standard);
}
.ms-pill:hover { background: var(--haze); }
.ms-pill[aria-pressed="true"], .ms-pill.is-on { background: var(--ink); color: var(--on-ink); }
.ms-pill:disabled { opacity: 0.4; cursor: not-allowed; }
.ms-pill--s { height: 26px; padding-inline: 10px; font-size: var(--size-caption); }
.ms-pillgroup { display: inline-flex; gap: var(--space-1); padding: 3px; border-radius: var(--radius-pill); background: rgb(243 236 223 / 0.04); }
.ms-pillgroup .ms-pill { background: transparent; }
.ms-pillgroup .ms-pill[aria-pressed="true"] { background: var(--ink); }

.ms-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding-inline: 8px;
  border-radius: var(--radius-pill);
  background: var(--haze); color: var(--dim);
  font-size: var(--size-micro); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  letter-spacing: 0;
}
.ms-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ms-badge--live { background: rgb(61 204 116 / 0.14); color: var(--live); }
.ms-badge--live i { animation: ms-breathe 1.8s var(--ease-standard) infinite; }
.ms-badge--go { background: rgb(61 204 116 / 0.14); color: var(--go); }
.ms-badge--spot { background: rgb(245 195 90 / 0.14); color: var(--spotlight); }
.ms-badge--mafia { background: rgb(164 38 43 / 0.35); color: var(--mafia); }
.ms-badge--ink { background: var(--ink); color: var(--on-ink); }
.ms-badge--danger { background: rgb(255 106 74 / 0.12); color: var(--danger); }
.ms-badge--count { height: 20px; min-width: 20px; padding-inline: 6px; justify-content: center; background: var(--ink); color: var(--on-ink); font-variant-numeric: tabular-nums; }
.ms-badge--level { background: transparent; box-shadow: inset 0 0 0 1px var(--spotlight-deep); color: var(--spotlight); }
@keyframes ms-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* =========================================================
   Panel: chrome (a quiet box) and stage (a region of light)
   ========================================================= */
.ms-panel {
  background: var(--smoke);
  border-radius: var(--radius-m);
  box-shadow: var(--edge);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-3);
  min-width: 0;
}
.ms-panel__head { display: flex; align-items: center; gap: var(--space-2); }
.ms-panel__title { font-size: var(--size-body-s); font-weight: var(--weight-medium); color: var(--ink); }
.ms-panel__head .ms-btn { margin-inline-start: auto; }
.ms-panel--dense { padding: var(--space-3); gap: var(--space-2); }
.ms-panel--stage {
  background: linear-gradient(to bottom, rgb(243 236 223 / 0.05), transparent 60%);
  box-shadow: none;
  border-radius: var(--radius-l);
  padding: var(--space-5);
}
.ms-panel--sheet { border-radius: var(--radius-l) var(--radius-l) 0 0; box-shadow: var(--shadow-chrome), var(--edge); }
.ms-panel--sheet::before { content: ""; align-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--mist); margin-block: -6px 2px; }
.ms-divider { height: 1px; background: var(--edge-colour); margin-block: var(--space-1); }
.ms-kv { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--size-body-s); }
.ms-kv dt { color: var(--dim); } .ms-kv dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }

/* =========================================================
   Avatar and level ring
   ========================================================= */
.ms-avatar {
  --size: 40px;
  position: relative; width: var(--size); height: var(--size); flex: none;
  border-radius: var(--radius-round); overflow: hidden; background: var(--haze);
}
.ms-avatar > img, .ms-avatar > svg { width: 100%; height: 100%; object-fit: cover; }
.ms-avatar--xs { --size: 20px; } .ms-avatar--s { --size: 28px; } .ms-avatar--l { --size: 56px; } .ms-avatar--xl { --size: 80px; } .ms-avatar--xxl { --size: 120px; }
.ms-avatar-ring {
  --size: 56px; --p: 0; --ring: 3px;
  position: relative; width: var(--size); height: var(--size); flex: none; display: inline-block;
}
.ms-avatar-ring::before {    /* progress to the next level, drawn clockwise; never mirrors */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--spotlight) calc(var(--p) * 360deg), var(--mist) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring)), #000 calc(100% - var(--ring) + 0.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring)), #000 calc(100% - var(--ring) + 0.5px));
}
.ms-avatar-ring .ms-avatar { --size: 100%; position: absolute; inset: calc(var(--ring) + 2px); width: auto; height: auto; }
.ms-avatar-ring__lvl {
  position: absolute; inset-block-end: -2px; inset-inline-end: -2px;
  min-width: 20px; height: 20px; padding-inline: 5px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--on-ink); box-shadow: 0 0 0 2px var(--stage);
  font-size: var(--size-micro); font-weight: var(--weight-strong); line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.ms-avatar-ring--l { --size: 80px; --ring: 4px; }
.ms-avatar-ring--xl { --size: 120px; --ring: 5px; }
.ms-avatar-ring--xl .ms-avatar-ring__lvl { min-width: 26px; height: 26px; line-height: 26px; font-size: var(--size-caption); }
.ms-facepile { display: inline-flex; }
.ms-facepile .ms-avatar { box-shadow: 0 0 0 2px var(--stage); margin-inline-start: -6px; }
.ms-facepile .ms-avatar:first-child { margin-inline-start: 0; }

/* =========================================================
   Role card: a prop. Works for any role name and any team.
   ========================================================= */
.ms-rolecard {
  --team: var(--ink); --band: rgb(243 236 223 / 0.14);
  position: relative; width: 220px; aspect-ratio: 5 / 7;
  border-radius: var(--radius-xl); overflow: hidden;
  background: linear-gradient(165deg, #1e1a17 0%, #0f0d0b 60%, #0b0a09 100%);
  box-shadow: var(--shadow-prop), var(--edge-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: var(--space-5) var(--space-4);
  color: var(--ink);
  transform-style: preserve-3d;
}
.ms-rolecard::before {   /* the team band */
  content: ""; position: absolute; inset-inline: 0; inset-block-start: 0; height: 6px; background: var(--band);
}
.ms-rolecard::after {    /* the inner frame, a printed card's margin */
  content: ""; position: absolute; inset: 12px; border-radius: calc(var(--radius-xl) - 8px); box-shadow: inset 0 0 0 1px rgb(243 236 223 / 0.07); pointer-events: none;
}
.ms-rolecard__mark { width: 56px; height: 56px; opacity: 0.9; margin-block-end: var(--space-3); }
.ms-rolecard__name {
  font-family: var(--font-display); font-weight: 400; font-size: var(--size-display-m); line-height: var(--leading-disp); letter-spacing: var(--tracking-display);
  color: var(--team); text-wrap: balance; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ms-rolecard__team { margin-block-start: var(--space-1); font-size: var(--size-body-s); color: var(--dim); font-weight: var(--weight-medium); }
.ms-rolecard__ability { margin-block-start: var(--space-4); font-size: var(--size-caption); line-height: var(--leading-body); color: var(--dim); max-width: 22ch; }
.ms-rolecard__hint { position: absolute; inset-block-end: var(--space-4); inset-inline: var(--space-4); font-size: var(--size-micro); color: var(--faint); }
.ms-rolecard.is-mafia { --team: var(--mafia); --band: var(--mafia-deep); background: linear-gradient(165deg, #261416 0%, #120d0c 55%, #0b0a09 100%); }
.ms-rolecard.is-independent { --team: var(--spotlight); --band: var(--spotlight-deep); }
.ms-rolecard--back { justify-content: center; }
.ms-rolecard--back .ms-rolecard__mark { width: 72px; height: 72px; margin: 0; opacity: 0.55; }
.ms-rolecard--back::after { border: 1px dashed rgb(243 236 223 / 0.14); box-shadow: none; }
.ms-rolecard--s { width: 150px; padding: var(--space-3); }
.ms-rolecard--s .ms-rolecard__mark { width: 36px; height: 36px; margin-block-end: var(--space-2); }
.ms-rolecard--s .ms-rolecard__name { font-size: var(--size-display-s); }
.ms-rolecard--s .ms-rolecard__ability, .ms-rolecard--s .ms-rolecard__hint { display: none; }
/* the reveal: a flip on the Y axis. Reduced motion: a cross-fade (durations collapse to 1ms, opacity carries it). */
.ms-flip { position: relative; width: 220px; aspect-ratio: 5 / 7; perspective: 1200px; }
.ms-flip .ms-rolecard { position: absolute; inset: 0; backface-visibility: hidden; transition: transform var(--dur-scene) var(--ease-stage), opacity var(--dur-scene) var(--ease-stage); }
.ms-flip .ms-rolecard:not(.ms-rolecard--back) { transform: rotateY(180deg); }
.ms-flip.is-revealed .ms-rolecard--back { transform: rotateY(-180deg); }
.ms-flip.is-revealed .ms-rolecard:not(.ms-rolecard--back) { transform: rotateY(0); }
@media (prefers-reduced-motion: reduce) {
  .ms-flip .ms-rolecard { transform: none !important; opacity: 0; }
  .ms-flip .ms-rolecard--back { opacity: 1; }
  .ms-flip.is-revealed .ms-rolecard--back { opacity: 0; }
  .ms-flip.is-revealed .ms-rolecard:not(.ms-rolecard--back) { opacity: 1; }
}

/* =========================================================
   Seat tile. Ten of these on a phone and on a laptop.
   ========================================================= */
.ms-table {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.ms-table--phone, .ms-table.is-phone { gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .ms-table { gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.ms-seat {
  --p: 0;
  position: relative; aspect-ratio: 4 / 3; min-width: 0;
  border-radius: var(--radius-l); overflow: hidden;
  background: var(--smoke);
  box-shadow: var(--edge);
  color: var(--ink);
  transition: box-shadow var(--dur-settle) var(--ease-standard), filter var(--dur-scene) var(--ease-stage), background-color var(--dur-night) var(--ease-stage), opacity var(--dur-night) var(--ease-stage);
  font-size: var(--size-caption);
  line-height: 1.2;
}
.ms-table--phone .ms-seat, .ms-table.is-phone .ms-seat { border-radius: var(--radius-m); font-size: var(--size-micro); }
@media (max-width: 720px) { .ms-seat { border-radius: var(--radius-m); font-size: var(--size-micro); } }
.ms-video { position: absolute; inset: 0; background: var(--haze); transition: filter var(--dur-night) var(--ease-stage), opacity var(--dur-night) var(--ease-stage); }
.ms-video > img, .ms-video > svg, .ms-video > video { width: 100%; height: 100%; object-fit: cover; }
.ms-seat__num {
  position: absolute; inset-block-start: 6px; inset-inline-start: 6px;
  min-width: 18px; height: 18px; padding-inline: 5px; border-radius: var(--radius-pill);
  background: rgb(11 10 9 / 0.7); color: var(--ink);
  font-size: var(--size-micro); font-weight: var(--weight-medium); line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}
.ms-seat__state {       /* the one pill that says what this seat is doing */
  position: absolute; inset-block-start: 6px; inset-inline-end: 6px;
  height: 18px; padding-inline: 7px; border-radius: var(--radius-pill);
  background: rgb(11 10 9 / 0.7); color: var(--dim);
  font-size: var(--size-micro); font-weight: var(--weight-medium); line-height: 18px; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.ms-seat__name {
  position: absolute; inset-inline: 0; inset-block-end: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(to top, rgb(11 10 9 / 0.85), rgb(11 10 9 / 0.0));
  display: flex; align-items: center; gap: 5px;
  font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-seat__name .ms-badge--level { height: 14px; padding-inline: 4px; font-size: 9px; }
.ms-seat__bar {   /* the speaker's remaining time, top edge, fills left to right in both directions */
  position: absolute; inset-inline: 0; inset-block-start: 0; height: 3px; background: rgb(243 236 223 / 0.12); direction: ltr; display: none;
}
.ms-seat__bar i { display: block; height: 100%; width: calc(var(--p) * 100%); background: var(--spotlight); transition: width 1s linear; }
.ms-seat__votes {   /* count disc and the voters' faces */
  position: absolute; inset-block-start: 4px; inset-inline-end: 4px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
}
.ms-seat__count {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--on-ink);
  font-family: var(--font-display); font-size: 18px; line-height: 28px; text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.5);
}
.ms-seat__count:lang(en) { font-size: 15px; }
.ms-seat__voters { display: flex; }
.ms-seat__voters .ms-avatar { --size: 16px; box-shadow: 0 0 0 1.5px var(--stage); margin-inline-start: -4px; }
.ms-seat__voters .ms-avatar:first-child { margin-inline-start: 0; }
.ms-seat__you {   /* lives inside the name strip, at its end */
  margin-inline-start: auto; flex: none;
  height: 14px; padding-inline: 5px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--on-ink); font-size: 9px; font-weight: var(--weight-strong); line-height: 14px;
}
/* when a seat carries votes, the votes own the top end corner and the state pill drops to the bottom end corner */
.ms-seat:has(.ms-seat__votes) .ms-seat__state { inset-block-start: auto; inset-block-end: 24px; }
/* at phone size the ring and the count carry the state; the pill would collide with the voters' faces */
.ms-table--phone .ms-seat:has(.ms-seat__votes) .ms-seat__state { display: none; }
@media (max-width: 720px) { .ms-seat:has(.ms-seat__votes) .ms-seat__state { display: none; } }
.ms-seat__sleep {   /* closed eyes, shown when asleep */
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: var(--dim);
}
.ms-seat__sleep svg { width: 34%; height: auto; opacity: 0.9; }
.ms-seat__hand {    /* a raised hand: challenge requested */
  position: absolute; inset-block-start: 28px; inset-inline-end: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--spotlight); color: var(--on-spotlight); display: none; align-items: center; justify-content: center;
}
.ms-seat__hand svg { width: 12px; height: 12px; }

/* states */
.ms-seat.is-speaking { box-shadow: var(--glow-spotlight); z-index: 2; }
.ms-seat.is-speaking .ms-seat__bar { display: block; }
.ms-seat.is-speaking .ms-seat__state { background: var(--spotlight); color: var(--on-spotlight); }
.ms-table.has-speaker .ms-seat:not(.is-speaking):not(.is-open) .ms-video { filter: brightness(0.72); }
.ms-seat.is-next .ms-seat__state { color: var(--spotlight); }
.ms-seat.is-open { box-shadow: var(--glow-go); }               /* this seat's five seconds are open */
.ms-seat.is-open .ms-seat__state { background: var(--go); color: var(--on-go); }
.ms-seat.is-accused { box-shadow: var(--ring-ink), 0 0 24px rgb(243 236 223 / 0.18); }
.ms-seat.is-accused .ms-seat__state { background: var(--ink); color: var(--on-ink); }
.ms-seat.is-challenging .ms-seat__hand { display: flex; }
.ms-seat.is-dead .ms-video { filter: grayscale(1) brightness(0.38) !important; }
.ms-seat.is-dead { box-shadow: none; }
.ms-seat.is-dead .ms-seat__name { color: var(--dim); }
.ms-seat.is-dead .ms-seat__state { color: var(--faint); background: rgb(11 10 9 / 0.5); }
.ms-seat.is-dead .ms-seat__num { color: var(--dim); }
.ms-seat.is-asleep { background: var(--smoke); }
.ms-seat.is-asleep .ms-video { opacity: 0.12; filter: grayscale(1); }
.ms-seat.is-asleep .ms-seat__sleep { display: flex; }
.ms-seat.is-asleep .ms-seat__name { color: var(--dim); background: none; }
.ms-seat.is-asleep .ms-seat__state { color: var(--faint); background: transparent; }
.ms-seat.is-mafia { box-shadow: var(--glow-mafia); }           /* awake with the team, private surface only */
.ms-seat.is-mafia .ms-seat__state { background: var(--mafia-deep); color: var(--ink); }
.ms-seat.is-mafia.is-boss { box-shadow: var(--glow-mafia), 0 0 48px rgb(238 89 96 / 0.35); }
.ms-seat.is-awake { box-shadow: var(--glow-spotlight); }       /* the God woke this role */
.ms-seat.is-awake .ms-seat__state { background: var(--spotlight); color: var(--on-spotlight); }
.ms-seat.is-self { box-shadow: var(--edge-strong); }
.ms-seat.is-self .ms-seat__you { display: block; }
.ms-seat:not(.is-self) .ms-seat__you { display: none; }
.ms-seat.is-self.is-speaking { box-shadow: var(--glow-spotlight); }
.ms-seat.is-muted:not(.is-self) .ms-seat__name::after { content: ""; width: 10px; height: 10px; margin-inline-start: auto; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><path d='M9 9v3a3 3 0 0 0 5.1 2.1M15 9.3V5a3 3 0 0 0-6 0v1M5 10a7 7 0 0 0 11.7 5.2M19 10a7 7 0 0 1-.6 2.8M12 17v4M3 3l18 18'/></svg>") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><path d='M9 9v3a3 3 0 0 0 5.1 2.1M15 9.3V5a3 3 0 0 0-6 0v1M5 10a7 7 0 0 0 11.7 5.2M19 10a7 7 0 0 1-.6 2.8M12 17v4M3 3l18 18'/></svg>") center / contain no-repeat; opacity: 0.7; }
/* a vote landing: the count and the newest face arrive with a small overshoot */
.ms-seat .is-landing { animation: ms-land var(--dur-settle) var(--ease-land) both; }
@keyframes ms-land { from { transform: scale(1.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ms-seat .is-landing { animation: none; } }

/* The speaker on the stage: the same seat, big, with the ring timer */
.ms-speaker {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-xl); overflow: hidden;
  background: var(--smoke); box-shadow: var(--glow-spotlight-soft), var(--edge-strong);
  transition: box-shadow var(--dur-night) var(--ease-stage), background-color var(--dur-night) var(--ease-stage);
}
.ms-speaker .ms-video { position: absolute; inset: 0; }
.ms-speaker__caption {
  position: absolute; inset-inline: 0; inset-block-end: 0; padding: 40px var(--space-4) var(--space-3);
  background: linear-gradient(to top, rgb(11 10 9 / 0.85), transparent);
  display: flex; align-items: flex-end; gap: var(--space-3);
}
.ms-speaker__name { font-family: var(--font-display); font-size: var(--size-display-s); line-height: 1; letter-spacing: var(--tracking-display); }
.ms-speaker__role { font-size: var(--size-body-s); color: var(--dim); margin-block-end: 2px; }
.ms-speaker__timer { position: absolute; inset-block-start: var(--space-3); inset-inline-end: var(--space-3); }
.ms-speaker--night { box-shadow: var(--edge); background: var(--smoke); display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--space-5); }
.ms-speaker--night .ms-video { display: none; }

/* =========================================================
   Timer. Never mirrors. Ring for the stage, inline for the chrome.
   ========================================================= */
.ms-timer { --p: 1; --size: 72px; position: relative; width: var(--size); height: var(--size); direction: ltr; flex: none; }
.ms-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ms-timer circle { fill: none; stroke-width: 6; }
.ms-timer .track { stroke: rgb(243 236 223 / 0.12); }
.ms-timer .arc { stroke: var(--ink); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p) * 100); transition: stroke-dashoffset 1s linear, stroke var(--dur-quick); }
.ms-timer__digits {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: calc(var(--size) * 0.34); line-height: 1; letter-spacing: 0;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.ms-timer__digits:lang(en) { font-size: calc(var(--size) * 0.3); }
.ms-timer--l { --size: 120px; }
.ms-timer--l circle { stroke-width: 5; }
.ms-timer--xl { --size: 180px; }
.ms-timer--xl circle { stroke-width: 4; }
.ms-timer.is-warning .arc { stroke: var(--spotlight); }
.ms-timer.is-warning .ms-timer__digits { color: var(--spotlight); animation: ms-tick 1s var(--ease-standard) infinite; }
.ms-timer.is-paused .arc { stroke: var(--dim); }
.ms-timer.is-paused .ms-timer__digits { color: var(--dim); }
.ms-timer.is-done .arc { stroke: transparent; }
.ms-timer.is-done .ms-timer__digits { color: var(--faint); }
@keyframes ms-tick { 0% { transform: scale(1.1); } 40%, 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .ms-timer.is-warning .ms-timer__digits { animation: none; } }
.ms-timer-inline { display: inline-flex; flex-direction: column; gap: 4px; direction: ltr; min-width: 120px; }
.ms-timer-inline__digits { font-family: var(--font-display); font-size: var(--size-display-s); line-height: 1; font-variant-numeric: tabular-nums; }
.ms-timer-inline .ms-progress { height: 3px; border-radius: 2px; background: rgb(243 236 223 / 0.12); overflow: hidden; }
.ms-timer-inline .ms-progress i { display: block; height: 100%; width: calc(var(--p, 1) * 100%); background: var(--ink); transition: width 1s linear; }
.ms-timer-inline.is-warning .ms-timer-inline__digits { color: var(--spotlight); }
.ms-timer-inline.is-warning .ms-progress i { background: var(--spotlight); }
.ms-timer-inline.is-paused { color: var(--dim); }

/* =========================================================
   Night ledger line: actor, action, target, outcome. The God confirms, edits or takes back.
   ========================================================= */
.ms-ledger { display: flex; flex-direction: column; }
.ms-ledger__line {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2);
  padding-block: 10px; box-shadow: 0 1px 0 var(--edge-colour);
  font-size: var(--size-body-s); line-height: var(--leading-tight);
}
.ms-ledger__line:last-child { box-shadow: none; }
.ms-ledger__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mist); justify-self: center; }
.ms-ledger__text { color: var(--ink); min-width: 0; }
.ms-ledger__text b { font-weight: var(--weight-medium); }
.ms-ledger__text small { display: block; color: var(--faint); font-size: var(--size-caption); }
.ms-ledger__outcome { font-weight: var(--weight-medium); white-space: nowrap; }
.ms-ledger__outcome.is-saved { color: var(--go); }
.ms-ledger__outcome.is-blocked { color: var(--faint); text-decoration: line-through; }
.ms-ledger__outcome.is-mafia { color: var(--mafia); }
.ms-ledger__outcome.is-dead { color: var(--ink); }
.ms-ledger__outcome.is-citizen { color: var(--dim); }
.ms-ledger__line.is-edited .ms-ledger__dot { background: var(--spotlight); }
.ms-ledger__line.is-confirmed .ms-ledger__dot { background: var(--go); }
.ms-ledger__line.is-confirmed .ms-ledger__text, .ms-ledger__line.is-confirmed .ms-ledger__outcome { color: var(--dim); }
.ms-ledger__line.is-undone .ms-ledger__text, .ms-ledger__line.is-undone .ms-ledger__outcome { color: var(--faint); text-decoration: line-through; }
.ms-ledger__line.is-undone .ms-ledger__dot { background: transparent; box-shadow: inset 0 0 0 1px var(--mist); }
.ms-ledger__line.is-pending .ms-ledger__dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--dim); }

/* =========================================================
   Toast
   ========================================================= */
.ms-toast {
  display: inline-flex; align-items: center; gap: var(--space-3);
  min-height: 48px; max-width: 420px; padding-block: 10px; padding-inline: 16px 14px;
  border-radius: var(--radius-m);
  background: var(--smoke); color: var(--ink);
  box-shadow: var(--shadow-chrome), var(--edge-strong);
  font-size: var(--size-body-s); line-height: var(--leading-tight);
  animation: ms-toast-in var(--dur-settle) var(--ease-enter) both;
}
.ms-toast::before { content: ""; width: 3px; align-self: stretch; border-radius: 2px; background: var(--mist); flex: none; margin-inline-start: -6px; }
.ms-toast--go::before { background: var(--go); }
.ms-toast--danger::before { background: var(--danger); }
.ms-toast--spot::before { background: var(--spotlight); }
.ms-toast--mafia::before { background: var(--mafia); }
.ms-toast__text { flex: 1; min-width: 0; }
.ms-toast__text small { display: block; color: var(--dim); font-size: var(--size-caption); }
.ms-toast .ms-btn { margin-inline-start: auto; }
.ms-toast--vote .ms-facepile { flex: none; }
@keyframes ms-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* =========================================================
   Phase word and stage captions
   ========================================================= */
.ms-phase { font-family: var(--font-display); font-size: var(--size-display-m); line-height: var(--leading-disp); letter-spacing: var(--tracking-display); }
.ms-phase small { display: block; font-family: var(--font-body); font-size: var(--size-body-s); color: var(--dim); font-weight: var(--weight-body); margin-block-start: 4px; letter-spacing: 0; }

/* God chip: the host is never a seat */
.ms-god { display: inline-flex; align-items: center; gap: var(--space-2); height: 36px; padding-inline: 4px 12px; border-radius: var(--radius-pill); background: rgb(243 236 223 / 0.06); box-shadow: var(--edge); font-size: var(--size-body-s); font-weight: var(--weight-medium); }
.ms-god .ms-avatar { --size: 28px; }
.ms-god small { color: var(--spotlight); font-weight: var(--weight-strong); font-size: var(--size-micro); }

/* The vote board on the stage: one candidate at a time, five seconds each, the strip of seats */
.ms-strip { display: flex; gap: 4px; direction: ltr; }
.ms-strip i { flex: 1; height: 6px; border-radius: 3px; background: var(--mist); }
.ms-strip i.is-done { background: var(--dim); }
.ms-strip i.is-over { background: var(--ink); }
.ms-strip i.is-now { background: var(--go); }
.ms-bar { display: grid; grid-template-columns: 20px 24px minmax(0,1fr) auto; align-items: center; gap: var(--space-2); font-size: var(--size-body-s); padding-block: 5px; }
.ms-bar__track { position: relative; height: 18px; border-radius: 9px; background: rgb(243 236 223 / 0.06); overflow: hidden; direction: ltr; }
.ms-bar__fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: calc(var(--p) * 100%); background: var(--dim); border-radius: 9px; transition: width var(--dur-settle) var(--ease-standard); }
.ms-bar.is-over .ms-bar__fill { background: var(--ink); }
.ms-bar.is-now .ms-bar__fill { background: var(--go); }
.ms-bar__line { position: absolute; inset-block: -2px; width: 2px; background: var(--spotlight); inset-inline-start: calc(var(--t) * 100%); }
.ms-bar__count { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: end; font-weight: var(--weight-medium); }

/* Chat line (mafia chat, spectator chat) */
.ms-chat { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--size-body-s); line-height: var(--leading-body); }
.ms-chat__line { display: flex; gap: var(--space-2); align-items: baseline; }
.ms-chat__who { font-weight: var(--weight-medium); white-space: nowrap; }
.ms-chat__who.is-boss { color: var(--mafia); }
.ms-chat__who.is-me { color: var(--spotlight); }
.ms-chat__sys { color: var(--dim); font-size: var(--size-caption); }

/* Controls row (mic, camera, hand, reactions) */
.ms-controls { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.ms-controls .ms-btn--icon { border-radius: var(--radius-round); background: rgb(243 236 223 / 0.08); color: var(--ink); }
.ms-controls .ms-btn--icon:hover { background: var(--haze); }
.ms-controls .ms-btn--icon.is-off { background: var(--ink); color: var(--on-ink); }
.ms-controls .ms-btn--icon.is-leave { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgb(255 106 74 / 0.4); }

/* Event feed */
.ms-feed { display: flex; flex-direction: column; gap: 6px; font-size: var(--size-caption); line-height: var(--leading-tight); color: var(--dim); }
.ms-feed li { display: flex; gap: var(--space-2); }
.ms-feed time { color: var(--faint); font-variant-numeric: tabular-nums; flex: none; direction: ltr; }
.ms-feed b { color: var(--ink); font-weight: var(--weight-medium); }
.ms-feed .is-go { color: var(--go); } .ms-feed .is-spot { color: var(--spotlight); }

/* =========================================================
   Additions after the three-way review (1 Nov): plan pieces the first version lacked.
   ========================================================= */
/* Record pill (سابقه): a public counter a player carries after surviving a tie. Ink, bottom start corner, under the name strip's top edge. */
.ms-seat__record {
  position: absolute; inset-block-end: 24px; inset-inline-start: 6px;
  height: 16px; padding-inline: 6px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--on-ink);
  font-size: 9px; font-weight: var(--weight-strong); line-height: 16px; white-space: nowrap;
}
/* Last card (Classic and Bazras): the card a leaving player draws. Spotlight band and name, so it reads as a prop of the stage, not a team. */
.ms-rolecard.is-lastcard { --team: var(--spotlight); --band: var(--spotlight-deep); }
/* Night falls seat by seat: the app adds is-falling to the table for the night transition and sets --i on each seat (seat order). 40 ms stagger, from Grok's review. */
.ms-table.is-falling .ms-seat, .ms-table.is-falling .ms-video { transition-delay: calc(var(--i, 0) * 40ms); }
/* Last ten seconds: the ring thickens as well as turning spotlight (Grok). */
.ms-timer.is-warning .arc { stroke-width: 8; }
.ms-timer--l.is-warning .arc { stroke-width: 7; }
.ms-timer--xl.is-warning .arc { stroke-width: 6; }
/* Chaos handshake: three players left, each names their citizen. Picks reveal together; the God confirms the engine's proposal. */
.ms-handshake { display: flex; gap: var(--space-5); justify-content: center; align-items: flex-start; }
.ms-handshake__seat { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; }
.ms-handshake__seat .ms-avatar { transition: box-shadow var(--dur-settle) var(--ease-standard); }
.ms-handshake__seat.is-picked .ms-avatar { box-shadow: var(--glow-go); }
.ms-handshake__seat.is-me .ms-avatar { box-shadow: var(--edge-strong); opacity: 0.7; }
/* Announce to town: the God's public line. Ink ground so it is unmistakably public; spotlight bar. Never used for private events. */
.ms-toast--town { background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-chrome); }
.ms-toast--town::before { background: var(--spotlight); }
.ms-toast--town .ms-toast__text small { color: rgb(11 10 9 / 0.7); }
.ms-toast--town b { font-weight: var(--weight-strong); }
/* Ready (introduction night): the go button plus a dot per mafia member. */
.ms-ready { display: flex; flex-direction: column; gap: var(--space-2); }
.ms-ready__dots { display: inline-flex; gap: 6px; }
.ms-ready__dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--mist); }
.ms-ready__dots i.is-on { background: var(--go); }
