:root {
  color-scheme: dark;
  --app-header-height: 75px;
  --bg: #021936;
  --panel: #082548;
  --panel-raised: #0d315a;
  --ink: #fff8eb;
  --muted: #bec9d7;
  --line: #315176;
  --green: #c98308;
  --green-2: #eda916;
  --green-accent: #ffd269;
  --gold: #f2aa17;
  --accent-text: #f2aa17;
  --red: #e14c54;
  --night: #00152e;
  --felt: #06305a;
  --walnut: #86510f;
  --card: #fff8eb;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --body-background:
    linear-gradient(180deg, rgba(25, 74, 126, 0.34), rgba(2, 25, 54, 0) 280px),
    var(--bg);
  --field-bg: #041d3b;
  --placeholder: #aab9ca;
  --focus-ring: rgba(255, 210, 105, 0.88);
  --header-bg: #01142c;
  --header-ink: #fff4d7;
  --header-muted: #d9ceb8;
  --header-border: rgba(197, 151, 58, 0.36);
  --header-control-bg: #041d3b;
  --header-control-tint: rgba(197, 151, 58, 0.12);
  --header-status-bg: rgba(255, 250, 242, 0.12);
  --menu-backdrop: rgba(0, 9, 24, 0.7);
  --home-background:
    linear-gradient(180deg, rgba(0, 17, 39, 0.99), rgba(2, 32, 67, 0.94) 58%, rgba(24, 18, 8, 0.96)),
    var(--night);
  --home-tabletop-background: linear-gradient(180deg, rgba(11, 53, 96, 0.94), rgba(3, 32, 66, 0.99));
  --home-tabletop-border: rgba(197, 151, 58, 0.28);
  --home-copy: #fff4d7;
  --home-subtitle: #dce5ef;
  --home-form-background:
    linear-gradient(180deg, rgba(18, 29, 32, 0.97), rgba(7, 16, 22, 0.95)),
    var(--night);
  --home-form-ink: #fffaf2;
  --home-form-muted: rgba(255, 250, 242, 0.74);
  --home-form-field: rgba(7, 16, 22, 0.94);
  --lobby-background:
    radial-gradient(circle at 18% 22%, rgba(25, 74, 126, 0.46), transparent 42%),
    linear-gradient(135deg, #00152e, #03254b 58%, #201607);
  --lobby-heading: #f6d98b;
  --lobby-body: #d4d9d4;
  --soft-surface: rgba(255, 255, 255, 0.035);
  --host-background:
    radial-gradient(circle at 50% 42%, rgba(25, 79, 138, 0.92), rgba(0, 21, 46, 0.98) 70%),
    var(--night);
  --host-blue-glow: rgba(52, 122, 191, 0.3);
  --host-gold-glow: rgba(242, 170, 23, 0.11);
  --stage-ink: #fff8eb;
  --invite-field-bg: rgba(4, 29, 59, 0.96);
  --test-preview-background:
    linear-gradient(180deg, rgba(7, 16, 22, 0.96), rgba(13, 38, 35, 0.9)),
    var(--night);
  --test-preview-ink: #fff4d7;
  --test-preview-muted: rgba(255, 250, 242, 0.76);
  --public-background:
    radial-gradient(circle at 50% 42%, rgba(18, 66, 116, 0.94), rgba(0, 21, 46, 0.98) 76%),
    var(--night);
  --public-ink: #fffaf2;
  --public-muted: rgba(255, 250, 242, 0.76);
  --public-panel: rgba(12, 23, 27, 0.96);
  --public-panel-border: rgba(215, 173, 85, 0.28);
  --dialog-bg: #071b34;
  --dialog-backdrop: rgba(0, 9, 24, 0.76);
  --scroll-edge: #021936;
  --active-turn-glow-outer: rgba(246, 217, 139, 0.72);
  --active-turn-glow-inner: rgba(242, 170, 23, 0.46);
  --active-turn-glow-focus: rgba(246, 217, 139, 0.76);
  --success-bg: rgba(39, 129, 112, 0.32);
  --success-ink: #ffd269;
  --offline-bg: rgba(173, 54, 50, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf6ff;
  --panel: #ffffff;
  --panel-raised: #dceef8;
  --ink: #10283d;
  --muted: #4f687c;
  --line: #9bc4d9;
  --green: #a76400;
  --green-2: #dc8f08;
  --green-accent: #704500;
  --gold: #e9a21c;
  --accent-text: #704500;
  --red: #b72e3b;
  --night: #d9eefb;
  --felt: #badff1;
  --walnut: #9a620d;
  --card: #fffaf2;
  --shadow: 0 5px 8px rgba(30, 91, 124, 0.15);
  --body-background:
    linear-gradient(180deg, rgba(77, 181, 235, 0.22), rgba(234, 246, 255, 0) 320px),
    var(--bg);
  --field-bg: #f8fcff;
  --placeholder: #536c80;
  --focus-ring: rgba(10, 91, 137, 0.62);
  --header-bg: #f8fcff;
  --header-ink: #0a2c44;
  --header-muted: #455f73;
  --header-border: rgba(20, 103, 148, 0.28);
  --header-control-bg: #ffffff;
  --header-control-tint: rgba(20, 123, 179, 0.1);
  --header-status-bg: rgba(20, 103, 148, 0.1);
  --menu-backdrop: rgba(8, 35, 53, 0.42);
  --home-background:
    linear-gradient(180deg, rgba(218, 243, 255, 0.98), rgba(152, 218, 249, 0.92) 58%, rgba(255, 236, 188, 0.9)),
    #bce7fb;
  --home-tabletop-background: linear-gradient(180deg, rgba(193, 231, 247, 0.96), rgba(223, 244, 253, 0.99));
  --home-tabletop-border: rgba(16, 98, 142, 0.24);
  --home-copy: #0c3048;
  --home-subtitle: #284f69;
  --home-form-background: #ffffff;
  --home-form-ink: #10283d;
  --home-form-muted: #4f687c;
  --home-form-field: #f8fcff;
  --lobby-background:
    radial-gradient(circle at 18% 22%, rgba(80, 185, 235, 0.28), transparent 42%),
    linear-gradient(135deg, #effaff, #caecfb 58%, #fff0ca);
  --lobby-heading: #694100;
  --lobby-body: #38566b;
  --soft-surface: rgba(255, 255, 255, 0.62);
  --host-background:
    radial-gradient(circle at 50% 42%, rgba(156, 223, 252, 0.96), rgba(224, 244, 253, 0.98) 70%),
    #dff4fd;
  --host-blue-glow: rgba(48, 163, 218, 0.2);
  --host-gold-glow: rgba(233, 162, 28, 0.14);
  --stage-ink: #12314a;
  --invite-field-bg: #f8fcff;
  --test-preview-background:
    linear-gradient(180deg, rgba(226, 246, 254, 0.98), rgba(193, 231, 247, 0.94)),
    #d9eefb;
  --test-preview-ink: #102f46;
  --test-preview-muted: #48657a;
  --public-background:
    radial-gradient(circle at 50% 42%, rgba(149, 218, 248, 0.94), rgba(226, 245, 253, 0.98) 76%),
    #e3f5fd;
  --public-ink: #10283d;
  --public-muted: #415e73;
  --public-panel: rgba(255, 255, 255, 0.94);
  --public-panel-border: rgba(23, 108, 153, 0.28);
  --dialog-bg: #ffffff;
  --dialog-backdrop: rgba(8, 35, 53, 0.44);
  --scroll-edge: #eaf6ff;
  --active-turn-glow-outer: rgba(6, 79, 121, 0.76);
  --active-turn-glow-inner: rgba(0, 151, 183, 0.58);
  --active-turn-glow-focus: rgba(0, 104, 153, 0.86);
  --success-bg: rgba(19, 121, 91, 0.14);
  --success-ink: #12664e;
  --offline-bg: rgba(183, 46, 59, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  min-height: 100svh;
  margin: 0;
  flex-direction: column;
  background: var(--body-background);
}

body,
body * {
  -webkit-touch-callout: none;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.button-icon {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--ink);
  padding: 0 12px;
}

input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  border-bottom: 1px solid var(--header-border);
  background: var(--header-bg);
  flex: 0 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--header-ink);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 600;
}

.app-version {
  align-self: center;
  margin-left: -4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1;
}

.brand-mark {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-mark-night {
  display: none;
}

:root[data-theme="dark"] .brand-mark-day {
  display: none;
}

:root[data-theme="dark"] .brand-mark-night {
  display: block;
}

.header-primary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle,
.header-refresh-button,
.header-menu-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  background: var(--header-control-tint);
  color: var(--header-ink);
}

.header-refresh-button .button-icon {
  display: block;
  place-self: center;
  transform: translateY(1px);
}

.theme-toggle:hover,
.header-refresh-button:hover,
.header-menu-button:hover {
  background: color-mix(in srgb, var(--header-control-tint) 68%, var(--header-ink) 12%);
}

.theme-toggle-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-control-label {
  display: none;
}

.theme-toggle-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle-sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle-moon {
  display: block;
}

.brand > span:last-child {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.header-test-navigation {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-test-navigation .ghost-link {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.82rem;
}

body:has(#card-menu-test-screen:not(.is-hidden)) .header-test-navigation,
body:has(#card-compact-test-screen:not(.is-hidden)) .header-test-navigation,
body:has(#card-deck-test-screen:not(.is-hidden)) .header-test-navigation,
body:has(#card-face-test-screen:not(.is-hidden)) .header-test-navigation,
body:has(#chips-stack-test-screen:not(.is-hidden)) .header-test-navigation {
  display: flex;
}

.header-private-message-panel {
  display: none;
  width: 100%;
  max-width: none;
  padding: 12px;
  box-shadow: none;
}

.header-controls .header-private-message-panel {
  display: none;
}

.header-private-table-info {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--header-border);
  padding-bottom: 12px;
  color: var(--header-ink);
}

.header-private-table-info > div:last-child {
  text-align: right;
}

body:has(#private-game-screen:not(.is-hidden)) .header-private-table-info {
  display: flex;
}

body:has(#private-game-screen:not(.is-hidden)) .header-private-message-panel {
  display: grid;
}

.header-menu-button {
  display: none;
}

.header-player-name {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--header-border);
  border-radius: 8px;
  background: var(--header-control-tint);
  color: var(--header-ink);
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.language-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--header-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.language-picker-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-picker select {
  width: auto;
  min-width: 132px;
  min-height: 36px;
  padding: 0 30px 0 10px;
}

.status-pill,
.player-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel-raised);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.app-header .status-pill {
  background: var(--header-status-bg);
  color: var(--header-muted);
}

.status-pill.is-online,
.player-status.online {
  background: var(--success-bg);
  color: var(--success-ink);
}

.player-status.offline {
  background: var(--offline-bg);
  color: var(--red);
}

.app-shell {
  display: flex;
  width: 100%;
  min-height: 0;
  margin: 0;
  flex: 1 0 auto;
  padding: clamp(18px, 4vw, 38px);
}

.app-shell:has(#home-screen:not(.is-hidden)) {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.screen {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  flex: 1 1 auto;
}

.home-screen {
  display: grid;
  gap: 22px;
}

.home-hero {
  position: relative;
  contain: layout paint style;
  display: grid;
  width: 100%;
  min-height: calc(100svh - var(--app-header-height));
  margin: 0;
  align-content: start;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(18px, 3vw, 34px);
  overflow: hidden;
  border: 1px solid var(--header-border);
  border-radius: 0;
  background: var(--home-background);
  box-shadow: 0 24px 70px rgba(7, 16, 22, 0.26);
  padding: clamp(28px, 5vw, 56px);
}

@media (min-width: 681px) and (min-height: 700px) {
  body:has(#home-screen:not(.is-hidden)) {
    display: flex;
    height: 100svh;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body:has(#home-screen:not(.is-hidden)) .app-header {
    flex: 0 0 auto;
  }

  body:has(#home-screen:not(.is-hidden)) .app-shell {
    min-height: 0;
    flex: 1 1 auto;
  }

  body:has(#home-screen:not(.is-hidden)) .home-screen {
    height: 100%;
  }

  body:has(#home-screen:not(.is-hidden)) .home-hero {
    height: 100%;
    min-height: 0;
  }
}

/* Keep the home menu vertically balanced across desktop landscape heights. */
@media (min-width: 681px) and (min-height: 700px) and (orientation: landscape) {
  body:has(#home-screen:not(.is-hidden)) .home-hero {
    gap: clamp(12px, 2.8vh, 34px);
    padding: clamp(16px, 4.6vh, 56px) clamp(32px, 4vw, 72px) clamp(14px, 4vh, 48px);
  }

  body:has(#home-screen:not(.is-hidden)) .home-hero-copy {
    gap: clamp(4px, 0.8vh, 10px);
  }

  body:has(#home-screen:not(.is-hidden)) .home-brand-logo {
    width: clamp(104px, 30vh, 360px);
  }

  body:has(#home-screen:not(.is-hidden)) .home-hero-copy p:last-child {
    font-size: clamp(1rem, 2.1vh, 1.55rem);
  }

  body:has(#home-screen:not(.is-hidden)) .playing-card-menu-list {
    min-height: clamp(300px, 42vh, 430px);
    padding-block: 0 clamp(8px, 1.4vh, 18px);
  }

  body:has(#home-screen:not(.is-hidden)) .playing-card-menu-card {
    width: clamp(180px, 26vh, 315px);
  }

  body:has(#home-screen:not(.is-hidden)) .home-flow-panels {
    padding: clamp(18px, 3vh, 32px) clamp(24px, 5vw, 72px) clamp(18px, 3vh, 32px);
  }
}

.home-hero::before {
  content: "";
  position: absolute;
  right: -12%;
  bottom: -30%;
  left: -12%;
  height: 48%;
  border: 2px solid var(--home-tabletop-border);
  border-radius: 50% 50% 0 0;
  background: var(--home-tabletop-background);
  box-shadow: inset 0 20px 60px rgba(7, 16, 22, 0.5), 0 -10px 40px rgba(100, 61, 34, 0.24);
}

.home-hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--home-copy);
  text-align: center;
  transition:
    opacity 420ms ease,
    transform 420ms ease;
}

.home-brand-logo {
  width: min(30vw, 30vh);
  aspect-ratio: 1;
  object-fit: cover;
}

:root[data-theme="light"] .home-brand-logo {
  filter: drop-shadow(0 3px 7px rgba(5, 44, 68, 0.32));
}

.home-hero-copy .eyebrow {
  color: var(--accent-text);
}

.home-hero-copy h1 {
  color: var(--home-copy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 8vw, 5.6rem);
  font-weight: 600;
  line-height: 0.95;
  text-shadow: 0 7px 24px rgba(0, 0, 0, 0.38);
}

.home-hero-copy p:last-child {
  color: var(--home-subtitle);
  font-size: clamp(1.05rem, 2.4vw, 1.55rem);
}

.home-flow-panels {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: start center;
  padding:
    clamp(18px, 3vh, 32px)
    clamp(16px, 6vw, 64px)
    clamp(26px, 6vw, 64px);
  pointer-events: none;
}

.home-flow-panel,
.home-screen.is-menu-ready .home-flow-panel {
  display: none;
}

.home-screen.is-menu-ready[data-active-flow="create"] #create-room-form,
.home-screen.is-menu-ready[data-active-flow="join"] #join-room-form {
  display: grid;
  width: min(560px, 100%);
  margin: 0 auto;
  pointer-events: auto;
  animation: home-form-emerge 640ms cubic-bezier(0.16, 1, 0.3, 1) 140ms both;
  scroll-margin-top: 92px;
}

.home-screen.is-menu-ready.is-home-menu-revealing .home-card-menu .playing-card-menu-card {
  animation: home-card-reveal 900ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-screen.is-menu-ready.is-home-menu-revealing .home-card-menu .playing-card-menu-card:nth-child(2) {
  animation-delay: 180ms;
}

.home-screen.is-menu-ready.is-home-menu-revealing .home-brand-logo,
.home-screen.is-menu-ready.is-home-menu-revealing .home-hero-copy p:last-child {
  animation: home-copy-reveal 900ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-screen.is-menu-ready.is-home-menu-revealing .home-hero-copy p:last-child {
  animation-delay: 180ms;
}

.home-flow-panel.is-active-flow {
  border-color: rgba(246, 217, 139, 0.6);
  background: var(--home-form-background);
  box-shadow:
    0 28px 86px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 250, 242, 0.08) inset;
  color: var(--home-form-ink);
}

.home-flow-panel.is-active-flow h1,
.home-flow-panel.is-active-flow h2 {
  color: var(--green-accent);
}

.home-flow-panel.is-active-flow .field,
.home-flow-panel.is-active-flow legend {
  color: var(--home-form-muted);
}

.home-flow-panel.is-active-flow .choice {
  color: var(--home-form-ink);
}

.home-flow-panel.is-active-flow input,
.home-flow-panel.is-active-flow select {
  border-color: rgba(246, 217, 139, 0.34);
  background: var(--home-form-field);
  color: var(--home-form-ink);
}

.home-flow-panel.is-active-flow .secondary-button {
  border-color: rgba(246, 217, 139, 0.74);
  background: rgba(246, 217, 139, 0.12);
  color: var(--green-accent);
}

.home-flow-panel.is-active-flow .ghost-button {
  border-color: rgba(255, 250, 242, 0.26);
  color: var(--home-form-ink);
}

.home-flow-panel .form-notice {
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--red) 55%, transparent);
  border-radius: 10px;
  background: var(--offline-bg);
  color: var(--home-form-ink);
  padding: 12px 14px;
  line-height: 1.45;
}

.home-screen.is-menu-ready[data-active-flow="create"] .home-hero-copy,
.home-screen.is-menu-ready[data-active-flow="join"] .home-hero-copy {
  opacity: 0.18;
  transform: scale(0.98);
}

.home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu,
.home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu {
  pointer-events: none;
  animation: home-menu-exit 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu .playing-card-menu-card.is-selected,
.home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu .playing-card-menu-card.is-selected {
  z-index: 20;
  animation: home-selected-card-zoom 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 24px);
}

.stack {
  display: grid;
  gap: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.05;
}

h2 {
  font-size: 1.14rem;
  font-weight: 600;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-wrap: pretty;
}

.game-choice-value {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.game-choice-menu {
  width: 100%;
}

body:has(#home-screen:not(.is-hidden)) .game-choice-menu .playing-card-menu-list {
  min-height: 220px;
  padding: 0 8px 4px;
}

body:has(#home-screen:not(.is-hidden)) .game-choice-menu .playing-card-menu-card {
  width: clamp(104px, 15vw, 150px);
  border-radius: 10px;
}

.game-choice-menu .playing-card-menu-card::before,
.game-choice-menu .playing-card-menu-card::after {
  display: none;
}

.game-choice-menu .playing-card-menu-card:hover,
.game-choice-menu .playing-card-menu-card:focus-visible,
.game-choice-menu .playing-card-menu-card.is-active,
.game-choice-menu .playing-card-menu-card.is-touch-focused {
  transform:
    translateX(var(--playing-card-menu-hover-offset, 0px))
    translateY(calc(-5px + var(--playing-card-menu-touch-lift, 0px)))
    rotate(0deg)
    scale(1.025);
}

.game-choice-card-face {
  position: relative;
  display: block;
  height: 100%;
}

.game-choice-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-choice-card-title {
  position: absolute;
  right: 7px;
  bottom: 7px;
  left: 7px;
  z-index: 4;
  border-radius: 6px;
  background: rgba(6, 17, 29, 0.88);
  color: #fff;
  padding: 4px 5px;
  font-size: clamp(0.68rem, 1.8vw, 0.78rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.home-flow-panel.is-active-flow .game-choice-menu .playing-card-menu-card {
  color: initial;
}

.home-screen.is-menu-ready[data-active-flow="create"] #create-room-form {
  gap: 12px;
}

.game-plugin-root {
  width: 100%;
  min-width: 0;
  min-height: 0;
}

#public-game-screen > .game-plugin-root:not(.is-hidden),
#private-game-screen > .game-plugin-root:not(.is-hidden) {
  display: block;
}

.mode-field {
  display: grid;
  gap: 10px;
}

.form-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.join-scan-button {
  justify-self: start;
  gap: 8px;
}

.qr-scan-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--dialog-bg);
  color: var(--ink);
  padding: 18px;
  box-shadow: 0 8px 8px rgba(0, 0, 0, 0.42);
}

.qr-scan-dialog::backdrop {
  background: var(--dialog-backdrop);
}

.qr-scan-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qr-scan-dialog-heading h2 {
  margin: 0;
}

.qr-scan-dialog-heading .icon-button {
  min-width: 40px;
  min-height: 40px;
}

.qr-scan-viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  margin-top: 16px;
  border-radius: 10px;
  background: #06101c;
}

.qr-scan-viewport video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scan-frame {
  position: absolute;
  inset: 18%;
  border: 3px solid var(--green-accent);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(3, 11, 20, 0.28);
  pointer-events: none;
}

.qr-scan-status {
  min-height: 2.8em;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

.choice,
.ready-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
}

.choice input,
.ready-toggle input {
  width: 20px;
  min-height: 20px;
}

.primary-button {
  background: var(--gold);
  color: #07182e;
}

.primary-button:hover {
  background: var(--green-2);
}

.secondary-button {
  border: 1px solid #d99a20;
  background: rgba(242, 170, 23, 0.12);
  color: var(--green-accent);
}

.secondary-button:hover {
  background: rgba(242, 170, 23, 0.24);
}

.danger-button {
  background: var(--red);
  color: #fff;
}

.danger-button:hover {
  background: #8f2926;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.room-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
}

.room-mode {
  font-weight: 600;
}

.lobby-screen {
  display: grid;
  min-height: 100%;
  background: var(--lobby-background);
  color: var(--ink);
  padding: clamp(28px, 5vw, 72px);
}

.lobby-stage {
  display: grid;
  width: min(1440px, 100%);
  margin: auto;
  grid-template-areas:
    "welcome community"
    "actions community";
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(24px, 4vw, 56px);
}

.lobby-welcome {
  display: grid;
  grid-area: welcome;
  align-content: center;
  justify-items: start;
  gap: clamp(16px, 2vw, 26px);
}

.lobby-welcome .eyebrow {
  color: var(--accent-text);
  font-size: clamp(0.9rem, 1.2vw, 1.15rem);
}

.lobby-welcome h1 {
  max-width: 13ch;
  color: var(--lobby-heading);
  font-size: clamp(3rem, 6vw, 6rem);
  letter-spacing: -0.035em;
  line-height: 0.95;
  text-wrap: balance;
}

.lobby-game-name {
  color: var(--green-accent);
  font-size: clamp(1.25rem, 2vw, 2rem);
  font-weight: 600;
}

.lobby-message {
  max-width: 68ch;
  color: var(--lobby-body);
  font-size: clamp(1.05rem, 1.45vw, 1.35rem);
  line-height: 1.65;
  text-wrap: pretty;
}

.lobby-details {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
}

.lobby-details div {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-surface);
  padding: 12px 16px;
}

