@font-face {
  font-family: "Mafia Flag Emoji";
  src: url("fonts/noto-flag-emoji.woff?v=157") format("woff");
  font-weight: 400 700;
  font-display: block;
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+FE0F, U+E0020-E007F;
}
@font-face {
  font-family: "Noto Serif";
  src: url("fonts/noto-serif-bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("fonts/open-sans.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("fonts/open-sans-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Open Sans Condensed";
  src: url("fonts/open-sans-condensed-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
:root {
  --ui-transition: 240ms;
  color-scheme: dark;
  --brand-font: "Noto Serif", Georgia, serif;
  --display-font: "Open Sans Condensed", "Arial Narrow", sans-serif;
  font-family: "Open Sans", system-ui, sans-serif;
  color: #fbefd8;
  background: #0b0e14;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.app {
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  display: grid;
  isolation: isolate;
  overflow: clip;
}
.street, .shade { position: absolute; inset: 0; z-index: -1; }
.street { background: #0f1721; }
.street > div {
  position: absolute;
  inset: 0;
  background: center 51% / cover no-repeat;
}
.street .street-day {
  background-image: linear-gradient(#111a285c, #111a2891), url("city-day.webp");
  filter: blur(11px) saturate(.67);
  scale: 1.09;
}
.street .street-night {
  opacity: 1;
  transition: opacity 1.8s ease-in-out;
}
.street-night::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(#09101e32, #09101e57), url("city-night.webp") center 51% / cover no-repeat;
  filter: blur(11px) saturate(.72);
  scale: 1.09;
}
@supports (-webkit-touch-callout: none) {
  /* Fade plain raster artwork on iOS without a live CSS filter. */
  .street .street-day {
    background-image: linear-gradient(#111a285c, #111a2891), url("city-day-soft.webp");
  }
  .street-night::before {
    background-image: linear-gradient(#09101e32, #09101e57), url("city-night-soft.webp");
  }
  .street .street-day, .street-night::before {
    filter: none;
    scale: none;
  }
  /* Keep the fading backdrop below independently composited game controls. */
  .app:has(> .demo:not([hidden], .is-finale)) > :is(.street, .shade) {
    z-index: 0;
  }
  .demo:not(.is-finale) {
    z-index: 1;
  }
  .demo:not(.is-finale) :is(.demo-toolbar, .demo-footer) {
    z-index: 1;
    transform: translateZ(0);
  }
}
.street .street-title {
  background-image: url("city-title.webp");
  opacity: 0;
  transition: opacity .55s ease-in-out;
}
.app[data-phase="day"] .street-night { opacity: 0; }
.app[data-phase="title"] .street-title { opacity: 1; }
.street-title::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(#17203338, #17203338), url("city-day.webp") center 51% / cover no-repeat;
  opacity: 0;
}
.app[data-phase="title"]:has(.home:not([hidden])) .street-title::after {
  animation: home-day-night 25s ease-in-out infinite;
}
@keyframes home-day-night {
  0%, 40%, 100% { opacity: 0; }
  50%, 90% { opacity: 1; }
}
.shade {
  background: linear-gradient(180deg, #0b10132c, transparent 43%, #07090b2b 65%, #05080bc9);
}

.app {
  --ui-button-height: 51px;
  --ui-button-font-size: 1rem;
  --ui-button-gap: 12px;
  --ui-button-icon-size: 20px;
  --ui-button-icon-gap: 10px;
  --ui-corner-button-size: 44px;
  --corner-button-size: var(--ui-corner-button-size);
  --button-icon-gap: var(--ui-button-icon-gap);
  --corner-button-color: #f2ce8e;
  --setup-top: max(18px, env(safe-area-inset-top));
  --setup-left: max(16px, env(safe-area-inset-left));
  --setup-right: max(16px, env(safe-area-inset-right));
}

.home {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  align-items: center;
  min-height: 470px;
  width: min(100%, 760px);
  margin-inline: auto;
  padding: 0 max(24px, env(safe-area-inset-right)) max(34px, calc(6svh + env(safe-area-inset-bottom))) max(24px, env(safe-area-inset-left));
}
.home-version {
  position: absolute;
  inset-block-end: max(9px, env(safe-area-inset-bottom));
  inset-inline-end: var(--setup-right);
  z-index: 1;
  display: flex;
  align-items: center;
  min-height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #cec1aa;
  font-size: .68rem;
  white-space: nowrap;
  font-weight: 400;
  text-shadow: 0 1px 5px #000;
}
.figure {
  position: absolute;
  z-index: -1;
  top: calc(max(5svh, env(safe-area-inset-top)) + 8px);
  left: 50%;
  translate: -50%;
  width: min(94%, 58svh, 510px);
  min-width: 210px;
  mask-image: linear-gradient(#000 76%, transparent 99%);
  animation: emerge .8s ease both;
}
.brand {
  text-align: center;
  margin-top: calc(clamp(165px, 40.3svh, 410px) + 8px);
  animation: fade-in .65s .12s ease both;
}
h2 { font-family: var(--display-font); }
.brand h1 {
  font-family: var(--brand-font);
  width: max-content;
  margin: 0 auto;
  font-size: clamp(2.8rem, min(15vw, 12svh), 6.9rem);
  line-height: .98;
  letter-spacing: .035em;
  color: #ffd58a;
  background: linear-gradient(#ffebba 18%, #f1c46e 56%, #ba813a 97%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 9px #0009);
}
.brand-tagline {
  display: flex;
  align-items: center;
  gap: .6em;
  margin: .65rem auto 0;
  font: 700 clamp(.59rem, 2.6vw, .95rem)/1.4 var(--brand-font);
  letter-spacing: .19em;
  text-transform: uppercase;
  text-shadow: 0 2px 6px #000;
}
.brand-tagline::before, .brand-tagline::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #e8ba69);
}
.brand-tagline::after { rotate: 180deg; }
.brand-description {
  width: fit-content;
  margin: .35rem auto 0;
  padding: .2em .55em;
  border-radius: .35em;
  background: #080b12b8;
  color: #f0dfc4;
  font-size: clamp(.6rem, 2.2vw, .74rem);
  text-transform: uppercase;
  text-shadow: 0 1px 5px #000, 0 1px 5px #000;
}
.actions {
  align-self: end;
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: minmax(34px, 1fr) minmax(0, max-content) minmax(34px, 1fr);
  row-gap: var(--ui-button-gap);
  margin-top: 20px;
  animation: emerge var(--ui-transition) ease both;
}
.actions[inert] { visibility: hidden; }
.actions button {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding-inline: 0;
  text-align: left;
}
.actions button span { overflow-wrap: anywhere; }
.home-action-icon {
  justify-self: end;
  margin-inline-end: var(--button-icon-gap);
  width: var(--ui-button-icon-size);
  height: var(--ui-button-icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.actions .outline .home-action-icon { color: #f2ce8e; }
.actions #history:disabled {
  color: #91949a;
  border-color: #555960;
  cursor: default;
}
.actions #history:disabled .home-action-icon { color: inherit; }
button, select, input {
  font: inherit;
  color: inherit;
  border: 1px solid #d9ab686e;
  border-radius: 12px;
  background: #12151ce8;
}
button {
  min-height: var(--ui-button-height, 51px);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--ui-button-font-size, 1rem);
  padding: .6rem 1rem;
  transition: filter var(--ui-transition), transform var(--ui-transition);
}
@media (max-width: 359px) {
  .app { --ui-button-font-size: 14px; }
}
@media (hover: hover) {
  button:hover { filter: brightness(1.13); }
}
button:enabled:active { filter: brightness(1.2); transform: scale(.98); }
:root:not(.keyboard-navigation) :focus { outline: none; }
.keyboard-navigation :is(button, [tabindex="0"]):focus-visible {
  outline: 2px solid #a9b4c7;
  outline-offset: -3px;
}
input:focus, select:focus { outline: none; }
:where(input:not([type="checkbox"]):not([type="radio"])):focus, select:focus { background-color: #1c2330; }
.keyboard-navigation input:is([type="checkbox"], [type="radio"]):focus-visible { outline: 2px solid #a9b4c7; outline-offset: 2px; }
.gold, button[aria-pressed="true"] {
  color: #201306;
  border-color: #f7d38c;
  background: linear-gradient(#f8d792, #d6a653);
}
.outline { background: #0e1218db; }
.demo {
  --role-height: 252px;
  --demo-gutter: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
  --action-height: 51px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100svh;
  height: 100dvh;
  gap: clamp(5px, 1.5dvh, 16px);
  width: min(100%, 720px);
  min-width: 0;
  margin-inline: auto;
  padding: max(12px, env(safe-area-inset-top)) var(--demo-gutter) max(14px, env(safe-area-inset-bottom));
}
.demo-toolbar {
  margin-inline: max(0px, calc(16px - var(--demo-gutter)));
  display: grid;
  grid-template-columns: var(--corner-button-size) minmax(0, 1fr) var(--corner-button-size);
  align-items: center;
  min-height: 56px;
  gap: 8px;
}
.demo-toolbar button, .setup-header .back {
  width: var(--corner-button-size);
  height: var(--corner-button-size);
  min-height: var(--corner-button-size);
  padding: 0;
  color: var(--corner-button-color);
}
#back { font-size: 1.55rem; line-height: 1; }
#setup-cancel, .remove-player { display: grid; place-items: center; }
#setup-cancel svg, #rules-back svg, .remove-player svg { width: 24px; height: 24px; }
#game-menu { font: 700 1.42rem/1 var(--brand-font); }
.match-heading {
  text-align: center;
  font-family: var(--display-font);
  font-weight: 700;
  line-height: 1.04;
  text-shadow: 0 2px 8px #000;
}
.match-heading p { margin: 0; }
#turn-phase {
  color: #ffe0a7;
  font-size: clamp(1.35rem, 5.6vw, 1.85rem);
  letter-spacing: .045em;
  text-transform: uppercase;
}
#turn-context {
  margin-top: 4px;
  color: #f4e7d0;
  font-size: clamp(.74rem, 3.5vw, .9rem);
  letter-spacing: .055em;
  text-transform: uppercase;
}
.play-viewport {
  min-height: 0; min-width: 0; overflow: auto; scrollbar-width: none;
  /* Use up to 9px of the existing gutter on each side, respecting safe areas. */
  margin-inline: calc(-1 * min(9px, max(0px, var(--demo-gutter) - max(env(safe-area-inset-left), env(safe-area-inset-right)) - 2px)));
}
.play-viewport::-webkit-scrollbar { display: none; }
:is(#match-menu, #log-panel, .players-scroll, .roles-scroll, #player-search-results) {
  scrollbar-width: thin;
  scrollbar-color: #9a794f #121721;
}
.play-area {
  position: relative;
  display: grid;
  min-height: max(100%, var(--ring-height, 0px));
  min-width: 0;
  width: 100%;
  isolation: isolate;
}
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  left: calc(50% + var(--seat-x));
  top: calc(50% + var(--seat-y));
  translate: -50% -50%;
  width: var(--seat-width);
  height: var(--seat-height, 44px);
  min-height: var(--seat-height, 44px);
  padding: 3px var(--seat-side-padding, 7px);
  border-radius: 12px;
  font: 700 var(--seat-font, .85rem)/1.04 var(--display-font);
  background: #111722ed;
  border-color: #c8a5756b;
}
.seat-name {
  font-size: calc(1em - 1px);
  min-width: 0;
  max-width: 100%;
  letter-spacing: var(--seat-letter-spacing, normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat {
  --seat-number-top: calc(-1px - var(--seat-badge-outset));
  --seat-icon-diameter: min(calc(2 * min(var(--seat-icon-size, 16px), 16px)), calc(var(--seat-height) - 11px));
}
.dense-table .seat {
  --seat-number-top: -6px;
  --seat-icon-diameter: min(26px, calc(var(--seat-height) - 9px));
}
.seat-badge {
  position: absolute;
  inset: var(--seat-number-top) auto auto calc(-1px - var(--seat-badge-outset));
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid #ad8a55;
  border-radius: 4px;
  background: #151b26;
  color: #f3d49e;
  font-size: .67rem;
  font-variant-numeric: tabular-nums;
}
 .seat-vote-badge { inset: var(--seat-number-top) calc(-1px - var(--seat-badge-outset)) auto auto; background:#555b65; border-color:#9297a0; color:#fff; }
.seat-vote-badge.vote-leader { background:#a73539; border-color:#ed8585; }
.seat-vote-badge.vote-tie { background:#236846; border-color:#8be5ac; }
.seat-icon {
  position: absolute;
  top: calc(var(--seat-number-top) + 18px);
  left: -1px;
  translate: -50% 0;
  width: var(--seat-icon-diameter);
  height: var(--seat-icon-diameter);
  object-fit: contain;
  filter: drop-shadow(0 1px 2px #000);
  pointer-events: none;
}
.seat:has(.seat-icon) {
  padding-left: calc(var(--seat-icon-diameter) / 2 + 2px);
  padding-right: 5px;
}
.seat:has(.seat-icon) .seat-name { translate: -2px 0; }
.seat:enabled:active { transform: none; }
.seat-doctor { color: #ffaaa6; border-color: #de7876; }
.seat[aria-pressed="true"] { color: #f1fff2; border-color: #8be5ac; background: #1b513a; }
.seat:disabled:not([aria-pressed="true"]) { opacity: .65; }
button:disabled { cursor: default; }
button:disabled:hover { filter: none; }
.turn {
  --turn-icon-size: clamp(68px, 15vw, 84px);
  --turn-title-size: min(clamp(1.3rem, 4.4vw, 2rem), 15.5cqi);
  --turn-status-size: clamp(.75rem, 6.5cqi, .98rem);
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: var(--role-width, 55%);
  height: var(--role-height);
  display: grid;
  grid-template-rows: var(--turn-icon-size) minmax(0, 1fr);
  justify-items: center;
  gap: 7px;
  padding-top: 27px;
  container-type: inline-size;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 8px #000;
}
.turn-copy { grid-row: 2; width: 100%; min-width: 0; }
.turn-copy.has-accent #turn-label, .turn-new-role {
  color: #ffe0a7;
  text-shadow: 0 2px 6px #000, 0 0 11px #edb76e42;
}
.turn-copy:not(.has-heading) :is(#turn-player, #turn-status) { margin-top: 0; }
.turn-copy:not(.has-heading) #turn-player:not([hidden]) + #turn-status { margin-top: 8px; }
/* The clock sits between player and status since 1.197. Preserve the original 5px gap. */
.turn-copy:not(.has-heading) #turn-player:not([hidden]) ~ #turn-status { margin-top: 8px; }
.demo.is-city-announcement .turn {
  display: grid;
  place-items: center;
  width: min(90%, 30rem);
  height: auto;
  grid-template-rows: auto;
  padding: 0;
}
.is-city-announcement .turn-icon-slot { display: none; }
.is-city-announcement .turn-copy { grid-row: 1; }
.is-city-announcement .turn h2 { font-size: clamp(1.75rem, 8cqi, 3rem); }
.is-city-announcement .seats {
  visibility: hidden;
  opacity: 0;
  transition: none;
}
.is-city-announcement .play-area { min-height: 100%; }

.turn h2, #turn-player {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 700;
  font-size: var(--turn-title-size);
  line-height: 1.04;
  overflow-wrap: anywhere;
}
#turn-status, .turn-copy.has-heading #turn-player {
  margin: 8px 0 0;
  color: #f1e3ce;
  font-family: inherit;
  font-weight: 400;
  font-size: var(--turn-status-size);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
#turn-status:empty { margin: 0; }
.turn-copy.has-heading #turn-label {
  overflow-wrap: normal;
}
.demo:not(.is-city-announcement, .is-finale) #turn-label {
  white-space: nowrap;
}
.turn-copy:is(.is-targeting, .is-vote-question) #turn-status {
  overflow-wrap: normal;
}
.turn-copy.is-vote-question #turn-status { font-size: min(var(--turn-status-size), 9.5cqi); }
.turn-copy:is(.is-night-death, .is-standing-announcement, .is-vote-question, .is-debate, .is-discipline-announcement) #turn-status {
  white-space: pre-line;
}
.turn-copy:is(.is-night-death, .is-standing-announcement, .is-vote-question, .is-debate, .is-discipline-announcement) #turn-status {
  display: block;
  text-wrap: balance;
}
#turn-label, #turn-status, #turn-player-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
#turn-player {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
#turn-player-name { min-width: 0; }
.turn-copy:has(#turn-label:empty) #demo-title { display: none; }
/* Keep every timed phase on the same compact two-row baseline.
   Allow glyph descenders to render instead of clipping the one-line heading. */
.turn-copy.is-timed-phase {
  display: grid;
  grid-template-rows: calc(var(--turn-title-size) * 1.04) auto;
  align-content: start;
  justify-items: center;
  row-gap: 8px;
}
.turn-copy.is-timed-phase :is(#demo-title, #turn-player) {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
}
.turn-copy.is-timed-phase #turn-label,
.turn-copy.is-timed-phase #turn-player-name {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  line-height: 1.04;
}
.turn-copy.is-timed-phase #demo-title { line-height: 1.04; }
/* Let descenders extend beyond their text box; the existing text shadow
   follows the glyphs and cannot create a full-width horizontal bar. */
.turn-copy #demo-title,
.turn-copy #turn-label,
.turn-copy #turn-player-name {
  overflow: visible;
  -webkit-line-clamp: unset;
}
.turn-copy.is-timed-phase #turn-clock:not([hidden]) {
  grid-row: 2;
  grid-column: 1;
  margin-top: 0;
}
.turn-copy.is-timed-speaking #turn-player {
  margin-top: 0;
  color: #fbefd8;
  font-family: var(--display-font);
  font-size: var(--turn-title-size);
  font-weight: 700;
  line-height: 1.04;
}
#turn-player-role { flex: none; }
.turn-copy.is-targeting {
  display: grid;
  grid-template-areas: "title" "detail" "verdict";
  align-content: start;
  font-size: var(--turn-title-size);
}
.turn-copy.is-targeting h2 { grid-area: title; }
.turn-copy.is-targeting :is(#turn-status, #turn-player) { grid-area: detail; }
.turn-copy.is-targeting .turn-verdict { grid-area: verdict; }
@media (min-width: 600px) and (min-height: 541px) {
  .demo { --role-height: 270px; }
}
.turn-player-icon { display: block; width: auto; height: 1.1em; object-fit: contain; }
.turn-new-role { display: inline-flex; align-items: center; gap: .25em; vertical-align: middle; }
.turn-verdict img { display: block; width: 34px; height: 34px; margin: 5px auto 0; object-fit: contain; }
.turn-icon-slot {
  grid-row: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: var(--turn-icon-size);
}
.turn-icon {
  display: block;
  width: auto;
  height: var(--turn-icon-size);
  object-fit: contain;
  filter: drop-shadow(0 3px 6px #000a);
}
.turn-icon.neutral-heart {
  mask: url("icons/lover-dark.webp?v=320") center / contain no-repeat luminance;
  filter: none;
}
.seats { transition: opacity .42s ease-out, filter .3s ease; }
.demo.is-finale .seats { filter: blur(6px); opacity: .35; }
.demo.is-finale :is(.play-area, .demo-toolbar, .demo-footer) { position: relative; z-index: 6; }
.demo.is-finale .play-area .turn {
  --turn-icon-size: clamp(92px, 24vmin, 168px);
  position: absolute;
  translate: -50% -50%;
  width: min(90%, 30rem);
  height: auto;
  grid-template-rows: var(--turn-icon-size) auto;
  gap: 14px;
  padding: 0;
  text-shadow: 0 2px 8px #000, 0 0 24px #000;
}
.demo.is-finale:not([hidden]) .turn-icon-slot {
  transform-origin: 50% 60%;
  animation: winner-sway 4.5s ease-in-out infinite;
}
@keyframes winner-sway {
  0%, 55%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(-9deg); }
  23% { transform: rotate(9deg); }
  35% { transform: rotate(-5deg); }
  45% { transform: rotate(3deg); }
}
.demo.is-finale .turn h2 { font-size: clamp(2rem, 10cqi, 3.6rem); }
.demo.is-finale #turn-label { display: block; line-height: 1.2; overflow: visible; }
.demo.is-finale #turn-status { font-size: clamp(.85rem, 5cqi, 1.1rem); }
#victory-celebration {
  position: fixed;
  z-index: 5;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.victory-particle { position: absolute; opacity: 0; }
.victory-rocket {
  width: 4px;
  height: 23px;
  border-radius: 100%;
  box-shadow: 0 0 9px currentColor;
  background: currentColor;
}
.victory-spark {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  background: currentColor;
}
.victory-ribbon {
  width: 7px;
  height: 15px;
  border-radius: 2px;
  background: currentColor;
}
#turn-clock:not([hidden]) {
  display: block;
  margin-top: 8px;
  font-family: var(--display-font);
  font-size: clamp(2.2rem, 25cqi, 3.8rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.log-entry {
  display: grid;
  grid-template-columns: 1.35em minmax(0, 1fr);
  align-items: start;
  column-gap: .35em;
}
.log-entry > span:not(.history-game-icons) { grid-column: 2; overflow-wrap: anywhere; }
.statistics-history button.log-entry {
  width: 100%;
  min-height: 0;
  padding: .35em 0;
  border: none;
  background: transparent;
  font-weight: inherit;
  text-align: start;
  transition: background-color var(--ui-transition);
}
@media (hover: hover) {
  .statistics-history button.log-entry:hover { background-color: #d9ab6815; }
}
.statistics-history button.log-entry:active {
  background-color: #d9ab6830;
  filter: none;
  transform: none;
}
.history-game-entry { grid-template-columns: max-content minmax(0, 1fr); }
.history-game-time { color:#e7be78;font-variant-numeric:tabular-nums;white-space:nowrap; }
.history-game-icons {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .35em;
  white-space: nowrap;
}
.log-game-type {
  width: 1em;
  height: 1em;
  color: #f2ce8e;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.log-player {
  display: inline-flex;
  align-items: baseline;
  max-width: 100%;
  vertical-align: baseline;
}
.log-player > .log-player-icon { flex: none; align-self: center; }
.log-player-name { min-width: 0; overflow-wrap: anywhere; }
.log-player-count, .log-vote-separator { flex: none; white-space: pre; }
.log-player-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline-end: .25em;
  object-fit: contain;
  vertical-align: -.15em;
}
.log-icon {
  grid-column: 1;
  width: 1.25em;
  height: 1.25em;
  object-fit: contain;
  justify-self: center;
}
.turn-copy[data-search-result]:not([data-search-result=""]) #turn-label {
  color: var(--search-result-color, #83e3a1);
}
.turn-copy[data-search-result="clear"] { --search-result-color: #ff7777; }
.turn-copy[data-search-result="boss"] { --search-result-color: #ffda79; }
#settings-title { margin-bottom: 0; }
img.mafia-hat { aspect-ratio: 1; object-fit: fill; }
.demo-footer, .demo-footer button { min-height: var(--action-height); }
.demo-footer button { width: 100%; min-width: 0; overflow-wrap: anywhere; }
.demo-footer button:disabled, .directory-toolbar button:disabled {
  color: #e1c7a1;
  background: #121721e8;
  border-color: #b8976975;
}
@media (max-height: 690px) {
  .demo { --role-height: 218px; --action-height: 44px; gap: 5px; padding-block: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-bottom)); }
  .turn { --turn-icon-size: 64px; padding-top: 16px; }
  .turn { --turn-title-size: min(clamp(1.2rem, 4.4vw, 1.65rem), 15.5cqi); }
}
dialog { color: inherit; width: min(calc(100% - 32px), 360px); border: 1px solid #d9ab688c; border-radius: 18px; background: #111720; padding: 22px; }
dialog::backdrop { background: #030609b8; }
dialog {
  opacity: 0;
  transition: opacity var(--ui-transition) ease;
  transition: opacity var(--ui-transition) ease, display var(--ui-transition) allow-discrete, overlay var(--ui-transition) allow-discrete;
}
dialog[open] {
  opacity: 1;
  animation: fade-in var(--ui-transition) ease;
}
dialog::backdrop {
  opacity: 0;
  transition: opacity var(--ui-transition) ease, display var(--ui-transition) allow-discrete, overlay var(--ui-transition) allow-discrete;
}
dialog[open]::backdrop {
  opacity: 1;
  animation: fade-in var(--ui-transition) ease;
}
.about-message, #notice-message { line-height: 1.45; text-align: center; }
.about-message:has(+ #developer-mode-row[hidden]) { margin-block-end: .65rem; }
.about-message p { margin: 0; }
.aligned-dialog-actions > p.about-message { margin: 0; padding-block: 6px; text-align: start; }
.aligned-dialog-actions > h2:has(+ p.about-message) { margin-block-end: 0; }
.about-message p + p { margin-block-start: .65em; }
.dialog-close { width: 100%; }
dialog h2 {
  position: relative;
  margin: 0 0 .65rem;
  padding-bottom: .65rem;
  text-align: center;
}
dialog h2::after {
  content: "";
  position: absolute;
  inset: auto 8px 0;
  border-bottom: 1px solid #d9ab6859;
}
dialog button.dialog-close { height: var(--ui-button-height, 51px); }
#notice-message { margin-block-end: .65rem; white-space: pre-line; }

form { display: grid; gap: var(--ui-button-gap, 12px); }
h2 { margin: 0 0 .25rem; font-size: 1.7rem; }
label { display: grid; gap: 5px; }
select, input { width: 100%; min-height: 42px; padding: .5rem; }
@keyframes emerge { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (orientation: landscape) {
  .street > div, .street-night::before, .street-title::after { background-position: center 54%; }
}
.animations-off *, .animations-off *::before, .animations-off *::after { animation: none !important; transition: none !important; }
.animations-off dialog::backdrop { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, dialog::backdrop { animation: none !important; transition: none !important; }
}

[hidden] { display: none !important; }
.demo-footer { display: grid; gap: 7px; grid-template: repeat(2, minmax(var(--action-height), auto)) / minmax(0, 1fr); }
.turn-actions {
  grid-row: 1;
  display: grid;
  grid-template-columns: var(--action-height) minmax(0, 1fr) var(--action-height);
  gap: 7px;
}
:is(#discipline-mode, #undo-turn, #directory-archive, #directory-reset-selected) { padding: 0; display: grid; place-items: center; }
.turn-actions button:disabled { opacity: .38; }
#lover-choices {
  grid-area: 1 / 2;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
#lover-choices button { display: flex; align-items: center; justify-content: center; gap: var(--button-icon-gap); padding: 0 4px; }
#lover-choices img { width: auto; height: 21px; object-fit: contain; }
.demo-footer #replay-match { grid-row: 1; }
.demo-footer :is(#confirm-turn, #edit-lineup) { grid-row: 2; }
#correction-dialog { max-height: 85dvh; }
.demo-footer select, dialog select { color: inherit; background: #161d28; }
.seat.seat-out:disabled {
  opacity: .24;
  background: transparent;
}
.seat-out .seat-name { text-decoration: line-through; }
#match-menu { max-height: 85vh; overflow: auto; row-gap: var(--ui-button-gap, 12px); }
#match-menu-title { margin-bottom: 1.3rem; }
.match-menu-action { align-items: center; width: 100%; }
.match-menu-action svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.match-menu-action.outline svg { color: #e3bb7c; }
.match-menu-action:disabled { opacity: .55; }
:is(#game-log) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  max-height: 85dvh;
}
:is(#log-panel) { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.log-period {
  margin: 10px 0 6px;
  padding: 5px 8px;
  border-block: 1px solid #b397654f;
  background: #d9ab6815;
  color: #ffe0a7;
  font: 700 1.05rem/1.25 var(--display-font);
  letter-spacing: .035em;
  text-align: center;
}
.seat-list { min-height: 100%; display: flex; flex-direction: column-reverse; gap: 16px; }
.seat-list .seats { position: static; padding-block-start: var(--seat-badge-outset); padding-inline: 16px 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--seat-width, 76px)), 1fr)); gap: 10px; }
.seat-list .seat { position: relative; inset: auto; translate: none; width: auto; }
.seat-list .turn { position: static; translate: none; width: auto; }
.timer-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-inline-size: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.timer-options label {
  display: grid;
  place-items: center;
  min-height: 44px;
  cursor: pointer;
  border: 1px solid #d9ab688c;
  border-radius: 8px;
}
.timer-options label:has(:checked) { background: #39301f; border-color: #f8d792; color: #f8d792; }

.app[data-phase="setup"] .shade { background: linear-gradient(#0a0d13b0, #0a0d13e8); }

.setup {
  width: min(100%, 760px);
  min-width: 0;
  align-self: start;
  margin-inline: auto;
  padding: var(--setup-top) var(--setup-right) 0 var(--setup-left);
}
.setup-header {
  display: grid;
  grid-template-columns: var(--corner-button-size) minmax(0, 1fr) var(--corner-button-size);
  align-items: center;
  gap: 8px;
  margin-bottom: clamp(4px, 0.85svh, 7px);
}
.setup-header :is(h1, h2) {
  grid-area: 1 / 2;
  min-width: 0;
  font: 700 1.7rem/1.1 var(--display-font);
  color: #ffe3ae;
  background: linear-gradient(#ffebba 18%, #f1c46e 56%, #ba813a 97%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin: 0;
}
#roles-back, #rules-back { display: grid; place-items: center; }
.setup form { gap: 18px; }
:is(#setup-players, #setup-roles-screen) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100svh;
  height: 100dvh;
}
#players-form {
  --player-control-size: var(--corner-button-size);
  --player-column-gap: 8px;
}
:is(#players-form, #roles-form) {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
}
.players-heading { display: grid; gap: 12px; padding-block: 4px 10px; }
.player-directory, .players-scroll {
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  padding-inline-end: 9px;
}
.player-directory { overflow: hidden; }
.players-scroll, .roles-scroll {
  display: grid;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-block-end: 6px;
}
.roles-scroll {
  scrollbar-width: thin;
  padding-inline-end: 6px;
}
.roles-footer, .players-footer { position: relative; bottom: auto; }
#roles-form > .setup-heading { padding-block: 4px 10px; }

.setup-heading { margin: 0; color: #d2c8b9; font-size: .9rem; }
.name-grid, .role-grid { display: grid; gap: 8px; }
.name-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.role-grid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 751px) {
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#setup-names { grid-template-columns: minmax(0, 1fr); }
.player-search-bar, .player-row {
  display: grid;
  grid-template-columns: var(--player-control-size) minmax(0, 1fr);
  column-gap: var(--player-column-gap);
}
.player-row:has(.remove-player:not([hidden])) {
  grid-template-columns: var(--player-control-size) minmax(0, 1fr) var(--player-control-size);
}
#create-player { display: grid; place-items: center; padding: 0; color: #f2ce8e; }
#create-player, .player-grip, .remove-player {
  align-self: center;
  width: var(--player-control-size);
  height: var(--player-control-size);
  min-height: var(--player-control-size);
}
:is(#player-search,#directory-query,#statistics-query) { min-width: 0; padding-inline: 12px; }
#player-search-results {
  display: grid;
  gap: 6px;
  max-height: min(245px, 20dvh);
  overflow: auto;
  margin: 8px 0 0;
  padding: 6px;
  list-style: none;
}
#player-search-results li { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
#player-search-results li:has(.profile-edit) { grid-template-columns: minmax(0, 1fr) var(--corner-button-size); }
.profile-pick {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-content: center;
  column-gap: 8px;
  height: var(--corner-button-size);
  min-height: var(--corner-button-size);
  padding: 0 8px;
  text-align: left;
  line-height: 1.1;
}
.profile-avatar { grid-row: span 2; align-self: center; width: 30px; height: 30px; object-fit: contain; }
.profile-pick:not(:has(.profile-avatar)) { grid-template-columns: minmax(0, 1fr); }
.profile-pick :is(strong, span) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-pick span { color: #ddccab; font-size: .75rem; }
.profile-pick:disabled { opacity: .55; }
.profile-add { padding-inline: 8px; text-align: left; overflow-wrap: anywhere; }

:is(.statistics-history,#log-panel) > .log-period:first-child { margin-top: 0; }
.profile-nickname-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--corner-button-size); gap: 8px; }
.profile-nickname-row > label, .profile-id-field { display: grid; gap: 5px; min-width: 0; }
.profile-id-field .dialog-field-label { text-align: left; }
#profile-display-id { display: grid; place-items: center; box-sizing: border-box; width: var(--corner-button-size); height: var(--corner-button-size); min-height: var(--corner-button-size); border: 1px solid #645742; border-radius: 12px; background: #10141b; color: inherit; opacity: .38; font: inherit; font-variant-numeric: tabular-nums; cursor: default; }
.profile-full-name { display: grid; gap: 5px; }
.profile-full-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
#profile-full-name:read-only { opacity: .38; background: #10141b; color: inherit; border-color: #645742; caret-color: transparent; cursor: default; }
#edit-profile-full-name, .profile-edit {
  display: grid;
  place-items: center;
  width: var(--corner-button-size);
  height: var(--corner-button-size);
  min-height: var(--corner-button-size);
  align-self: center;
  padding: 0;
  color: #f2ce8e;
}
#edit-profile-full-name:disabled { opacity: .38; cursor: default; filter: grayscale(1); }
#profile-full-name:read-only ~ button .lock-open,
#profile-full-name:not(:read-only) ~ button .lock-closed { display: none; }
/* The closed lock sits on the gold pressed-state background. */
#edit-profile-full-name[aria-pressed="true"] { color: #201306; }
#player-profile-error { margin: 0; color: #ffb0a5; }
.profile-gender {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.profile-gender legend { margin-bottom: 6px; padding: 0; }
.profile-gender label {
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 5px 10px;
  min-height: 76px;
  padding: 8px 4px;
  border: 1px solid #a885506b;
  border-radius: 10px;
  background: #141922;
  cursor: pointer;
}
.profile-gender label:has(:checked) { border-color: #efc579; background: #3b3020; }
.profile-gender:disabled label { opacity: .38; cursor: default; }
.profile-gender:disabled label:has(:checked) { opacity: .38; }
.keyboard-navigation .profile-gender label:has(:focus-visible) { outline: 2px solid #a9b4c7; outline-offset: -3px; }
.profile-gender img { width: 36px; height: 36px; }
.profile-gender input { width: 16px; min-height: 0; height: 16px; margin: 0; padding: 0; accent-color: #efc579; }
.profile-gender span { grid-column: 1 / -1; text-align: center; font-size: .85rem; }
.player-row { align-items: center; min-width: 0; }
.player-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-inline: 10px 8px;
  border: 1px solid #a885506b;
  border-radius: 10px;
  background: #141922;
}
.player-row label:focus-within { background-color: #1c2330; }
.seat-number { color: #e0b877; font-size: .78rem; font-variant-numeric: tabular-nums; }
.player-row input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding-inline: 0;
  background: transparent;
  border: 0;
  outline: 0;
}
.player-row input:focus { background-color: transparent; }
.player-row input::placeholder { color: #b0a99c; }
.player-avatar { flex: none; width: 24px; height: 24px; object-fit: contain; }
.remove-player { padding: 0; color: var(--corner-button-color); }
.add-player { color: #f2ce8e; }
.add-player:disabled { opacity: .48; }
.setup-footer {
  position: sticky;
  z-index: 1;
  bottom: 0;
  display: grid;
  gap: 7px;
  padding-block: 10px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(#0b0f16dd, #0b0f16 24%);
  box-shadow: 0 -8px 20px #090b1060;
}
.setup-footer button { width: 100%; }
.setup-footer button span { margin-left: .35em; }
.setup-footer button:disabled { background: #29251e; color: #c2ab83; border-color: #8e7652; }
.setup-footer .directory-toolbar button:disabled { color: #e1c7a1; background: #121721e8; border-color: #b8976975; }
.setup-footer:not(.rules-actions) button { line-height: 1.15; }
.players-footer > button { align-items: center; }
.roles-footer button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--button-icon-gap);
}
.setup-footer button.composition-error:disabled { color: #ffb0a5; }
.setup-footer button[type="submit"] { height: var(--ui-button-height); }
.setup-footer button[type="submit"] span, .setup-footer .add-player span { margin: 0; }
.setup-footer button.composition-error:disabled svg, .roles-footer button:disabled svg { display: none; }

.role-groups { display: grid; gap: 20px; }
.role-group h3 {
  margin: 0 0 7px;
  color: #dfbd80;
  font: 700 1.15rem var(--display-font);
}
.role-card {
  min-width: 0;
  display: grid;
  align-content: center;
  min-height: 61px;
  padding: 4px 10px;
  border: 1px solid #51505a;
  border-radius: 11px;
  background: #151b25ed;
}
.role-card:has(.role-switch:checked) { border-color: #b58f517d; background: #25221ded; }
.role-label {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 49px;
  gap: 9px;
}
.role-label-team { grid-template-columns: 42px minmax(0, 1fr) auto 44px; gap: 6px; }
.role-label-team .role-switch { grid-column: 4; }
.role-label-team .role-hint { overflow-wrap: anywhere; }
label.role-label:has(.role-switch:enabled) { cursor: pointer; }
.role-art { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; width: 42px; height: 42px; }
.role-icon { display: block; width: auto; height: 32px; object-fit: contain; filter: drop-shadow(0 2px 3px #0006); }
.role-art-pair .role-icon { position: absolute; height: 27px; }
.role-art-pair .role-icon:first-child { top: 4px; left: 0; }
.role-art-pair .role-icon:last-child { right: 0; bottom: 3px; }
.role-card:has(.role-switch:not(:checked)) .role-art { opacity: .64; }
.role-name { display: block; color: #fbefd8; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.role-hint { display: block; margin-top: 3px; color: #ccbfac; font-size: .73rem; line-height: 1.25; }
.role-switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #8f9099;
  border-radius: 99px;
  background: #343945;
  cursor: pointer;
}
.role-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #d7d8df;
  transition: translate .16s ease;
}
.role-switch:checked { border-color: #ffd68b; background: #e6b968; }
.role-switch:checked::before { translate: 18px; background: #352309; }
.role-switch:disabled { opacity: .64; cursor: default; }
.role-stepper {
  display: grid;
  grid-template-columns: 32px 18px 32px;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.role-stepper button { min-height: 42px; padding: 0; color: #f4cd8b; font-size: 1.05rem; }
.role-stepper button:disabled { opacity: .46; }
.role-stepper output { font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .name-grid { grid-template-columns: minmax(0, 1fr); }
  .setup form { gap: 12px; }
}

.offline-status, .sync-status {
  position: absolute;
  inset-inline-start: max(16px, env(safe-area-inset-left));
  inset-block-end: max(9px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #cec1aa;
}
.offline-status svg, .sync-status svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}
.offline-status:not([data-offline]),
.sync-status:is([data-state="synced"], [data-state="pending"]) { color: #f5d08a; }
.offline-status:not([data-offline]) .offline-slash { display: none; }

.home-credit {
  position: absolute;
  inset: auto max(82px, calc(66px + env(safe-area-inset-left)), calc(66px + env(safe-area-inset-right))) max(9px, env(safe-area-inset-bottom));
  min-height: 20px;
  display: grid;
  align-content: center;
  text-align: center;
  color: #cec1aa;
  font-size: .68rem;
  letter-spacing: .035em;
  text-shadow: 0 1px 5px #000;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}
.player-grip {
  min-height: 42px;
  padding: 0;
  color: #d9bc8d;
  font-size: 1.25rem;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.player-dragging .player-grip { cursor: grabbing; }
.player-reordering .player-row:not(.player-dragging) {
  transition: transform 150ms ease-out;
}
.player-dragging { position: relative; z-index: 1; }
.player-dragging label { border-color: #f8d792; box-shadow: 0 5px 14px #0008; }
@media (prefers-reduced-motion: reduce) {
  .player-reordering .player-row:not(.player-dragging) { transition: none; }
}
.player-row { scroll-margin-block: 4px; }
.timer-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
}
.timer-options label { position: relative; }
.keyboard-navigation .timer-options label:has(:focus-visible) { outline: 2px solid #a9b4c7; outline-offset: -3px; }

.setting-switch .role-switch { flex: none; }

#turn-clock.clock-final-seconds {
  color: #ffc479;
  animation: clock-final-pulse 1s ease-in-out infinite;
  transform-origin: center;
}
#turn-clock.clock-expired { color: #ff4444; }
@keyframes clock-final-pulse {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.065); }
}
@media (prefers-reduced-motion: reduce) {
  #turn-clock.clock-final-seconds { animation: none; }
}
.audio-options { min-inline-size: 0; border: 0; margin: 0; padding: 0; }
#settings-dialog legend {
  inline-size: 100%;
  margin-block-end: 6px;
  padding: 0;
}
#settings-dialog legend, .dialog-field-label {
  color: #f8d792;
  font-weight: 600;
}
.setting-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}


.setting-switch-label {
  display: flex;
  align-items: center;
  gap: .5em;
  min-width: 0;
}
.setting-switch-label .home-action-icon {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  color: #f2ce8e;
}


:is(.aligned-dialog-actions, #match-menu, #workspace-dialog, :where(.demo-footer:has(:is(#replay-match, #cancel-discipline):not([hidden])))) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto minmax(0, 1fr);
  column-gap: var(--button-icon-gap);
}
.aligned-dialog-actions { row-gap: var(--ui-button-gap); }
/* Keep the layout while the closing dialog is still fading out. */
:is(#match-menu, #workspace-dialog, #game-log, .rules-detail):not([open]) { display: none; pointer-events: none; }
:is(.aligned-dialog-actions, #match-menu, #workspace-dialog, .workspace-action-grid) > * { grid-column: 1 / -1; }
.demo-footer:has(:is(#replay-match, #cancel-discipline):not([hidden])) > button {
  grid-column: 1 / -1;
  padding-inline: 0;
}
:is(:is(.aligned-dialog-actions, #match-menu, .workspace-action-grid) > button, .demo-footer:has(:is(#replay-match, #cancel-discipline):not([hidden])) > button) {
  display: grid;
  grid-template-columns: subgrid;
  justify-content: stretch;
  text-align: start;
}
:is(:is(.aligned-dialog-actions, #match-menu, .workspace-action-grid) > button, .demo-footer:has(:is(#replay-match, #cancel-discipline):not([hidden])) > button) > svg { grid-column: 2; margin-inline-end: 0; }
:is(:is(.aligned-dialog-actions, #match-menu, .workspace-action-grid) > button, .demo-footer:has(:is(#replay-match, #cancel-discipline):not([hidden])) > button) span { grid-column: 3; }

:is(.rules-corner, .account-corner, .interface-corner) {
  position: absolute;
  inset-block-start: var(--setup-top);
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--corner-button-size);
  height: var(--corner-button-size);
  min-height: 0;
  padding: 0;
}
.rules-corner { inset-inline-end: var(--setup-right); }
.account-corner { inset-inline-start: var(--setup-left); }
.interface-corner { inset-inline-end: calc(var(--setup-right) + var(--corner-button-size) + 8px); }
:is(.rules-corner, .account-corner, .interface-corner) .home-action-icon {
  margin: 0;
  justify-self: center;
  color: var(--corner-button-color);
}
.debug-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--button-icon-gap);
}
.debug-action .home-action-icon { flex: none; margin: 0; }
.debug-action.outline .home-action-icon { color: #f2ce8e; }

.about-actions { display: grid; }
#open-changelog { margin-block-end: var(--ui-button-gap); }
.debug-reveal {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows var(--ui-transition) ease, opacity var(--ui-transition) ease;
}
.debug-reveal[inert] {
  grid-template-rows: 0fr;
  opacity: 0;
}
.debug-reveal > div {
  min-height: 0;
  overflow: hidden;
}
#open-debug { width: 100%; margin-block-end: var(--ui-button-gap); }

#workspace-dialog { max-height: 85dvh; overflow: auto; }
/* Preserve the previous spacing between the account rows in the dialog grid. */
#workspace-dialog:has(#workspace-city-row:not([hidden])) > .workspace-identity:first-of-type {
  margin-block-end: 0;
}
#workspace-dialog form, #workspace-logout { margin-block-start: var(--ui-button-gap); }
.workspace-action-grid {
  display: grid;
  grid-template-columns: subgrid;
}
.workspace-action-grid > button { overflow-wrap: anywhere; }
#workspace-login { row-gap: 0; }
#workspace-login label + label { margin-block-start: var(--ui-button-gap); }
#workspace-sign-in { margin-block-start: var(--ui-button-gap); }
#workspace-login > .workspace-feedback { min-block-size: calc(1.7rem - 12px); }
/* Equal breathing room around the login error; keep the existing reveal transition. */
#workspace-login > .workspace-feedback p:not(:empty) { margin-block-end: 12px; }
.workspace-feedback {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows var(--ui-transition) ease, opacity var(--ui-transition) ease;
}
.workspace-feedback:has(p:empty) {
  grid-template-rows: 0fr;
  opacity: 0;
}
.workspace-feedback > div { min-block-size: 0; overflow: hidden; }
.workspace-feedback p { margin: 12px 0 0; color: #ffb0a5; }
.workspace-status:empty { display: none; }

.workspace-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5em;
}
.workspace-identity > span { flex: none; }
.workspace-identity strong, #update-status strong {
  min-width: 0;
  padding: .32em .7em;
  border: 1px solid #b48b51;
  border-radius: 8px;
  background: #090d14;
  color: #ffe0a7;
  overflow-wrap: anywhere;
}

:is(#update-title, #session-replaced-title, #interrupt-title:has(+ #interrupt-message:not([hidden]))) { margin-block-end: 0; }
:is(#update-status, #session-replaced-status) {
  margin-block: 12px;
}
:is(#update-status, #session-replaced-status, #interrupt-message) {
  min-block-size: 2.4rem;
  align-content: center;
  text-align: center;
}
#update-status strong { display: inline-block; }

#discipline-mode { grid-area: 1 / 1; color: var(--corner-button-color); }
#skip-turn { grid-area: 1 / 2; color: var(--corner-button-color); }
#undo-turn { grid-area: 1 / 3; color: var(--corner-button-color); }
#discipline-mode[aria-pressed="true"] { border-color: #f8d792; color: #000; }
.seat-status-icons {
  position: absolute;
  top: -1px;
  right: 11px;
  translate: 0 -50%;
  display: flex;
  gap: 3px;
  pointer-events: none;
}
.seat-status-icons img { width: 18px; height: 18px; object-fit: contain; filter: drop-shadow(0 1px 2px #000); }
.seat:has(.seat-status-icons) { z-index: 1; }

#discipline-dialog .aligned-dialog-actions > button {
  align-items: center;
  padding-inline: 0;
}
#discipline-dialog .aligned-dialog-actions > button > * { grid-row: 1; }
#discipline-dialog button.outline svg { color: #f8d792; }
#discipline-dialog .workspace-identity { justify-content: center; text-align: center; }
#discipline-dialog .workspace-identity > span { flex-shrink: 1; min-width: 0; }
#cancel-discipline { grid-row: 1; }

#workspace-city { font-family: "Open Sans", "Mafia Flag Emoji", system-ui, sans-serif; }

.sync-status { inset-inline-start: calc(max(16px, env(safe-area-inset-left)) + 24px); }
.sync-status[data-state="error"] { color: #ffb0a5; }
.sync-status:not([data-state="synced"]) .sync-ok,
.sync-status:not([data-state="pending"]) .sync-pending,
.sync-status:not([data-state="error"]) .sync-error { display: none; }

.labeled-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--button-icon-gap);
}
.labeled-action .home-action-icon { flex: none; margin-inline-end: 0; }
.labeled-action.outline:not(:disabled):not([aria-pressed="true"]) .home-action-icon { color: var(--corner-button-color); }
.labeled-action:disabled .home-action-icon { color: inherit; }

.rules-screen {
  width: min(100%, 520px);
  height: 100svh;
  height: 100dvh;
  margin-inline: auto;
  padding: var(--setup-top) var(--setup-right) 0 var(--setup-left);
  display: flex;
  flex-direction: column;
}
.rules-screen, .home.returning-from-rules {
  animation: fade-in var(--ui-transition) ease;
}
.rules-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px 3px 10px;
}
#rules-groups section + section { margin-block-start: 12px; }
#rules-groups h2 {
  color: #f2ce8e;
  text-align: center;
  font-size: 1.35rem;
  margin: 0 0 6px;
}
.rules-cards {
  --rules-gap: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--rules-gap);
}
.rules-cards .rules-card {
  flex: 0 0 calc((100% - 2 * var(--rules-gap)) / 3);
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 4px;
  min-width: 0;
  min-height: 66px;
  padding: 4px 3px;
  font-size: .83rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.rules-card-art, .rules-detail-art {
  display: flex;
  justify-content: center;
  align-items: center;
}
.rules-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.rules-card-art .role-art { height: 34px; }
.rules-card-art .role-art-pair { width: 36px; }
.rules-card-art .role-art-pair .role-icon { height: 23px; }
.rules-detail-art .role-art-pair { width: 66px; height: 66px; }
.rules-detail-art .role-art-pair .role-icon { height: 43px; }
.rules-actions { position: relative; flex: none; }
.rules-actions > button { align-items: center; }
.rules-actions > button > * { grid-row: 1; }
.rules-actions > button span { margin: 0; }
.rules-actions > .outline { color: var(--corner-button-color); }
.rules-detail { width: min(calc(100% - 32px), 520px); max-height: 88dvh; overflow: hidden; }
.rules-detail { display: flex; flex-direction: column; }
.rules-detail > :not(.rules-copy) { flex: none; }
.rules-detail-art .rules-icon { width: 66px; height: 66px; }
.rules-copy { min-height: 0; overflow: auto; overscroll-behavior: contain; text-align: left; line-height: 1.5; }
.rules-copy h3 { margin: 1em 0 .3em; color: #f2ce8e; }
.changelog-date { font-size: .75em; font-weight: 400; color: var(--muted, #a8a29a); white-space: nowrap; }
.rules-copy > h3:first-child { margin-block-start: .55em; }
.rules-copy p, .rules-copy ul, .rules-copy ol { margin: .65em 0; }
.rules-copy ul, .rules-copy ol { padding-inline-start: 1.25em; }
.rules-copy li + li { margin-block-start: .35em; }
.rules-detail form { margin-block-start: 1rem; }

:is(#discipline-dialog #discipline-bet, #directory-create):disabled {
  color: #92949e;
  border-color: #4a4d57;
  background: #1a1d25;
  opacity: 1;
}
:is(#discipline-dialog #discipline-bet, #directory-create):disabled svg { color: inherit; }

/* Admin menu uses the same shared icon and label columns as host actions. */
#admin-actions > button { display: grid; grid-template-columns: subgrid; align-items: center; text-align: left; }
/* The active interface toggle is gold; its joystick must be black. */
#admin-interface-switch[aria-pressed="true"] { background: #e9bd70; border-color: #e9bd70; color: #101010; }
#admin-interface-switch[aria-pressed="true"] svg { color: #101010; stroke: #101010; }

/* Beta update dialog: full-width separated actions. */
#update-dialog #update-status-retry { display: flex; width: 100%; align-items: center; justify-content: center; gap: .65rem; margin: 1rem 0; }
#update-dialog #update-status-retry .home-action-icon { width: 1.3em; height: 1.3em; }
#update-dialog > form { margin-top: 1rem; }
#update-dialog > form > button, #sync-dialog > form > button { width: 100%; }

/* Keep the update dialog steady while short status messages change. */

#update-dialog #update-status { min-height: 3.5rem; display: flex; align-items: center; justify-content: center; text-align: center; overflow-wrap: anywhere; }

/* Beta 1.216: align icon/label columns across each button group.
   The widest label centers the complete icon-and-label block. */
.actions {
  grid-template-columns: minmax(0, 1fr) 20px max-content minmax(0, 1fr);
  column-gap: var(--button-icon-gap);
}
.actions > button { grid-column: 1 / -1; grid-template-columns: subgrid; }
.actions > button > svg.home-action-icon { grid-column: 2; justify-self: center; margin-inline-end: 0; }
.actions > button > span { grid-column: 3; }
#admin-actions > button .home-action-icon { grid-column: 2; justify-self: center; margin-inline-end: 0; }
#admin-actions > button > span { grid-column: 3; }
#admin-release-stable.gold { background: #e9bd70; border-color: #e9bd70; color: #101010; }
#admin-release-stable.gold .home-action-icon { color: #101010; }
/* Dialog action groups use the same symmetric outside columns. */
:is(.aligned-dialog-actions, #match-menu, #workspace-dialog, .workspace-action-grid) {
  grid-template-columns: minmax(0, 1fr) 20px max-content minmax(0, 1fr);
}
:is(.aligned-dialog-actions, #match-menu, .workspace-action-grid) > button > svg { justify-self: center; }
:is(.aligned-dialog-actions, #match-menu, .workspace-action-grid) > button > span { margin: 0; }
/* Keep the update actions aligned, except for the About dialog. */
#update-dialog:has(#update-status-retry:not([hidden])) {
  --update-label-width: max-content;
}

/* Beta 1.217: one consistent action layout for all icon/label buttons.
   The width is set from the longest visible label in each dialog by app.js. */
dialog:not(#about-dialog) button.labeled-action:has(> svg.home-action-icon):has(> span),
#about-dialog button.labeled-action:has(> svg.home-action-icon):has(> span),
dialog:not(#about-dialog) .workspace-action-grid > button.labeled-action:has(> svg.home-action-icon):has(> span),
#update-dialog > button.labeled-action:has(> svg.home-action-icon):has(> span) {
  display: grid;
  grid-template-columns: minmax(0,1fr) 1.3em minmax(max-content, var(--dialog-action-label-width, max-content)) minmax(0,1fr);
  column-gap: var(--button-icon-gap);
  align-items: center;
  text-align: left;
  justify-content: stretch;
}
dialog:not(#about-dialog) button.labeled-action > svg.home-action-icon,
#about-dialog button.labeled-action > svg.home-action-icon {
  grid-column: 2;
  justify-self: center;
  margin: 0;
}
dialog:not(#about-dialog) button.labeled-action > span,
#about-dialog button.labeled-action > span {
  grid-column: 3;
  justify-self: start;
  margin: 0;
}
#workspace-dialog .workspace-action-grid,
#workspace-dialog #workspace-base-form,
#workspace-dialog #workspace-rename-base,
#workspace-dialog #workspace-new-base,
#workspace-dialog #workspace-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
#workspace-dialog .workspace-action-grid > * { grid-column: 1 / -1; }
#update-dialog #update-status-retry {
  display: grid;
  width: 100%;
  margin: 1rem 0;
  min-height: 2.8rem;
}
#update-dialog #update-version-row {
  min-height: 2.5rem;
  justify-content: center;
  margin: .35rem 0;
}
#update-dialog #update-version-row[hidden] { visibility: hidden; display: flex; }
#update-dialog #update-version-row:not([hidden]) { display: flex; }
#update-dialog #update-status { margin-block: .5rem; }

/* Beta 1.218: fixed-height single-line status with an inline version chip. */
#update-dialog #update-status {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 3.5rem;
  white-space: normal;
  font-size: inherit;
}
#update-dialog #update-status-text { flex: 0 1 auto; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: center; }
#update-dialog #update-version {
  display: inline-flex;
  flex: none;
  align-items: center;
  white-space: nowrap;
}
#update-dialog #update-status-retry { margin: 0; }
#update-dialog .update-close-actions, #sync-dialog .update-close-actions { margin-top: var(--ui-button-gap); }
#sync-status { cursor:pointer; }
#sync-dialog > h2 { margin-block-end:0; }
#sync-detail { height:3.5rem; margin-block-start:var(--ui-button-gap); display:flex; flex-direction:column; justify-content:center; align-items:center; gap:0; text-align:center; overflow:hidden; }
#sync-message { margin:0; overflow-wrap:anywhere; min-height:0; max-width:100%; overflow:auto; }
#sync-count { margin:0; flex:none; min-height:1.5em; color:var(--corner-button-color); font-variant-numeric:tabular-nums; }
#update-dialog #update-status-retry:disabled {
  color: #92949e;
  border-color: #4a4d57;
  background: #1a1d25;
  opacity: 1;
  cursor: default;
}
#update-dialog #update-status-retry:disabled svg { color: inherit; }

/* Account actions use the existing shared four-track subgrid, not independent button grids.
   One widest label determines the icon and text columns for the whole action group. */
#workspace-dialog > .workspace-action-grid:last-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.3em minmax(max-content, var(--dialog-action-label-width, max-content)) minmax(0, 1fr);
  column-gap: var(--button-icon-gap);
  row-gap: var(--ui-button-gap);
}
#workspace-dialog > .workspace-action-grid:last-child > :is(#workspace-sign-in, #workspace-logout, #workspace-close) {
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  width: 100%;
  margin: 0;
}
 /* The badge takes no visible space except after a successful installation. */
#update-dialog #update-version[hidden] { display: none; }

/* Shared dialog rule: preserve typography and center wrapped status messages. */

/* Stable promotion: one centered message and shared full-width action grid. */
#update-dialog:has(#update-confirmation:not([hidden])) #update-status {
  display: block;
  min-height: 0;
  margin: 0.8rem 0 1rem;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
}
#update-dialog #update-confirmation:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
#update-dialog #update-confirmation[hidden] { display: none; }
#update-dialog #update-confirm-stable,
#update-dialog .update-close-actions > button {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: var(--ui-button-height);
  grid-template-columns: minmax(0, 1fr) 1.3em minmax(max-content, var(--dialog-action-label-width, max-content)) minmax(0, 1fr);
  column-gap: var(--button-icon-gap);
  align-items: center;
  text-align: left;
}
#update-dialog #update-confirm-stable > svg,
#update-dialog .update-close-actions > button > svg { grid-column: 2; justify-self: center; margin: 0; }
#update-dialog #update-confirm-stable > span,
#update-dialog .update-close-actions > button > span { grid-column: 3; justify-self: start; margin: 0; }
#update-dialog #update-confirmation { margin: 0; }
#update-dialog:has(#update-confirmation:not([hidden])) .update-close-actions { margin-top: var(--ui-button-gap); }

/* Stable release: separate the closing confirmation sentence. */
#update-dialog .release-confirm-prompt { display: block; margin-block-start: .65em; text-align: center; }

/* Beta 1.223: one spacing system for Users and Databases administration.
   Keep the same icon/text grid, button sizes and type hierarchy. */
#workspace-dialog #workspace-admin,
#workspace-dialog :is(#workspace-bases-panel, #workspace-users-panel),
#workspace-dialog :is(#workspace-base-form, #workspace-rename-base, #workspace-new-base, #workspace-user) {
  row-gap: var(--ui-button-gap);
}
#workspace-dialog :is(#workspace-base-form, #workspace-rename-base, #workspace-new-base, #workspace-user) {
  margin-block-start: 0;
}
#workspace-dialog:has(#workspace-admin:not([hidden])) > .workspace-action-grid:last-child {
  margin-block-start: var(--ui-button-gap);
}

/* Mafia UI Standard 1.0: full-size action buttons, not compact game controls. */
:is(.actions > button, dialog button.labeled-action, #about-dialog button.dialog-close, #match-menu > button.match-menu-action, .rules-actions > button) {
  height: var(--ui-button-height);
  min-height: var(--ui-button-height);
}

/* A single disabled state for name and gender, matching unavailable turn actions. */
#profile-full-name:read-only, .profile-gender:disabled label { opacity: .38; }

/* Account buttons inherit the common labeled-action grid. */
#workspace-dialog button.labeled-action > span { white-space: nowrap; overflow-wrap: normal; }

/* The grip's stationary long-press menu is independent of its pointer-drag gesture. */
#player-grip-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0;
  width: max-content;
  max-width: calc(100vw - 24px);
  --ui-button-height: 51px;
  --ui-button-icon-size: 20px;
  --button-icon-gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #f3dfb8;
  z-index: 30;
}
#player-grip-menu > button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--button-icon-gap);
  width: auto;
  min-height: var(--ui-button-height);
  padding-inline: 15px;
  font: inherit;
  white-space: nowrap;
}
#player-grip-menu > button > svg.home-action-icon {
  display: block;
  width: var(--ui-button-icon-size);
  height: var(--ui-button-icon-size);
  min-width: var(--ui-button-icon-size);
  min-height: var(--ui-button-icon-size);
  flex: 0 0 var(--ui-button-icon-size);
  margin: 0;
}
#player-grip-menu > button > span { white-space: nowrap; }
#player-grip-menu > button:focus:not(:focus-visible) { outline: none; box-shadow: none; }

/* Existing citizen art, desaturated to indicate an undetermined gender. */
.player-avatar.player-avatar-neutral { filter: grayscale(1) brightness(.85); opacity: .75; }

/* The status-check button is never present in layout while unavailable. */
#update-dialog #update-status-retry[hidden] { display: none !important; }
#update-dialog #update-status-retry.retry-enter {
  animation: retry-appear .28s ease-out both;
}
#update-dialog #update-status-retry.retry-exit {
  animation: retry-disappear .2s ease-in both;
}
@keyframes retry-appear {
  from { opacity: 0; transform: translateY(-7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes retry-disappear {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-7px); }
}
@media (prefers-reduced-motion: reduce) {
  #update-dialog #update-status-retry.retry-enter,
  #update-dialog #update-status-retry.retry-exit { animation: none; }
}


/* Reserve the confirmation row while a Stable release runs; no dialog jumps. */
#update-dialog[data-update-target="stable"] #update-confirmation { min-height: 3.2rem; display: flex; align-items: center; justify-content: center; }
#update-dialog[data-update-target="stable"] #update-confirmation[hidden] { visibility: hidden; }

/* Player directory */

/* Player directory shares the existing setup screen, search, scroll and footer layout. */
.directory-corner { margin-left: auto; width: var(--corner-button-size); height: var(--corner-button-size); min-height: var(--corner-button-size); padding: 0; display: grid; place-items: center; }
.directory-corner.outline:not(:disabled) { color: var(--corner-button-color); }
.directory-corner svg { width: 24px; height: 24px; }
:is(#directory-archive, #directory-reset-selected).outline:not(:disabled) { color: var(--corner-button-color); }
:is(#directory-archive, #directory-reset-selected) > .home-action-icon { width: 24px; height: 24px; margin: 0; justify-self: center; }
:is(#player-directory-dialog, #statistics-screen) { display: grid; grid-template-rows: auto minmax(0,1fr); height: 100dvh; }
:is(#player-directory-dialog, #statistics-screen)[hidden] { display: none; }
:is(#directory-form, .statistics-shell) { --player-control-size: var(--corner-button-size); --player-column-gap: 8px; display: grid; min-height: 0; grid-template-rows: auto minmax(0,1fr) auto; gap: 0; }
#directory-clear { display: grid; place-items: center; width: var(--corner-button-size); height: var(--corner-button-size); min-height: var(--corner-button-size); padding: 0; }
#directory-clear svg { width: 24px; height: 24px; }

/* Directory rows reuse the setup card and profile-picker dimensions. */
:is(#player-directory-dialog, #statistics-screen) .directory-back { display: grid; place-items: center; }
.directory-search { grid-template-columns: minmax(0,1fr); }
.directory-item { display: grid; gap: 8px; }
.directory-inline-actions { display: grid; gap: 8px; padding-inline-start: calc(var(--player-control-size) + var(--player-column-gap)); }
.directory-inline-actions button { width: 100%; }
.directory-list { grid-template-columns: minmax(0,1fr); align-content: start; }
.directory-entry { display: flex; align-items: center; gap: 10px; height: var(--corner-button-size); min-height: var(--corner-button-size); padding: 0 12px; background: #151b25; border: 1px solid #5b4932; border-radius: var(--ui-radius,12px); }
.directory-entry:is([aria-disabled="true"], .archived) { opacity: .55; }
.profile-status-icon { flex: none; color: var(--corner-button-color); margin: 0; width: 20px; height: 20px; opacity: .55; }
.directory-entry.archived > .profile-status-icon { opacity: 1; }
:is(.directory-entry,.player-row label):has(> .profile-status-icon:last-child:not([hidden])) { padding-inline-end: calc((var(--corner-button-size) - 20px) / 2 - 1px); }
.profile-status-icon[hidden] { display: none; }
.directory-entry input[type=checkbox] { accent-color: #dcb16b; width: 21px; height: 21px; flex: none; }
.directory-id { color: #e7be78; font-variant-numeric: tabular-nums; }
.directory-person { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; color: #fff0d9; padding: 0; }
.directory-person { line-height: 1.1; }
.directory-person strong,.directory-person small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-person small { color: #aab0b9; font-size: .78rem; }
.directory-actions { display: grid; gap: 8px; }
.directory-actions button { width: 100%; }
.directory-entry:has(input:checked:not(:disabled)) { border-color: #dcb16b; opacity: 1; }


/* Three shared button sizes: action 51px, square 51px, compact square 44px.
   Screen-specific rules may control layout, never redefine these dimensions. */
:where(.players-footer, .directory-footer) > button,
#directory-popover > button { box-sizing: border-box; height: var(--ui-button-height); min-height: var(--ui-button-height); max-height: var(--ui-button-height); }
:where(.players-footer, .directory-footer) > button { padding-block: 0; }
#setup-players .players-footer > #add-player { align-self: stretch; }

/* Both search inputs use one clear-button design. */
:is(#player-directory-dialog, #statistics-screen) .directory-search { display: block; position: relative; }
#setup-players .player-search-input-wrap { position: relative; min-width: 0; width: 100%; }
#setup-players .player-search-input-wrap #player-search,
:is(#player-directory-dialog #directory-query, #statistics-screen #statistics-query) { display: block; box-sizing: border-box; width: 100%; height: var(--corner-button-size); min-height: var(--corner-button-size); padding-right: 48px; }
#setup-players #player-search::-webkit-search-cancel-button,
:is(#player-directory-dialog #directory-query, #statistics-screen #statistics-query)::-webkit-search-cancel-button { display: none; }
#setup-players .player-search-input-wrap #player-search-clear,
:is(#player-directory-dialog #directory-clear, #statistics-screen #statistics-clear) {
  position: absolute; inset: 50% 4px auto auto; transform: translateY(-50%);
  display: grid; place-items: center; box-sizing: border-box;
  width: 36px; height: 36px; min-height: 0; max-height: 36px;
  margin: 0; padding: 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--corner-button-color); cursor: pointer;
}
#setup-players .player-search-input-wrap #player-search-clear[hidden],
#player-directory-dialog #directory-clear[hidden], #statistics-screen #statistics-clear[hidden] { display: none; }
#setup-players .player-search-input-wrap #player-search-clear svg,
:is(#player-directory-dialog #directory-clear, #statistics-screen #statistics-clear) svg { width: 20px; height: 20px; }
#player-directory-dialog .directory-entry input.directory-check {
  appearance: none; -webkit-appearance: none; box-sizing: border-box;
  display: block; flex: 0 0 22px; inline-size: 22px; block-size: 22px;
  min-inline-size: 22px; max-inline-size: 22px; min-block-size: 22px; max-block-size: 22px;
  padding: 0; margin: 0; border: 1px solid #5b4932; border-radius: 50%;
  background: transparent; position: relative;
}
#player-directory-dialog .directory-entry input.directory-check:checked { background: #e7be78; border-color: #e7be78; }
#player-directory-dialog .directory-entry input.directory-check:checked::after {
  content: ''; position: absolute; left: 7px; top: 3px;
  width: 5px; height: 10px; border: solid #171c25; border-width: 0 2px 2px 0;
  border-radius: 0; background: transparent; transform: rotate(45deg);
}
#directory-popover { position: fixed; inset: auto; margin: 0; padding: 0; width: max-content;
  max-width: calc(100vw - 24px); border: 0; background: transparent; box-shadow: none;
  display: none; flex-direction: column; gap: 8px; z-index: 100; }
#directory-popover:popover-open { display: flex; }
#directory-popover > button { display: flex; align-items: center; justify-content: flex-start;
  gap: var(--button-icon-gap); width: auto; padding-inline: 15px; white-space: nowrap; }
#directory-popover > button .home-action-icon { display: block; width: var(--ui-button-icon-size); height: var(--ui-button-icon-size);
  flex: 0 0 var(--ui-button-icon-size); margin: 0; }

.directory-footer { --action-height: var(--ui-button-height); margin-inline: min(0px, calc(max(12px, env(safe-area-inset-left), env(safe-area-inset-right)) - var(--setup-left))) min(0px, calc(max(12px, env(safe-area-inset-left), env(safe-area-inset-right)) - var(--setup-right))); }
.directory-toolbar > button { height: var(--ui-button-height); min-width: 0; }
.directory-footer .labeled-action > span { margin: 0; }

.turn-copy.is-counting-votes { display:flex; flex-direction:column; align-items:center; gap:8px; }
.is-counting-votes #demo-title { display:flex; align-items:center; justify-content:center; gap:5px; max-width:100%; }
.demo:not(.is-city-announcement, .is-finale) .is-counting-votes #turn-label { white-space:normal; overflow-wrap:anywhere; }
#vote-title-role { flex:none; }
.is-counting-votes #turn-status { margin:0; }
#vote-controls { display:grid; justify-items:center; gap:8px; pointer-events:auto; }
#vote-total { margin:0; font-size:.75rem; }

/* Statistics reuse setup, directory and standard action dimensions. */
#statistics-screen .setup-header h2 { overflow-wrap:anywhere; }
#statistics-screen .players-heading { min-width:0; gap:10px; }
#statistics-screen .players-heading:not(:has(> :not([hidden]))) { padding-block-end:0; }
#statistics-screen #statistics-search { padding-inline-end:0; scrollbar-gutter:auto; }
#statistics-screen .setup-footer[hidden], #statistics-screen [hidden] { display:none; }
.statistics-shell { min-width:0; grid-template-rows:auto minmax(0,1fr) auto; }
.statistics-actions { display:grid; gap:7px; grid-template-columns:repeat(3,minmax(0,1fr)); }
.statistics-actions>button { height:var(--ui-button-height); min-width:0; padding:0; white-space:nowrap; }
#statistics-clear { padding:0; display:grid; place-items:center; }
#statistics-clear>.home-action-icon { margin:0;justify-self:center;align-self:center; }
:is(#statistics-period,#ranking-category,#balance-size,#balance-mode) { width:100%;height:var(--corner-button-size);min-height:var(--corner-button-size);appearance:none;padding-inline-end:48px; }
.statistics-period-arrow { position:absolute;inset:50% 12px auto auto;transform:translateY(-50%);width:20px;height:20px;margin:0;pointer-events:none;color:var(--corner-button-color); }
#statistics-custom { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; }
#statistics-custom label,#statistics-custom input { min-width:0;width:100%; }
.statistics-tiles { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px; }
.statistics-tile { height:74px;min-height:74px;flex-direction:column;justify-content:center;text-align:center;gap:4px;padding:8px 4px; }
.statistics-tile strong,.statistics-points { color:#e7be78;font-variant-numeric:tabular-nums; }
.statistics-tile strong { font-size:1.25rem;white-space:nowrap; }
.statistics-unit { font-size:.7em;font-weight:400; }
.statistics-tile small { color:#d2c8b9;font-size:.78rem;overflow-wrap:anywhere; }
.statistics-heading { color:#e7be78;margin:8px 0 0;font-size:1rem;display:flex;align-items:center;gap:8px; }
.statistics-heading .log-icon { flex:none;margin:0; }
.statistics-line { display:flex;justify-content:space-between;align-items:center;gap:8px;min-width:0; }
.statistics-line-label { display:flex;align-items:center;gap:8px;min-width:0; }
.statistics-line-label :is(img,svg) { flex:none;margin:0; }
.statistics-line strong { color:#e7be78;white-space:nowrap; }
.statistics-track { height:5px;background:#303640;border-radius:4px;overflow:hidden; }
.statistics-track>div { height:100%;background:#bc995e; }
.statistics-player,.statistics-role { width:100%;min-width:0;text-align:left; }
.statistics-player { font-weight:400; }
.statistics-player .directory-person strong { font-weight:600; }
.statistics-player .profile-avatar { flex:none; }
.statistics-role { min-height:var(--ui-button-height);height:auto;padding-block:6px; }
.statistics-player .directory-person,.statistics-role .directory-person { flex:1; }
.statistics-podium { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:end;gap:8px; }
.statistics-podium-place { display:flex;flex-direction:column;justify-content:center;height:110px;min-width:0;gap:4px;padding:6px;overflow:hidden;color:#e7be78; }
.statistics-podium-place[data-place="1"] { height:136px;border-color:#e7be78; }
.statistics-podium-place[data-place="2"] { height:123px;border-color:#aeb8c4; }
.statistics-podium-place[data-place="3"] { border-color:#bf865e; }
.statistics-podium-place strong { max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.statistics-podium-body { flex:0 0 auto;min-height:0;min-width:0;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px; }
.statistics-medal { display:grid;place-items:center;flex:none;width:28px;height:28px;border-radius:50%;font-size:1rem;color:#24170b;background:linear-gradient(135deg,#ffe5a4,#c99439);border:1px solid #f4d595; }
.statistics-podium-place[data-place="2"] .statistics-medal { background:linear-gradient(135deg,#e9edf3,#a1aab7);border-color:#d8dfe8;color:#252a32; }
.statistics-podium-place[data-place="3"] .statistics-medal { background:linear-gradient(135deg,#efb886,#a65e35);border-color:#d59a70;color:#29180e; }

#statistics-person-footer>button { width:100%; }
#statistics-share-dialog[open] { display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:var(--ui-button-gap);max-height:90dvh; }
#statistics-share-preview { display:block;max-width:100%;max-height:48dvh;min-height:0;object-fit:contain;justify-self:center; }

.statistics-cache-note { display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--ui-transition),opacity var(--ui-transition); }
.statistics-cache-note>div { overflow:hidden;min-height:0; }
.statistics-cache-note p { margin:0 0 8px; }
.statistics-cache-note.visible { grid-template-rows:1fr;opacity:1; }
#update-status-retry[aria-busy="true"] svg { animation: update-check-spin 1s linear infinite; }
@keyframes update-check-spin { to { transform:rotate(360deg); } }

#log-panel .log-player-link { display:inline;max-width:100%;overflow-wrap:anywhere;white-space:normal;text-align:start;min-height:0;padding:0;border:0;border-radius:0;background:transparent;color:#e7be78;font:inherit;text-decoration:underline;text-underline-offset:.15em; }
#log-panel .log-player-link:active { transform:none; }

/* Evening markers reuse the original game-type SVG geometry. */
.evening-type-icon { color:var(--corner-button-color);flex:none;width:24px;height:24px;margin:0; }
.log-period > .evening-type-icon { display:inline-block;vertical-align:middle;width:20px;height:20px;margin-inline-end:6px; }

.statistics-role-wrap { min-width:0; }
.statistics-role-wrap > .statistics-role { font:inherit; color:inherit; }
.statistics-role-chevron { flex:none; width:20px; height:20px; margin:0; color:var(--corner-button-color); }
.statistics-role[aria-expanded='true'] .statistics-role-chevron { transform:rotate(180deg); }
.statistics-role-detail:not([hidden]) { display:grid; gap:8px; padding:10px 12px 2px; }
.statistics-role-detail[hidden] { display:none; }

.balance-chart { width:min(100%,260px); aspect-ratio:1; border-radius:50%; background:#252c37; align-self:center; margin:8px auto; display:grid; place-items:center; }
.balance-center { width:66%; aspect-ratio:1; border-radius:50%; background:#151b25; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.balance-center strong { color:#e7be78; font-size:2rem; }
.balance-center small,.balance-note { color:#aab0b9; }
.balance-dot { flex:none; width:10px; height:10px; border-radius:50%; }
.balance-note { font-size:.8rem; line-height:1.4; }

/* All balance filters occupy the fixed heading, outside the reserved scroll gutter. */
#balance-filters { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; min-width:0; }
#balance-filters .statistics-period-wrap { width:100%; min-width:0; box-sizing:border-box; }
.balance-light { background:#397d55; }
.balance-dark { background:#a13c3c; }
.balance-neutral { background:#808894; }
.balance-comparison { display:grid;gap:5px;min-width:0; }
.balance-comparison-track { display:flex;height:12px;border-radius:4px;overflow:hidden;background:#303640; }
.balance-comparison-track>div { height:100%; }
.balance-comparison-values { display:flex;justify-content:space-between;align-items:center;gap:4px;color:#d2c8b9;font-size:.75rem; }
.balance-comparison-values span { display:inline-flex;align-items:center;gap:4px;white-space:nowrap; }
@media (max-width:360px) { .balance-comparison-values { font-size:.65rem;gap:2px; } .balance-comparison-values span { gap:2px; } .balance-comparison-values .balance-dot { width:7px;height:7px; } }
