:root {
  --app-height: 100vh;
  --frame-width: 32rem;
  --edge: clamp(.625rem, 3vw, 1rem);
  --gap: .625rem;
  --ink: #0c1121;
  --panel: linear-gradient(160deg, #171b2d, #101728 80%);
  --line: #746298;
  --muted-line: #424963;
  --lilac: #c5b5f2;
  --gold: #ffbe45;
  --violet: linear-gradient(104deg, #6331e9, #7028f0 55%, #652cf0);
  --type-note: .75rem;
  --type-label: clamp(.8125rem, .76rem + .27vw, .9rem);
  --type-body: clamp(.875rem, .81rem + .32vw, .98rem);
  --type-action: clamp(.95rem, .85rem + .4vw, 1.12rem);
  --motion-quick: 150ms;
  --motion-enter: 210ms;
  --motion-ease: cubic-bezier(.2, .7, .3, 1);
  color-scheme: dark;
}

@supports (height: 100dvh) {
  :root { --app-height: 100dvh; }
}

html, body.app-shell {
  height: var(--app-height);
  overflow: hidden;
  overscroll-behavior: none;
}
.app-shell:not(:has(#view-result:not(.hidden))) #confetti-canvas { visibility: hidden; }

.app-bar {
  flex: none;
  padding: calc(.4rem + env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right)) .4rem max(var(--edge), env(safe-area-inset-left));
  background: rgba(9, 12, 22, .94);
}

.app-bar-inner { max-width: var(--frame-width); }
.app-bar button { min-width: 2.25rem; min-height: 2.25rem; }
.brand-pin { flex: none; width: auto; height: 2.2rem; }
.brand-wordmark { width: 3.4rem; height: auto; }
.brand-player { max-width: 4.25rem; font-size: .575rem; line-height: 1.15; margin-top: .12rem; }
.brand-version { align-self: flex-start; margin-top: .12rem; white-space: nowrap; }
#connection-banner { flex: none; }

.app-main {
  display: flex;
  flex: 1;
  min-height: 0;
  max-width: var(--frame-width);
  padding: var(--gap) max(var(--edge), env(safe-area-inset-right)) max(var(--gap), env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left));
  background: linear-gradient(170deg, #0b1122b3, #0b1122 85%);
}
.app-main .glass-panel, .app-shell > div[id^="modal-"] > .glass-panel {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: none;
}

.app-screen:not(.hidden) {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  gap: var(--gap);
}

.app-screen > :not(.hidden) { flex-shrink: 0; }
.app-shell .hidden { display: none !important; }
.app-shell :is(button, summary, #role-card-wrapper):focus-visible {
  outline: 2px solid #a5a4ff;
  outline-offset: 2px;
}

.screen-title {
  font-family: Kanit, sans-serif;
  font-size: clamp(1.32rem, 1.15rem + .9vw, 1.65rem);
  font-weight: 700;
  line-height: 1.2;
  color: #fcf9ff;
}
.panel-title { font-size: var(--type-action); font-weight: 700; color: #f1ebff; }
.panel-title i { color: var(--lilac); margin-right: .24rem; }

.primary-action, .secondary-action, .judge-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.6rem;
  padding: .35rem .65rem;
  border: 1px solid #9a7cdb;
  border-radius: .65rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
}
.primary-action {
  background: var(--violet);
  font-family: Kanit, sans-serif;
  font-size: var(--type-action);
  color: white;
}
.secondary-action { color: #eee7ff; background: linear-gradient(155deg, #1b2032, #141a2b); font-size: var(--type-body); }
.primary-action:hover:not(:disabled), .secondary-action:hover:not(:disabled), .judge-button:hover { filter: brightness(1.14); }
.primary-action:disabled { opacity: .52; cursor: not-allowed; }

.home-screen:not(.hidden) { justify-content: flex-start; }
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  height: clamp(9.5rem, calc(var(--app-height) * .32), 17rem);
  border-radius: .8rem;
  overflow: hidden;
  background: linear-gradient(0deg, #0b1122 0%, #0b10241c 50%, #10102f20),
              url('/assets/night-city.jpg') center 57% / cover no-repeat #11152b;
  box-shadow: inset 0 0 2rem #090b1ab3;
}

.hero-pin {
  width: auto;
  height: clamp(3.25rem, calc(var(--app-height) * .115), 6.25rem);
  filter: drop-shadow(0 0 .7rem #0b0924) drop-shadow(0 0 1.05rem #8570ffa0);
}

.hero-wordmark {
  width: clamp(5.1rem, calc(var(--app-height) * .17), 8.8rem);
  height: auto;
  filter: drop-shadow(0 2px 4px #080813);
}

.hero-slogan {
  color: #ffecce;
  padding: .16rem .65rem;
  border-radius: .55rem;
  font-size: var(--type-action);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 2px 3px #080813;
}

.app-screen > .home-form {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  padding: clamp(.75rem, 3vw, 1rem);
}

.home-form > * + * { margin-top: .55rem; }
.home-form { border-radius: 1rem; }
.home-divider { border-color: var(--muted-line); margin-block: .65rem; }
.home-join { display: flex; flex-direction: column; gap: .5rem; }
.home-form label, .home-form summary, #inline-error-box { font-size: var(--type-label); }
.field-note { color: #aeb5ca; font-size: var(--type-note); text-align: right; }
.home-form input { font-size: 1rem; padding-block: .46rem; }
.home-form #input-room-code { font-size: 1.15rem; }
.home-form button { padding-block: .58rem; min-height: 2.5rem; }
.home-form details summary { min-height: 1.5rem; padding: .16rem 0; }
.home-form > div:last-child { padding-top: .5rem; }
.home-recovery-heading, .home-recovery summary > span:last-child { display: none; }
.home-recovery[open] summary > span:first-child { display: none; }
.home-recovery[open] summary > span:last-child { display: inline; }
.home-screen:has(.home-recovery[open]) .home-recovery-heading { display: block; }
.home-screen:has(.home-recovery[open]) :is(.home-hero, .home-name, #btn-create-room, .home-divider) { display: none; }
.home-screen:has(.home-recovery[open]) .home-form {
  background: none;
  border-color: transparent;
  padding: .7rem .05rem;
}
.home-recovery[open], .home-join:has(.home-recovery[open]) > :first-child {
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--panel);
}
.home-join:has(.home-recovery[open]) #btn-join-room { order: 1; background: var(--violet); color: white; }
.home-join:has(.home-recovery[open]) #btn-join-room i { color: white; }
.secret-field { position: relative; }
.secret-field input { padding-right: 2.45rem; }
.secret-field button {
  position: absolute;
  inset: auto .2rem .1rem auto;
  display: grid;
  place-items: center;
  padding: 0;
  min-height: 0;
  width: 2rem;
  height: 2rem;
  color: var(--lilac);
}

.room-share {
  display: grid;
  grid-template-columns: minmax(0, 1.07fr) minmax(0, 1fr);
  align-items: center;
  gap: .7rem;
  padding: .7rem .75rem;
  border-radius: .75rem;
}
.room-share h3, .room-roster-heading { color: #f8f3ff; font-family: Kanit, sans-serif; font-size: 1.1rem; font-weight: 700; }
.room-share-actions { display: grid; gap: .4rem; border-left: 1px solid var(--line); padding-left: .65rem; }
.room-share-actions button { min-height: 2.1rem; padding-inline: .3rem; }
#lobby-room-code, .qr-room-code {
  color: var(--gold);
  font-family: Kanit, sans-serif;
  font-size: clamp(2rem, 5.8vh, 3rem);
  font-weight: 800;
  letter-spacing: .065em;
  line-height: 1.05;
}

.app-screen > .room-roster {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: .65rem .75rem;
  border-radius: .75rem;
  gap: .46rem;
}

.room-roster > * { flex-shrink: 0; }
.room-roster-heading { display: flex; justify-content: space-between; }
.room-roster-note, #guest-rules-text { font-size: var(--type-label); }
#lobby-player-list { flex: 1 1 auto; min-height: 0; max-height: min(19rem, calc(var(--app-height) * .37)); overscroll-behavior: contain; }
#guest-settings-summary { flex-shrink: 1; overflow: auto; max-height: 8.5rem; padding: .52rem .75rem; border-radius: 1rem; }
#guest-rules-text { margin-top: .4rem; border-top: 1px solid var(--muted-line); padding-top: .4rem; }
#lobby-guest-waiting { background: #302a55; font-family: Kanit, sans-serif; font-size: 1.12rem; }

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 2.65rem;
  padding: .32rem .55rem;
  border: 1px solid var(--muted-line);
  border-radius: .65rem;
  background: #0e1423;
  color: #f4eeff;
  font-size: var(--type-body);
  font-weight: 600;
}
.player-avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: #433368;
  color: #decbff;
  font-size: .74rem;
}
.player-row .truncate { overflow-wrap: anywhere; white-space: normal; }
.room-manage { min-height: 1.7rem; padding: .2rem .35rem; font-size: var(--type-note); }

#btn-open-settings:not(.hidden), #guest-settings-summary summary {
  display: grid;
  grid-template-columns: 1.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
  color: #f0eefc;
  font-size: 1rem;
  cursor: pointer;
}

#btn-open-settings:not(.hidden) { padding: .52rem .75rem; }
.room-settings-button small, #guest-settings-summary small { display: block; color: #aeb5d2; font-size: var(--type-label); margin-top: .1rem; }
#guest-settings-summary[open] summary > i:last-child { transform: rotate(180deg); }

.screen-actions {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.screen-actions button { min-height: 2.4rem; padding-block: .5rem; }
.screen-actions:has(> :not(.hidden)) { margin-top: auto; }
#view-lobby .screen-actions { margin-top: .2rem; }
.game-actions:not(:has(> :not(.hidden))) { display: none; }

.settings-sheet {
  --sheet-edge: max(.625rem, env(safe-area-inset-bottom));
  position: fixed;
  inset: auto 0 calc(max(0px, 100% - var(--app-height)) + var(--sheet-edge));
  margin: 0 auto;
  padding: 0;
  width: min(calc(100% - 1.25rem), var(--frame-width));
  max-width: none;
  max-height: calc(var(--app-height) - var(--sheet-edge) - max(1rem, env(safe-area-inset-top)));
  overflow: visible;
  border: 0;
  border-radius: 1.5rem;
  background: #101526;
  color: #e2e8f0;
}
.settings-sheet::backdrop { background: #050711a6; clip-path: inset(calc(3.35rem + env(safe-area-inset-top)) 0 0); }
#host-settings-panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: #101526;
  border-color: var(--line);
  overflow: hidden;
}
.settings-heading { flex: none; padding: .42rem .8rem; border-bottom: 1px solid #2b2c49; }
.dialog-close { width: 2.25rem; height: 2.25rem; font-size: 1rem; color: #e2e8f0; }
.settings-content, .settings-options, .settings-categories {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: .55rem;
}
.settings-content { padding: .65rem .75rem; }
.settings-options > :not(.settings-categories), .settings-custom { flex: none; }
.settings-categories, .settings-custom { padding-top: .5rem; }
#custom-locations-tags { overflow-x: auto; }
#custom-locations-tags:empty { display: none; }
#custom-locations-tags > span { flex: none; }
.settings-content input, .game-content input { min-width: 0; font-size: 1rem; }
.settings-content :is(label, select, [data-cat-id], #setting-board-size-wrap > span, .settings-categories > div:first-child > span, #btn-add-custom-loc) {
  font-size: var(--type-label);
}
.settings-content select { border-color: var(--line); }
#btn-cat-all, #btn-cat-clear { font-size: var(--type-note); }
.settings-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .48rem .65rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  color: #ebe4ff;
  font-size: .82rem;
}
.settings-switch i { color: var(--lilac); margin-right: .25rem; }
.settings-switch input {
  appearance: none;
  width: 2.05rem;
  height: 1.18rem;
  flex: none;
  padding: .15rem;
  border-radius: 1rem;
  background: #545d79;
  cursor: pointer;
}
.settings-switch input::after { content: ''; display: block; height: 100%; aspect-ratio: 1; border-radius: 50%; background: #f9f4ff; }
.settings-switch input:checked { background: #7138e9; }
.settings-switch input:checked::after { margin-left: auto; }
.settings-switch input:disabled { opacity: .55; cursor: default; }
#host-categories-grid { min-height: 0; max-height: 13.75rem; overscroll-behavior: contain; }
/* When the keyboard leaves very little height, scroll the options as one list. */
.compact-settings .settings-options { display: block; overflow-y: auto; }
.compact-settings .settings-options > * + * { margin-top: .55rem; }
.compact-settings #host-categories-grid { max-height: none; overflow: visible; }
.settings-toast { position: absolute; z-index: 1; inset: auto .6rem .55rem; pointer-events: none; }

.phase-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .48rem .72rem;
  border-radius: .68rem;
  color: #f2eaff;
  font-weight: 600;
  font-size: .87rem;
}
.phase-line i { color: var(--lilac); margin-right: .25rem; }
#game-timer { color: var(--gold); font-weight: 800; font-size: clamp(1.25rem, 3.9vh, 1.85rem); line-height: 1.05; font-variant-numeric: tabular-nums; }
#game-timer.timer-warning { color: #fda4af; }
.game-spy-count { font-size: var(--type-note); color: var(--lilac); white-space: nowrap; }
#hud-voting-banner h2 { font-size: 1rem; font-weight: 700; }
#voting-progress { padding: .55rem .68rem; border-radius: .7rem; font-size: var(--type-label); color: #d0c6e8; }
#voting-progress label { font-size: .9rem; font-weight: 700; color: #f4ecff; }
.vote-progress-track {
  height: .62rem;
  margin-top: .3rem;
  background: #363d55;
  border-radius: 1rem;
  overflow: hidden;
}
#vote-progress-fill {
  height: 100%;
  background: var(--violet);
  border-radius: inherit;
  transform: scaleX(var(--vote-fill, 0));
  transform-origin: left;
  transition: transform 240ms var(--motion-ease);
}
.danger-heading {
  padding: .62rem .75rem;
  border: 1px solid #d75589;
  border-radius: .9rem;
  background: radial-gradient(ellipse at top, #9b2450 0%, #601638 62%, #401129);
  text-align: center;
  color: #ffdeea;
}
.danger-heading h2 { font-family: Kanit, sans-serif; font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.danger-heading i { margin-right: .27rem; }
.danger-heading p { color: #ffdfa5; margin-top: .24rem; font-size: var(--type-label); font-weight: 600; }
#view-game.board-expanded > :is(#hud-playing-bar, #hud-voting-banner, #voting-progress, #hud-spyguess-banner, #game-navigation) { display: none; }
#view-game.board-expanded #first-speaker-bar { display: none; }

.game-navigation {
  display: flex;
  gap: .4rem;
}
.game-navigation button {
  flex: 1;
  min-width: 0;
  min-height: 2.55rem;
  padding: .28rem .16rem;
  border: 1px solid var(--line);
  border-radius: .68rem;
  background: var(--panel);
  color: #efe8fb;
  font-size: var(--type-body);
  font-weight: 700;
  white-space: nowrap;
}
.game-navigation button[aria-pressed="true"] { color: #f9f3ff; background: var(--violet); border-color: #aa83f4; }
.game-navigation button i { color: #a5a4ff; margin-right: .08rem; }
#view-game:is([data-phase="VOTING"], [data-phase="SPY_GUESS"]) .game-navigation { order: 1; }
#view-game:is([data-phase="VOTING"], [data-phase="SPY_GUESS"]) .game-navigation button { min-height: 1.9rem; font-size: var(--type-label); }
#view-game .game-actions { order: 2; }
#first-speaker-name { max-width: 65%; }

.app-screen > .game-content { flex: 1 1 auto; }
.game-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.game-content > :not(.hidden) { flex-shrink: 0; }
#view-game:has(#role-card-wrapper:not(.hidden)) .game-content { flex: 0 1 auto; }
.app-shell:not(.short-viewport) #view-game:has(#role-card-wrapper:not(.hidden)) .game-content { overflow: visible; }
#view-game:has(#role-card-wrapper:not(.hidden)) .game-actions { margin-top: 0; }
#role-card-wrapper {
  --role-cover-max: 26rem;
  flex: 0 1 auto;
  height: clamp(14.5rem, calc(var(--app-height) * .56), var(--role-cover-max));
  min-height: 14.5rem;
  touch-action: manipulation;
}
#role-card-front, #role-card-back { border-radius: .9rem; backdrop-filter: none; }
#role-card-front {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(.68rem, 2.2vh, 1.2rem);
  overflow: hidden;
  padding: .9rem;
  border: 1px solid #8878b2;
  background:
    radial-gradient(ellipse at 50% 41%, #56429257, #211c3980 55%, #13172c 92%),
    repeating-conic-gradient(from 3deg at 50% 39%, #a391ea19 0deg .45deg, transparent .45deg 10deg),
    #191b35;
}
#role-card-front > :not(.role-cover-ornaments) { position: relative; }
.role-cover-ornaments { position: absolute; inset: 0; pointer-events: none; }
.role-cover-ornaments::before {
  content: "";
  position: absolute;
  inset: .56rem;
  border: 1px solid #b7a2e325;
  border-radius: .62rem;
}
.role-cover-print {
  position: absolute;
  color: #bdadff;
  font-size: clamp(7rem, 30vw, 11.5rem);
  opacity: .09;
}
.role-cover-print-top { top: -.92rem; left: -1.9rem; transform: rotate(-28deg); }
.role-cover-print-bottom { bottom: -1.5rem; right: -1.9rem; transform: rotate(30deg); }
.role-cover-seal {
  display: grid;
  place-items: center;
  width: clamp(5.15rem, 14vh, 7.1rem);
  aspect-ratio: 1;
  border: 2px solid #f6c36b;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 23%, #594489, #2a2158 65%, #1a193e);
  box-shadow: inset 0 0 0 .24rem #bba2ef22, 0 0 1.6rem #7556ba58;
  color: #dfcbff;
  font-size: clamp(2.6rem, 7.4vh, 3.8rem);
}
#role-card-front h3 {
  color: #f7efff;
  font-family: Kanit, sans-serif;
  font-size: clamp(1.42rem, 4vw, 1.95rem);
  font-weight: 700;
  line-height: 1.2;
}
#btn-show-role {
  min-width: min(10rem, 100%);
  padding-inline: 1.05rem;
  border-color: #ebbd77;
  background: linear-gradient(165deg, #493482, #2b2255);
  color: #fff5ff;
  font-family: Kanit, sans-serif;
  font-size: var(--type-action);
}
@media (max-width: 600px) {
  #role-card-wrapper { --role-cover-max: 23rem; }
}
#role-card-back { padding: 0 0 .78rem; border: 1px solid var(--line); gap: .64rem; }
#role-card-back.glass-panel-spy { border-color: #b04d77; }
.role-meta { position: absolute; top: .45rem; inset-inline: .5rem; width: auto; z-index: 1; }
#role-card-visual { flex: 1; min-height: 2.4rem; max-height: calc(var(--app-height) * .31); height: auto; margin: 0; border: 0; border-radius: 0; }
.role-details { padding-inline: .85rem; }
.role-location { display: flex; align-items: center; justify-content: center; gap: .3rem; color: var(--gold); }
#game-location-display { min-width: 0; color: inherit; font-size: var(--type-action); line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
.role-name { margin-top: .32rem; padding-top: .25rem; border-top: 1px solid var(--line); }
#game-role-display { line-height: 1.35; font-size: var(--type-body); color: #f6edff; }
#role-badge, #role-category-pill { font-size: var(--type-note); }
#btn-hide-role { align-self: center; flex: none; min-height: 1.9rem; padding: .25rem .7rem; }
#spy-ambush-btn-wrap { padding: 0 .65rem; }
#btn-spy-ambush { border: 1px solid #d75589; background: #8e2853; }

.game-panel:not(.hidden), #location-panes:not(.hidden),
#spy-input-box:not(.hidden), #spy-classic-picker:not(.hidden) {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: .6rem;
}
.game-panel > :not(.scroll-list, .hidden),
#spy-input-box > :not(.scroll-list, #spy-classic-picker, .hidden),
#spy-classic-picker > :not(.scroll-list, .hidden) { flex-shrink: 0; }
.game-panel { padding: .7rem; border-radius: .9rem; }
.game-panel .scroll-list {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  align-content: start;
  overscroll-behavior: contain;
}
#board-locations-grid, #spy-guess-grid, #game-suspects-list { grid-auto-rows: max-content; }
#board-classic-panel,
.app-main :is(#voting-arena-panel, #playing-suspects-panel) { border-color: var(--muted-line); }
#board-classic-panel #board-locations-grid { flex: 1 1 auto; }
#board-locations-grid button, #spy-guess-grid button { min-width: 0; }
#board-hint-panel, #board-blind-panel { flex: none; }
#input-search-location { padding-block: .42rem; }
.location-card {
  display: block;
  overflow: hidden;
  border: 1px solid #605783;
  border-radius: .76rem;
  background: #101728;
  text-align: left;
}
.location-card:hover { border-color: #b89ded; }
.location-card-scene { height: clamp(3.1rem, calc(var(--app-height) * .107), 5.5rem); pointer-events: none; }
.illustration-shade { background: linear-gradient(0deg, #080e2863, transparent 58%); }
.scene-photo { opacity: 0; }
.scene-photo-ready { opacity: 1; }
.scene-photo-ready ~ .scene-symbol { display: none; }
.location-card-name { padding: .33rem .48rem; color: #f4effc; font-size: .76rem; font-weight: 700; line-height: 1.3; }
.location-card-name span { overflow: visible; text-overflow: clip; white-space: normal; }
.location-flippable {
  min-width: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.location-card-turn {
  display: grid;
  grid-template-areas: "face";
  transform: perspective(700px) rotateY(0deg);
  transform-style: preserve-3d;
  transition: transform .3s cubic-bezier(.24, .7, .32, 1);
}
.location-flippable.is-flipped .location-card-turn { transform: perspective(700px) rotateY(180deg); }
.location-card-face {
  grid-area: face;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #605783;
  border-radius: .76rem;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.location-card-front {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  background: #101728;
  text-align: left;
}
.location-card-front:hover { border-color: #b89ded; }
.location-card-front .location-card-scene { width: 100%; flex: none; }
.location-card-front .location-card-name { display: flex; width: 100%; align-items: center; gap: .22rem; font-size: var(--type-label); }
.location-card-front .location-card-name span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.location-turn-mark, .location-cut-mark { flex: none; color: var(--lilac); font-size: .68rem; }
.location-cut-mark { display: none; }
.is-struck .location-cut-mark, .location-list-option[aria-pressed="true"] .location-cut-mark { display: inline-block; }
.is-struck .location-card-front .location-card-scene { opacity: .4; }
.is-struck .location-card-front .location-card-name span { text-decoration: line-through; }
.location-card-back {
  display: flex;
  flex-direction: column;
  padding: .28rem;
  border-color: #9580d8;
  background: linear-gradient(#201735a3, #0e1424 92%), var(--location-back-art, none) center 68% / cover, #201735;
  transform: rotateY(180deg);
}
.location-card-return {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: .15rem;
  flex: 1;
  width: 100%;
  min-block-size: 1.8rem;
  padding: .2rem;
  border: 0;
  background: transparent;
  color: #fff4db;
  font-size: var(--type-body);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.location-card-return i { color: #e0cef9; }
.location-card-action {
  flex: none;
  width: 100%;
  min-block-size: 1.75rem;
  padding: .16rem .25rem;
  border: 1px solid #9b80d5;
  border-radius: .43rem;
  background: #352257;
  color: #fff3ff;
  font-size: var(--type-label);
  font-weight: 700;
}
.location-card-action:hover { background: #4b3180; }
.location-card-action[data-guess-loc] { background: #6b274a; border-color: #de7da3; }
.location-card-action[data-guess-loc]:hover { background: #85325d; }
.location-card-front:focus-visible, .location-card-back :focus-visible { outline-offset: -2px; }
.location-list-option { font-size: var(--type-label); transition: opacity var(--motion-quick) ease; }
.vote-row-content { display: flex; flex: 1; min-width: 0; justify-content: space-between; align-items: center; gap: .4rem; }
.vote-player-info { display: flex; align-items: center; flex: 1; min-width: 0; gap: .4rem; }
.vote-player-info > div { min-width: 0; }
.vote-player-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.vote-note, .vote-count { font-size: var(--type-note); }
.vote-note { display: inline-block; line-height: 1.25; }
.vote-count { white-space: nowrap; }
.vote-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .28rem; max-width: 44%; }
.voting-self { opacity: .82; }
.player-row[aria-pressed="true"] { background: #282640; border-color: #ba9cf3; }
.vote-radio, .suspect-check {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.12rem;
  height: 1.12rem;
  color: #150e27;
  border: 1px solid #b39ee4;
  border-radius: .27rem;
  font-size: .68rem;
}
.vote-radio { border-radius: 50%; }
.player-row[aria-pressed="true"] .suspect-check { background: #b095ff; }

.app-main #spyguess-arena-panel { background: transparent; border: 0; padding: 0; }
#spyguess-arena-panel:not(:has(#spy-input-box:not(.hidden), #host-judge-panel:not(.hidden))) { display: none; }
#spy-personal-status-badge { padding: .3rem .55rem; color: #f7c6d8; font-size: var(--type-label); text-align: center; }
#spy-guess-grid { padding: .48rem; border: 1px solid var(--muted-line); border-radius: .88rem; background: var(--ink); }
#spy-freetext-picker { padding: .75rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--panel); }
#spy-freetext-picker input { border-color: var(--line); background: #262a41; }
.app-main .guess-status { padding: .42rem .65rem; border-radius: .68rem; border-color: var(--muted-line); font-size: var(--type-label); color: #f3eafc; }
.guess-status i { color: #e9a9bf; margin-right: .2rem; }
#guess-progress-count { color: var(--lilac); white-space: nowrap; }
#spy-guess-progress-list { max-height: 4rem; overflow: auto; }
#spy-guess-progress-list > div { gap: .65rem; overflow-wrap: anywhere; }
#spy-guess-progress-list > div { padding: .25rem .32rem; background: none; border: 0; }
#host-judge-panel:not(.hidden) { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.judge-card { padding: .65rem .75rem; border-radius: .85rem; }
.judge-card h3 { display: flex; align-items: center; gap: .4rem; color: #f6f0ff; font-weight: 700; }
.judge-card p { margin-top: .55rem; padding-top: .48rem; border-top: 1px solid var(--line); color: #f1e8ff; font-size: .86rem; overflow-wrap: anywhere; }
.judge-card strong { color: var(--gold); margin-inline-start: .35rem; }
.judge-note { margin-block: .6rem; color: var(--lilac); text-align: center; font-size: .8rem; }
.judge-button { color: #fff; background: linear-gradient(130deg,#175841,#103c35); border-color: #58c790; }
.judge-button[data-judge-pass="false"] { background: linear-gradient(130deg,#973058,#641432); border-color: #e36a99; }

.app-screen > .result-content {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: var(--gap);
  overflow: auto;
  overscroll-behavior: contain;
}
.result-content > * { flex-shrink: 0; }
.result-heading { display: flex; align-items: center; justify-content: space-between; }
#result-round-badge { font-size: var(--type-label); color: var(--lilac); }
.result-reveal, .result-scores { padding: .66rem .75rem; border-radius: .8rem; }
.result-reveal { text-align: center; }
#result-winner { color: var(--gold); font-family: Kanit, sans-serif; font-size: 1.48rem; font-weight: 700; line-height: 1.2; }
#result-winner[data-winner="CITIZENS"] { color: #4cf3a0; }
#result-winner[data-winner="SPIES"] { color: #ff96b7; }
#result-actual-location { padding: .22rem 0 .4rem; font-size: 1.03rem; font-weight: 700; color: #faf3ff; overflow-wrap: anywhere; }
.result-spies { display: flex; align-items: flex-start; justify-content: center; gap: .8rem; padding-top: .48rem; border-top: 1px solid var(--line); font-size: .84rem; }
.result-spies span { color: var(--lilac); padding-right: .78rem; border-right: 1px solid var(--line); white-space: nowrap; }
.result-spies strong { font-weight: 700; overflow-wrap: anywhere; }
.result-details { font-size: var(--type-label); color: var(--lilac); margin-top: .28rem; overflow-wrap: anywhere; }
.result-details summary { cursor: pointer; }
.result-details > p { padding-top: .3rem; color: #eae5f3; }
.result-content > .result-scores { display: flex; flex: 0 1 auto; flex-direction: column; gap: .45rem; min-height: 6rem; }
#result-players-list { flex: 1 1 auto; min-height: 0; max-height: min(17rem, calc(var(--app-height) * .4)); }
.score-row { min-height: 2.55rem; cursor: pointer; }
.score-details { margin-top: .22rem; padding: .36rem .65rem; color: #cfc0ed; font-size: var(--type-label); overflow-wrap: anywhere; }
.score-delta { font-size: 1rem; font-weight: 800; }
#result-host-actions:not(.hidden) { margin-top: 0; }

.app-shell > :is(#modal-members, #modal-member-action, #modal-rules, #modal-leaderboard, #modal-qr, #modal-confirm, #loading-overlay) {
  inset: 0 0 auto;
  height: var(--app-height);
  padding: max(.625rem, env(safe-area-inset-top)) var(--edge) max(.625rem, env(safe-area-inset-bottom));
}
.app-shell > :is(#modal-members, #modal-member-action, #modal-rules, #modal-leaderboard, #modal-qr, #modal-confirm) > .glass-panel {
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: .9rem;
}
.app-shell > :is(#modal-members, #modal-member-action, #modal-rules, #modal-leaderboard, #modal-qr, #modal-confirm) {
  background: #050812a6;
  backdrop-filter: blur(1px);
}
#modal-member-action { align-items: flex-end; }
#modal-member-action > .glass-panel { max-width: 27rem; margin-bottom: .65rem; }
#qr-code-img { width: min(11rem, calc(var(--app-height) * .4)); height: auto; aspect-ratio: 1; }
#modal-qr .screen-title, #modal-leaderboard .screen-title { font-size: clamp(1.19rem, 3.2vh, 1.6rem); }
#modal-qr h3 i { color: var(--lilac); }
.qr-card {
  display: grid;
  justify-items: center;
  gap: .38rem;
  padding: .75rem;
  border: 1px solid var(--muted-line);
  border-radius: .8rem;
  background: #0e1526;
}
#btn-qr-done { background: #28224f; }
#btn-reset-scores { border-color: var(--gold); }
#btn-reset-scores i, .rules-scroller > div > div:first-child { color: var(--gold); }
.rules-scroller { font-size: var(--type-body); line-height: 1.55; }
.rules-scroller > div { border-color: var(--line); border-radius: .7rem; background: var(--panel); }
.rules-scroller .font-mono { flex: none; }
.rules-scroller > div > div:first-child i { color: var(--lilac); }
.modal-room-code { font-size: .74rem; color: var(--lilac); }
#recovery-panel { padding: .52rem .65rem; border: 1px solid var(--line); border-radius: .72rem; }
#btn-action-kick-ban { color: #ff8e9f; border-color: #d9617c; background: #291a2a; }
#confirm-message { padding: .62rem; border: 1px solid var(--muted-line); border-radius: .65rem; background: #11182a; font-size: var(--type-body); }
#board-classic-panel > :first-child > :first-child, #board-classic-panel > :first-child button, #btn-result-open-lb { font-size: var(--type-note); }

@media (max-width: 345px) {
  .brand-version { display: none; }
  #btn-open-leaderboard span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  #board-classic-panel > :first-child { flex-wrap: wrap; gap: .3rem; }
}

@media (max-width: 700px) and (max-height: 600px) {
  .home-hero { height: 8.75rem; }
  .hero-pin { height: 3rem; }
  .hero-wordmark { width: 5rem; }
  .hero-slogan { font-size: .95rem; }
  .home-form > * + * { margin-top: .42rem; }
}

@media (max-width: 700px) and (max-height: 479px) {
  .app-main { --gap: .45rem; }
}

.short-viewport .home-hero {
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
  min-height: 3rem;
  padding: .35rem;
}
.short-viewport .hero-pin { height: 2.1rem; }
.short-viewport .hero-wordmark { width: 3.1rem; }
.short-viewport .hero-slogan { font-size: .85rem; }
.short-viewport #view-lobby .room-share { padding-block: .4rem; }
.short-viewport #lobby-room-code { font-size: 1.6rem; }
.short-viewport #guest-settings-summary { max-height: 5rem; }
.short-viewport #view-game > :is(#hud-playing-bar, #hud-voting-banner, #hud-spyguess-banner) { padding-block: .36rem; }
.short-viewport #spy-personal-status-badge { padding: .35rem .45rem; }
.short-viewport #spy-guess-progress-list { max-height: 2.55rem; }

.app-shell :is(.primary-action, .secondary-action, .judge-button, .app-bar button, .game-navigation button, .player-row, .location-card-action) {
  transition: transform var(--motion-quick) var(--motion-ease), border-color var(--motion-quick) ease,
              background-color var(--motion-quick) ease, filter var(--motion-quick) ease;
}
.app-shell :is(.primary-action, .secondary-action, .judge-button, .app-bar button, .game-navigation button, button.player-row, .location-card-action):active:not(:disabled) {
  transform: scale(.98);
}

#view-home:not(.hidden) > :is(.home-hero, .home-form),
#view-lobby:not(.hidden) > :is(.room-share, .room-roster),
#view-game :is(#role-card-wrapper, #location-panes, #playing-suspects-panel, #voting-arena-panel, #spyguess-arena-panel):not(.hidden),
#view-game :is(#hud-voting-banner, #hud-spyguess-banner):not(.hidden),
#view-result:not(.hidden) .result-reveal {
  animation: panel-in var(--motion-enter) var(--motion-ease) backwards;
}
#view-game #role-card-wrapper:not(.hidden) { animation-name: fade-in; }
#view-home:not(.hidden) > .home-form,
#view-lobby:not(.hidden) > .room-roster {
  animation-delay: 40ms;
}
.settings-sheet[open] { animation: sheet-in 240ms var(--motion-ease) backwards; }
.settings-sheet[open]::backdrop { animation: fade-in var(--motion-quick) ease backwards; }
.app-shell > div[id^="modal-"]:not(.hidden) > .glass-panel {
  animation: panel-in var(--motion-enter) var(--motion-ease) backwards;
}
.roster-joined { animation: panel-in 210ms var(--motion-ease) backwards; }

.vote-radio::after, .suspect-check i {
  transition: opacity var(--motion-quick) ease, transform var(--motion-quick) var(--motion-ease);
}
.vote-radio::after {
  content: '';
  width: .63rem;
  height: .63rem;
  border-radius: 50%;
  background: #b095ff;
  opacity: 0;
  transform: scale(.6);
}
.player-row[aria-pressed="true"] .vote-radio::after { opacity: 1; transform: scale(1); }
.suspect-check i { opacity: 0; transform: scale(.6); }
.player-row[aria-pressed="true"] .suspect-check i { opacity: 1; transform: scale(1); }
.vote-just-selected :is(.vote-radio, .suspect-check), .timer-warning {
  animation: indicator-in 240ms var(--motion-ease);
}
.score-revealed { animation: indicator-in 235ms var(--motion-ease) 135ms backwards; }

@keyframes panel-in {
  from { opacity: .45; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-in {
  from { opacity: .65; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes indicator-in {
  from { opacity: .65; transform: scale(.87); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion-quick: 0ms; --motion-enter: 0ms; }
  .app-shell :is(.primary-action, .secondary-action, .judge-button, .app-bar button, .game-navigation button, button.player-row, .location-card-action):active:not(:disabled) {
    transform: none;
  }
  #view-home:not(.hidden) > .home-form,
  #view-lobby:not(.hidden) > .room-roster { animation-delay: 0ms; }
  .settings-sheet[open], .roster-joined, .vote-just-selected :is(.vote-radio, .suspect-check), .timer-warning, .score-revealed { animation: none; }
  #vote-progress-fill { transition: none; }
  .card-inner { transition: none; }
  .card-inner.is-flipped, #role-card-back { transform: none; }
  .card-face[inert] { visibility: hidden; }
  .card-face:not([inert]) { animation: role-face-in 150ms ease-out; }
  .location-list-option, .location-card-turn { transition: none; }
  .location-card-turn, .location-flippable.is-flipped .location-card-turn, .location-card-back { transform: none; }
  .location-card-face[inert] { visibility: hidden; }
  .location-card-face:not([inert]) { animation: role-face-in 150ms ease-out; }
}

@keyframes role-face-in {
  from { opacity: .45; }
  to { opacity: 1; }
}