.lobby-details dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.lobby-details dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 600;
}

.lobby-rules-link {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: #07182e;
  padding: 0 20px;
  text-decoration: none;
  font-weight: 600;
}

.lobby-rules-link:hover {
  background: var(--green-2);
}

.lobby-community {
  display: grid;
  min-width: 0;
  grid-area: community;
  align-content: center;
  gap: 18px;
}

.lobby-players-panel {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.lobby-actions {
  display: flex;
  grid-area: actions;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.lobby-actions button {
  min-width: 130px;
  min-height: 52px;
}

.lobby-actions .ready-toggle {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
}

.player-lobby-stage {
  display: grid;
  width: min(1100px, 100%);
  min-height: calc(100svh - 140px);
  margin: 0 auto;
  grid-template-rows: minmax(0, 40svh) minmax(250px, 1fr);
  gap: 16px;
  padding-bottom: calc(clamp(18px, 3vh, 32px) + env(safe-area-inset-bottom));
}

#room-screen:has(#player-lobby-stage:not(.is-hidden)) {
  padding: 0;
}

.player-lobby-stage .lobby-welcome {
  grid-area: auto;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.player-lobby-stage .lobby-welcome h1,
.player-lobby-stage .lobby-message {
  margin-inline: auto;
}

.player-hand-widget {
  width: 100%;
  min-height: 250px;
  align-self: end;
}

.playing-card-menu.is-scroll-navigation {
  --playing-card-menu-scroll-edge-color: var(--scroll-edge);
}

.player-hand-widget .playing-card-menu-list {
  min-height: 250px;
  align-items: end;
  padding-bottom: 0;
}

.player-hand-widget .playing-card-menu-card {
  width: clamp(116px, 15vw, 180px);
}

.player-hand-widget.is-empty::before {
  content: attr(aria-label);
  display: block;
  color: var(--muted);
  text-align: center;
}

.player-hand-widget .playing-card-menu-card.is-newly-dealt {
  animation: player-hand-deal-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.player-game-hand {
  margin: 12px 0 24px;
}

.header-leave-room-button {
  min-height: 36px;
}

@media (min-width: 681px) {
  body:has(#player-lobby-stage:not(.is-hidden)) .header-menu-button,
  body:has(#private-game-screen:not(.is-hidden)) .header-menu-button {
    display: inline-grid;
    width: 44px;
    min-width: 44px;
    place-items: center;
    background: var(--header-control-tint);
    color: var(--header-ink);
  }

  body:has(#player-lobby-stage:not(.is-hidden)) .header-controls,
  body:has(#private-game-screen:not(.is-hidden)) .header-controls {
    position: absolute;
    top: calc(100% + 8px);
    right: clamp(16px, 4vw, 36px);
    z-index: 6;
    width: min(320px, calc(100vw - 32px));
    align-items: stretch;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--header-control-bg);
    padding: 16px;
    box-shadow: 0 8px 8px rgba(0, 0, 0, 0.34);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    visibility: hidden;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  }

  body:has(#player-lobby-stage:not(.is-hidden)) .app-header.is-menu-open .header-controls,
  body:has(#private-game-screen:not(.is-hidden)) .app-header.is-menu-open .header-controls {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    visibility: visible;
  }

  body:has(#player-lobby-stage:not(.is-hidden)) .header-player-name,
  body:has(#private-game-screen:not(.is-hidden)) .header-player-name,
  body:has(#player-lobby-stage:not(.is-hidden)) .header-controls .status-pill,
  body:has(#private-game-screen:not(.is-hidden)) .header-controls .status-pill {
    width: 100%;
    justify-content: center;
  }

  body:has(#player-lobby-stage:not(.is-hidden)) .language-picker,
  body:has(#private-game-screen:not(.is-hidden)) .language-picker {
    align-items: stretch;
    flex-direction: column;
  }

  body:has(#player-lobby-stage:not(.is-hidden)) .language-picker select,
  body:has(#private-game-screen:not(.is-hidden)) .language-picker select {
    width: 100%;
  }
}

@keyframes player-hand-deal-in {
  from {
    opacity: 0;
    transform: translateY(-90px) scale(0.82);
  }

  to {
    opacity: 1;
    transform: translateY(18px) rotate(var(--card-tilt, 0deg));
  }
}

.app-shell:has(#host-lobby-stage:not(.is-hidden)) {
  padding: 0;
}

#room-screen:has(#host-lobby-stage:not(.is-hidden)) {
  min-height: calc(100svh - var(--app-header-height));
  background: none;
  padding: 0;
}

.host-lobby-stage {
  --host-lobby-deck-width: clamp(
    76px,
    min(13vw, calc((100svh - var(--app-header-height) - 350px) / 4.2)),
    168px
  );
  --host-lobby-qr-size: clamp(240px, 32vh, 380px);
  display: grid;
  position: relative;
  contain: layout paint style;
  isolation: isolate;
  width: 100%;
  height: calc(100svh - var(--app-header-height));
  min-height: calc(100svh - var(--app-header-height));
  /* Keep the host table in three equal viewport bands: tabletop, discard, players. */
  grid-template-rows: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(10px, 1.4vh, 18px);
  overflow: hidden;
  background: var(--host-background);
  padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 48px) clamp(8px, 1.2vh, 14px);
}

.host-lobby-stage::before,
.host-lobby-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.host-lobby-stage::before {
  inset: -32% 18% 35%;
  background: radial-gradient(circle, var(--host-blue-glow), transparent 68%);
  opacity: 0.72;
  transform: scale(1.02);
}

.host-lobby-stage::after {
  right: 8%;
  bottom: -24%;
  width: min(46vw, 720px);
  aspect-ratio: 1;
  background: radial-gradient(circle, var(--host-gold-glow), transparent 66%);
  opacity: 0.72;
}

.host-lobby-stage > * {
  position: relative;
  z-index: 1;
}

.host-lobby-tabletop {
  z-index: 2;
  display: grid;
  width: min(1600px, 100%);
  min-height: 0;
  margin-inline: auto;
  grid-template-areas: "controls source actions";
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: clamp(18px, 3vw, 54px);
}

.host-lobby-tabletop .host-control-panel {
  width: min(360px, 100%);
  min-width: 0;
  grid-area: controls;
  justify-self: start;
  gap: 12px;
  padding: 16px;
  box-shadow: 0 8px 8px rgba(0, 9, 24, 0.28);
}

.host-lobby-tabletop .host-control-panel h1 {
  font-size: 1.3rem;
}

.host-language-picker {
  width: 100%;
  align-items: stretch;
  flex-direction: column;
}

.host-language-picker select {
  width: 100%;
}

.host-game-settings {
  display: grid;
  gap: 10px;
}

.host-game-setting {
  width: 100%;
  align-items: stretch;
  flex-direction: column;
}

.host-game-setting select {
  width: 100%;
}

.host-lobby-source {
  display: grid;
  min-width: 0;
  grid-area: source;
  justify-self: center;
  place-items: center;
}

.host-lobby-qr-overlay {
  display: grid;
  width: var(--host-lobby-qr-size);
  max-height: 100%;
  align-self: center;
  justify-self: center;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  place-items: center;
  pointer-events: auto;
  animation: host-lobby-focus-enter 560ms cubic-bezier(0.16, 1, 0.3, 1) both;
  z-index: 4;
}

.host-lobby-qr-overlay .qr-frame {
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 1 / 1;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 3%;
  overflow: hidden;
  border: 0;
  background: #fff;
  margin: 0;
  padding: 6%;
  box-shadow: 0 8px 8px rgba(0, 0, 0, 0.42);
}

.host-lobby-qr-overlay .qr-frame img {
  width: auto;
  max-width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.host-lobby-qr-room-id {
  display: grid;
  width: 100%;
  min-width: 0;
  align-items: center;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4cqi;
  border-top: 1px solid #d3d9e0;
  color: #56677b;
  padding: 4cqi 1cqi 0;
  font-size: clamp(0.52rem, 5.5cqi, 0.78rem);
  font-weight: 600;
  line-height: 1.05;
}

.host-lobby-qr-room-id h2 {
  min-width: 0;
  color: #082548;
  font-size: clamp(0.78rem, 9.5cqi, 1.55rem);
  letter-spacing: 0.05em;
  line-height: 1;
  overflow-wrap: anywhere;
  text-align: right;
}

.host-lobby-qr-hint {
  width: min(640px, calc(100vw - 32px));
  color: var(--stage-ink);
  line-height: 1.4;
  text-align: center;
}

.host-lobby-qr-hint {
  margin-top: -6px;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.4vw, 1.15rem);
  font-weight: 500;
}

.host-lobby-qr-actions {
  width: min(560px, calc(100vw - 32px));
}

.host-lobby-qr-actions.invite-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
}

.host-lobby-qr-actions.invite-row input {
  min-width: 0;
  flex: 1 1 auto;
}

.host-lobby-qr-actions.invite-row button {
  flex: 0 0 auto;
}

.host-lobby-qr-actions input {
  background: var(--invite-field-bg);
}

.host-lobby-stage.is-game-started .host-lobby-qr-hint,
.host-lobby-stage.is-game-started .host-lobby-qr-actions {
  display: none;
}

.host-lobby-stage.is-game-started .host-lobby-qr-overlay {
  width: fit-content;
  min-width: 0;
  pointer-events: auto;
}

.host-game-table-cards.playing-card-deck {
  --playing-card-deck-card-width: var(--host-lobby-deck-width);
}

.host-game-messages {
  height: 150px;
  max-height: 150px;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.host-game-messages .message-list {
  min-height: 0;
  max-height: none;
}

.host-game-messages .message-list li {
  padding: 9px 10px;
}

.host-lobby-source .playing-card-deck {
  --playing-card-deck-card-width: var(--host-lobby-deck-width);
}

.host-lobby-start-action {
  display: grid;
  width: min(360px, 100%);
  min-width: 0;
  grid-area: actions;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 54px;
  justify-self: end;
  gap: 10px;
  padding: 16px;
}

.host-lobby-action-slot {
  display: grid;
  grid-template-areas: "action";
  min-width: 0;
  min-height: 54px;
}

.host-lobby-action-slot > button {
  grid-area: action;
  width: 100%;
  min-width: 0;
}

/* Keep the four action cells stable while alternate actions are unavailable. */
.host-lobby-action-slot > .is-hidden {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}

.host-lobby-start-action button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.host-lobby-start-action .primary-button {
  width: 100%;
  min-height: 54px;
  font-size: 1rem;
}

.host-lobby-start-action .secondary-button,
.host-lobby-start-action .ghost-button {
  width: 100%;
  min-height: 48px;
}

.host-lobby-start-action .danger-button {
  width: 100%;
  min-height: 54px;
  font-size: 1rem;
}

.host-lobby-start-action .primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.host-lobby-player-decks {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  min-height: 0;
  height: 100%;
  align-items: end;
  justify-content: space-evenly;
  gap: clamp(8px, 1.4vw, 20px);
  overflow: visible;
  padding: 0 clamp(4px, 1vw, 12px) env(safe-area-inset-bottom);
}

.host-lobby-stage:not(.is-game-started) .host-lobby-player-decks {
  opacity: 0.72;
}

.host-lobby-stage:not(.is-game-started) .host-lobby-source {
  opacity: 0.72;
}

.host-lobby-player-slot {
  position: relative;
  display: grid;
  min-width: 230px;
  flex: 1 0 230px;
  gap: 4px;
  place-items: end center;
}

.public-player-rejoin-target {
  position: relative;
}

.public-player-rejoin {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
  background: #fff;
  box-shadow: 0 3px 8px rgba(7, 24, 46, 0.3);
  padding: 8px;
}

.host-lobby-player-slot .public-player-rejoin {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 32px;
  display: grid;
  width: calc(var(--host-lobby-deck-width) + 72px);
  height: calc(var(--host-lobby-deck-width) * 1.4 + 92px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  transform: translateX(-50%);
}

.public-player-rejoin-name,
.public-player-rejoin-hint {
  max-width: 100%;
  overflow: hidden;
  color: #07182e;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-player-rejoin-name {
  font-size: clamp(0.72rem, 1.4vw, 0.95rem);
  line-height: 1.1;
}

.public-player-rejoin-hint {
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  font-weight: 700;
  line-height: 1.1;
}

.public-player-rejoin img {
  display: block;
  min-height: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}

.player-action-bubble {
  position: relative;
  z-index: 4;
  display: grid;
  min-height: 34px;
  max-width: min(240px, 90vw);
  margin: 0 0 4px;
  place-items: center;
  border-radius: 12px;
  background: #fff8eb;
  color: #07182e;
  padding: 7px 11px;
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: opacity 180ms ease-out, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  visibility: hidden;
}

.player-action-bubble.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.player-action-bubble.is-pulsing {
  animation: player-action-bubble-pulse 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.player-action-bubble.is-fading {
  animation: player-action-bubble-fade 320ms ease-in forwards;
}

@keyframes player-action-bubble-pulse {
  0% { transform: translateY(6px) scale(0.92); }
  45% { transform: translateY(0) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes player-action-bubble-fade {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

.host-lobby-player-slot .playing-card-deck {
  --playing-card-deck-card-width: var(--host-lobby-deck-width);
}

.host-lobby-player-slot.is-active-turn .playing-card-deck,
.playing-card-deck.is-active-turn {
  filter: drop-shadow(0 0 7px var(--active-turn-glow-outer))
    drop-shadow(0 0 18px var(--active-turn-glow-inner));
  animation: active-player-deck-glow 1.8s ease-in-out infinite;
}

@keyframes active-player-deck-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 7px color-mix(in srgb, var(--active-turn-glow-outer) 86%, transparent))
      drop-shadow(0 0 16px color-mix(in srgb, var(--active-turn-glow-inner) 74%, transparent));
  }

  50% {
    filter: drop-shadow(0 0 10px var(--active-turn-glow-outer))
      drop-shadow(0 0 24px var(--active-turn-glow-inner));
  }
}

.host-lobby-player-meta {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.host-lobby-stage.is-game-started .host-lobby-card-count {
  color: var(--stage-ink);
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  font-weight: 800;
  line-height: 1;
}

.host-lobby-card-count.is-score-pulsing {
  animation: host-score-pulse 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes host-score-pulse {
  0% {
    color: var(--stage-ink);
    filter: drop-shadow(0 0 0 rgba(242, 170, 23, 0));
    transform: scale(1);
  }

  45% {
    color: #ffd269;
    filter: drop-shadow(0 0 7px rgba(242, 170, 23, 0.72));
    transform: scale(1.24);
  }

  100% {
    color: var(--stage-ink);
    filter: drop-shadow(0 0 0 rgba(242, 170, 23, 0));
    transform: scale(1);
  }
}

.host-lobby-offline-badge {
  display: none;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: var(--offline-bg);
  color: var(--red);
  padding: 0 9px;
}

@media (max-width: 680px) and (orientation: portrait) and (pointer: coarse) {
  body:has(#host-lobby-stage:not(.is-hidden)) {
    overflow-y: auto;
  }

  body:has(#host-lobby-stage:not(.is-hidden)) .app-shell,
  #room-screen:has(#host-lobby-stage:not(.is-hidden)) {
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .host-lobby-stage {
    display: flex;
    height: auto;
    min-height: calc(100svh - var(--app-header-height));
    flex-direction: column;
    gap: 16px;
    overflow: visible;
    padding: 16px 14px 28px;
  }

  .host-lobby-stage > .host-lobby-qr-overlay {
    order: 1;
    width: min(100%, 360px);
    align-self: center;
    animation: none;
  }

  .host-lobby-stage > .host-lobby-tabletop {
    order: 2;
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 14px;
  }

  .host-lobby-source,
  .host-game-table-state,
  .host-lobby-player-slot > :first-child,
  .host-lobby-player-slot .player-action-bubble,
  .host-lobby-card-count {
    display: none !important;
  }

  .host-lobby-tabletop .host-control-panel,
  .host-lobby-start-action {
    width: 100%;
    justify-self: auto;
  }

  .host-lobby-start-action {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .host-lobby-stage > .host-lobby-player-decks {
    order: 3;
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 0;
  }

  .host-lobby-player-slot {
    display: flex;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    padding: 10px 12px;
  }

  .host-lobby-player-meta {
    width: 100%;
    min-height: 24px;
    justify-content: space-between;
    color: var(--stage-ink);
    font-size: 0.95rem;
  }

  .host-lobby-player-name::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--success-ink);
    vertical-align: 1px;
  }

  .host-lobby-player-slot.is-offline .host-lobby-player-name::before {
    background: var(--red);
  }

  .host-lobby-offline-badge {
    display: inline-flex;
    min-height: 24px;
  }
}

.host-lobby-player-slot.is-offline .host-lobby-offline-badge {
  display: inline-flex;
}

.test-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.ghost-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 0 14px;
  text-decoration: none;
  font-weight: 600;
}

.card-menu-test-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 22px;
  min-height: 0;
  flex: 1 1 auto;
  align-items: stretch;
}

.card-menu-test-screen:not(.is-hidden) {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

body:has(.card-menu-test-screen:not(.is-hidden)) {
  height: 100svh;
  overflow: hidden;
}

.app-shell:has(.card-menu-test-screen:not(.is-hidden)) {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 8px 12px calc(4px + env(safe-area-inset-bottom));
}

.card-menu-test-controls {
  position: sticky;
  top: 80px;
  height: calc(100% - 4px);
  max-height: calc(100svh - 240px);
  align-self: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.segmented-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.segmented-actions button:disabled {
  cursor: not-allowed;
}

.field output {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.card-menu-test-preview {
  min-width: 0;
  height: calc(100% - 4px);
  max-height: calc(100svh - 240px);
  min-height: 0;
  align-self: start;
  display: grid;
  grid-template-rows: min-content minmax(0, 1fr);
  gap: 16px;
  overflow: hidden;
  border: 1px solid var(--header-border);
  border-radius: 8px;
  background: var(--test-preview-background);
  padding: clamp(16px, 3vw, 28px);
  box-shadow: 0 24px 70px rgba(7, 16, 22, 0.2);
}

.card-menu-test-widget {
  min-height: 0;
  height: 100%;
}

.card-compact-test-stage {
  display: flex;
  min-height: 0;
  align-items: flex-start;
  align-content: flex-start;
  overflow: auto;
  padding: 8px 0;
}

.card-compact-test-stage .playing-card-compact {
  width: 100%;
}

.card-compact-test-controls .muted {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.card-face-test-widget {
  min-height: 0;
  height: 100%;
}

.card-face-test-widget .playing-card-menu-list {
  justify-content: center;
  min-height: 0;
}

.card-face-test-widget .playing-card-menu-card {
  width: var(--card-face-test-card-width, 150px);
}

.card-menu-test-heading {
  display: flex;
  height: min-content;
  min-height: 0;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  color: var(--test-preview-ink);
}

.card-menu-test-heading .muted {
  color: var(--test-preview-muted);
  font-weight: 500;
}

.card-menu-test-widget .playing-card-menu-list {
  align-items: start;
  gap: clamp(12px, 2vw, 22px);
  justify-content: center;
  min-height: 0;
  padding: 18px 8px 28px;
}

.card-menu-test-widget .playing-card-menu-card {
  width: var(--card-menu-test-card-width, clamp(150px, 18vw, 230px));
}

.card-menu-test-widget .playing-card-menu-card:nth-child(4n + 1) {
  --card-tilt: -5deg;
}

.card-menu-test-widget .playing-card-menu-card:nth-child(4n + 2) {
  --card-tilt: 3deg;
}

.card-menu-test-widget .playing-card-menu-card:nth-child(4n + 3) {
  --card-tilt: -2deg;
}

.card-menu-test-widget .playing-card-menu-card:nth-child(4n + 4) {
  --card-tilt: 5deg;
}

.chips-stack-test-preview {
  min-height: 0;
}

.chips-stack-test-grid {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(132px, auto));
  align-content: start;
  gap: clamp(10px, 2vw, 24px);
  overflow: auto;
  padding: 8px;
}

.chips-stack-test-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.35fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  height: clamp(220px, 24vw, 300px);
  min-height: 220px;
  overflow: hidden;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  padding: 12px 16px;
}

.chips-stack-test-row h3 {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  color: var(--test-preview-ink);
  font-size: 0.9rem;
  text-align: left;
}

.chips-stack-test-widget {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: grid;
  border: 1px solid var(--line);
  overflow: auto;
  place-items: center;
}

.chips-stack-test-widget.chips-stack {
  display: block;
}

.chips-stack-test-widget .chips-stack-groups {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: max-content;
  translate: -50% 0;
}

.chips-stack-test-widget .chips-stack-total {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  translate: -50% 0;
}

.chips-stack-test-actions {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 12px;
  gap: 8px;
}

.chips-stack-test-actions button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.78rem;
}

@media (min-width: 861px) {
  .chips-stack-test-controls,
  .chips-stack-test-preview {
    height: 100%;
    max-height: none;
  }

  .chips-stack-test-grid {
    grid-template-rows: repeat(3, minmax(220px, 1fr));
    align-content: stretch;
    overflow-y: auto;
  }

  .chips-stack-test-row {
    height: auto;
    min-height: 0;
  }
}

.card-deck-test-controls .field span {
  color: var(--test-preview-muted);
}

.card-deck-test-controls .range-field-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-deck-test-controls input[type="range"] {
  min-height: 44px;
  padding: 0;
  accent-color: var(--gold);
}

.card-deck-test-grid {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 18px);
}

.card-deck-test-widget.playing-card-deck {
  --playing-card-deck-card-width: clamp(96px, 17vh, 170px);
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 8px;
  cursor: pointer;
  place-items: center;
  touch-action: manipulation;
  transition: filter 180ms ease, transform 180ms ease;
}

.card-deck-test-face {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 5px;
  padding: 32px 18px;
  background-image: url("/assets/images/card-front-background.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  text-align: center;
}

.card-deck-test-face--hearts,
.card-deck-test-face--diamonds {
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.42),
    inset 0 0 0 8px rgba(180, 35, 45, 0.2);
}

.card-deck-test-face-content {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.card-deck-test-art {
  position: absolute;
  display: grid;
  width: 80%;
  place-items: center;
}

.card-deck-test-art img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.card-deck-test-corner {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 1px;
  place-items: center;
  color: #101418;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.92rem, 1.3vw, 1.18rem);
  font-weight: 600;
  line-height: 0.92;
}

.card-deck-test-face--hearts .card-deck-test-corner,
.card-deck-test-face--diamonds .card-deck-test-corner {
  color: var(--red);
}

.card-deck-test-rank {
  font-size: 0.62em;
}

.card-deck-test-suit {
  font-size: 0.84em;
}

.card-deck-test-corner--top {
  top: 12px;
  left: 12px;
}

.card-deck-test-corner--bottom {
  right: 12px;
  bottom: 12px;
  transform: rotate(180deg);
}

.card-deck-test-widget:hover:not(.is-disabled) {
  filter: brightness(1.08);
}

.card-deck-test-widget:active:not(.is-disabled) {
  transform: scale(0.985);
}

.card-deck-test-widget:focus-visible {
  outline: 3px solid rgba(215, 173, 85, 0.72);
  outline-offset: -3px;
}

.card-deck-test-widget.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.invite-row,
.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.qr-frame {
  display: grid;
  width: min(280px, 100%);
  aspect-ratio: 1 / 1;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  margin: 2em;
}

.qr-frame img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.empty-slot,
.muted {
  color: var(--muted);
}

.player-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.player-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.player-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.game-table-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.app-shell:has(#public-game-screen:not(.is-hidden)) {
  padding: 0;
}

#public-game-screen {
  display: grid;
  min-height: calc(100svh - var(--app-header-height));
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(24px, 3vw, 42px);
  background: var(--public-background);
  color: var(--public-ink);
  padding: clamp(28px, 4vw, 64px);
}

#public-game-screen .room-bar {
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: clamp(24px, 4vw, 64px);
}

#public-game-screen .room-bar h1 {
  color: var(--lobby-heading);
  font-size: clamp(2.8rem, 5vw, 5.5rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
  text-wrap: balance;
}

#public-game-screen .eyebrow {
  margin-bottom: 8px;
  color: var(--public-muted);
  font-size: clamp(0.95rem, 1.25vw, 1.35rem);
}

#public-game-screen .room-mode {
  color: var(--public-ink);
  font-size: clamp(2rem, 3.5vw, 4rem);
  letter-spacing: 0.08em;
}

#public-game-screen .ghost-button {
  min-height: 64px;
  border-color: rgba(246, 217, 139, 0.56);
  color: var(--public-ink);
  padding: 0 24px;
  font-size: clamp(1.05rem, 1.3vw, 1.4rem);
}

#public-game-screen .game-table-layout {
  min-height: 0;
  height: fit-content;
  align-self: start;
  grid-template-columns: minmax(260px, 0.7fr) minmax(280px, 0.8fr) minmax(0, 1.5fr);
  gap: clamp(22px, 3vw, 40px);
  align-items: stretch;
}

.public-card-state-layout {
  --public-direction-slot-size: clamp(64px, 6vw, 96px);
  display: grid;
  grid-template-columns:
    minmax(110px, 0.7fr)
    var(--public-direction-slot-size)
    auto
    var(--public-direction-slot-size);
  gap: 20px;
  align-items: center;
}

.public-card-state-layout::after {
  content: "";
  display: block;
  width: var(--public-direction-slot-size);
  height: var(--public-direction-slot-size);
}

.public-direction-indicator {
  display: grid;
  width: clamp(64px, 6vw, 96px);
  min-width: clamp(64px, 6vw, 96px);
  min-height: clamp(64px, 6vw, 96px);
  place-items: center;
  color: var(--accent-text);
  font-size: clamp(3.25rem, 6vw, 5rem);
}

.host-game-table-state {
  --host-direction-slot-size: min(96px, calc(var(--host-lobby-deck-width) * 0.7));
  position: relative;
  display: grid;
  grid-template-columns: var(--host-direction-slot-size) auto var(--host-direction-slot-size);
  align-items: center;
  gap: 8px;
}

.host-game-recycle-temp-deck.playing-card-deck {
  --playing-card-deck-card-width: var(--host-lobby-deck-width);
  position: absolute;
  top: 50%;
  left: calc(50% + (var(--host-lobby-deck-width) / 2) + 8px);
  z-index: 2;
  transform: translateY(-50%);
}

.host-game-table-state::after {
  content: "";
  display: block;
  width: var(--host-direction-slot-size);
  height: var(--host-direction-slot-size);
}

.host-game-table-state:has(#host-game-table-cards.is-hidden) {
  display: none;
}

.host-game-table-state .public-direction-indicator {
  width: var(--host-direction-slot-size);
  min-width: var(--host-direction-slot-size);
  min-height: var(--host-direction-slot-size);
  font-size: var(--host-direction-slot-size);
}

.public-direction-indicator .fa-solid {
  width: 1em;
}

.fa-rotate-left::before { content: "\f2ea"; }
.fa-rotate-right::before { content: "\f2f9"; }

.fa-spin {
  animation: fa-spin 2s infinite linear;
}

.fa-spin-reverse {
  animation: fa-spin-reverse 2s infinite linear;
}

@keyframes fa-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fa-spin-reverse {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

#public-draw-pile.playing-card-deck {
  --playing-card-deck-card-width: clamp(92px, 10vw, 150px);
}

#public-table-cards .playing-card-menu-card {
  width: clamp(100px, 11vw, 170px);
}

#public-game-screen .panel {
  min-height: 0;
  border: 1px solid var(--public-panel-border);
  background: var(--public-panel);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18);
  color: var(--ink);
  padding: clamp(24px, 3vw, 44px);
}

#public-game-screen .panel h2 {
  color: var(--lobby-heading);
  font-size: clamp(1.8rem, 2.5vw, 3rem);
  line-height: 1;
}

:root[data-theme="light"] #public-game-screen .playing-card-deck.is-active-turn {
  --active-turn-glow-outer: rgba(5, 73, 116, 0.86);
  --active-turn-glow-inner: rgba(0, 143, 178, 0.72);
  --active-turn-glow-focus: rgba(2, 77, 126, 0.94);
}

