:root {
  color-scheme: dark;
  --bg: #0f1218;
  --surface: #171b22;
  --surface-2: #202632;
  --ink: #f4f7fb;
  --muted: #a8b1c2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #d8a84d;
  --danger: #d85f5f;
  --ok: #4fbf8a;
  --blue: #5d8cff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(15, 18, 24, 0.85), rgba(15, 18, 24, 0.95)),
    url("data:image/svg+xml,%3Csvg width='1600' height='900' viewBox='0 0 1600 900' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1600' height='900' fill='%2310151d'/%3E%3Cpath d='M0 650h1600v250H0z' fill='%231b2029'/%3E%3Cpath d='M180 660V220h260v440M520 660V140h360v520M960 660V250h300v410M1320 660V190h180v470' stroke='%23303a4b' stroke-width='18' fill='none'/%3E%3Cpath d='M210 290h190M210 360h190M210 430h190M210 500h190M560 220h280M560 300h280M560 380h280M560 460h280M1000 320h220M1000 400h220M1000 480h220M1350 270h120M1350 350h120M1350 430h120' stroke='%23252d3a' stroke-width='22'/%3E%3Ccircle cx='760' cy='80' r='170' fill='%23332622' opacity='.65'/%3E%3C/svg%3E");
  background-size: cover;
  background-attachment: fixed;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.entry-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: block;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(15, 18, 24, 0.74), rgba(15, 18, 24, 0.94)),
    radial-gradient(circle at 50% 22%, rgba(216, 168, 77, 0.22), transparent 28rem);
  backdrop-filter: blur(14px);
}

.entry-card {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.94);
  box-shadow: var(--shadow);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 22px;
  align-items: stretch;
  min-height: 330px;
}

.home-hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 320px;
  padding: clamp(18px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(216, 168, 77, 0.16), rgba(216, 95, 95, 0.08)),
    rgba(11, 14, 20, 0.72);
}

.home-hero-copy h1 {
  margin: 4px 0 12px;
  font-size: clamp(2.1rem, 6vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.home-hero-copy h1,
.brand h1 {
  position: relative;
  color: #d71920;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 #2a0305,
    0 2px 0 #140102,
    0 0 8px rgba(215, 25, 32, 0.45),
    0 0 18px rgba(80, 0, 0, 0.75);
}

.home-hero-copy h1::after,
.brand h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.18em;
  width: min(100%, 11rem);
  height: 0.2em;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 60%, rgba(118, 0, 0, 0.95) 0 0.08em, transparent 0.09em),
    radial-gradient(circle at 34% 78%, rgba(146, 0, 0, 0.9) 0 0.06em, transparent 0.07em),
    linear-gradient(90deg, rgba(70, 0, 0, 0.1), rgba(200, 0, 0, 0.95), rgba(70, 0, 0, 0.08));
  opacity: 0.88;
  filter: drop-shadow(0 0 4px rgba(150, 0, 0, 0.75));
}

.home-hero-copy p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.home-hero-media {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0b0e14;
}

.home-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-logo {
  background:
    linear-gradient(135deg, rgba(216, 168, 77, 0.2), rgba(216, 95, 95, 0.08)),
    #171b22;
}

.logo-mark {
  color: #15100a;
  background:
    linear-gradient(135deg, #d8a84d, #f0d28c);
  letter-spacing: 0;
}

.developer-credit {
  margin: 12px 0 0;
  color: var(--accent);
  font-weight: 900;
}

.home-hero-copy .developer-credit {
  margin-top: 18px;
  color: var(--accent);
}

.rights-note {
  margin-top: 6px;
  font-size: 0.78rem;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
  margin-top: 18px;
}

.home-showcase,
.login-panel,
.rules-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 18, 24, 0.62);
}

.home-showcase,
.login-panel {
  padding: 16px;
}

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

.screenshot-grid figure {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.screenshot-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.screenshot-grid figcaption {
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.rules-preview {
  margin-top: 14px;
  padding: 16px;
}

.rules-preview h2 {
  margin: 0 0 10px;
}

.rules-preview ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.48;
}

.rules-preview li + li {
  margin-top: 7px;
}

.rules-details {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.rules-details.hidden {
  display: none;
}

.rules-details ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.rules-details li + li {
  margin-top: 7px;
}

.rules-sim {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.rules-sim img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
}

.rules-sim span {
  color: var(--accent);
  font-weight: 900;
}

.card-guide {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 18, 24, 0.62);
}

.card-guide-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.card-guide-tabs button {
  min-height: 32px;
  padding-inline: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.card-guide-tabs button.active {
  color: #10141b;
  background: var(--accent);
}

.card-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.guide-card img {
  width: 58px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
}

.guide-card strong,
.guide-card span,
.guide-card p {
  display: block;
}

.guide-card strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.guide-card span {
  margin-top: 2px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
}

.guide-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.entry-brand {
  min-height: 88px;
}

.entry-copy {
  color: var(--muted);
  line-height: 1.5;
}

.account-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
}

.account-tabs button {
  flex: 1;
}

.account-tabs button.active {
  color: #10141b;
  background: var(--accent);
}

.site-auth-form,
.add-user-form {
  display: grid;
  gap: 8px;
}

.site-auth-form {
  margin-bottom: 12px;
}

.add-user-form {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 10px;
}

.permission-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.firebase-test-button {
  width: 100%;
  margin-top: 10px;
}

.offline-entry {
  width: 100%;
  margin-top: 12px;
  color: #06150e;
  border: 0;
  background: var(--ok);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button[data-icon]::before {
  content: attr(data-icon);
  width: 1.15em;
  display: inline-grid;
  place-items: center;
  font-weight: 900;
  line-height: 1;
}

.compact-button {
  width: auto;
  min-height: 30px;
  margin: 0;
}

.app-shell {
  width: calc(100vw - 10px);
  height: calc(100dvh - 10px);
  margin: 5px auto;
  display: grid;
  grid-template-columns: clamp(205px, 12vw, 228px) minmax(0, 1fr) clamp(286px, 16vw, 310px);
  gap: 6px;
  overflow: hidden;
}

.sidebar,
.right-rail,
.game-surface {
  min-width: 0;
}

.sidebar,
.right-rail {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: calc(100dvh - 10px);
  overflow: hidden;
}

.panel,
.game-surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 8px;
}

.game-surface {
  padding: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.brand,
.profile-row,
.section-title,
.topbar,
.top-actions,
.stats-row,
.action-row,
.segmented {
  display: flex;
  align-items: center;
}

.brand {
  min-height: 62px;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(96, 0, 0, 0.36), rgba(18, 22, 28, 0.88)),
    radial-gradient(circle at 12% 22%, rgba(215, 25, 32, 0.28), transparent 5rem);
  border: 1px solid var(--line);
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #111827;
  font-weight: 900;
  background: var(--accent);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #f7f3e8;
  background:
    radial-gradient(circle at 50% 50%, #d71920 0 36%, #f7f3e8 37% 44%, #111827 45% 58%, #d71920 59% 100%);
  box-shadow: 0 0 16px rgba(215, 25, 32, 0.32);
  font-size: 0.9rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.eyebrow,
.small,
.status,
label,
.rules-panel li {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 0.84rem;
  letter-spacing: 0;
}

.small,
.status {
  margin-bottom: 0;
  font-size: 0.72rem;
  line-height: 1.45;
}

.hidden {
  display: none;
}

body.offline-mode .online-panel,
body.offline-mode [data-session="friends"],
body.offline-mode [data-session="matchmaking"],
body.offline-mode #friend-list,
body.offline-mode .chat-panel,
body.offline-mode .availability-toggle,
body.offline-mode .logout-button {
  display: none;
}

body:not(.offline-mode) #fill-room {
  display: none;
}

body:not(.offline-mode) .offline-home-button {
  display: none;
}

button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-2);
}

button {
  min-height: 32px;
  padding: 0 8px;
  font-weight: 800;
  font-size: 0.78rem;
}

button:hover,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(216, 168, 77, 0.55);
  outline-offset: 2px;
}

label {
  display: block;
  margin: 7px 0 4px;
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.primary-button,
.start-button {
  width: 100%;
  margin-top: 6px;
  border: 0;
}

.primary-button {
  color: #10141b;
  background: var(--accent);
}

.start-button {
  color: #06150e;
  background: var(--ok);
}

.ghost-button,
.voice-button,
.tutorial-button,
.sound-button {
  min-height: 30px;
  padding-inline: 8px;
  color: var(--muted);
  background: transparent;
}

.tutorial-button {
  color: #10141b;
  background: rgba(79, 191, 138, 0.92);
}

.sound-button[aria-pressed="true"] {
  color: #10141b;
  background: var(--accent);
}

.volume-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(108px, 1fr));
  gap: 6px;
  min-width: min(340px, 35vw);
}

.volume-controls label {
  display: grid;
  gap: 4px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.volume-controls span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.volume-controls input {
  width: 100%;
  accent-color: var(--accent);
}

.section-title,
.topbar,
.stats-row {
  justify-content: space-between;
  gap: 8px;
}

.profile-row {
  gap: 9px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
  font-size: 0.66rem;
}

.stats-row span {
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
}

.stats-row strong {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
}

.availability-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--ink);
  font-size: 0.74rem;
}

.availability-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--ok);
}

.logout-button {
  width: 100%;
  margin-top: 6px;
}

.segmented {
  margin-top: 8px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.segmented button {
  flex: 1;
  min-height: 30px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: #10141b;
  background: var(--accent);
}

.friend-list,
.invitation-list {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

#site-users,
#friend-list,
#invitation-list {
  max-height: 116px;
  overflow: hidden auto;
}

.friend,
.invitation-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.friend span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  overflow-wrap: anywhere;
}