#public-game-screen .player-list {
  align-content: start;
  gap: clamp(14px, 1.5vw, 24px);
}

#public-game-screen .player-list li {
  gap: 18px;
  padding: 0 0 clamp(14px, 1.5vw, 24px);
  font-size: clamp(1.35rem, 1.8vw, 2.15rem);
}

#public-game-screen .player-list small {
  margin-top: 6px;
  font-size: clamp(1rem, 1.2vw, 1.4rem);
}

#public-game-screen .player-status {
  min-height: 42px;
  padding: 0 16px;
  font-size: clamp(0.95rem, 1.1vw, 1.25rem);
}

#public-game-screen .messages-panel {
  height: 150px;
  min-height: 150px;
  max-height: 150px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

#public-game-screen .message-list {
  min-height: 0;
  max-height: none;
  align-content: start;
  gap: clamp(12px, 1.2vw, 18px);
}

#public-game-screen .message-list li {
  gap: 8px;
  padding: clamp(14px, 1.4vw, 22px);
}

#public-game-screen .message-list strong {
  font-size: clamp(1.05rem, 1.3vw, 1.5rem);
}

#public-game-screen .message-list span,
#public-game-screen .empty-message {
  color: var(--ink);
  font-size: clamp(1.25rem, 1.7vw, 2rem);
  line-height: 1.35;
}

#public-game-screen .message-row {
  gap: 16px;
}

#public-game-screen .message-row input,
#public-game-screen .message-row button {
  min-height: 64px;
  font-size: clamp(1.1rem, 1.35vw, 1.5rem);
}

#public-game-screen img,
#public-game-screen svg,
#public-game-screen canvas {
  max-width: 100%;
  max-height: min(58vh, 720px);
  object-fit: contain;
}

.messages-panel {
  height: 150px;
  min-height: 150px;
  max-height: 150px;
}

.message-list {
  display: grid;
  gap: 10px;
  min-height: 260px;
  max-height: min(420px, 52vh);
  margin: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.message-list li {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
  padding: 10px 12px;
}

.message-list li.is-game-action {
  background: color-mix(in srgb, var(--gold) 16%, var(--panel-raised));
}

.message-list strong {
  color: var(--green-accent);
  font-size: 0.86rem;
}

.message-list span,
.empty-message {
  color: var(--muted);
}

.private-message-panel {
  width: min(720px, 100%);
  max-width: 720px;
}

body:has(#private-game-screen:not(.is-hidden)) {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body:has(#private-game-screen:not(.is-hidden)) .app-shell {
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 0;
}

body:has(#private-game-screen:not(.is-hidden)),
body:has(#private-game-screen:not(.is-hidden)) * {
  -webkit-user-select: none;
  user-select: none;
}

body:has(#private-game-screen:not(.is-hidden)) input,
body:has(#private-game-screen:not(.is-hidden)) select {
  -webkit-user-select: text;
  user-select: text;
}

#private-game-screen:not(.is-hidden) {
  --private-player-card-width: max(
    clamp(86px, min(15vw, 20svh), 180px),
    calc(25svh * 5 / 7)
  );
  position: relative;
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 16px);
  overflow: clip;
  overscroll-behavior: contain;
  touch-action: manipulation;
}

.private-game-turn-label {
  width: min(920px, 100%);
  margin: 0;
  padding: 8px 0;
  color: var(--ink);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
}

.private-next-round-ready {
  width: 100%;
  display: grid;
  align-self: center;
  justify-items: center;
  gap: 8px;
  color: var(--ink);
  padding: 8px 16px;
  text-align: center;
}

.private-next-round-ready p {
  margin: 0;
  font-weight: 600;
}

.private-next-round-ready button {
  min-width: 140px;
}

.private-next-round-ready button.is-waiting {
  cursor: wait;
  opacity: 0.88;
}

.ready-button-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline-end: 0.5em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -0.15em;
  animation: ready-button-spin 0.8s linear infinite;
}