.friend button {
  min-height: 26px;
  max-width: 74px;
  padding-inline: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invite-actions {
  display: flex;
  gap: 6px;
}

.invite-actions button {
  min-height: 32px;
  padding-inline: 9px;
}

.friend.offline {
  opacity: 0.48;
}

.turn-pill {
  min-width: 84px;
  padding: 8px 10px;
  border-radius: 999px;
  text-align: center;
  color: #10141b;
  font-weight: 900;
  background: var(--accent);
}

.top-actions {
  gap: 6px;
}

.board {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(150px, 190px) minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(216, 168, 77, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(rgba(17, 22, 29, 0.46), rgba(17, 22, 29, 0.74)),
    url("../assets/brand/umbrella-main-board.png") center / contain no-repeat,
    linear-gradient(90deg, rgba(216, 168, 77, 0.05), rgba(79, 191, 138, 0.05)),
    radial-gradient(circle at 50% 40%, rgba(216, 168, 77, 0.12), transparent 34rem),
    #11161d;
  background-origin: border-box;
  background-clip: border-box;
  overflow: auto;
}

@media (min-width: 861px) {
  .board {
    grid-template-rows: minmax(110px, 136px) minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
    overflow: hidden;
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .player-card {
    padding: 6px;
  }

  .portrait {
    height: 42px;
    margin-bottom: 5px;
  }

  .player-card p {
    min-height: 20px;
    font-size: 0.62rem;
  }

  .health-bar {
    height: 8px;
    margin: 6px 0;
  }

  .player-meta {
    gap: 4px;
    font-size: 0.64rem;
  }
}

@media (min-width: 861px) and (min-height: 700px) {
  .right-rail {
    grid-template-rows: minmax(420px, 48dvh) auto minmax(0, 1fr);
  }
}

@media (min-width: 861px) and (max-height: 699px) {
  .right-rail {
    grid-template-rows: minmax(220px, 36dvh) auto minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  .right-rail {
    grid-template-rows: minmax(96px, 34dvh) auto minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (min-width: 1001px) and (min-height: 541px) and (max-width: 1368px) and (max-height: 1030px) {
  .right-rail {
    grid-template-rows: minmax(180px, 34dvh) auto minmax(0, 1fr);
  }
}

@media (min-width: 861px) {
  .play-area {
    grid-template-columns: clamp(180px, 19vw, 280px) minmax(0, 1fr);
  }

  .mansion-row {
    grid-template-rows: minmax(132px, 1fr) auto;
  }

  .deck-stack {
    min-height: 132px;
  }

  .mansion-card,
  .deck-card {
    width: min(164px, 90%);
  }

  .mansion-card.card-face {
    max-height: none;
    min-height: 0;
    height: auto;
    aspect-ratio: 2.5 / 3.5;
  }

  .dice-roll-panel {
    min-height: 34px;
    margin-top: 4px;
    padding: 4px 6px;
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-result {
    padding: 3px;
  }

  .dice-result strong {
    width: 24px;
    height: 24px;
    font-size: 0.84rem;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .board {
    grid-template-rows: clamp(72px, 12dvh, 104px) minmax(0, 1fr);
  }

  .table-grid .player-card {
    min-height: 62px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 52px;
  }

  .table-grid .character-read-btn,
  .table-grid .player-card > span {
    display: none;
  }

  .mansion-row {
    grid-template-rows: minmax(112px, 1fr) auto;
  }

  .deck-stack {
    min-height: 112px;
  }

  .mansion-card,
  .deck-card {
    width: min(136px, 92%);
  }

  .mansion-card.card-face {
    max-height: none;
    min-height: 0;
    height: auto;
    aspect-ratio: 2.5 / 3.5;
  }

  .turn-command {
    min-height: 21px;
    height: 21px;
  }
}

/* Final anti-overlap layout shared by online/offline, desktop and mobile. */
.controls-panel {
  isolation: isolate;
}

.controls-panel > *,
.current-hero,
.live-trackers,
.hand,
.player-card-zones,
.action-picker,
.weapon-picker,
.action-row,
.dice-roll-panel,
.turn-footer {
  min-width: 0;
  position: relative;
}

.current-hero {
  z-index: 1;
  overflow: hidden;
}

.current-hero .portrait {
  align-self: stretch;
  max-height: 100%;
  overflow: hidden;
}

.live-trackers {
  z-index: 2;
  align-self: stretch;
}

.live-trackers div,
.hand .card-face {
  overflow: hidden;
}

.hand {
  z-index: 1;
  align-self: stretch;
}

.mansion-card.has-card-image .card-copy {
  display: none;
}

@media (min-width: 861px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(42px, auto)
      minmax(30px, auto)
      minmax(74px, 1fr)
      minmax(42px, auto)
      minmax(54px, auto)
      minmax(44px, auto)
      minmax(34px, auto)
      minmax(28px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .current-hero,
  .live-trackers {
    margin-bottom: 0;
  }

  .mansion-card,
  .deck-card {
    width: min(178px, 94%);
  }

  .mansion-card.card-face {
    max-height: none;
    height: auto;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(34px, auto)
      minmax(26px, auto)
      minmax(58px, 1fr)
      minmax(38px, auto)
      minmax(44px, auto)
      minmax(36px, auto)
      minmax(28px, auto)
      minmax(24px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .mansion-card,
  .deck-card {
    width: min(150px, 94%);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  .play-area {
    grid-template-columns: clamp(108px, 21vw, 136px) minmax(0, 1fr);
  }

  .mansion-panel .section-title span {
    font-size: 0.58rem;
    line-height: 1;
  }

  .deck-stack {
    min-height: 126px;
  }

  .mansion-card,
  .deck-card {
    width: min(98px, 92%);
  }

  .mansion-card {
    min-height: 136px;
  }

  .controls-panel {
    grid-template-rows: 26px 20px minmax(50px, 1fr) 32px 28px 30px 30px minmax(0, 26px);
  }

  .current-hero {
    max-height: 26px;
  }

  .current-hero .portrait {
    width: 22px;
    height: 22px;
    min-height: 22px;
  }

  .live-trackers {
    max-height: 20px;
    overflow: hidden;
  }

  .hand {
    max-height: 78px;
    overflow: hidden auto;
  }
}

@media (orientation: landscape) and (max-width: 760px) and (max-height: 430px) {
  .play-area {
    grid-template-columns: clamp(96px, 20vw, 118px) minmax(0, 1fr);
  }

  .mansion-card,
  .deck-card {
    width: min(86px, 92%);
  }

  .mansion-card {
    min-height: 120px;
  }
}

/* Final anti-overlap layout shared by online/offline, desktop and mobile. */
.controls-panel {
  isolation: isolate;
}

.controls-panel > *,
.current-hero,
.live-trackers,
.hand,
.player-card-zones,
.action-picker,
.weapon-picker,
.action-row,
.dice-roll-panel,
.turn-footer {
  min-width: 0;
  position: relative;
}

.current-hero {
  z-index: 1;
  overflow: hidden;
}

.current-hero .portrait {
  align-self: stretch;
  max-height: 100%;
  overflow: hidden;
}

.live-trackers {
  z-index: 2;
  align-self: stretch;
}

.live-trackers div {
  overflow: hidden;
}

.hand {
  z-index: 1;
  align-self: stretch;
}

.hand .card-face {
  max-width: 100%;
  overflow: hidden;
}

.mansion-card.has-card-image .card-copy {
  display: none;
}

@media (min-width: 861px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(42px, auto)
      minmax(30px, auto)
      minmax(74px, 1fr)
      minmax(42px, auto)
      minmax(54px, auto)
      minmax(44px, auto)
      minmax(34px, auto)
      minmax(28px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .current-hero {
    margin-bottom: 0;
  }

  .live-trackers {
    margin-bottom: 0;
  }

  .mansion-card,
  .deck-card {
    width: min(178px, 94%);
  }

  .mansion-card.card-face {
    max-height: none;
    height: auto;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(34px, auto)
      minmax(26px, auto)
      minmax(58px, 1fr)
      minmax(38px, auto)
      minmax(44px, auto)
      minmax(36px, auto)
      minmax(28px, auto)
      minmax(24px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .mansion-card,
  .deck-card {
    width: min(150px, 94%);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  .play-area {
    grid-template-columns: clamp(108px, 21vw, 136px) minmax(0, 1fr);
  }

  .mansion-panel .section-title span {
    font-size: 0.58rem;
    line-height: 1;
  }

  .deck-stack {
    min-height: 126px;
  }

  .mansion-card,
  .deck-card {
    width: min(98px, 92%);
  }

  .mansion-card {
    min-height: 136px;
  }

  .controls-panel {
    grid-template-rows: 26px 20px minmax(50px, 1fr) 32px 28px 30px 30px minmax(0, 26px);
  }

  .current-hero {
    max-height: 26px;
  }

  .current-hero .portrait {
    height: 22px;
    min-height: 22px;
    width: 22px;
  }

  .live-trackers {
    max-height: 20px;
    overflow: hidden;
  }

  .hand {
    max-height: 78px;
    overflow: hidden auto;
  }
}

@media (orientation: landscape) and (max-width: 760px) and (max-height: 430px) {
  .play-area {
    grid-template-columns: clamp(96px, 20vw, 118px) minmax(0, 1fr);
  }

  .mansion-card,
  .deck-card {
    width: min(86px, 92%);
  }

  .mansion-card {
    min-height: 120px;
  }
}

@media (min-width: 861px) {
  .play-area {
    grid-template-columns: clamp(180px, 19vw, 280px) minmax(0, 1fr);
  }

  .mansion-row {
    grid-template-rows: minmax(132px, 1fr) auto;
  }

  .deck-stack {
    min-height: 132px;
  }

  .mansion-card,
  .deck-card {
    width: min(164px, 90%);
  }

  .dice-roll-panel {
    min-height: 34px;
    margin-top: 4px;
    padding: 4px 6px;
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-result {
    padding: 3px;
  }

  .dice-result strong {
    width: 24px;
    height: 24px;
    font-size: 0.84rem;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .board {
    grid-template-rows: clamp(72px, 12dvh, 104px) minmax(0, 1fr);
  }

  .table-grid .player-card {
    min-height: 62px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 52px;
  }

  .table-grid .character-read-btn,
  .table-grid .player-card > span {
    display: none;
  }

  .mansion-row {
    grid-template-rows: minmax(112px, 1fr) auto;
  }

  .deck-stack {
    min-height: 112px;
  }

  .mansion-card,
  .deck-card {
    width: min(136px, 92%);
  }

  .turn-command {
    min-height: 21px;
    height: 21px;
  }
}

@media (min-width: 861px) {
  .play-area {
    grid-template-columns: clamp(180px, 19vw, 280px) minmax(0, 1fr);
  }

  .mansion-row {
    grid-template-rows: minmax(132px, 1fr) auto;
  }

  .deck-stack {
    min-height: 132px;
  }

  .mansion-card,
  .deck-card {
    width: min(164px, 90%);
  }

  .dice-roll-panel {
    min-height: 34px;
    margin-top: 4px;
    padding: 4px 6px;
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-result {
    padding: 3px;
  }

  .dice-result strong {
    width: 24px;
    height: 24px;
    font-size: 0.84rem;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .board {
    grid-template-rows: clamp(72px, 12dvh, 104px) minmax(0, 1fr);
  }

  .table-grid .player-card {
    min-height: 62px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 52px;
  }

  .table-grid .character-read-btn,
  .table-grid .player-card > span {
    display: none;
  }

  .mansion-row {
    grid-template-rows: minmax(112px, 1fr) auto;
  }

  .deck-stack {
    min-height: 112px;
  }

  .mansion-card,
  .deck-card {
    width: min(136px, 92%);
  }

  .turn-command {
    min-height: 21px;
    height: 21px;
  }
}

@media (min-width: 861px) {
  .board {
    grid-template-rows: clamp(82px, 13dvh, 122px) minmax(0, 1fr);
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
  }

  .table-grid .player-card {
    min-height: 78px;
    grid-template-columns: clamp(44px, 18%, 68px) minmax(0, 1fr);
    column-gap: 5px;
    padding: 5px;
  }

  .table-grid .player-card .portrait {
    min-height: 64px;
  }

  .table-grid .player-card > span {
    font-size: clamp(0.5rem, 0.62vw, 0.64rem);
    line-height: 1.15;
  }

  .table-grid .character-read-btn {
    min-height: 18px;
    height: 18px;
    padding-inline: 6px;
    font-size: 0.5rem;
  }

  .table-grid .player-meta {
    font-size: clamp(0.5rem, 0.6vw, 0.62rem);
  }

  .play-area {
    grid-template-columns: clamp(210px, 20vw, 300px) minmax(0, 1fr);
  }

  .mansion-card {
    width: min(176px, 88%);
  }

  .deck-card {
    width: min(176px, 86%);
  }

  .dice-roll-panel {
    min-height: 34px;
    margin-top: 4px;
    padding: 4px 6px;
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-roll-panel .section-title {
    margin: 0;
    align-items: center;
  }

  .dice-roll-panel .section-title h2 {
    font-size: 0.68rem;
  }

  #dice-roll-status {
    font-size: 0.64rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dice-roll-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .dice-result {
    gap: 2px;
    padding: 3px;
  }

  .dice-result strong {
    width: 24px;
    height: 24px;
    font-size: 0.84rem;
  }

  .dice-result span {
    font-size: 0.54rem;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .table-grid .player-card {
    min-height: 64px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 54px;
  }

  .table-grid .character-read-btn,
  .table-grid .player-card > span {
    display: none;
  }

  .table-grid .player-name-row strong {
    font-size: 0.62rem;
  }

  .table-grid .player-name-row em {
    padding: 2px 5px;
    font-size: 0.52rem;
  }

  .table-grid .health-bar {
    height: 5px;
    margin: 3px 0;
  }

  .table-grid .player-meta {
    font-size: 0.5rem;
  }

  .mansion-card {
    width: min(154px, 90%);
  }

  .deck-card {
    width: min(154px, 88%);
  }

  .action-row {
    gap: 3px;
    padding: 3px;
  }

  .turn-command {
    min-height: 22px;
    height: 22px;
    font-size: 0.56rem;
  }
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  min-height: 0;
}

.player-card {
  min-height: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    #171d25;
  overflow: hidden;
}

.player-card.active {
  border-color: rgba(216, 168, 77, 0.75);
}

.table-grid .player-card {
  display: grid;
  grid-template-columns: clamp(68px, 22%, 92px) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto;
  column-gap: 8px;
  min-height: 104px;
}

.table-grid .player-card .portrait {
  grid-row: 1 / -1;
  width: 100%;
  height: 100%;
  min-height: 88px;
  margin: 0;
  background: rgba(8, 10, 14, 0.78);
}

.table-grid .player-card .portrait img {
  object-fit: contain;
  background: rgba(8, 10, 14, 0.78);
}

.table-grid .player-name-row,
.table-grid .player-card > span,
.table-grid .character-read-btn,
.table-grid .health-bar,
.table-grid .player-meta {
  grid-column: 2;
}

.character-read-btn {
  justify-self: start;
  min-height: 22px;
  height: 22px;
  margin: 2px 0 4px;
  padding: 0 8px;
  border: 1px solid rgba(216, 168, 77, 0.38);
  border-radius: 999px;
  color: #f6d47a;
  background: rgba(216, 168, 77, 0.1);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
}

.character-read-btn:hover {
  border-color: rgba(216, 168, 77, 0.72);
  background: rgba(216, 168, 77, 0.18);
}

.portrait {
  height: 58px;
  border-radius: 8px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #334155, #111827);
}

.portrait img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait::before,
.portrait::after {
  content: "";
  position: absolute;
  inset: auto;
  display: block;
}

.portrait::before {
  width: 52px;
  height: 52px;
  left: 50%;
  top: 13px;
  transform: translateX(-50%);
  border-radius: 50% 50% 44% 44%;
  background: #d1b089;
  box-shadow:
    -18px 18px 0 -8px rgba(17, 24, 39, 0.95),
    18px 18px 0 -8px rgba(17, 24, 39, 0.95);
}

.portrait::after {
  width: 112px;
  height: 52px;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  border-radius: 46% 46% 0 0;
  background: #263244;
}

.portrait:has(img)::before,
.portrait:has(img)::after {
  display: none;
}

.portrait span {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 2;
  padding: 3px 7px;
  border-radius: 999px;
  color: #10141b;
  background: rgba(216, 168, 77, 0.92);
  font-size: 0.72rem;
  font-weight: 900;
}

.portrait-scout {
  background: linear-gradient(135deg, #2f4858, #151923);
}

.portrait-medic {
  background: linear-gradient(135deg, #375a4d, #151923);
}

.portrait-tactician {
  background: linear-gradient(135deg, #4d4b70, #151923);
}

.portrait-warden {
  background: linear-gradient(135deg, #65413d, #151923);
}

.portrait-agent {
  background: linear-gradient(135deg, #314a66, #151923);
}

.portrait-operator {
  background: linear-gradient(135deg, #5d5133, #151923);
}

.player-name-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.player-name-row em {
  padding: 3px 6px;
  border-radius: 999px;
  color: #10141b;
  background: var(--accent);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}

.player-card p {
  min-height: 28px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.25;
}

.health-bar {
  height: 9px;
  margin: 10px 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.health-bar span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.player-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.play-area {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.table-zone {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.78);
  padding: 8px;
  overflow: auto;
}

.mansion-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.mansion-row {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
}

.deck-stack {
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
}

.deck-card {
  position: absolute;
  width: min(150px, 82%);
  aspect-ratio: 2.5 / 3.5;
  border: 1px solid rgba(216, 168, 77, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(rgba(36, 32, 42, 0.18), rgba(36, 32, 42, 0.18)),
    url("../assets/cards/ReversoMansion.png") center / cover,
    #24202a;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.24);
}

.deck-card:nth-child(1) {
  transform: rotate(-6deg) translate(-7px, 5px);
}

.deck-card:nth-child(2) {
  transform: rotate(4deg) translate(8px, 2px);
}

.mansion-card {
  z-index: 1;
  width: min(150px, 84%);
  min-height: 0;
  aspect-ratio: 2.5 / 3.5;
  display: grid;
  padding: 10px;
  transition: transform 0.3s ease;
}

/* Flip-back effect when deck closes at end of turn */
.mansion-card.card-back {
  animation: deckClose 0.5s ease-in-out both;
}

@keyframes deckClose {
  0%   { transform: rotateY(0deg) scale(1); }
  40%  { transform: rotateY(50deg) scale(0.95); opacity: 0.7; }
  70%  { transform: rotateY(90deg) scale(0.9); opacity: 0.3; }
  85%  { transform: rotateY(90deg) scale(0.9); opacity: 0; }
  86%  { transform: rotateY(-90deg) scale(0.9); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.mansion-card.card-face.has-card-image {
  grid-template-rows: minmax(0, 1fr);
  padding: 4px;
}

.mansion-card.has-card-image .card-art {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 6px;
}

.mansion-card.has-card-image .card-art img {
  object-fit: contain;
  background: #080a0e;
  filter: brightness(1.2) contrast(1.1);
}

.mansion-card.has-card-image .card-copy {
  grid-area: 1 / 1;
  z-index: 2;
  align-self: end;
  margin: 4px;
  padding: 5px;
  border-radius: 6px;
  background: rgba(6, 8, 12, 0.86);
  box-shadow: 0 -8px 22px rgba(0, 0, 0, 0.35);
}

.card-mark {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #10141b;
  font-size: 2.2rem;
  font-weight: 900;
  background: var(--accent);
}

.discard-slot {
  min-height: 66px;
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.discard-slot strong,
.discard-slot small,
.discard-slot span {
  display: block;
}

@media (min-width: 861px) {
  .play-area {
    grid-template-columns: clamp(190px, 18vw, 220px) minmax(0, 1fr);
    gap: 6px;
  }

  .table-zone {
    padding: 6px;
    overflow: hidden;
  }

  .mansion-row {
    gap: 6px;
  }

  .deck-card {
    width: min(120px, 78%);
  }

  .mansion-card {
    width: min(122px, 80%);
    padding: 8px;
  }

  .card-mark {
    width: 54px;
    height: 54px;
    font-size: 1.6rem;
  }

  .discard-slot {
    min-height: 50px;
    padding: 7px;
  }
}

.controls-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto auto;
}

.current-hero {
  min-height: 76px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid rgba(216, 168, 77, 0.22);
  border-radius: 8px;
  background: rgba(216, 168, 77, 0.06);
}

.current-hero .portrait {
  width: 64px;
  height: auto;
  aspect-ratio: 2.5 / 3.5;
  margin: 0;
}

.current-hero strong,
.current-hero span {
  display: block;
}

.current-hero span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.hero-read-btn {
  margin-top: 4px;
}

@media (min-width: 861px) {
  .controls-panel {
    grid-template-rows: auto auto auto minmax(0, 0.9fr) auto auto auto auto;
  }

  .current-hero {
    min-height: 54px;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 6px;
    padding: 6px;
  }

  .current-hero .portrait {
    width: 46px;
  }

  .current-hero strong {
    font-size: 0.82rem;
  }

  .current-hero span {
    margin-top: 2px;
    font-size: 0.64rem;
  }

  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 5px;
  }

  .tracker-icon {
    width: 22px;
    height: 22px;
  }

  .live-trackers div {
    padding: 5px 3px 3px;
    border-radius: 6px;
  }

  .live-trackers div::before {
    left: 6px;
    width: 12px;
    height: 12px;
    font-size: 0.5rem;
  }

  .live-trackers span {
    font-size: 0.44rem;
  }

  .live-trackers strong {
    font-size: 0.68rem;
  }

  .hand {
    grid-template-columns: repeat(5, minmax(56px, 1fr));
    gap: 5px;
    overflow: hidden;
  }

  .action-picker,
  .weapon-picker,
  .played-row {
    margin-top: 6px;
    padding-top: 6px;
  }

  .action-picker {
    padding: 6px;
  }

  .weapon-list {
    grid-template-columns: repeat(4, minmax(54px, 1fr));
    gap: 5px;
  }

  .played-cards {
    min-height: 48px;
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    overflow: hidden;
  }
}

.live-trackers {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

.tracker-icon {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  margin: 0 auto 3px;
  flex-shrink: 0;
}

.live-trackers div {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px 4px;
  border: 1px solid rgba(216, 168, 77, 0.18);
  border-radius: 8px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(216, 168, 77, 0.09), rgba(79, 191, 138, 0.045)),
    rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.live-trackers .tracker-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* Pseudo-elementos eliminados para limpiar la interfaz */

.live-trackers span,
.live-trackers strong {
  display: block;
  text-align: center;
}

.live-trackers span {
  color: var(--muted);
  font-size: 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.live-trackers strong {
  margin-top: 1px;
  font-size: 0.78rem;
  line-height: 1;
}

.hand {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 7px;
  min-height: 0;
  align-items: end;
  overflow: auto;
}

.player-card-zones {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.2fr);
  gap: 8px;
  min-height: 74px;
}

.player-zone {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.42);
}

.compact-title {
  margin-bottom: 5px;
}

.compact-title h2,
.compact-title span {
  font-size: 0.72rem;
}

.player-stack-zone,
.player-discard-zone {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.mini-stack {
  position: relative;
  width: 68px;
  height: 46px;
}

.mini-back-card {
  position: absolute;
  inset: 4px 12px 2px 4px;
  border: 1px solid rgba(216, 168, 77, 0.45);
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(71, 25, 25, 0.8), rgba(18, 23, 32, 0.95)),
    url("../assets/cards/ReversoRecursos.png") center / cover;
  transform: translateX(calc(var(--i) * 5px)) translateY(calc(var(--i) * -1px)) rotate(calc(var(--i) * 1deg));
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.35);
}

.mini-stack span {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 22px;
  padding: 3px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #11151b;
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.mini-stack.dealing .mini-back-card:last-of-type {
  animation: dealToHand 0.58s ease-out both;
}

/* Shuffle animation when discard is recycled into deck */
@keyframes shuffleCard {
  0%   { transform: translateX(calc(var(--i) * 5px)) translateY(calc(var(--i) * -1px)) rotate(calc(var(--i) * 1deg)); }
  20%  { transform: translateX(calc(var(--i) * 5px - 14px)) translateY(calc(var(--i) * -1px - 6px)) rotate(calc(var(--i) * 1deg - 12deg)); }
  40%  { transform: translateX(calc(var(--i) * 5px + 14px)) translateY(calc(var(--i) * -1px + 4px)) rotate(calc(var(--i) * 1deg + 10deg)); }
  60%  { transform: translateX(calc(var(--i) * 5px - 8px)) translateY(calc(var(--i) * -1px - 3px)) rotate(calc(var(--i) * 1deg - 6deg)); }
  80%  { transform: translateX(calc(var(--i) * 5px + 4px)) translateY(calc(var(--i) * -1px + 2px)) rotate(calc(var(--i) * 1deg + 3deg)); }
  100% { transform: translateX(calc(var(--i) * 5px)) translateY(calc(var(--i) * -1px)) rotate(calc(var(--i) * 1deg)); }
}

.mini-stack.shuffling .mini-back-card {
  animation: shuffleCard 0.75s ease-in-out both;
  animation-delay: calc(var(--i) * 0.06s);
}

.mini-stack.shuffling .mini-back-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: rgba(216, 168, 77, 0.18);
  animation: shuffleGlow 0.75s ease-in-out both;
}

@keyframes shuffleGlow {
  0%, 100% { opacity: 0; }
  40%       { opacity: 1; }
}

.empty-stack {
  color: var(--muted);
  font-size: 0.72rem;
}

.empty-stack strong {
  display: block;
  color: var(--text);
}

.discard-mini-card {
  width: 54px;
  height: 48px;
  min-height: 48px;
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px;
}

.discard-mini-card .card-copy small,
.discard-mini-card .card-copy span {
  display: none;
}

.discard-mini-card .card-copy strong {
  font-size: 0.52rem;
}

.used-card {
  opacity: 0.42;
  filter: grayscale(0.8);
}

@keyframes dealToHand {
  from {
    transform: translateX(0) translateY(0) rotate(0deg);
  }
  to {
    transform: translateX(180px) translateY(-70px) rotate(8deg);
    opacity: 0;
  }
}

@media (max-width: 860px) {
  .player-card-zones {
    grid-template-columns: 1fr 1fr;
    min-height: 58px;
  }

  .player-zone {
    padding: 5px;
  }

  .player-stack-zone,
  .player-discard-zone {
    min-height: 38px;
  }

  .mini-stack {
    width: 54px;
    height: 36px;
  }

  .discard-mini-card {
    width: 44px;
    height: 38px;
    min-height: 38px;
  }

  .discard-mini-card .card-copy strong {
    font-size: 0.46rem;
  }
}

.action-picker {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid rgba(216, 168, 77, 0.28);
  border-radius: 8px;
  background: rgba(216, 168, 77, 0.07);
}

.action-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 184px));
  gap: 7px;
  align-items: start;
  justify-content: start;
}

.action-card-list .status {
  grid-column: 1 / -1;
}

.action-choice {
  width: 100%;
  position: relative;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.action-card-list .action-select-card {
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 5px;
}

.action-card-list .action-select-card .card-art {
  min-height: 0;
  height: 100%;
}

.action-card-list .action-select-card .card-copy {
  justify-content: center;
  min-height: 0;
}

.action-card-list .action-select-card .card-copy small {
  font-size: 0.5rem;
}

.action-card-list .action-select-card .card-copy strong {
  font-size: 0.64rem;
}

.action-card-list .action-select-card .card-copy span {
  display: block;
  font-size: 0.5rem;
}

.action-card-list .action-select-card .action-effect {
  display: none;
}

.action-choice::after,
.action-hand-card::after {
  content: "Acción";
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #10141b;
  background: var(--accent);
  font-size: 0.62rem;
  font-weight: 900;
}

.action-effect {
  display: block;
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 4px;
  border-radius: 6px;
  color: #f7f3e8;
  background: rgba(10, 12, 16, 0.82);
  font-size: 0.68rem;
  line-height: 1.15;
}

.played-row {
  min-height: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.weapon-picker {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.weapon-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 6px;
}

.weapon-list .card-face {
  width: 100%;
}

.weapon-list .status {
  grid-column: 1 / -1;
}

.played-cards {
  min-height: 64px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 184px));
  gap: 6px;
  align-items: start;
  justify-content: start;
  overflow: hidden auto;
}

.played-cards .played-turn-card {
  width: 100%;
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: 1fr;
  gap: 5px;
  opacity: 0.86;
}

.played-cards .played-turn-card .card-art {
  min-height: 0;
  height: 100%;
}

.played-cards .played-turn-card .card-copy {
  justify-content: center;
  min-height: 0;
}

.played-cards .played-turn-card .card-copy small {
  font-size: 0.5rem;
}

.played-cards .played-turn-card .card-copy strong {
  font-size: 0.64rem;
}

.played-cards .played-turn-card .card-copy span {
  display: block;
  font-size: 0.5rem;
}

.target-row {
  display: none;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.target-row.active {
  display: grid;
}

.target-row label {
  margin: 0;
}

.resource-grid {
  max-height: 330px;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.resource-grid.collapsed {
  display: none;
}

.resource-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.resource-types button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.resource-types button.active {
  color: #10141b;
  background: var(--accent);
}

.resource-group {
  display: grid;
  gap: 8px;
}

.resource-group h3 {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.resource-group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.resource-card {
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.resource-card button {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.resource-card .card-face {
  width: 100%;
  box-shadow: none;
}

.resource-card footer {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.resource-card .remaining {
  color: var(--accent);
  font-weight: 900;
}

.resource-card.empty {
  opacity: 0.45;
}

.resource-card.empty button {
  cursor: not-allowed;
}

.card-face {
  min-height: 0;
  aspect-ratio: 2.5 / 3.5;
  display: grid;
  grid-template-rows: 58% 42%;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #232a36;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.mansion-card.card-face {
  display: grid !important;
}

.card-face:hover {
  transform: translateY(-4px);
}

.selected-card {
  border-color: var(--ok);
  box-shadow:
    0 0 15px rgba(79, 191, 138, 0.4),
    0 0 0 2px rgba(79, 191, 138, 0.45),
    0 14px 30px rgba(0, 0, 0, 0.35);
}

.card-art {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.28), transparent 2rem),
    linear-gradient(135deg, #3c4657, #151923);
}

.card-art img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(1.2) contrast(1.1);
  transition: filter 0.3s ease;
}

.card-face:hover .card-art img {
  filter: brightness(1.4) contrast(1.15) saturate(1.1);
}

.card-art:has(img)::before,
.card-art:has(img)::after {
  display: none;
}

.card-art::before,
.card-art::after {
  content: "";
  position: absolute;
  display: block;
}

.card-art::before {
  width: 58%;
  height: 58%;
  border: 5px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  transform: rotate(-18deg);
}

.card-art::after {
  width: 78%;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  transform: rotate(-24deg);
}

.card-art span {
  z-index: 1;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #10141b;
  background: rgba(216, 168, 77, 0.94);
  font-size: 0.82rem;
  font-weight: 900;
}

.card-copy {
  min-height: 0;
}

.card-copy small,
.card-copy strong,
.card-copy span {
  display: block;
}

.card-copy small {
  color: var(--accent);
  font-size: 0.5rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-copy strong {
  margin: 2px 0;
  font-size: clamp(0.56rem, 0.8vw, 0.72rem);
  line-height: 1.05;
}

.card-copy span {
  color: var(--muted);
  font-size: 0.52rem;
  line-height: 1.2;
}

.card-back {
  place-items: center;
  align-content: center;
  grid-template-rows: auto auto auto;
  gap: 8px;
  background:
    linear-gradient(rgba(17, 24, 39, 0.78), rgba(17, 24, 39, 0.94)),
    url("../assets/cards/ReversoMansion.png") center / cover,
    repeating-linear-gradient(45deg, rgba(216, 168, 77, 0.18) 0 8px, transparent 8px 18px);
}

.card-ammo .card-art {
  background: linear-gradient(135deg, #6d5a2e, #18130d);
}

.card-handgun .card-art,
.card-shotgun .card-art {
  background: linear-gradient(135deg, #415061, #111827);
}

.card-knife .card-art {
  background: linear-gradient(135deg, #54606f, #1b2029);
}

.card-herb .card-art {
  background: linear-gradient(135deg, #2f6b4f, #101d15);
}

.card-infected .card-art,
.card-runner .card-art,
.card-brute .card-art,
.card-boss .card-art {
  background: linear-gradient(135deg, #5e3538, #151010);
}

.card-trap .card-art {
  background: linear-gradient(135deg, #6c4b2e, #17110d);
}

.player-card strong {
  display: block;
}

.player-card span {
  color: var(--muted);
  font-size: 0.68rem;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  margin: 5px 0;
  padding: 5px;
  min-height: 38px;
  max-height: 82px;
  align-items: stretch;
  border: 1px solid rgba(216, 168, 77, 0.24);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.62);
  overflow: hidden;
}

.action-row button {
  min-width: 0;
}

/* Botones con iconos RE */
.re-btn-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: auto !important;
  min-height: 48px !important;
  padding: 5px 4px !important;
}

.re-btn-img {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.re-btn-icon span {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Zona de acción principal */
.mansion-command-zone .action-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Fila del botón fin de turno */
.action-row-end {
  display: block;
  margin-top: 0;
  margin-bottom: 0;
  border: none;
  background: none;
  padding: 0;
  min-height: 0;
}

.action-row-end #end-turn {
  width: 100%;
  min-height: 48px !important;
  height: auto !important;
  border-radius: 8px;
  font-weight: 900;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px !important;
}

.action-row-end #end-turn .re-btn-img {
  width: 32px;
  height: 32px;
}

.action-row-end #end-turn span {
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.turn-command {
  width: 100%;
  min-height: 28px;
  height: 28px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 0.62rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-command.re-btn-icon {
  height: auto;
  min-height: 48px;
  white-space: normal;
}

@media (max-width: 1320px) and (min-width: 861px) {
  .action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 74px;
  }

  .turn-command {
    min-height: 26px;
    height: 26px;
    font-size: 0.6rem;
  }
}

.end-command {
  color: #10141b;
  border: 0;
  background: var(--ok);
}

.vote-command {
  color: #10141b;
  border: 0;
  background: var(--accent);
}

.room-end-command {
  width: 100%;
  min-height: 34px;
  margin-top: 6px;
  border-radius: 8px;
  font-weight: 900;
}

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

.dice-roll-panel {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid rgba(216, 168, 77, 0.28);
  border-radius: 8px;
  background: rgba(216, 168, 77, 0.07);
}

.dice-roll-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.dice-result {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  touch-action: manipulation;
}

.dice-result span {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-result strong {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #10141b;
  background: var(--accent);
  font-size: 1.25rem;
}

.dice-result.rolling strong {
  animation: dice-spin 0.34s linear infinite;
}

.dice-result.winner {
  border-color: rgba(79, 191, 138, 0.75);
}

.dice-result.winner strong {
  background: var(--ok);
}

@keyframes dice-spin {
  from {
    transform: rotate(0deg) scale(0.96);
  }
  to {
    transform: rotate(360deg) scale(1.04);
  }
}

#turn-timer {
  min-width: 70px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.045);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(320px, calc(100vw - 24px));
  display: grid;
  gap: 10px;
}

.toast {
  padding: 10px 12px;
  border: 1px solid rgba(216, 168, 77, 0.34);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(23, 27, 34, 0.96);
  box-shadow: var(--shadow);
}

.toast strong,
.toast span {
  display: block;
}

.toast span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.toast.error {
  border-color: rgba(216, 95, 95, 0.55);
}

.toast.success {
  border-color: rgba(79, 191, 138, 0.55);
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}

.tutorial-overlay.hidden {
  display: none;
}

.tutorial-card {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(390px, calc(100vw - 28px));
  padding: 16px;
  border: 1px solid rgba(216, 168, 77, 0.6);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(16, 20, 27, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.tutorial-card-header,
.tutorial-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tutorial-card-header span {
  color: var(--accent);
  font-weight: 900;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.tutorial-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.tutorial-card h2 {
  margin: 10px 0 8px;
  font-size: 1.25rem;
}

.tutorial-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.tutorial-actions button {
  width: auto;
  min-width: 110px;
  margin-top: 0;
}

.tutorial-focus {
  position: relative;
  z-index: 44;
  outline: 3px solid rgba(79, 191, 138, 0.95);
  outline-offset: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55), 0 0 26px rgba(79, 191, 138, 0.6);
}

.game-over-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, 0.82);
}

.game-over-modal.hidden {
  display: none;
}

.game-over-modal > div {
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(216, 95, 95, 0.75);
  border-radius: 8px;
  text-align: center;
  background: #171b22;
  box-shadow: var(--shadow);
}

.game-over-modal h2 {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 2rem;
}

.game-over-modal p {
  margin: 0 0 20px;
  color: var(--ink);
  line-height: 1.45;
}

.chat-panel {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr) auto;
}

.right-achievements-panel {
  display: none !important;
}

#chat-log,
.achievement-list,
.rules-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#chat-log,
.achievement-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

#chat-log li,
.achievement-list li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
}

#chat-log li.chat-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #10141b;
  background: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.chat-bubble {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-meta strong {
  color: var(--ink);
  text-transform: uppercase;
}

.chat-meta span {
  color: var(--muted);
  font-size: 0.72rem;
}

.chat-bubble p {
  margin: 0;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-bubble audio {
  width: 100%;
  min-height: 34px;
}

.chat-reactions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.chat-reactions button {
  min-height: 26px;
  width: 30px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.reaction-summary {
  display: flex;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

#voice-message.recording {
  color: #fff;
  background: var(--danger);
}

.match-history li {
  display: grid;
  gap: 3px;
}

.match-history strong {
  color: var(--ink);
}

.match-history span {
  color: var(--muted);
  font-size: 0.78rem;
}

#chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-top: 12px;
}

.rules-panel li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}

@media (max-width: 1180px) {
  .home-hero,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .screenshot-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .card-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    height: auto;
    min-height: calc(100vh - 28px);
    overflow: visible;
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
    background-attachment: scroll;
  }

  .entry-screen {
    padding: 10px;
  }

  .entry-card {
    padding: 12px;
  }

  .home-hero {
    gap: 12px;
    min-height: 0;
  }

  .home-hero-copy,
  .home-hero-media {
    min-height: 240px;
  }

  .home-grid {
    gap: 12px;
    margin-top: 12px;
  }

  .screenshot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-guide-grid {
    grid-template-columns: 1fr;
  }

  .app-shell,
  .play-area,
  .right-rail {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .right-rail,
  .game-surface {
    max-height: none;
    overflow: visible;
  }

  .board {
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .game-surface,
  .board,
  .table-zone {
    overflow: visible;
  }

  .play-area {
    gap: 8px;
  }

  .table-grid,
  .hand,
  .action-card-list,
  .played-cards,
  .weapon-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mansion-command-zone .action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .live-trackers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tracker-icon {
    width: 24px;
    height: 24px;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

  .resource-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mansion-row {
    grid-template-columns: 160px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
  }

  .deck-stack {
    min-height: 220px;
  }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 1100px) {
  body {
    min-height: 100dvh;
    overflow: auto;
    background-attachment: scroll;
  }

  .entry-screen {
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .entry-card {
    padding: 10px;
  }

  .home-hero,
  .home-grid,
  .app-shell,
  .play-area,
  .right-rail {
    grid-template-columns: 1fr;
  }

  .home-hero {
    gap: 10px;
    min-height: 0;
  }

  .home-hero-copy {
    min-height: auto;
    padding: 14px;
  }

  .home-hero-copy h1 {
    font-size: 2.25rem;
    line-height: 1;
  }

  .home-hero-media {
    min-height: 170px;
  }

  .home-grid {
    gap: 10px;
    margin-top: 10px;
  }

  .screenshot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-shell {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    margin: 0;
    gap: 8px;
    overflow: visible;
  }

  .sidebar,
  .right-rail,
  .game-surface {
    max-height: none;
    overflow: visible;
    border-radius: 0;
  }

  .sidebar,
  .right-rail {
    gap: 8px;
  }

  .sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .profile-panel,
  .online-panel,
  .room-panel {
    min-height: 0;
  }

  .brand {
    min-height: auto;
  }

  #site-users,
  #friend-list,
  #invitation-list {
    max-height: 92px;
  }

  .add-user-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-guide {
    padding: 10px;
  }

  .card-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-card {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 7px;
  }

  .guide-card img {
    width: 48px;
  }

  .room-panel .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel,
  .game-surface {
    padding: 8px;
  }

  .brand {
    min-height: 58px;
    padding: 8px;
  }

  .brand-mark,
  .avatar {
    width: 38px;
    height: 38px;
  }

  h1 {
    font-size: 1.08rem;
  }

  h2 {
    margin-bottom: 6px;
    font-size: 0.82rem;
  }

  .eyebrow,
  .small,
  .status,
  label {
    font-size: 0.72rem;
  }

  button {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  select,
  input {
    min-height: 34px;
    font-size: 0.78rem;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    gap: 6px;
  }

  .volume-controls {
    min-width: 220px;
    grid-template-columns: repeat(2, minmax(92px, 1fr));
    gap: 6px;
  }

  .volume-controls label {
    padding: 4px 6px;
  }

  .tutorial-card {
    right: 8px;
    bottom: 8px;
    width: min(340px, calc(100vw - 16px));
    padding: 10px;
  }

  .tutorial-card h2 {
    font-size: 1rem;
  }

  .tutorial-card p {
    font-size: 0.76rem;
  }

  .tutorial-actions button {
    min-width: 92px;
  }

  .turn-pill {
    min-width: 76px;
    padding: 8px;
  }

  .board {
    grid-template-rows: auto auto;
    padding: 8px;
    overflow: visible;
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .player-card {
    padding: 6px;
  }

  .portrait {
    height: 44px;
    margin-bottom: 6px;
  }

  .player-card p {
    min-height: 0;
    font-size: 0.62rem;
  }

  .health-bar {
    margin: 6px 0;
  }

  .player-meta {
    grid-template-columns: 1fr;
    gap: 2px;
    font-size: 0.66rem;
  }

  .table-zone {
    overflow: visible;
  }

  .mansion-row {
    grid-template-columns: 150px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
  }

  .deck-stack {
    min-height: 200px;
  }

  .controls-panel {
    display: block;
  }

  .current-hero {
    min-height: 64px;
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .current-hero .portrait {
    width: 52px;
  }

  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 3px;
  }

  .tracker-icon {
    width: 20px;
    height: 20px;
  }

  .resource-grid,
  #chat-log,
  .achievement-list {
    max-height: none;
  }
}

@media (max-width: 860px) and (min-height: 541px) {
  .action-card-list {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
    overflow: hidden auto;
  }

  .action-card-list .action-select-card {
    height: 60px;
    min-height: 60px;
    max-height: 60px;
    grid-template-columns: 52px minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .action-card-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .home-hero-copy,
  .home-showcase,
  .login-panel,
  .rules-preview {
    padding: 10px;
  }

  .home-hero-copy {
    min-height: auto;
  }

  .home-hero-media {
    min-height: 180px;
  }

  .home-hero-copy h1 {
    font-size: 2rem;
  }

  .screenshot-grid {
    gap: 8px;
  }

  .rules-sim {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .rules-sim img {
    max-width: 120px;
    margin-inline: auto;
  }

  .card-guide-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .screenshot-grid figcaption {
    padding: 6px;
  }

  .rules-preview ul {
    padding-left: 16px;
    font-size: 0.82rem;
  }

  .app-shell {
    width: 100%;
    margin: 0;
    min-height: 100vh;
    gap: 8px;
  }

  .sidebar,
  .right-rail,
  .game-surface {
    border-radius: 0;
  }

  .panel,
  .game-surface {
    padding: 9px;
  }

  h1 {
    font-size: 1.18rem;
  }

  h2 {
    font-size: 0.84rem;
  }

  button,
  select,
  input {
    font-size: 0.82rem;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .volume-controls {
    order: 3;
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
  }

  #chat-form {
    grid-template-columns: 1fr;
  }

  .tutorial-card {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
  }

  .brand {
    min-height: 64px;
  }

  .table-grid,
  .action-row,
  .dice-roll-grid,
  .resource-group-grid {
    grid-template-columns: 1fr;
  }

  .hand,
  .action-card-list,
  .played-cards,
  .weapon-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .live-trackers div {
    padding: 5px 2px 3px;
  }

  .tracker-icon {
    width: 20px;
    height: 20px;
  }

  .current-hero {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .current-hero .portrait {
    width: 52px;
  }

  .mansion-row {
    grid-template-columns: 1fr;
  }

  .deck-stack {
    min-height: 190px;
  }

  .card-copy span {
    display: none;
  }

  .resource-grid,
  #chat-log,
  .achievement-list {
    max-height: 240px;
  }
}

@media (min-width: 861px) {
  .sidebar *,
  .right-rail *,
  .game-surface * {
    min-width: 0;
  }

  .profile-row > div,
  .brand div,
  .friend > div,
  .invitation-card > div,
  .player-name-row {
    min-width: 0;
  }

  .brand h1,
  #player-name,
  .friend strong,
  .friend span,
  .invitation-card strong,
  .invitation-card span,
  .player-name-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .online-panel,
  .room-panel {
    overflow: hidden;
  }

  .right-rail {
    grid-template-rows: minmax(184px, 30dvh) auto minmax(0, 1fr) auto;
    align-content: stretch;
  }

  .chat-panel,
  .resources-panel,
  .achievements-panel,
  .history-panel {
    min-height: 0;
    overflow: hidden;
  }

  .chat-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  #chat-log,
  .resource-grid,
  .achievement-list,
  .match-history {
    overflow: hidden auto;
  }

  #chat-log {
    max-height: none;
    gap: 5px;
  }

  #chat-log li,
  .achievement-list li {
    padding: 7px;
    font-size: 0.76rem;
  }

  #chat-log li.chat-message {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.66rem;
  }

  #chat-form {
    grid-template-columns: minmax(0, 1fr) minmax(58px, auto) minmax(70px, auto);
    gap: 5px;
    margin-top: 6px;
  }

  #chat-form button {
    min-width: 0;
    padding-inline: 6px;
    white-space: nowrap;
  }

  .resource-types {
    gap: 5px;
    margin-bottom: 6px;
  }

  .resource-types button {
    min-height: 26px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .resource-grid {
    max-height: 222px;
    gap: 5px;
  }

  .achievement-list {
    max-height: 252px;
    gap: 5px;
  }

  .match-history {
    max-height: 170px;
  }

  .player-name-row {
    gap: 4px;
  }

  .player-name-row strong {
    font-size: 0.74rem;
  }

  .player-name-row em {
    padding: 2px 5px;
    font-size: 0.58rem;
  }

  .card-face {
    min-height: 78px;
  }

  .action-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    margin: 4px 0;
    padding: 4px;
  }

  .turn-footer {
    gap: 8px;
  }

  #turn-timer {
    min-width: 70px;
    padding: 8px;
  }
}

@media (min-width: 861px) and (min-height: 541px) {
  .controls-panel {
    display: grid;
    grid-template-rows:
      auto
      auto
      auto
      clamp(70px, 9dvh, 96px)
      clamp(58px, 7dvh, 76px)
      clamp(74px, 9dvh, 92px)
      clamp(62px, 8dvh, 78px)
      clamp(58px, 7dvh, 76px)
      auto
      auto
      auto;
    gap: 4px;
    overflow: hidden;
  }

  .hand {
    min-height: 78px;
    max-height: 104px;
    align-items: stretch;
    overflow: hidden;
  }

  .hand .card-face {
    width: min(126px, 100%);
    max-height: 104px;
    justify-self: center;
  }

  .action-picker,
  .weapon-picker,
  .played-row {
    min-height: 0;
    margin-top: 4px;
    padding-top: 4px;
  }

  .action-picker {
    padding: 5px;
    min-height: 74px;
    max-height: 92px;
    overflow: hidden;
  }

  .action-card-list {
    max-height: 58px;
    overflow: hidden;
  }

  .played-row {
    max-height: 76px;
    overflow: hidden;
  }

  .played-cards {
    min-height: 52px;
    max-height: 52px;
    overflow: hidden;
  }

  .played-cards .played-turn-card {
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .played-cards .played-turn-card .card-copy strong {
    font-size: 0.58rem;
  }

  .played-cards .played-turn-card .card-copy span {
    font-size: 0.46rem;
  }

  .played-row .section-title {
    margin-bottom: 4px;
  }

  .weapon-picker {
    max-height: 78px;
    overflow: hidden;
  }

  .weapon-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 184px));
    align-items: start;
    justify-content: start;
    max-height: 64px;
    overflow: hidden;
  }

  .weapon-list .weapon-select-card {
    width: 100%;
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: 1fr;
    gap: 5px;
    justify-self: start;
  }

  .weapon-list .weapon-select-card .card-art {
    min-height: 0;
    height: 100%;
  }

  .weapon-list .weapon-select-card .card-copy {
    justify-content: center;
    min-height: 0;
  }

  .weapon-list .weapon-select-card .card-copy small {
    font-size: 0.5rem;
  }

  .weapon-list .weapon-select-card .card-copy strong {
    font-size: 0.64rem;
  }

  .weapon-list .weapon-select-card .card-copy span {
    display: block;
    font-size: 0.5rem;
  }

  .action-row {
    gap: 5px;
    margin: 4px 0;
  }

  .turn-command {
    min-height: 26px;
    height: 26px;
  }
}

@media (min-width: 861px) and (max-height: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 0;
    height: calc(100dvh - 8px);
    margin: 4px auto;
  }

  .game-surface,
  .board,
  .play-area,
  .controls-panel {
    min-height: 0;
  }

  .topbar {
    min-height: 46px;
    gap: 5px;
  }

  .topbar p {
    font-size: 0.72rem;
  }

  .top-actions button,
  .sound-panel {
    min-height: 30px;
  }

  .turn-pill {
    min-width: 74px;
    padding: 6px 8px;
  }

  .board {
    grid-template-rows: minmax(92px, 116px) minmax(0, 1fr);
    gap: 5px;
    padding: 5px;
  }

  .table-grid .player-card {
    min-height: 88px;
    grid-template-columns: clamp(54px, 18%, 70px) minmax(0, 1fr);
    column-gap: 6px;
    padding: 5px;
  }

  .table-grid .player-card .portrait {
    min-height: 74px;
  }

  .player-name-row strong {
    font-size: 0.68rem;
  }

  .table-grid .player-card > span,
  .player-meta {
    font-size: 0.56rem;
  }

  .character-read-btn {
    height: 19px;
    min-height: 19px;
    padding-inline: 6px;
    font-size: 0.52rem;
  }

  .controls-panel {
    grid-template-rows:
      auto
      auto
      auto
      minmax(58px, 74px)
      minmax(46px, 58px)
      minmax(58px, 70px)
      minmax(52px, 64px)
      minmax(44px, 56px)
      auto
      auto
      auto;
    gap: 3px;
  }

  .current-hero {
    min-height: 42px;
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 5px;
    margin-bottom: 0;
  }

  .current-hero .portrait {
    width: 38px;
  }

  .current-hero strong {
    font-size: 0.72rem;
  }

  .current-hero span {
    display: none;
  }

  .live-trackers {
    gap: 3px;
    margin-bottom: 2px;
  }

  .live-trackers div {
    min-height: 0;
    padding: 4px 2px 2px;
  }

  .tracker-icon {
    width: 18px;
    height: 18px;
  }

  .live-trackers span {
    font-size: 0.4rem;
  }

  .live-trackers strong {
    font-size: 0.62rem;
  }

  .hand {
    min-height: 58px;
    max-height: 74px;
    gap: 4px;
  }

  .hand .card-face {
    max-height: 74px;
    min-height: 54px;
  }

  .player-card-zones {
    min-height: 46px;
    gap: 5px;
  }

  .player-zone {
    padding: 4px;
  }

  .compact-title {
    margin-bottom: 2px;
  }

  .compact-title h2,
  .compact-title span {
    font-size: 0.58rem;
  }

  .player-stack-zone,
  .player-discard-zone {
    min-height: 30px;
  }

  .mini-stack {
    height: 30px;
  }

  .action-picker {
    min-height: 58px;
    max-height: 70px;
    padding: 4px;
  }

  .action-card-list,
  .weapon-list {
    max-height: 42px;
  }

  .action-card-list .action-select-card,
  .weapon-list .weapon-select-card,
  .played-cards .played-turn-card {
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .weapon-picker,
  .played-row {
    max-height: 64px;
  }

  .played-cards {
    min-height: 42px;
    max-height: 42px;
  }

  .card-copy small,
  .card-copy span {
    font-size: 0.42rem;
  }

  .card-copy strong {
    font-size: 0.54rem;
  }

  .action-row {
    min-height: 32px;
    margin: 2px 0;
    padding: 3px;
  }

  .turn-command {
    height: 22px;
    min-height: 22px;
    font-size: 0.54rem;
  }

  .turn-footer {
    gap: 5px;
  }

  .turn-footer .status {
    font-size: 0.66rem;
  }

  #turn-timer {
    min-width: 56px;
    padding: 5px 6px;
    font-size: 0.72rem;
  }
}

@media (min-width: 861px) and (max-width: 1450px) {
  .app-shell {
    grid-template-columns: clamp(176px, 15vw, 210px) minmax(0, 1fr) clamp(226px, 20vw, 282px);
    gap: 5px;
  }

  .panel,
  .game-surface {
    padding: 6px;
  }

  .brand {
    min-height: 54px;
    padding: 6px;
  }

  .brand h1 {
    font-size: 1.02rem;
  }

  .right-rail {
    grid-template-rows: minmax(150px, 25dvh) auto minmax(0, 1fr) auto;
  }

  .resource-card {
    min-width: 0;
  }
}

@media (min-width: 861px) and (max-width: 1250px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-width: 1180px;
  }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 1100px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    min-width: 0;
    margin: 0;
    grid-template-columns: minmax(150px, 18vw) minmax(0, 1fr) minmax(190px, 23vw);
    grid-template-rows: minmax(0, 1fr);
    gap: 4px;
    align-items: stretch;
    overflow: hidden;
  }

  .sidebar,
  .right-rail,
  .game-surface {
    grid-column: auto;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    border-radius: 0;
  }

  .sidebar,
  .right-rail {
    gap: 4px;
  }

  .sidebar {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .sidebar > .panel:last-child {
    min-height: 0;
    overflow: hidden;
  }

  .panel,
  .game-surface {
    padding: 5px;
  }

  .brand {
    height: 42px;
    min-height: 42px;
    gap: 5px;
    padding: 5px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .brand h1 {
    font-size: 0.86rem;
  }

  .brand span,
  .profile-panel .small,
  .availability-toggle .status,
  .room-panel .status,
  #room-status {
    display: none;
  }

  .offline-home-button {
    display: none;
  }

  .profile-row {
    gap: 5px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }

  .stats-row {
    display: none;
  }

  .availability-toggle,
  .logout-button,
  button,
  select,
  input {
    min-height: 24px;
    padding: 0 6px;
    font-size: 0.66rem;
  }

  h2,
  h3 {
    font-size: 0.72rem;
    margin-bottom: 4px;
  }

  #site-users,
  #friend-list,
  #invitation-list {
    max-height: 48px;
  }

  .friend,
  .invitation-card {
    padding: 4px;
  }

  .friend button,
  .invitation-card button {
    max-width: 58px;
    min-height: 22px;
    font-size: 0.58rem;
  }

  .game-surface {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px;
  }

  .topbar {
    gap: 4px;
    min-height: 34px;
  }

  .topbar p {
    font-size: 0.7rem;
  }

  .top-actions {
    gap: 4px;
    flex-wrap: nowrap;
  }

  .volume-controls {
    display: none;
  }

  .turn-pill {
    min-width: 58px;
    padding: 6px;
    font-size: 0.72rem;
  }

  .board {
    grid-template-rows: 64px minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
    overflow: hidden;
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .player-card {
    padding: 4px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .portrait,
  .table-grid .player-card .portrait {
    grid-row: auto;
    height: 24px;
    min-height: 24px;
    margin-bottom: 3px;
  }

  .table-grid .player-card .portrait img {
    object-fit: cover;
  }

  .table-grid .player-name-row,
  .table-grid .player-card > span,
  .table-grid .player-card > p,
  .table-grid .health-bar,
  .table-grid .player-meta {
    grid-column: auto;
  }

  .player-card p,
  .player-meta {
    display: none;
  }

  .health-bar {
    height: 5px;
    margin: 3px 0 0;
  }

  .play-area {
    grid-template-columns: minmax(96px, 24%) minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
  }

  .table-zone {
    padding: 4px;
    overflow: hidden;
  }

  .mansion-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .deck-stack {
    min-height: 112px;
  }

  .deck-card {
    width: 62px;
  }

  .mansion-card {
    width: 66px;
    padding: 5px;
    font-size: 0.64rem;
  }

  .mansion-card.has-card-image .card-copy {
    display: none;
  }

  .card-mark {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .discard-slot {
    min-height: 40px;
    padding: 5px;
  }

  .controls-panel {
    display: grid;
    grid-template-rows: auto auto auto minmax(24px, 1fr) 68px 42px auto;
    gap: 4px;
    overflow: hidden;
  }

  .current-hero {
    grid-row: 2;
    min-height: 38px;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 5px;
    padding: 5px;
    margin-bottom: 0;
  }

  .current-hero .portrait {
    width: 34px;
  }

  .current-hero strong {
    font-size: 0.68rem;
  }

  .current-hero span,
  .live-trackers span,
  .card-copy span {
    display: none;
  }

  .live-trackers {
    grid-row: 3;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 0;
  }

  .live-trackers div {
    padding: 3px;
  }

  .live-trackers strong {
    font-size: 0.62rem;
  }

  .hand,
  .weapon-list,
  .played-cards {
    grid-template-columns: repeat(4, minmax(42px, 1fr));
    gap: 4px;
  }

  .hand {
    grid-row: 4;
    max-height: none;
    overflow: hidden auto;
  }

  .card-face {
    min-height: 52px;
    padding: 3px;
  }

  .card-copy small {
    font-size: 0.45rem;
  }

  .card-copy strong {
    font-size: 0.52rem;
  }

  .action-picker,
  .weapon-picker,
  .played-row {
    margin-top: 0;
    padding-top: 0;
  }

  .action-picker {
    grid-row: 5;
    padding: 4px;
    height: 68px;
    max-height: 68px;
    overflow: hidden;
  }

  .action-card-list {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    max-height: 36px;
    overflow: hidden auto;
  }

  .action-card-list .action-select-card {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .action-card-list .action-select-card .card-copy strong {
    font-size: 0.5rem;
  }

  .weapon-picker {
    grid-row: 6;
    height: 42px;
    max-height: 42px;
    overflow: hidden;
  }

  .played-row {
    display: none;
  }

  .action-row {
    grid-row: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
  }

  .turn-command {
    min-height: 24px;
    font-size: 0.58rem;
  }

  .turn-footer {
    grid-row: 7;
    gap: 4px;
    align-items: end;
  }

  #turn-hint {
    font-size: 0.62rem;
  }

  #turn-timer {
    min-width: 54px;
    padding: 5px;
    font-size: 0.72rem;
  }

  .right-rail {
    grid-column: auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(96px, 28dvh) auto minmax(0, 1fr) auto;
  }

  .chat-panel {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  #chat-log {
    gap: 4px;
  }

  #chat-log li,
  .achievement-list li {
    padding: 5px;
    font-size: 0.64rem;
  }

  #chat-form {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 4px;
    margin-top: 4px;
  }

  .resource-types {
    gap: 4px;
    margin-bottom: 4px;
  }

  .resource-types button {
    min-height: 22px;
    font-size: 0.58rem;
  }

  .resource-grid,
  .achievement-list,
  .match-history {
    max-height: 96px;
    gap: 4px;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 460px) {
  .app-shell {
    grid-template-columns: clamp(96px, 14vw, 124px) minmax(0, 1fr) clamp(118px, 17vw, 148px);
    gap: 3px;
  }

  .sidebar,
  .right-rail {
    gap: 3px;
  }

  .panel,
  .game-surface {
    padding: 3px;
  }

  .brand,
  .profile-panel {
    min-height: 34px;
    height: 34px;
    padding: 3px;
  }

  .brand h1,
  #player-name,
  .room-panel label,
  .room-panel select {
    font-size: 0.58rem;
  }

  .brand-mark,
  .avatar {
    width: 24px;
    height: 24px;
    font-size: 0.66rem;
  }

  .online-panel,
  .history-panel,
  .right-rail > .panel:last-of-type {
    display: none;
  }

  .room-panel {
    overflow: hidden auto;
  }

  .room-panel .section-title,
  .room-panel label,
  .friend-list,
  .profile-panel .small,
  .availability-toggle,
  .logout-button {
    display: none;
  }

  .sidebar {
    grid-template-rows: 32px 34px minmax(0, 1fr);
  }

  .profile-panel {
    overflow: hidden;
  }

  .profile-row {
    gap: 4px;
  }

  .room-panel button,
  .room-panel select {
    min-height: 20px;
    height: 20px;
    font-size: 0.55rem;
  }

  .room-end-command {
    min-height: 20px;
    margin-top: 3px;
  }

  .topbar {
    min-height: 28px;
  }

  .topbar h2 {
    font-size: 0.68rem;
  }

  .top-actions button,
  .sound-button,
  .tutorial-button {
    min-height: 22px;
    height: 22px;
    font-size: 0.56rem;
  }

  .turn-pill {
    min-width: 48px;
    padding: 4px;
    font-size: 0.62rem;
  }

  .board {
    grid-template-rows: 36px minmax(0, 1fr);
    gap: 3px;
    padding: 3px;
  }

  .table-grid {
    gap: 3px;
    align-items: stretch;
  }

  .player-card {
    min-height: 0;
    height: 36px;
    padding: 2px 3px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 3px;
    align-items: center;
  }

  .player-name-row em,
  .table-grid .player-card > span,
  .character-read-btn {
    display: none;
  }

  .portrait,
  .table-grid .player-card .portrait {
    width: 22px;
    height: 28px;
    min-height: 28px;
    margin: 0;
  }

  .player-name-row strong {
    font-size: 0.5rem;
    line-height: 1;
  }

  .health-bar {
    height: 4px;
    margin: 1px 0 0;
  }

  .play-area {
    grid-template-columns: clamp(82px, 17vw, 104px) minmax(0, 1fr);
    gap: 3px;
  }

  .deck-stack {
    min-height: 104px;
  }

  .deck-card {
    width: 70px;
  }

  .mansion-card {
    width: 76px;
    min-height: 106px;
    padding: 4px;
  }

  .discard-slot {
    display: none;
  }

  .controls-panel {
    grid-template-rows: 26px 20px minmax(44px, 1fr) 32px 28px 30px 30px minmax(0, 26px);
    gap: 2px;
  }

  .action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-row: 7;
    min-height: 30px;
    align-self: end;
    gap: 2px;
  }

  .turn-command {
    min-height: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 5px;
    font-size: 0.44rem;
    line-height: 1;
  }

  .current-hero {
    grid-row: 1;
    min-height: 26px;
    grid-template-columns: 28px minmax(0, 1fr);
    padding: 3px;
  }

  .current-hero .portrait {
    width: 24px;
  }

  .current-hero strong {
    font-size: 0.54rem;
  }

  .controls-panel > .section-title {
    display: none;
  }

  .hero-read-btn,
  .played-row,
  .turn-footer .status {
    display: none;
  }

  .live-trackers {
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }

  .live-trackers div {
    min-height: 18px;
    padding: 2px 3px 2px 15px;
  }

  .live-trackers div::before {
    left: 4px;
    width: 8px;
    height: 8px;
    font-size: 0.38rem;
  }

  .live-trackers strong {
    font-size: 0.48rem;
  }

  .hand {
    grid-row: 3;
    grid-template-columns: repeat(5, minmax(36px, 1fr));
    gap: 3px;
    max-height: 74px;
    overflow: hidden auto;
  }

  .card-face {
    min-height: 42px;
  }

  .card-copy small,
  .card-copy strong {
    font-size: 0.42rem;
  }

  .action-picker {
    grid-row: 5;
    height: 28px;
    max-height: 28px;
    padding: 2px 3px;
  }

  .action-card-list .action-select-card,
  .weapon-list .weapon-select-card {
    height: 20px;
    min-height: 20px;
    max-height: 20px;
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .weapon-picker {
    grid-row: 6;
    height: 30px;
    max-height: 30px;
    padding: 2px 3px;
  }

  .weapon-list,
  .action-card-list {
    max-height: 21px;
    overflow: hidden auto;
  }

  .player-card-zones {
    grid-row: 4;
    display: grid;
    grid-template-columns: 0.7fr 1.3fr;
    gap: 3px;
    min-height: 34px;
    height: 34px;
    overflow: hidden;
  }

  .turn-footer {
    grid-row: 8;
    min-height: 22px;
    justify-content: end;
    align-items: center;
  }

  #turn-timer {
    min-width: 42px;
    height: 22px;
    padding: 2px 5px;
    font-size: 0.58rem;
    border-radius: 6px;
  }

  .dice-roll-panel {
    grid-row: 8;
    grid-column: 1;
    justify-self: start;
    align-self: stretch;
    width: min(72%, 230px);
    min-height: 22px;
    margin: 0;
    padding: 2px 4px;
    display: grid;
    grid-template-columns: minmax(44px, auto) minmax(0, 1fr);
    gap: 4px;
    align-items: center;
    overflow: hidden;
  }

  .turn-footer {
    grid-column: 1;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-roll-panel .section-title {
    min-height: 0;
    margin: 0;
    display: grid;
    gap: 0;
  }

  .dice-roll-panel .section-title h2 {
    font-size: 0.48rem;
    line-height: 1;
    margin: 0;
  }

  #dice-roll-status {
    font-size: 0.46rem;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dice-roll-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }

  .dice-result {
    gap: 1px;
    padding: 1px;
    border-radius: 5px;
  }

  .dice-result span {
    font-size: 0.42rem;
    line-height: 1;
  }

  .dice-result strong {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    font-size: 0.62rem;
  }

  .player-zone {
    padding: 3px;
    border-radius: 5px;
  }

  .compact-title {
    margin-bottom: 1px;
  }

  .compact-title h2,
  .compact-title span {
    font-size: 0.48rem;
    line-height: 1;
  }

  .player-stack-zone,
  .player-discard-zone {
    min-height: 20px;
    height: 20px;
    gap: 3px;
    overflow: hidden;
  }

  .mini-stack {
    width: 34px;
    height: 20px;
  }

  .mini-back-card {
    inset: 2px 8px 1px 2px;
    border-radius: 3px;
    transform: translateX(calc(var(--i) * 3px)) translateY(calc(var(--i) * -0.5px)) rotate(calc(var(--i) * 1deg));
  }

  .mini-stack span {
    min-width: 15px;
    padding: 1px 3px;
    font-size: 0.46rem;
  }

  .empty-stack {
    font-size: 0.48rem;
    line-height: 1;
  }

  .discard-mini-card {
    width: 28px;
    height: 20px;
    min-height: 20px;
    grid-template-columns: 12px minmax(0, 1fr);
    gap: 2px;
    padding: 2px;
    border-radius: 4px;
  }

  .discard-mini-card .card-copy small,
  .discard-mini-card .card-copy span {
    display: none;
  }

  .discard-mini-card .card-copy strong {
    font-size: 0.38rem;
    line-height: 1;
  }

  .right-rail {
    grid-template-rows: minmax(78px, 24dvh) minmax(0, 1fr);
  }

  .chat-panel,
  .resources-panel,
  .achievements-panel,
  .right-rail > .panel {
    min-height: 0;
  }

  .resources-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  .chat-panel .section-title {
    margin-bottom: 3px;
  }

  #chat-form {
    grid-template-columns: 20px minmax(48px, 1fr) minmax(52px, auto);
    gap: 3px;
  }

  #chat-input {
    min-width: 20px;
    padding: 0 4px;
    font-size: 0;
  }

  #chat-input::placeholder {
    font-size: 0;
  }

  #voice-message,
  #chat-form button[type="submit"] {
    min-width: 0;
    padding: 0 5px;
    font-size: 0.56rem;
  }

  .right-rail .section-title span,
  #resource-status {
    display: none;
  }

  .resource-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 3px;
  }

  .resource-types button {
    min-height: 22px;
    padding: 0 4px;
    font-size: 0.56rem;
  }

  .resource-grid {
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 2px;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .resource-group {
    gap: 4px;
  }

  .resource-group h3 {
    margin-top: 3px;
    font-size: 0.58rem;
  }

  .resource-group-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .resource-card {
    padding: 4px;
  }

  .resource-card .card-face {
    min-height: 54px;
    aspect-ratio: 2.8 / 2.1;
    grid-template-rows: 52% 48%;
  }

  .resource-card footer {
    margin-top: 3px;
    font-size: 0.58rem;
  }

  #chat-log,
  .resource-grid,
  .achievement-list {
    max-height: none;
  }
}

@media (orientation: landscape) and (min-width: 1001px) and (min-height: 541px) and (max-width: 1368px) and (max-height: 1030px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    min-width: 0;
    margin: 0;
    grid-template-columns: clamp(150px, 16vw, 196px) minmax(0, 1fr) clamp(210px, 22vw, 286px);
    gap: 4px;
    overflow: hidden;
  }

  .sidebar,
  .right-rail,
  .game-surface {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
  }

  .panel,
  .game-surface {
    padding: 5px;
  }

  .sidebar,
  .right-rail {
    gap: 4px;
  }

  .brand {
    min-height: 46px;
    padding: 5px;
  }

  .brand-mark,
  .avatar {
    width: 30px;
    height: 30px;
  }

  .brand h1 {
    font-size: 0.88rem;
  }

  .brand span,
  .profile-panel .small,
  #room-status {
    display: none;
  }

  .stats-row {
    display: none;
  }

  .online-panel {
    max-height: 124px;
  }

  #site-users,
  #friend-list,
  #invitation-list {
    max-height: 86px;
  }

  .room-panel {
    overflow: hidden auto;
  }

  .room-panel button,
  .room-panel select {
    min-height: 24px;
    font-size: 0.62rem;
  }

  .room-end-command {
    min-height: 26px;
  }

  .topbar {
    min-height: 36px;
  }

  .volume-controls {
    display: none;
  }

  .board {
    grid-template-rows: clamp(76px, 13dvh, 112px) minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
  }

  .table-grid {
    gap: 4px;
  }

  .table-grid .player-card {
    min-height: 72px;
    grid-template-columns: clamp(44px, 16%, 62px) minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 58px;
  }

  .character-read-btn {
    height: 18px;
    min-height: 18px;
    font-size: 0.5rem;
  }

  .play-area {
    grid-template-columns: clamp(86px, 15%, 132px) minmax(0, 1fr);
    gap: 4px;
  }

  .mansion-row {
    gap: 4px;
  }

  .deck-stack {
    min-height: clamp(118px, 27dvh, 210px);
  }

  .mansion-card {
    width: clamp(58px, 9vw, 96px);
    min-height: clamp(82px, 22dvh, 148px);
  }

  .discard-slot {
    min-height: 46px;
  }

  .controls-panel {
    grid-template-rows:
      30px
      minmax(38px, 52px)
      minmax(26px, 34px)
      minmax(58px, 1fr)
      minmax(42px, 58px)
      minmax(56px, 70px)
      minmax(44px, 56px)
      30px
      minmax(26px, 32px)
      auto;
    gap: 3px;
  }

  .action-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 28px;
    padding: 3px;
  }

  .turn-command {
    height: 22px;
    min-height: 22px;
    font-size: 0.54rem;
  }

  .current-hero {
    min-height: 38px;
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 4px;
    margin-bottom: 0;
  }

  .current-hero .portrait {
    width: 30px;
  }

  .current-hero strong {
    font-size: 0.64rem;
  }

  .current-hero span,
  .hero-read-btn {
    display: none;
  }

  .live-trackers {
    gap: 2px;
    margin-bottom: 0;
  }

  .live-trackers div {
    min-height: 22px;
    padding: 2px 3px 2px 17px;
  }

  .live-trackers div::before {
    left: 4px;
    width: 9px;
    height: 9px;
    font-size: 0.4rem;
  }

  .live-trackers span {
    display: none;
  }

  .live-trackers strong {
    font-size: 0.56rem;
  }

  .hand {
    min-height: 52px;
    max-height: none;
    grid-template-columns: repeat(5, minmax(42px, 1fr));
    gap: 3px;
    overflow: hidden auto;
  }

  .hand .card-face,
  .card-face {
    min-height: 48px;
    max-height: 76px;
    padding: 3px;
  }

  .card-copy span {
    display: none;
  }

  .card-copy small,
  .card-copy strong {
    font-size: 0.48rem;
  }

  .player-card-zones {
    min-height: 40px;
    gap: 4px;
  }

  .player-zone {
    padding: 4px;
  }

  .compact-title {
    margin-bottom: 2px;
  }

  .compact-title h2,
  .compact-title span {
    font-size: 0.56rem;
  }

  .player-stack-zone,
  .player-discard-zone {
    min-height: 28px;
  }

  .action-picker,
  .weapon-picker,
  .played-row {
    margin-top: 0;
    padding-top: 0;
  }

  .action-picker {
    min-height: 42px;
    max-height: 58px;
    padding: 3px;
  }

  .action-card-list,
  .weapon-list {
    max-height: 36px;
    overflow: hidden auto;
  }

  .action-card-list .action-select-card,
  .weapon-list .weapon-select-card,
  .played-cards .played-turn-card {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .weapon-picker,
  .played-row {
    max-height: 56px;
  }

  .played-cards {
    min-height: 34px;
    max-height: 34px;
  }

  .turn-footer .status {
    font-size: 0.58rem;
  }

  #turn-timer {
    min-width: 54px;
    padding: 4px;
    font-size: 0.66rem;
  }

  .right-rail {
    grid-template-rows: minmax(104px, 22dvh) auto minmax(0, 1fr) minmax(90px, 20dvh);
  }

  .chat-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  #chat-log,
  .resource-grid,
  .achievement-list,
  .match-history {
    overflow: hidden auto;
    max-height: none;
  }
}

@media (min-width: 861px) and (min-height: 700px) {
  .right-rail {
    grid-template-rows: minmax(420px, 48dvh) auto minmax(0, 1fr);
  }
}

@media (min-width: 861px) and (max-height: 699px) {
  .right-rail {
    grid-template-rows: minmax(220px, 36dvh) auto minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  .right-rail {
    grid-template-rows: minmax(96px, 34dvh) auto minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (min-width: 1001px) and (min-height: 541px) and (max-width: 1368px) and (max-height: 1030px) {
  .right-rail {
    grid-template-rows: minmax(180px, 34dvh) auto minmax(0, 1fr);
  }
}
/* Desktop/offline final visual normalization. */
@media (min-width: 861px) {
  .play-area {
    grid-template-columns: clamp(180px, 19vw, 280px) minmax(0, 1fr);
  }

  .mansion-row {
    grid-template-rows: minmax(132px, 1fr) auto;
  }

  .deck-stack {
    min-height: 132px;
  }

  .mansion-card,
  .deck-card {
    width: min(164px, 90%);
  }

  .mansion-card.card-face {
    max-height: none;
    min-height: 0;
    height: auto;
    aspect-ratio: 2.5 / 3.5;
  }

  .dice-roll-panel {
    min-height: 34px;
    margin-top: 4px;
    padding: 4px 6px;
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    gap: 6px;
    align-items: center;
  }

  .dice-roll-panel.hidden {
    display: none;
  }

  .dice-result {
    padding: 3px;
  }

  .dice-result strong {
    width: 24px;
    height: 24px;
    font-size: 0.84rem;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .board {
    grid-template-rows: clamp(72px, 12dvh, 104px) minmax(0, 1fr);
  }

  .table-grid .player-card {
    min-height: 62px;
    grid-template-columns: 38px minmax(0, 1fr);
    padding: 4px;
  }

  .table-grid .player-card .portrait {
    min-height: 52px;
  }

  .table-grid .character-read-btn,
  .table-grid .player-card > span {
    display: none;
  }

  .mansion-row {
    grid-template-rows: minmax(112px, 1fr) auto;
  }

  .deck-stack {
    min-height: 112px;
  }

  .mansion-card,
  .deck-card {
    width: min(136px, 92%);
  }

  .mansion-card.card-face {
    max-height: none;
    min-height: 0;
    height: auto;
    aspect-ratio: 2.5 / 3.5;
  }

  .turn-command {
    min-height: 21px;
    height: 21px;
  }
}
/* Mansion DBG final global anti-overlap overrides. */
.controls-panel {
  isolation: isolate;
}

.controls-panel > *,
.current-hero,
.live-trackers,
.hand,
.player-card-zones,
.action-picker,
.weapon-picker,
.action-row,
.dice-roll-panel,
.turn-footer {
  min-width: 0;
  position: relative;
}

.current-hero {
  z-index: 1;
  overflow: hidden;
}

.current-hero .portrait {
  align-self: stretch;
  max-height: 100%;
  overflow: hidden;
}

.live-trackers {
  z-index: 2;
  align-self: stretch;
}

.live-trackers div,
.hand .card-face {
  overflow: hidden;
}

.hand {
  z-index: 1;
  align-self: stretch;
}

.mansion-card.has-card-image .card-copy {
  display: none;
}

@media (min-width: 861px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(42px, auto)
      minmax(30px, auto)
      minmax(74px, 1fr)
      minmax(42px, auto)
      minmax(54px, auto)
      minmax(44px, auto)
      minmax(34px, auto)
      minmax(28px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .current-hero,
  .live-trackers {
    margin-bottom: 0;
  }

  .mansion-card,
  .deck-card {
    width: min(178px, 94%);
  }

  .mansion-card.card-face {
    max-height: none;
    height: auto;
  }
}

@media (min-width: 861px) and (max-width: 1600px), (min-width: 861px) and (max-height: 900px) {
  .controls-panel {
    grid-template-rows:
      auto
      minmax(34px, auto)
      minmax(26px, auto)
      minmax(58px, 1fr)
      minmax(38px, auto)
      minmax(44px, auto)
      minmax(36px, auto)
      minmax(28px, auto)
      minmax(24px, auto)
      minmax(0, auto)
      minmax(0, auto);
  }

  .mansion-card,
  .deck-card {
    width: min(150px, 94%);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  .play-area {
    grid-template-columns: clamp(108px, 21vw, 136px) minmax(0, 1fr);
  }

  .mansion-panel .section-title span {
    font-size: 0.58rem;
    line-height: 1;
  }

  .deck-stack {
    min-height: 126px;
  }

  .mansion-card,
  .deck-card {
    width: min(98px, 92%);
  }

  .mansion-card {
    min-height: 136px;
  }

  .controls-panel {
    grid-template-rows: 26px 20px minmax(50px, 1fr) 32px 28px 30px 30px minmax(0, 26px);
  }

  .current-hero {
    max-height: 26px;
  }

  .current-hero .portrait {
    width: 22px;
    height: 22px;
    min-height: 22px;
  }

  .live-trackers {
    max-height: 20px;
    overflow: hidden;
  }

  .hand {
    max-height: 78px;
    overflow: hidden auto;
  }
}

@media (orientation: landscape) and (max-width: 760px) and (max-height: 430px) {
  .play-area {
    grid-template-columns: clamp(96px, 20vw, 118px) minmax(0, 1fr);
  }

  .mansion-card,
  .deck-card {
    width: min(86px, 92%);
  }

  .mansion-card {
    min-height: 120px;
  }
}

/* ============================================================
   MEJORAS RESPONSIVAS - MESA ACTUAL (game board)
   Cubre vertical y horizontal en todos los dispositivos
   ============================================================ */

/* Móvil vertical pequeño (≤480px) */
@media (max-width: 480px) {
  .live-trackers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .tracker-icon {
    width: 22px;
    height: 22px;
  }

  .live-trackers div {
    padding: 5px 2px 3px;
  }

  .live-trackers span {
    font-size: 0.42rem;
  }

  .live-trackers strong {
    font-size: 0.66rem;
  }

  .re-btn-img {
    width: 24px;
    height: 24px;
  }

  .re-btn-icon {
    min-height: 44px !important;
    gap: 2px;
  }

  .action-row-end #end-turn {
    min-height: 44px !important;
  }

  .action-row-end #end-turn .re-btn-img {
    width: 28px;
    height: 28px;
  }

  .action-row-end #end-turn span {
    font-size: 0.74rem;
  }
}

/* Móvil vertical muy pequeño (≤360px) */
@media (max-width: 360px) {
  .live-trackers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }

  .tracker-icon {
    width: 18px;
    height: 18px;
  }

  .live-trackers div {
    padding: 4px 1px 2px;
  }

  .live-trackers span {
    font-size: 0.38rem;
  }

  .live-trackers strong {
    font-size: 0.6rem;
  }
}

/* Tableta horizontal y escritorio mediano */
@media (min-width: 861px) and (max-width: 1200px) {
  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 3px;
  }

  .tracker-icon {
    width: 20px;
    height: 20px;
  }

  .live-trackers div {
    padding: 4px 2px 3px;
  }

  .re-btn-img {
    width: 24px;
    height: 24px;
  }

  .re-btn-icon {
    min-height: 44px !important;
  }

  .action-row-end #end-turn .re-btn-img {
    width: 28px;
    height: 28px;
  }
}

/* Asegurar que en landscape móvil los botones no se corten */
@media (orientation: landscape) and (max-height: 540px) {
  .re-btn-icon {
    min-height: 40px !important;
    gap: 2px;
  }

  .re-btn-img {
    width: 22px;
    height: 22px;
  }

  .re-btn-icon span {
    font-size: 0.48rem;
  }

  .action-row-end #end-turn {
    min-height: 40px !important;
    padding: 6px 10px !important;
  }

  .action-row-end #end-turn .re-btn-img {
    width: 24px;
    height: 24px;
  }

  .action-row-end #end-turn span {
    font-size: 0.72rem;
  }

  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 2px;
    margin-bottom: 3px;
  }

  .tracker-icon {
    width: 18px;
    height: 18px;
  }

  .live-trackers span {
    font-size: 0.38rem;
  }

  .live-trackers strong {
    font-size: 0.58rem;
  }
}

/* ─── Alerta de inicio de turno ─────────────────────────── */
.turn-alert {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, 0.88);
  animation: turn-alert-bg-in 0.35s ease;
}

.turn-alert.hidden {
  display: none;
}

@keyframes turn-alert-bg-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.turn-alert-box {
  width: min(480px, 100%);
  padding: 40px 32px 36px;
  border: 2px solid rgba(216, 170, 50, 0.8);
  border-radius: 10px;
  text-align: center;
  background: #171b22;
  box-shadow: 0 0 40px rgba(216, 170, 50, 0.25), var(--shadow, 0 4px 24px #000a);
  animation: turn-alert-box-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes turn-alert-box-in {
  from { transform: scale(0.82) translateY(20px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.turn-alert-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: turn-alert-pulse 1.2s ease-in-out infinite;
}

@keyframes turn-alert-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

.turn-alert-box h2 {
  margin: 0 0 8px;
  color: #d8aa32;
  font-size: 1.85rem;
  letter-spacing: 0.02em;
  text-shadow: 0 0 16px rgba(216, 170, 50, 0.5);
}

.turn-alert-box p {
  margin: 0 0 28px;
  color: var(--ink, #cdd6e0);
  font-size: 1.05rem;
  line-height: 1.4;
}

.turn-alert-close {
  min-width: 160px;
  padding: 12px 28px;
  font-size: 1rem;
  background: #d8aa32;
  color: #111;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.1s;
}

.turn-alert-close:hover {
  background: #e8c040;
  transform: scale(1.04);
}

.turn-alert-close:active {
  transform: scale(0.97);
}

/* ─── Modal ganador de partida ───────────────────────────── */
.winner-alert {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, 0.9);
  animation: turn-alert-bg-in 0.35s ease;
}

.winner-alert.hidden {
  display: none;
}

.winner-alert-box {
  width: min(520px, 100%);
  padding: 40px 32px 36px;
  border: 2px solid rgba(100, 200, 100, 0.7);
  border-radius: 10px;
  text-align: center;
  background: #171b22;
  box-shadow: 0 0 48px rgba(80, 200, 80, 0.2), var(--shadow, 0 4px 24px #000a);
  animation: turn-alert-box-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.winner-alert-trophy {
  font-size: 3.5rem;
  margin-bottom: 10px;
  animation: turn-alert-pulse 1.4s ease-in-out infinite;
}

.winner-alert-box h2 {
  margin: 0 0 6px;
  color: #64c864;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  text-shadow: 0 0 16px rgba(80, 200, 80, 0.45);
}

.winner-alert-reason {
  margin: 0 0 18px;
  color: var(--ink-muted, #8a9baf);
  font-size: 0.92rem;
  line-height: 1.4;
}

.winner-alert-name {
  font-size: 1.55rem;
  font-weight: 800;
  color: #f5e97a;
  margin-bottom: 18px;
  letter-spacing: 0.03em;
  text-shadow: 0 0 12px rgba(245, 233, 122, 0.4);
}

.winner-alert-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.winner-stat {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 18px;
  min-width: 90px;
}

.winner-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.winner-stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted, #8a9baf);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.winner-alert-close {
  min-width: 180px;
  padding: 12px 28px;
  font-size: 1rem;
  background: #64c864;
  color: #0d1117;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.1s;
}

.winner-alert-close:hover {
  background: #7ade7a;
  transform: scale(1.04);
}

.winner-alert-close:active {
  transform: scale(0.97);
}

/* ══════════════════════════════════════════════════════════
   MODAL CENTRAL DE INVITACIÓN A SALA
   ══════════════════════════════════════════════════════════ */
.invite-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  animation: invite-overlay-in 0.3s ease;
}

.invite-modal-overlay.hidden {
  display: none;
}

@keyframes invite-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.invite-modal-box {
  background: var(--surface, #1a1f2e);
  border: 1px solid var(--accent, #e2312e);
  border-radius: 18px;
  padding: 32px 28px 24px;
  max-width: 380px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7), 0 0 0 1px rgba(226,49,46,0.25);
  animation: invite-box-in 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes invite-box-in {
  from { opacity: 0; transform: scale(0.82) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.invite-modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: invite-pulse 1.4s ease-in-out infinite;
}

@keyframes invite-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.18); }
}

.invite-modal-box h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent, #e2312e);
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

#invite-modal-from {
  font-size: 1rem;
  color: var(--fg, #eee);
  margin: 0 0 6px;
  font-weight: 600;
}

.invite-modal-details {
  font-size: 0.8rem;
  color: var(--muted, #888);
  margin: 0 0 20px;
}

.invite-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.invite-modal-actions .primary-button {
  min-width: 120px;
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 10px;
  background: var(--accent, #e2312e);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: opacity 0.15s;
}

.invite-modal-actions .primary-button:hover { opacity: 0.85; }

.invite-modal-actions .ghost-button {
  min-width: 120px;
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 10px;
  background: transparent;
  color: var(--fg, #eee);
  border: 1px solid var(--line, #444);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.invite-modal-actions .ghost-button:hover { background: rgba(255,255,255,0.06); }

.start-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(4px);
}

.start-confirm-overlay.hidden {
  display: none;
}

.start-confirm-box {
  width: min(390px, calc(100% - 32px));
  padding: 30px 24px 22px;
  text-align: center;
  background: var(--surface, #1a1f2e);
  border: 1px solid var(--accent, #e2312e);
  border-radius: 12px;
  box-shadow: 0 10px 46px rgba(0, 0, 0, 0.7);
}

.start-confirm-icon {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--accent, #e2312e);
  color: #fff;
  font-weight: 900;
  font-size: 1.35rem;
}

.start-confirm-box h2 {
  margin: 0 0 8px;
  color: var(--fg, #eee);
  font-size: 1.2rem;
}

.start-confirm-box p {
  margin: 0 0 10px;
  color: var(--muted, #aaa);
}

.start-confirm-status {
  font-weight: 800;
  color: var(--fg, #eee) !important;
}

.start-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.start-confirm-actions button {
  min-width: 118px;
}

.player-slot-empty {
  min-width: 0;
  display: grid;
  align-items: center;
  min-height: 62px;
  padding: 8px;
  border: 1px dashed rgba(216, 168, 77, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.player-slot-empty strong,
.player-slot-empty span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-slot-empty strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.player-slot-empty span {
  margin-top: 2px;
  font-size: 0.7rem;
}

@media (orientation: landscape) and (min-width: 1001px) and (max-width: 1500px) {
  .app-shell {
    grid-template-columns: clamp(215px, 16vw, 250px) minmax(0, 1fr) clamp(300px, 22vw, 340px);
  }

  .hand {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow-x: hidden;
  }

  .hand .card-face {
    min-width: 0;
  }

  .chat-panel {
    grid-template-rows: auto minmax(170px, 1fr) auto;
  }

  #chat-form {
    grid-template-columns: minmax(92px, 1fr) minmax(62px, auto) minmax(66px, auto);
    gap: 6px;
  }
}

/* Mobile landscape: prioritize the playable board over secondary panels. */
@media (orientation: landscape) and (max-width: 1100px) and (max-height: 540px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 292px !important;
    grid-template-rows: minmax(0, 1fr) 96px !important;
    grid-template-areas:
      "game side"
      "game rail";
    gap: 4px;
    overflow: hidden;
  }

  .game-surface {
    grid-area: game;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    padding: 4px;
    border-radius: 0;
    grid-template-rows: 34px minmax(0, 1fr);
    gap: 4px;
    overflow: hidden;
  }

  .sidebar {
    grid-area: side;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 4px;
    overflow: hidden;
    border-radius: 0;
  }

  .right-rail {
    grid-area: rail;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    display: grid !important;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    border-radius: 0;
  }

  .panel,
  .game-surface {
    padding: 4px;
  }

  .brand {
    min-height: 34px;
    height: 34px;
    padding: 3px 5px;
  }

  .brand-mark,
  .avatar {
    width: 26px;
    height: 26px;
    font-size: 0.68rem;
  }

  .brand h1,
  #player-name {
    font-size: 0.62rem;
    line-height: 1;
  }

  .brand span,
  .profile-panel .small,
  .stats-row,
  .availability-toggle,
  .history-panel,
  .right-rail .resources-panel,
  .right-rail .rules-panel {
    display: none !important;
  }

  .profile-panel {
    min-height: 34px;
    height: 34px;
    overflow: hidden;
  }

  .profile-row {
    gap: 5px;
  }

  .logout-button {
    min-height: 24px;
  }

  .online-panel {
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .online-panel .section-title,
  .add-user-form {
    margin-bottom: 3px;
  }

  #site-users,
  #friend-list,
  #invitation-list {
    max-height: 66px;
    overflow: hidden auto;
  }

  .friend {
    min-height: 28px;
    padding: 4px;
  }

  .friend strong {
    font-size: 0.62rem;
  }

  .friend span {
    font-size: 0.54rem;
  }

  .friend button {
    min-height: 22px;
    max-width: 64px;
    font-size: 0.56rem;
  }

  .room-panel {
    min-height: 0;
    overflow: hidden auto;
  }

  .room-panel label,
  .room-panel select,
  .room-panel button {
    min-height: 22px;
    font-size: 0.58rem;
  }

  .room-panel .section-title,
  .room-panel label {
    margin-bottom: 2px;
  }

  .room-panel .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    margin-top: 4px;
  }

  .start-button,
  .room-end-command {
    margin-top: 4px;
  }

  #room-status {
    display: none;
  }

  .topbar {
    min-height: 0;
    align-items: center;
    gap: 4px;
  }

  .topbar .eyebrow {
    display: none;
  }

  #room-title {
    font-size: 0.82rem;
    line-height: 1.1;
  }

  .top-actions {
    margin-left: auto;
    gap: 4px;
    flex-wrap: nowrap;
  }

  .top-actions button,
  .turn-pill {
    min-height: 24px;
    height: 24px;
    padding: 0 7px;
    font-size: 0.6rem;
  }

  .volume-controls {
    display: none;
  }

  .board {
    min-height: 0;
    height: 100%;
    grid-template-rows: clamp(44px, 15dvh, 64px) minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
    overflow: hidden;
  }

  .table-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-height: 0;
  }

  .table-grid .player-card,
  .player-slot-empty {
    min-height: 0;
    height: 100%;
    padding: 3px;
    overflow: hidden;
  }

  .table-grid .player-card {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 4px;
    align-items: center;
  }

  .table-grid .player-card .portrait {
    width: 30px;
    height: 38px;
    min-height: 38px;
    margin: 0;
    grid-row: 1 / 4;
  }

  .table-grid .player-card > span,
  .table-grid .character-read-btn,
  .player-meta,
  .player-name-row em,
  .player-slot-empty span {
    display: none;
  }

  .player-name-row strong,
  .player-slot-empty strong {
    font-size: 0.58rem;
    line-height: 1.05;
  }

  .health-bar {
    height: 5px;
    margin: 2px 0 0;
  }

  .play-area {
    grid-template-columns: clamp(128px, 25%, 190px) minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
    height: 100%;
  }

  .table-zone {
    min-height: 0;
    padding: 4px;
    overflow: hidden;
  }

  .mansion-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 4px;
  }

  .mansion-row {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }

  .deck-stack {
    min-height: 0;
    height: 100%;
  }

  .mansion-card {
    width: min(96px, 72%);
    min-height: 0;
    aspect-ratio: 2.5 / 3.5;
    padding: 5px;
    font-size: 0.62rem;
  }

  .deck-card {
    width: min(92px, 70%);
  }

  .discard-slot {
    display: none;
  }

  .mansion-command-zone {
    display: grid;
    gap: 3px;
  }

  .action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    margin: 0;
    padding: 3px;
  }

  .action-row-end {
    grid-template-columns: 1fr;
  }

  .turn-command {
    min-height: 24px;
    height: 24px;
    padding: 0 3px;
    font-size: 0.48rem;
  }

  .re-btn-img {
    width: 18px;
    height: 18px;
  }

  .turn-footer {
    min-height: 24px;
    gap: 4px;
  }

  .turn-footer .status {
    font-size: 0.52rem;
    line-height: 1.15;
  }

  #turn-timer {
    min-width: 52px;
    height: 24px;
    padding: 2px 5px;
    font-size: 0.64rem;
  }

  .controls-panel {
    display: grid;
    grid-template-rows: auto auto minmax(70px, 1fr) 42px 44px 38px minmax(0, 28px);
    gap: 4px;
    overflow: hidden;
  }

  .controls-panel > .section-title {
    margin-bottom: 0;
  }

  .controls-panel > .section-title h2 {
    font-size: 0.72rem;
  }

  .live-trackers {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 3px;
  }

  .live-trackers div {
    min-height: 24px;
    padding: 2px;
  }

  .tracker-icon {
    width: 16px;
    height: 16px;
  }

  .live-trackers span {
    display: none;
  }

  .live-trackers strong {
    font-size: 0.56rem;
  }

  .hand {
    min-height: 0;
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    gap: 4px;
    overflow: hidden auto;
  }

  .hand .card-face,
  .card-face {
    min-height: 58px;
    max-height: 88px;
    padding: 3px;
  }

  .card-copy span {
    display: none;
  }

  .card-copy small {
    font-size: 0.46rem;
  }

  .card-copy strong {
    font-size: 0.52rem;
  }

  .player-card-zones {
    min-height: 0;
    height: 42px;
    gap: 4px;
    overflow: hidden;
  }

  .player-zone {
    padding: 3px;
  }

  .compact-title {
    margin-bottom: 1px;
  }

  .compact-title h2,
  .compact-title span {
    font-size: 0.5rem;
    line-height: 1;
  }

  .player-stack-zone,
  .player-discard-zone {
    min-height: 20px;
    height: 20px;
    overflow: hidden;
  }

  .action-picker,
  .weapon-picker,
  .played-row {
    min-height: 0;
    margin-top: 0;
    padding: 3px;
    overflow: hidden;
  }

  .action-card-list,
  .weapon-list,
  .played-cards {
    max-height: 24px;
    overflow: hidden auto;
  }

  .action-card-list .action-select-card,
  .weapon-list .weapon-select-card,
  .played-cards .played-turn-card {
    height: 24px;
    min-height: 24px;
    max-height: 24px;
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .played-row .section-title,
  .weapon-picker .section-title,
  .action-picker .section-title {
    margin-bottom: 2px;
  }

  .played-row .section-title h2,
  .weapon-picker .section-title h2,
  .action-picker .section-title h2 {
    font-size: 0.58rem;
  }

  .chat-panel {
    min-height: 0;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .chat-panel .section-title {
    margin-bottom: 2px;
  }

  #chat-log {
    display: none;
  }

  #chat-form {
    grid-template-columns: minmax(0, 1fr) minmax(56px, auto) minmax(58px, auto);
    gap: 3px;
    margin-top: 0;
  }

  #chat-input,
  #voice-message,
  #chat-submit {
    min-height: 24px;
    font-size: 0.58rem;
  }
}

@media (orientation: landscape) and (max-width: 760px) and (max-height: 430px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) 190px !important;
    grid-template-rows: minmax(0, 1fr) 76px !important;
  }

  .online-panel {
    display: none;
  }

  .sidebar {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .brand {
    display: none;
  }

  .play-area {
    grid-template-columns: clamp(96px, 23%, 126px) minmax(0, 1fr);
  }

  .board {
    grid-template-rows: 40px minmax(0, 1fr);
  }

  .controls-panel {
    grid-template-rows: auto auto minmax(58px, 1fr) 34px 34px minmax(0, 24px);
  }

  .played-row {
    display: none;
  }

  .turn-footer .status {
    display: none;
  }
}

/* ══════════════════════════════════════════════════════════
   NOTIFICACIÓN FLOTANTE DE CHAT
   ══════════════════════════════════════════════════════════ */
.chat-notif-toast {
  position: fixed;
  bottom: 80px;
  right: 18px;
  z-index: 8888;
  background: var(--surface, #1a1f2e);
  border: 1px solid var(--line, #444);
  border-left: 4px solid #3b82f6;
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 280px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: chat-notif-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

@keyframes chat-notif-in {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

.chat-notif-toast strong {
  font-size: 0.82rem;
  color: #3b82f6;
  font-weight: 700;
}

.chat-notif-toast span {
  font-size: 0.78rem;
  color: var(--fg, #eee);
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

@media (max-width: 480px) {
  .invite-modal-box {
    padding: 24px 16px 20px;
  }
  .chat-notif-toast {
    bottom: 60px;
    right: 10px;
    max-width: 230px;
  }
}

/* Panel único para Acciones / Armas / Cartas jugadas */
.hand-zone-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.hand-zone-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.hand-zone-tab {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 10px 8px;
  background: rgba(10, 16, 24, .78);
  color: #f5f5f5;
  font-weight: 700;
  cursor: pointer;
}
.hand-zone-tab.active {
  background: linear-gradient(135deg, rgba(160, 20, 30, .95), rgba(50, 12, 18, .95));
  border-color: rgba(255,255,255,.35);
  box-shadow: 0 0 0 2px rgba(255,255,255,.08) inset;
}
.hand-zone-panel { display: none; }
.hand-zone-panel.active { display: block; }
@media (max-width: 720px) {
  .hand-zone-tabs { grid-template-columns: 1fr; }
}


/* Inicio remake sangriento + lupa de cartas */
.blood-title {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #f3f5f8;
  text-shadow: 0 2px 0 #210000, 0 0 16px rgba(199, 0, 0, 0.8), 0 0 34px rgba(255, 178, 64, 0.35);
}

.blood-title span {
  background: linear-gradient(180deg, #fff 0%, #f0c35b 34%, #b00000 66%, #4a0000 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 rgba(20, 0, 0, 0.8));
}

.blood-title em {
  width: fit-content;
  padding: 3px 10px 4px;
  border: 1px solid rgba(170, 0, 0, 0.75);
  border-radius: 999px;
  color: #fff1d6;
  background: linear-gradient(135deg, rgba(70, 0, 0, 0.95), rgba(160, 0, 0, 0.78), rgba(24, 0, 0, 0.95));
  box-shadow: inset 0 0 18px rgba(255, 0, 0, 0.22), 0 0 18px rgba(140, 0, 0, 0.35);
  font-size: clamp(0.78rem, 2.4vw, 1.1rem);
  font-style: normal;
  letter-spacing: 2px;
}

.guide-card {
  position: relative;
  overflow: hidden;
}

.guide-card-zoom {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(239, 190, 76, 0.92);
  color: #f7c65c;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 14px rgba(239, 190, 76, 0.28);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.guide-card-zoom:hover,
.guide-card-zoom:focus-visible {
  transform: scale(1.08);
  color: #10141b;
  background: var(--accent);
}

.home-card-zoom-modal.hidden {
  display: none;
}

.home-card-zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
}

.home-card-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 18%, rgba(90, 0, 0, 0.34), transparent 34%), rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(7px);
}

.home-card-zoom-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 96vw);
  max-height: 94vh;
  display: grid;
  grid-template-columns: minmax(220px, 390px) minmax(240px, 1fr);
  gap: 18px;
  padding: 18px;
  overflow: auto;
  border: 1px solid rgba(239, 190, 76, 0.58);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(12, 15, 22, 0.98), rgba(32, 8, 9, 0.97));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72), inset 0 0 46px rgba(150, 0, 0, 0.16);
}

.home-card-zoom-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  color: #fff;
  background: rgba(140, 0, 0, 0.86);
  border: 1px solid rgba(255, 210, 105, 0.66);
  font-size: 1.8rem;
  line-height: 1;
}

.home-card-zoom-image-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
}

.home-card-zoom-image-wrap img {
  width: min(100%, 390px);
  max-height: 82vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(239, 190, 76, 0.38);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.68), 0 0 22px rgba(196, 0, 0, 0.22);
}

.home-card-zoom-info {
  align-self: center;
  color: #f5f7fb;
}

.home-card-zoom-info span {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #10141b;
  background: var(--accent);
  font-weight: 900;
  text-transform: uppercase;
}

.home-card-zoom-info h3 {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(1.7rem, 4vw, 3rem);
  text-shadow: 0 0 18px rgba(190, 0, 0, 0.66);
}

.home-card-zoom-info p {
  color: #d9e1ee;
  font-size: 1rem;
  line-height: 1.55;
}

.home-card-zoom-info strong {
  display: block;
  margin-top: 14px;
  color: var(--accent);
  font-size: 1.05rem;
}

body.card-zoom-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .home-card-zoom-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .home-card-zoom-image-wrap img {
    max-height: 58vh;
  }
}
/* PHP/MySQL auth: campos de registro ocultos hasta elegir Crear cuenta */
#site-name,
#site-fullname,
#site-birthdate,
#site-age,
#site-password-confirm {
  display: none;
}


/* Notificaciones centrales tipo juego (reemplazan alert/confirm del navegador) */
.center-notification-stack {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  gap: 14px;
  pointer-events: none;
  padding: 18px;
}

.center-notification {
  width: min(560px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(216, 168, 77, 0.55);
  border-radius: 18px;
  color: var(--ink);
  background: radial-gradient(circle at top left, rgba(216, 168, 77, 0.16), rgba(12, 14, 18, 0.98) 45%, rgba(5, 6, 9, 0.98));
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.62), inset 0 0 0 1px rgba(255,255,255,0.04);
  pointer-events: auto;
  animation: center-notification-in 0.24s ease-out;
}

@keyframes center-notification-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.center-notification.success { border-color: rgba(79, 191, 138, 0.72); }
.center-notification.error { border-color: rgba(216, 95, 95, 0.72); }
.center-notification.confirm { border-color: rgba(113, 223, 235, 0.82); }

.center-notification-card-img {
  width: 86px;
  height: 118px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(216, 168, 77, 0.48);
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
  background: #050608;
}

.center-notification-body strong,
.center-notification-body span {
  display: block;
}

.center-notification-body strong {
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.center-notification-body span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.center-notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.center-notification-actions button {
  min-width: 118px;
}

@media (max-width: 560px) {
  .center-notification {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
  .center-notification-actions { justify-content: center; }
}

/* Confirmación central con miniatura de carta y botones siempre clickeables */
.center-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
  pointer-events: auto;
}

.center-confirm-card {
  width: min(560px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(113, 223, 235, 0.82);
  border-radius: 18px;
  color: var(--ink);
  background: radial-gradient(circle at top left, rgba(216, 168, 77, 0.16), rgba(12, 14, 18, 0.98) 45%, rgba(5, 6, 9, 0.98));
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255,255,255,0.04);
  pointer-events: auto;
  animation: center-notification-in 0.24s ease-out;
}

.center-confirm-card .center-notification-actions button {
  cursor: pointer;
  pointer-events: auto;
}

@media (max-width: 560px) {
  .center-confirm-card {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
}

/* Selector central de cartas con miniaturas */
.center-choice-card {
  width: min(900px, calc(100vw - 36px));
  max-height: min(86vh, 760px);
  align-items: start;
}
.center-choice-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
  max-height: 46vh;
  overflow: auto;
  padding: 4px 4px 8px;
}
.center-choice-option {
  min-height: 166px;
  cursor: pointer;
  position: relative;
  border: 1px solid rgba(216, 168, 77, 0.35);
}
.center-choice-option.selected-card {
  outline: 3px solid rgba(113, 223, 235, 0.95);
  box-shadow: 0 0 0 4px rgba(113, 223, 235, 0.16), 0 16px 34px rgba(0,0,0,0.55);
  transform: translateY(-2px);
}
.center-choice-name {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 4px 5px;
  border-radius: 8px;
  background: rgba(0,0,0,0.72);
  color: var(--ink);
  font-size: 0.68rem;
  line-height: 1.1;
  pointer-events: none;
}
.center-choice-counter {
  margin-top: 10px;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.86rem;
}
.center-choice-overlay .primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
@media (max-width: 560px) {
  .center-choice-card { grid-template-columns: 1fr; }
  .center-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