@keyframes ready-button-spin {
  to {
    transform: rotate(360deg);
  }
}

.game-result-message {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--accent-color, #d7a84b);
  border-radius: 0.75rem;
  text-align: center;
  font-weight: 700;
}

#private-game-screen .room-bar,
#private-game-screen .game-turn-panel,
#private-game-screen .player-game-hand,
#private-game-screen .private-game-play-area {
  margin: 0;
}

#private-game-screen .private-game-play-area {
  display: grid;
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: end;
  justify-items: center;
}

#private-game-screen .private-discard-pile.playing-card-deck {
  --playing-card-deck-card-width: var(--private-player-card-width);
  align-self: center;
}

#private-game-screen .player-game-hand,
#private-game-screen .playing-card-menu,
#private-game-screen .playing-card-menu-list,
#private-game-screen .playing-card-menu-row {
  width: 100%;
  min-width: 0;
  min-height: 0;
}

#private-game-screen .player-game-hand {
  align-self: end;
  height: auto;
  min-height: 0;
  margin-bottom: 5px;
  padding-top: 0;
  overflow: visible;
}

#private-game-screen .playing-card-menu,
#private-game-screen .playing-card-menu-list {
  height: auto;
  min-height: 0;
}

#private-game-screen .playing-card-menu-list {
  align-items: center;
  /* Preserve lift room inside the bottom-anchored hand strip. */
  padding: clamp(28px, 4svh, 48px) 0 23px;
  margin-bottom: 0;
}

#private-game-screen .playing-card-menu-card {
  width: var(--private-player-card-width);
}

#private-game-screen .game-turn-panel {
  position: absolute;
  right: 0;
  bottom: calc(5px + env(safe-area-inset-bottom));
  z-index: 4;
  width: auto;
  max-width: calc(100% - 10px);
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 12px;
  justify-content: flex-end;
}

.game-turn-panel {
  display: flex;
  max-width: 920px;
  margin: 18px 0;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px 16px;
}

.game-turn-label {
  margin: 0;
}

.game-turn-label {
  color: var(--ink);
  font-weight: 700;
}

.game-action-buttons,
.game-color-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-action-buttons {
  margin-left: auto;
  justify-content: flex-end;
}

.game-color-buttons {
  margin-left: auto;
  justify-content: flex-end;
}

.game-action-buttons button {
  padding: 0 16px;
}

.game-color-button {
  width: 48px;
  min-width: 48px;
  overflow: hidden;
  color: transparent;
  border: 2px solid rgba(255, 255, 255, 0.72);
}

.game-color-button.is-red { background: #d92b34; }
.game-color-button.is-blue { background: #245dcc; }
.game-color-button.is-green { background: #21834b; }
.game-color-button.is-yellow { background: #e5b51c; }

@media (max-width: 680px) {
  /* iOS Safari zooms the page when a focused text control is below 16px. */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .game-turn-panel {
    align-items: stretch;
  }

}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(340px, calc(100vw - 36px));
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--ink);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 600;
}

.confirmation-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid rgba(225, 76, 84, 0.58);
  border-radius: 12px;
  background: var(--dialog-bg);
  color: var(--ink);
  padding: 22px;
  box-shadow: 0 8px 8px rgba(0, 0, 0, 0.42);
}

.confirmation-dialog::backdrop {
  background: var(--dialog-backdrop);
}

.confirmation-dialog-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.confirmation-dialog-content h2,
.confirmation-dialog-content p {
  margin: 0;
}

.confirmation-dialog-content p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.confirmation-dialog-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(225, 76, 84, 0.16);
  color: var(--red);
  font-size: 1.35rem;
}

.confirmation-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.confirmation-dialog-actions button {
  min-width: 120px;
}

.offline-panel {
  max-width: 520px;
  margin: 10vh auto 0;
  text-align: center;
}

.offline-brand-logo {
  width: min(220px, 70vw);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 14px;
  object-fit: cover;
}

:root[data-theme="light"] .offline-brand-logo.brand-mark-day,
:root[data-theme="dark"] .offline-brand-logo.brand-mark-night {
  display: block;
}

.offline-header .theme-toggle {
  margin-left: auto;
}

.is-hidden {
  display: none !important;
}

@keyframes home-card-reveal {
  from {
    opacity: 0;
    transform: translateY(72px) rotate(var(--card-tilt, 0deg)) scale(0.86);
  }

  to {
    opacity: 1;
    transform: translateY(18px) rotate(var(--card-tilt, 0deg)) scale(1);
  }
}

@keyframes home-copy-reveal {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes form-reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes home-menu-exit {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  42% {
    opacity: 0.88;
    transform: scale(1.04);
  }

  100% {
    opacity: 0;
    transform: scale(0.78);
  }
}

@keyframes home-selected-card-zoom {
  0% {
    opacity: 1;
    transform:
      translateX(var(--playing-card-menu-hover-offset, 0px))
      translateY(-12px)
      rotate(0deg)
      scale(1.035);
  }

  44% {
    opacity: 1;
    transform:
      translateX(var(--playing-card-menu-hover-offset, 0px))
      translateY(-44px)
      rotate(0deg)
      scale(1.16);
  }

  100% {
    opacity: 0;
    transform:
      translateX(var(--playing-card-menu-hover-offset, 0px))
      translateY(-20px)
      rotate(0deg)
      scale(1.38);
  }
}

@keyframes home-form-emerge {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.86);
  }

  58% {
    opacity: 1;
    transform: translateY(0) scale(1.035);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes host-lobby-focus-enter {
  from {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* Large shared displays: compose the host surfaces around a 16:9 TV viewport. */
@media (min-width: 1100px) and (min-aspect-ratio: 8 / 5) {
  .host-lobby-stage {
    --host-lobby-deck-width: clamp(
      76px,
      min(13vw, calc((100svh - var(--app-header-height) - 320px) / 4.2)),
      168px
    );
    --host-lobby-qr-size: clamp(210px, 28vh, 320px);
    height: calc(100svh - var(--app-header-height));
    min-height: calc(100svh - var(--app-header-height));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: clamp(8px, 1.2vh, 14px);
    padding: clamp(10px, 1.6vh, 18px) clamp(24px, 2.5vw, 48px) clamp(6px, 1vh, 12px);
  }

  .host-lobby-tabletop {
    grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
    gap: clamp(20px, 2.5vw, 48px);
  }

  .host-lobby-tabletop .host-control-panel {
    width: min(360px, 100%);
    max-height: 38vh;
    overflow: auto;
  }

  .host-lobby-start-action {
    width: min(360px, 100%);
  }

  .host-lobby-player-decks {
    min-height: 0;
    height: 100%;
  }

  .host-lobby-player-slot {
    min-width: 190px;
    flex-basis: 190px;
  }

  #public-game-screen {
    height: calc(100svh - var(--app-header-height));
    min-height: 0;
    gap: clamp(14px, 2.2vh, 26px);
    overflow: hidden;
    padding: clamp(20px, 3vh, 36px) clamp(28px, 3vw, 58px);
  }

  #public-game-screen .room-bar {
    gap: clamp(28px, 3vw, 56px);
  }

  #public-game-screen .room-bar h1 {
    font-size: clamp(2.6rem, 5.4vh, 4.4rem);
  }

  #public-game-screen .eyebrow {
    margin-bottom: 4px;
    font-size: clamp(0.85rem, 1.7vh, 1.15rem);
  }

  #public-game-screen .room-mode {
    font-size: clamp(1.8rem, 4vh, 3.2rem);
  }

  #public-game-screen .ghost-button {
    min-height: clamp(50px, 6vh, 64px);
    font-size: clamp(1rem, 1.8vh, 1.25rem);
  }

  #public-game-screen .game-table-layout {
    grid-template-columns: minmax(280px, 0.85fr) minmax(260px, 0.72fr) minmax(360px, 1.43fr);
    gap: clamp(18px, 2vw, 38px);
  }

  #public-game-screen .panel {
    padding: clamp(18px, 2.2vh, 28px) clamp(18px, 1.6vw, 30px);
  }

  #public-game-screen .panel h2 {
    font-size: clamp(1.5rem, 3vh, 2.3rem);
  }

  #public-game-screen .player-list {
    gap: clamp(10px, 1.4vh, 18px);
  }

  #public-game-screen .player-list li {
    padding-bottom: clamp(10px, 1.4vh, 18px);
    font-size: clamp(1.05rem, 2.2vh, 1.65rem);
  }

  #public-game-screen .player-list small,
  #public-game-screen .player-status {
    font-size: clamp(0.85rem, 1.6vh, 1.1rem);
  }

  #public-game-screen .message-list {
    gap: clamp(8px, 1vh, 14px);
  }

  #public-game-screen .message-list li {
    padding: clamp(10px, 1.2vh, 16px);
  }

  #public-game-screen .message-list strong {
    font-size: clamp(0.9rem, 1.7vh, 1.2rem);
  }

  #public-game-screen .message-list span,
  #public-game-screen .empty-message {
    font-size: clamp(1rem, 2vh, 1.45rem);
  }

  #public-game-screen .message-row input,
  #public-game-screen .message-row button {
    min-height: clamp(50px, 6vh, 64px);
    font-size: clamp(1rem, 1.8vh, 1.25rem);
  }

  #public-game-screen img,
  #public-game-screen svg,
  #public-game-screen canvas {
    max-height: 48vh;
  }
}

@media (min-width: 861px) and (max-height: 820px) {
  .host-lobby-stage {
    --host-lobby-deck-width: clamp(
      76px,
      min(13vw, calc((100svh - var(--app-header-height) - 320px) / 4.2)),
      136px
    );
    --host-lobby-qr-size: 300px;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }

  .host-lobby-qr-overlay {
    gap: 8px;
  }

}

@media (max-width: 860px) {
  .home-grid,
  .card-menu-test-layout,
  .game-table-layout,
  .room-bar {
    grid-template-columns: 1fr;
  }

  .card-menu-test-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .card-menu-test-controls {
    position: static;
  }

  .card-menu-test-preview {
    max-height: calc(100svh - 190px);
  }

  .chips-stack-test-row {
    grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
    gap: 12px;
  }

  .chips-stack-test-actions button {
    flex: 1 1 180px;
  }

  .app-header {
    align-items: flex-start;
  }

  .invite-row,
  .message-row {
    grid-template-columns: 1fr;
  }

  #private-game-screen .private-message-panel .message-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #public-game-screen {
    overflow: auto;
    padding: 24px;
  }

  #public-game-screen .room-bar,
  #public-game-screen .game-table-layout {
    grid-template-columns: 1fr;
  }

  .lobby-stage {
    grid-template-areas:
      "welcome"
      "community"
      "actions";
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .lobby-community {
    align-content: start;
  }

  .host-lobby-stage {
    --host-lobby-deck-width: clamp(
      76px,
      min(16vw, calc((100svh - var(--app-header-height) - 320px) / 4.2)),
      132px
    );
    --host-lobby-qr-size: clamp(210px, 34vh, 320px);
    height: calc(100svh - var(--app-header-height));
    min-height: calc(100svh - var(--app-header-height));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    overflow-y: auto;
  }

  .host-lobby-tabletop {
    grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
    gap: 12px;
  }

  .host-lobby-tabletop .host-control-panel {
    padding: 12px;
  }

  .host-lobby-start-action {
    padding: 12px;
  }
}

@media (max-width: 680px) {
  :root {
    --app-header-height: 65px;
  }

  body.is-header-menu-open {
    overflow: hidden;
  }

  .card-deck-test-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: minmax(260px, 1fr);
  }

  .app-header {
    z-index: 20;
    min-height: var(--app-header-height);
    align-items: center;
    flex-direction: row;
    padding: 10px 14px;
  }

  body:has(#private-game-screen:not(.is-hidden)) .app-shell {
    padding: 0;
  }

  #private-game-screen:not(.is-hidden) {
    gap: clamp(6px, 1.2vh, 10px);
  }

  #private-game-screen .room-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  #private-game-screen .room-bar h1 {
    overflow: hidden;
    font-size: 1.45rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #private-game-screen .game-turn-panel {
    gap: 8px;
    padding: 0 8px;
  }

  #private-game-screen .game-action-buttons,
  #private-game-screen .game-color-buttons {
    flex-wrap: nowrap;
  }

  #private-game-screen .private-message-panel {
    gap: 8px;
    padding: 10px 12px;
  }

  #private-game-screen .private-message-panel .panel-heading {
    display: none;
  }

  .app-header::before {
    content: "";
    position: fixed;
    inset: var(--app-header-height) 0 0;
    z-index: 5;
    visibility: hidden;
    background: var(--menu-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 200ms ease;
  }

  .app-header.is-menu-open::before {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .brand {
    min-width: 0;
  }

  .brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-menu-button {
    position: relative;
    z-index: 7;
    display: inline-grid;
    width: 44px;
    min-width: 44px;
    min-height: 42px;
    margin-left: 0;
    place-items: center;
    background: var(--header-control-tint);
    color: var(--header-ink);
    font-size: 1.7rem;
    line-height: 1;
  }

  .header-controls {
    position: fixed;
    top: var(--app-header-height);
    right: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    width: min(88vw, 360px);
    height: 100vh;
    align-items: stretch;
    align-content: start;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 14px;
    overflow-y: auto;
    border-left: 1px solid var(--header-border);
    background: var(--header-control-bg);
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.34);
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), visibility 220ms ease;
  }

  .header-test-navigation {
    width: 100%;
    flex-direction: column;
  }

  .header-test-navigation .ghost-link {
    width: 100%;
    justify-content: center;
  }

  .app-header.is-menu-open .header-controls {
    visibility: visible;
    transform: translateX(0);
  }

  .header-player-name,
  .header-controls .status-pill {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .header-refresh-button,
  .theme-toggle {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 14px;
  }

  .header-control-label {
    display: inline;
  }

  .theme-toggle-label-moon {
    display: none;
  }

  :root[data-theme="light"] .theme-toggle-label-sun {
    display: none;
  }

  :root[data-theme="light"] .theme-toggle-label-moon {
    display: inline;
  }

  .language-picker {
    align-items: center;
    flex-direction: row;
  }

  .language-picker select {
    width: auto;
    min-width: 0;
    flex: 1;
  }

  .language-picker {
    width: 100%;
    align-items: center;
    flex-direction: row;
  }

  .language-picker select {
    width: auto;
    min-width: 0;
    flex: 1;
    min-height: 48px;
  }

  .home-hero {
    min-height: calc(100svh - var(--app-header-height));
    padding: 24px 14px 30px;
  }

  .public-card-state-layout {
    grid-template-columns: minmax(84px, 0.7fr) auto minmax(110px, 1fr);
    gap: 10px;
  }

  .public-direction-indicator {
    width: 64px;
    min-width: 64px;
    min-height: 64px;
    font-size: 3.25rem;
  }

  .home-hero-copy h1 {
    font-size: clamp(2.4rem, 12vw, 4rem);
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-hero,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-hero {
    gap: 0;
    padding: 20px 14px;
    display: block;
    min-height: 0;
    overflow: visible;
  }

  body:has(#home-screen.is-menu-ready:not(.is-hidden)) {
    overflow-y: auto;
  }

  body:has(#home-screen.is-menu-ready:not(.is-hidden)) .app-shell,
  body:has(#home-screen.is-menu-ready:not(.is-hidden)) .home-screen {
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-hero-copy,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-hero-copy,
  .home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu {
    display: none;
  }

  .home-screen.is-menu-ready .home-flow-panels {
    position: relative;
    inset: auto;
    display: grid;
    min-height: 0;
    padding: 0 0 32px;
    pointer-events: none;
  }

  .home-screen.is-menu-ready[data-active-flow="join"] #join-room-form {
    width: min(100%, 360px);
  }

  .home-screen.is-menu-ready[data-active-flow="join"] #join-room-form input {
    width: min(100%, 320px);
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-hero-copy h1,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-hero-copy h1 {
    font-size: 2.25rem;
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-hero-copy p:last-child,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-hero-copy p:last-child {
    display: none;
  }

  .host-lobby-stage {
    --host-lobby-deck-width: clamp(
      76px,
      min(28vw, calc((100svh - var(--app-header-height) - 300px) / 4.2)),
      132px
    );
    height: calc(100svh - var(--app-header-height));
    min-height: calc(100svh - var(--app-header-height));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    overflow-y: auto;
    padding: 12px;
  }

  .host-lobby-tabletop {
    width: 100%;
    grid-template-areas:
      "source source"
      "controls actions";
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .host-lobby-player-decks {
    width: 100%;
    min-height: 0;
  }

  .host-lobby-qr-overlay {
    width: min(var(--host-lobby-qr-size), 72vw);
    padding-block: 12px;
  }

  .host-lobby-start-action,
  .host-lobby-tabletop .host-control-panel {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .app-header {
    align-items: center;
    flex-direction: row;
  }

  .header-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .language-picker {
    align-items: center;
    flex-direction: row;
  }

  .language-picker select {
    width: auto;
    min-width: 0;
    flex: 1;
  }

  .app-shell {
    padding: 14px;
  }

  .host-lobby-tabletop {
    grid-template-areas:
      "source"
      "controls"
      "actions";
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .home-screen.is-menu-ready[data-active-flow="create"] #create-room-form,
  .home-screen.is-menu-ready[data-active-flow="join"] #join-room-form {
    scroll-margin-top: 192px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-header::before,
  .header-controls,
  .card-deck-test-widget,
  .fa-spin,
  .fa-spin-reverse,
  .ready-button-spinner {
    transition: none;
    animation: none;
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu,
  .home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu .playing-card-menu-card.is-selected,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu .playing-card-menu-card.is-selected,
  .home-screen.is-home-menu-revealing .home-card-menu .playing-card-menu-card,
  .home-screen.is-home-menu-revealing .home-brand-logo,
  .home-screen.is-home-menu-revealing .home-hero-copy p:last-child,
  .home-screen.is-menu-ready[data-active-flow="create"] #create-room-form,
  .home-screen.is-menu-ready[data-active-flow="join"] #join-room-form {
    animation: none;
    transition: none;
  }

  .player-hand-widget .playing-card-menu-card.is-newly-dealt {
    animation: none;
  }

  .player-action-bubble {
    transform: none;
    transition: opacity 100ms linear;
  }

  .player-action-bubble.is-pulsing,
  .player-action-bubble.is-fading {
    animation: none;
  }

  .host-lobby-player-slot.is-active-turn .playing-card-deck,
  .playing-card-deck.is-active-turn {
    animation: none;
    filter: drop-shadow(0 0 9px var(--active-turn-glow-focus));
  }

  .host-lobby-card-count.is-score-pulsing {
    animation: none;
  }

  .host-lobby-stage::before,
  .host-lobby-stage::after,
  .host-lobby-qr-overlay {
    animation: none;
    transition: none;
    transform: none;
  }

  .home-screen.is-menu-ready[data-active-flow="create"] .home-card-menu,
  .home-screen.is-menu-ready[data-active-flow="join"] .home-card-menu {
    opacity: 0;
    filter: blur(8px);
    transform: scale(0.92);
  }
}
