:root {
  --bg: #080a0f;
  --panel: rgba(22, 26, 36, 0.92);
  --panel-2: rgba(31, 37, 50, 0.95);
  --line: rgba(255, 255, 255, 0.13);
  --text: #eef3ff;
  --muted: #9ea9bd;
  --accent: #74d4ff;
  --accent-2: #d14f6d;
  --you-rgb: 116, 212, 255;
  --opponent-rgb: 209, 79, 109;
  --you-color: rgb(var(--you-rgb));
  --opponent-color: rgb(var(--opponent-rgb));
  --danger: #bd324f;
  --card-w: 104px;
  --card-h: 146px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(116, 212, 255, 0.14), transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(209, 79, 109, 0.16), transparent 25%),
    linear-gradient(140deg, #06070b, #111827 55%, #080a0f);
  min-height: 100vh;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  background: #22293a;
  cursor: pointer;
}

button:hover { filter: brightness(1.13); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: #146a8f; }
button.secondary { background: #394155; }
button.danger { background: var(--danger); }
button.tiny { padding: 0.25rem 0.5rem; font-size: 0.82rem; border-radius: 8px; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  color: var(--text);
  background: #0f1420;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.assist-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: max-content;
}

.assist-toggle input {
  width: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1rem 0;
}

#app {
  position: relative;
  z-index: 1;
  width: min(1760px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 22px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 12px;
}

.app-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.55rem, 2vw, 2.25rem);
  letter-spacing: 0.02em;
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.pill {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.pill.ok { color: #a5ffc7; }
.pill.bad { color: #ffb0b9; }
.pill.warn { color: #ffe199; }

.account-page {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 70);
  display: block;
  overflow: auto;
  padding: 24px;
  background:
    radial-gradient(circle at 14% 14%, rgba(116, 212, 255, 0.16), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(209, 79, 109, 0.14), transparent 24%),
    linear-gradient(145deg, #070910, #111827 58%, #07090e);
}

.account-page.hidden { display: none; }

body.account-page-open {
  overflow: hidden;
}

.account-shell {
  width: min(1180px, calc(100vw - 48px));
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  overflow: visible;
  display: grid;
  gap: 0.85rem;
  align-content: start;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(15, 18, 28, 0.9);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 24px 80px rgba(0,0,0,0.62);
}

.account-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.account-tabs button {
  min-width: 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.82);
  font-weight: 800;
  cursor: pointer;
}

.account-tabs button.selected {
  border-color: rgba(106, 168, 255, 0.82);
  background: rgba(106, 168, 255, 0.18);
  color: #fff;
}

.account-tab-panel {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.account-status-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
}

.account-status-card span,
.account-status-card small,
.account-message {
  color: var(--muted);
}

.account-status-card strong {
  color: #fff;
  overflow-wrap: anywhere;
}

.patreon-link-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
}

.patreon-link-panel.connected {
  border-color: rgba(106, 255, 172, 0.28);
  background: rgba(106, 255, 172, 0.08);
}

.patreon-link-panel strong {
  color: #fff;
}

.patreon-link-panel p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.patreon-link-panel button {
  white-space: nowrap;
}

.account-detail-rows {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.account-detail-rows div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.account-detail-rows span {
  font-size: 0.78rem;
}

.account-detail-rows strong {
  max-width: 68%;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.account-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.account-form-grid label {
  display: grid;
  gap: 0.35rem;
}

.account-form-grid input {
  min-width: 0;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.account-actions button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.account-message {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.88rem;
}

.account-signup-note {
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 225, 153, 0.24);
  background: rgba(255, 225, 153, 0.1);
  color: #ffe199;
  font-size: 0.84rem;
  line-height: 1.35;
}

.account-signup-confirmation {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(116, 212, 255, 0.24);
  background: rgba(116, 212, 255, 0.09);
  text-align: center;
}

.account-signup-confirmation.hidden {
  display: none;
}

.account-signup-confirmation strong {
  color: #fff;
  font-size: 1.05rem;
}

.account-signup-confirmation p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.account-signup-confirmation span {
  color: #fff;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.account-api-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.account-api-grid section {
  display: grid;
  gap: 0.15rem;
  padding: 0.55rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  text-align: center;
}

.account-api-grid span {
  color: var(--muted);
  font-size: 0.78rem;
}

.account-api-grid strong {
  font-size: 1.1rem;
}

.account-section-note,
.account-section-error {
  margin: 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.account-section-error {
  color: #ffb0b9;
  background: rgba(248, 113, 113, 0.12);
}

.open-pack-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(116, 212, 255, 0.24);
  background: linear-gradient(135deg, rgba(116, 212, 255, 0.13), rgba(209, 79, 109, 0.08));
}

.open-pack-copy {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.open-pack-copy strong {
  color: #fff;
}

.open-pack-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.open-pack-panel > .account-section-error,
.pack-result-panel {
  grid-column: 1 / -1;
}

.pack-result-panel {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.pack-result-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.pack-result-header span,
.pack-pull-meta,
.pack-pull-main small {
  color: var(--muted);
}

.pack-pull-list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pack-pull-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) minmax(5.5rem, auto) minmax(5.5rem, auto);
  gap: 0.55rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.pack-pull-index {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgba(116, 212, 255, 0.18);
  color: #dff6ff;
  font-weight: 800;
}

.pack-pull-main {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.pack-pull-main strong,
.pack-pull-main small {
  overflow-wrap: anywhere;
}

.account-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.account-data-table th,
.account-data-table td {
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.account-data-table th {
  color: rgba(255,255,255,0.72);
  font-size: 0.72rem;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .account-tabs,
  .account-form-grid,
  .account-api-grid {
    grid-template-columns: 1fr;
  }

  .open-pack-panel,
  .patreon-link-panel,
  .pack-pull-row {
    grid-template-columns: 1fr;
  }

  .pack-pull-row {
    align-items: start;
  }
}

.lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.lobby-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.lobby-card h2,
.left-panel h2,
.right-panel h2,
.hand-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.hint, .subtle, .muted {
  color: var(--muted);
}

.hidden { display: none !important; }

.game {
  display: grid;
  gap: 12px;
}

.top-row {
  padding: 0.5rem 0.65rem;
  display: grid;
  align-items: stretch;
}

.turn-control-row {
  display: grid;
  align-items: center;
  padding: 0.42rem 0.65rem;
}

.room-game-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(max-content, auto) minmax(max-content, auto);
  gap: 0.7rem;
  align-items: center;
  min-width: 0;
  width: 100%;
}

.room-line {
  font-size: 0.9rem;
  line-height: 1.05;
}

.room-info,
.room-subline {
  min-width: 0;
}

.room-subline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
}

.game-info-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
  justify-self: center;
}

.toolbar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  justify-self: end;
  margin-left: auto;
  min-width: max-content;
}

.damage-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
}

.damage-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.damage-group:last-child {
  justify-content: flex-end;
}

.damage-seat {
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #dff6ff;
}

.damage-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.045);
}

.damage-counter.aftershock {
  background: rgba(116, 212, 255, 0.075);
  border-color: rgba(116, 212, 255, 0.16);
}

.damage-label {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.damage-value {
  min-width: 1.6rem;
  text-align: center;
  font-size: 1.08rem;
}

.damage-divider {
  color: rgba(255,255,255,0.42);
  font-weight: 900;
  letter-spacing: 0.2em;
  user-select: none;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(820px, 1fr) 300px;
  gap: 12px;
}

.left-panel, .right-panel {
  padding: 0.85rem;
  min-height: 620px;
}

.board-wrap {
  padding: 0.6rem;
  overflow: auto;
}

.board-stage {
  position: relative;
  width: 100%;
  min-width: 820px;
  height: 680px;
  min-height: 620px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.11);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(116,212,255,0.08), transparent 45%),
    #0c111a;
  background-size: 16.666% 100%, auto, auto;
}

.site-zone {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: none;
  border: 1px dashed rgba(255, 255, 255, 0.19);
  background: rgba(255, 255, 255, 0.035);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.08rem;
  padding-top: 8px;
  color: rgba(255, 255, 255, 0.58);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  user-select: none;
}

.site-zone.space { background: rgba(255, 255, 255, 0.025); }
.site-zone.interior { background: rgba(255, 255, 255, 0.04); }
.site-zone.exterior { background: rgba(209, 79, 109, 0.04); }
.site-zone.p1 { border-color: rgba(116, 212, 255, 0.22); }
.site-zone.p2 { border-color: rgba(209, 79, 109, 0.22); }

.zone-seat {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.42);
}

.zone-name {
  font-weight: 700;
}

.perspective-note {
  position: absolute;
  left: 50%;
  top: 8px;
  z-index: 3;
  transform: translateX(-50%);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.36);
  color: rgba(255,255,255,0.58);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

.center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.24);
  box-shadow: 0 0 18px rgba(116,212,255,0.35);
  pointer-events: none;
}

.board-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10, 14, 21, 0.82);
  color: #dff6ff;
  font-size: 0.79rem;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.table-card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.22);
  background: #171d28;
  box-shadow: 0 10px 22px rgba(0,0,0,0.48);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.1s ease, filter 0.1s ease;
}

.table-card.dragging {
  cursor: grabbing;
  filter: brightness(1.12);
  z-index: 99999999 !important;
}

.table-card.selected {
  outline: 3px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(116,212,255,0.18), 0 18px 30px rgba(0,0,0,0.55);
}

.table-card.attach-source {
  outline: 3px solid #ffd86e;
  box-shadow: 0 0 0 6px rgba(255, 216, 110, 0.18), 0 18px 30px rgba(0,0,0,0.55);
}

.table-card.attack-source {
  outline: 3px solid rgba(255, 86, 86, 0.92);
  box-shadow: 0 0 0 6px rgba(255, 86, 86, 0.2), 0 18px 30px rgba(0,0,0,0.55);
}

.table-card.attached-card {
  border-color: rgba(255,255,255,0.3);
}

.table-card.tapped {
  transform: rotate(90deg);
}

.table-card-art,
.hand-art,
.combat-modal-art,
.card-art {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d121d;
}

.card-img {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0d121d;
}

.card-img.missing-image,
.zoom-img.missing-image {
  display: none;
}

.card-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0.45rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  background: linear-gradient(160deg, #20283a, #111722);
}

.face-down-fallback {
  z-index: 2;
  background:
    radial-gradient(circle at 50% 30%, rgba(116, 212, 255, 0.16), transparent 32%),
    linear-gradient(160deg, #20283a, #111722);
}

.can-zoom { cursor: zoom-in; }

.zoom-mini-button {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 12;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.32);
  background: rgba(0,0,0,0.68);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1;
  cursor: zoom-in;
}

.zoom-mini-button:hover { filter: brightness(1.25); }

.layer-badge {
  position: absolute;
  left: 32px;
  top: 4px;
  padding: 0.08rem 0.3rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.64);
  color: #c9f1ff;
  font-size: 0.64rem;
  border: 1px solid rgba(255,255,255,0.16);
}

.owner-badge {
  position: absolute;
  right: 4px;
  top: 4px;
  padding: 0.08rem 0.32rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.64);
  color: white;
  font-size: 0.67rem;
}

.attachment-badge {
  position: absolute;
  right: 4px;
  top: 24px;
  padding: 0.08rem 0.32rem;
  border-radius: 999px;
  background: rgba(18, 28, 42, 0.82);
  color: #ffe8b0;
  font-size: 0.61rem;
  border: 1px solid rgba(255,255,255,0.14);
}

.counter-row {
  position: absolute;
  left: 3px;
  bottom: 3px;
  z-index: 24;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  max-width: 98%;
}

.counter {
  padding: 0.06rem 0.28rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.18);
}

.counter.wound { color: #ff9aa9; }
.counter.echo { color: #a5e9ff; }
.counter.generic { color: #ffe6a5; }

.wound-overlay {
  position: absolute;
  right: 6px;
  bottom: 24px;
  z-index: 22;
  display: grid;
  place-items: center;
  min-width: 38px;
  min-height: 38px;
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
  background: rgba(160, 0, 25, 0.88);
  border: 2px solid rgba(255, 230, 235, 0.86);
  color: #fff;
  box-shadow: 0 0 14px rgba(255, 40, 80, 0.55), 0 8px 16px rgba(0,0,0,0.48);
  pointer-events: none;
  transform: rotate(-8deg);
}

.wound-overlay span {
  display: block;
  font-size: 0.45rem;
  line-height: 1;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.wound-overlay strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 900;
}

.floating-counter-stack {
  position: absolute;
  left: 4px;
  top: 32px;
  z-index: 23;
  display: grid;
  gap: 2px;
  pointer-events: none;
}

.players-card {
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  margin-bottom: 0.55rem;
}

.players-card strong { display: block; }
.players-card .small { color: var(--muted); font-size: 0.86rem; margin-top: 0.15rem; }

.selected-panel {
  display: grid;
  gap: 0.5rem;
}

.selected-name {
  font-weight: 700;
  line-height: 1.25;
}

.attach-mode-note {
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255, 216, 110, 0.08);
  color: #ffe9af;
  font-size: 0.84rem;
}

.selected-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.log-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  margin: 0.65rem 0;
}

.game-log {
  height: 360px;
  overflow: auto;
  padding-right: 0.25rem;
}

.log-line {
  padding: 0.42rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 0.9rem;
}

.log-line time {
  color: var(--muted);
  font-size: 0.76rem;
  margin-right: 0.35rem;
}

.hand-panel {
  padding: 0.85rem;
}

.hand-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.hand-cards {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.65rem;
  min-height: 205px;
}

.hand-card {
  flex: 0 0 126px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 0.45rem;
}

.hand-art {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2.5 / 3.5;
  border-radius: 8px;
  overflow: hidden;
  background: #111722;
  border: 1px solid rgba(255,255,255,0.12);
}

.hand-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.18;
  min-height: 2.2em;
  margin: 0.35rem 0;
}

.hand-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}

.discard-details {
  color: var(--muted);
}

.discard-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.discard-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.84rem;
  cursor: zoom-in;
}


.planet-panel {
  display: grid;
  gap: 0.55rem;
  padding: 0.6rem;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
}

.planet-panel-header {
  display: grid;
  gap: 0.12rem;
}

.planet-panel-header strong {
  font-size: 0.92rem;
}

.planet-panel-header span {
  color: var(--muted);
  font-size: 0.78rem;
}

.echo-tracker {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem;
  border-radius: 12px;
  background: rgba(116, 212, 255, 0.07);
  border: 1px solid rgba(116, 212, 255, 0.14);
}

.echo-value {
  display: grid;
  place-items: center;
  line-height: 1;
}

.echo-value span {
  font-size: 1.7rem;
  font-weight: 800;
  color: #d9f6ff;
}

.echo-value small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
}

.planet-slot {
  min-height: 170px;
  display: grid;
  gap: 0.5rem;
  align-items: start;
}

.planet-empty {
  display: grid;
  place-items: center;
  min-height: 145px;
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  padding: 0.7rem;
  font-size: 0.85rem;
}

.planet-card {
  position: relative;
  width: min(150px, 100%);
  justify-self: center;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  background: rgba(13, 18, 29, 0.96);
  box-shadow: 0 10px 24px rgba(0,0,0,0.38);
  overflow: hidden;
  cursor: pointer;
}

.planet-card.selected {
  outline: 3px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(116,212,255,0.18), 0 18px 30px rgba(0,0,0,0.55);
}

.planet-card-art {
  position: relative;
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  overflow: hidden;
  background: #0d121d;
}

.planet-card.landscape-planet-card {
  width: min(260px, 100%);
}

.planet-card.landscape-planet-card .planet-card-art {
  aspect-ratio: 3.5 / 2.5;
}

.planet-card-footer {
  padding: 0.35rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.15;
  min-height: 2.1em;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .left-panel, .right-panel { min-height: auto; }
  .game-log { height: 220px; }
}

@media (max-width: 720px) {
  #app { width: calc(100vw - 12px); padding-top: 8px; }
  .app-header, .top-row, .hand-heading { align-items: stretch; flex-direction: column; }
  .damage-row { grid-template-columns: 1fr; }
  .damage-divider { display: none; }
  .damage-group, .damage-group:last-child { justify-content: flex-start; }
  .lobby { grid-template-columns: 1fr; }
  .board-stage { height: 580px; }
  :root { --card-w: 82px; --card-h: 115px; }
}

.hand-art { cursor: zoom-in; }

.zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
}

.zoom-card-shell {
  width: min(92vw, 620px);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  padding: 0.85rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(16, 20, 30, 0.98);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.zoom-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.zoom-body {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: auto;
}

.zoom-body img,
.zoom-img {
  position: relative;
  z-index: 2;
  width: auto;
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.zoom-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 2rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 14px;
  background: linear-gradient(160deg, #20283a, #111722);
  color: var(--text);
}

.zoom-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

/* v10 private pile console */
.deck-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0.9rem;
  align-items: stretch;
}

.hand-main-area {
  min-width: 0;
}

.pile-sidebar {
  border-left: 1px solid rgba(255,255,255,0.1);
  padding-left: 0.85rem;
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.pile-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.pile-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.pile-box {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  padding: 0.5rem;
  display: grid;
  gap: 0.45rem;
  min-height: 150px;
}

.pile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pile-header strong {
  font-size: 0.82rem;
  line-height: 1.1;
}

.pile-header span {
  min-width: 26px;
  text-align: center;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: rgba(116, 212, 255, 0.1);
  color: #c9f1ff;
  font-size: 0.75rem;
  font-weight: 700;
}

.pile-top {
  position: relative;
  min-height: 52px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.11);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.pile-top.face-down {
  background:
    radial-gradient(circle at 50% 32%, rgba(116, 212, 255, 0.16), transparent 35%),
    linear-gradient(160deg, #20283a, #111722);
  color: #dceaff;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pile-top.face-up {
  min-height: 96px;
  align-items: stretch;
  justify-items: stretch;
  background: #0d121d;
}

.pile-top.empty {
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.38);
  font-weight: 400;
  text-transform: none;
}

.pile-top-art {
  position: relative;
  width: 56px;
  height: 78px;
  justify-self: center;
  margin-top: 0.25rem;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
}

.pile-top-name {
  padding: 0.2rem 0.3rem 0.35rem;
  font-size: 0.66rem;
  line-height: 1.15;
  color: var(--text);
}

.pile-actions {
  display: grid;
  gap: 0.28rem;
}

.pile-actions button {
  width: 100%;
  padding-left: 0.3rem;
  padding-right: 0.3rem;
}

.token-bank-preview {
  position: relative;
  min-height: 74px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 9px;
  background: rgba(116, 212, 255, 0.055);
  color: var(--text);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
}

.token-bank-art,
.token-option-art {
  position: relative;
  overflow: hidden;
  border-radius: 7px;
  background: #0d121d;
}

.token-bank-art {
  width: 48px;
  height: 68px;
}

.token-option-art {
  width: 92px;
  height: 129px;
  flex: 0 0 auto;
}

.token-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 6, 14, 0.72);
  z-index: 2147483000;
}

.token-modal.hidden {
  display: none;
}

.token-modal-card {
  width: min(620px, 94vw);
  max-height: min(760px, 88vh);
  overflow: auto;
  border: 1px solid rgba(116, 212, 255, 0.28);
  border-radius: 14px;
  background: #101827;
  box-shadow: 0 24px 70px rgba(0,0,0,0.62);
  padding: 0.9rem;
}

.token-modal-body {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.token-option {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  padding: 0.7rem;
}

.token-option-meta {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.token-option-meta strong {
  color: #f2fbff;
}

.token-option-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.token-option-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.hand-actions-expanded {
  grid-template-columns: 1fr 1fr;
}

.hand-actions-expanded button:nth-child(n+3) {
  font-size: 0.72rem;
}

.hand-empty {
  min-width: 220px;
  display: grid;
  align-content: center;
}

.ability-check-modal,
.discard-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.ability-check-shell,
.discard-shell {
  width: min(92vw, 620px);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  padding: 0.85rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(16, 20, 30, 0.98);
  box-shadow: 0 30px 90px rgba(0,0,0,0.65);
}

.ability-check-body {
  display: grid;
  place-items: center;
  gap: 0.5rem;
  overflow: auto;
}

.ability-check-art {
  position: relative;
  width: min(360px, 78vw);
  aspect-ratio: 2.5 / 3.5;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background: #0d121d;
  box-shadow: 0 18px 40px rgba(0,0,0,0.55);
}

.ability-check-name {
  font-weight: 700;
  text-align: center;
}

.ability-check-result {
  display: grid;
  gap: 0.25rem;
  width: min(360px, 78vw);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  font-size: 0.88rem;
  line-height: 1.28;
  text-align: center;
}

.ability-check-result.success {
  border-color: rgba(85, 214, 154, 0.55);
  background: rgba(32, 142, 91, 0.2);
}

.ability-check-result.failure {
  border-color: rgba(255, 124, 124, 0.5);
  background: rgba(150, 44, 44, 0.2);
}

.ability-check-result-title {
  font-weight: 800;
}

.discard-browser-body {
  display: grid;
  gap: 0.55rem;
  overflow: auto;
  padding-right: 0.25rem;
}

.discard-browser-row {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
}

.discard-browser-art {
  position: relative;
  width: 58px;
  height: 82px;
  border-radius: 7px;
  overflow: hidden;
  background: #0d121d;
  border: 1px solid rgba(255,255,255,0.12);
}

.discard-browser-info {
  display: grid;
  gap: 0.15rem;
}

.discard-browser-info strong {
  font-size: 0.92rem;
}

.discard-browser-info span {
  color: var(--muted);
  font-size: 0.78rem;
}

.discard-browser-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .deck-console { grid-template-columns: 1fr; }
  .pile-sidebar { border-left: 0; border-top: 1px solid rgba(255,255,255,0.1); padding-left: 0; padding-top: 0.85rem; }
}

@media (max-width: 640px) {
  .pile-controls { grid-template-columns: 1fr; }
  .discard-browser-row { grid-template-columns: 52px 1fr; }
  .discard-browser-actions { grid-column: 1 / -1; justify-content: stretch; }
  .discard-browser-actions button { width: 100%; }
}


/* v11 perspective theming: viewer-relative You / Opponent colors */
.you-theme {
  --theme-rgb: var(--you-rgb);
  --theme-color: var(--you-color);
  --theme-soft: rgba(var(--you-rgb), 0.08);
  --theme-border: rgba(var(--you-rgb), 0.35);
  --theme-strong: rgba(var(--you-rgb), 0.82);
}

.opponent-theme {
  --theme-rgb: var(--opponent-rgb);
  --theme-color: var(--opponent-color);
  --theme-soft: rgba(var(--opponent-rgb), 0.08);
  --theme-border: rgba(var(--opponent-rgb), 0.35);
  --theme-strong: rgba(var(--opponent-rgb), 0.82);
}

.players-card.you-theme,
.players-card.opponent-theme,
.planet-panel.you-theme,
.planet-panel.opponent-theme,
.damage-group.you-theme,
.damage-group.opponent-theme {
  border-color: var(--theme-border);
  background: linear-gradient(160deg, var(--theme-soft), rgba(255,255,255,0.025));
}

.players-card.you-theme strong,
.players-card.opponent-theme strong,
.planet-panel.you-theme .planet-panel-header strong,
.planet-panel.opponent-theme .planet-panel-header strong,
.damage-group.you-theme .damage-seat,
.damage-group.opponent-theme .damage-seat {
  color: var(--theme-color);
}

.damage-group.you-theme .damage-counter,
.damage-group.opponent-theme .damage-counter,
.damage-group.you-theme .damage-counter.aftershock,
.damage-group.opponent-theme .damage-counter.aftershock {
  border-color: rgba(var(--theme-rgb), 0.22);
  background: rgba(var(--theme-rgb), 0.08);
}

.site-zone.you-theme,
.site-zone.opponent-theme {
  border-color: rgba(var(--theme-rgb), 0.28);
  background: rgba(var(--theme-rgb), 0.045);
}

.site-zone.you-theme .zone-seat,
.site-zone.opponent-theme .zone-seat {
  color: rgba(var(--theme-rgb), 0.72);
}

.site-zone.you-theme .zone-name,
.site-zone.opponent-theme .zone-name {
  color: rgba(255,255,255,0.76);
}

.table-card.you-theme,
.table-card.opponent-theme,
.planet-card.you-theme,
.planet-card.opponent-theme {
  border-color: rgba(var(--theme-rgb), 0.42);
  box-shadow: 0 10px 22px rgba(0,0,0,0.48), 0 0 0 1px rgba(var(--theme-rgb), 0.12);
}

.table-card.selected.you-theme,
.planet-card.selected.you-theme {
  outline-color: var(--you-color);
  box-shadow: 0 0 0 5px rgba(var(--you-rgb),0.18), 0 18px 30px rgba(0,0,0,0.55);
}

.table-card.selected.opponent-theme,
.planet-card.selected.opponent-theme {
  outline-color: var(--opponent-color);
  box-shadow: 0 0 0 5px rgba(var(--opponent-rgb),0.18), 0 18px 30px rgba(0,0,0,0.55);
}

.owner-badge.you-theme {
  background: rgba(var(--you-rgb), 0.86);
  color: #061018;
  font-weight: 800;
}

.owner-badge.opponent-theme {
  background: rgba(var(--opponent-rgb), 0.86);
  color: #fff;
  font-weight: 800;
}

.planet-panel.you-theme .echo-tracker,
.planet-panel.opponent-theme .echo-tracker {
  background: rgba(var(--theme-rgb), 0.075);
  border-color: rgba(var(--theme-rgb), 0.18);
}

.planet-panel.you-theme .echo-value span,
.planet-panel.opponent-theme .echo-value span {
  color: var(--theme-color);
}

.hand-panel {
  border-color: rgba(var(--you-rgb), 0.24);
  background: linear-gradient(160deg, rgba(var(--you-rgb), 0.055), var(--panel));
}

.hand-heading h2,
.pile-sidebar h2 {
  color: var(--you-color);
}

.pile-sidebar {
  border-left-color: rgba(var(--you-rgb), 0.22);
}

.pile-box {
  border-color: rgba(var(--you-rgb), 0.16);
}

.pile-header span {
  background: rgba(var(--you-rgb), 0.1);
  color: #c9f1ff;
}

/* v12 desktop playmat layout: fixed-width behavior, overlapping hand, T-piles, horizontal sites */
:root {
  --card-w: 104px;
  --card-h: 146px;
  --site-card-w: 170px;
  --site-card-h: 112px;
  --playmat-max: 1880px;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

#app {
  width: min(var(--playmat-max), calc(100vw - 24px));
  max-width: var(--playmat-max);
}

.app-header,
.top-row,
.hand-heading {
  flex-direction: row !important;
  align-items: center !important;
}

.lobby {
  grid-template-columns: repeat(2, minmax(260px, 1fr)) !important;
}

.layout {
  grid-template-columns: 280px minmax(0, 1fr) 300px !important;
}

.left-panel,
.right-panel {
  min-height: 620px !important;
}

.game-log {
  height: 360px !important;
}

.board-wrap {
  overflow: hidden !important;
}

.board-stage {
  width: 100%;
  min-width: 0 !important;
  height: 640px;
  min-height: 640px;
}

.table-card.horizontal-card {
  width: var(--site-card-w);
  height: var(--site-card-h);
}

.table-card.horizontal-card .table-card-art {
  aspect-ratio: 3.5 / 2.5;
}

.table-card.horizontal-card .card-fallback {
  font-size: 0.82rem;
}

.damage-row {
  grid-template-columns: 1fr auto 1fr !important;
}

.damage-divider {
  display: block !important;
}

.damage-group,
.damage-group:last-child {
  justify-content: flex-start;
}

.damage-group:last-child {
  justify-content: flex-end;
}

.deck-console {
  grid-template-columns: minmax(0, 1fr) 430px !important;
  gap: 1rem;
  min-height: 284px;
}

.hand-main-area {
  min-width: 0;
  overflow: hidden;
}

.hand-cards {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow: hidden;
  min-height: 245px;
  max-height: 245px;
  padding: 0.35rem 0 0.8rem 0.35rem;
}

.hand-card {
  position: relative;
  flex: 0 0 126px;
  width: 126px;
  margin-right: -74px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.hand-card:hover,
.hand-card:focus-within {
  z-index: 999 !important;
  transform: translateY(-10px);
  box-shadow: 0 18px 30px rgba(0,0,0,0.55), 0 0 0 2px rgba(var(--you-rgb),0.28);
  filter: brightness(1.08);
}

.hand-card:last-child {
  margin-right: 0;
}

.hand-actions-expanded button:nth-child(n+3) {
  font-size: 0.68rem;
}

.pile-sidebar {
  width: 430px;
  min-width: 430px;
  border-left: 1px solid rgba(var(--you-rgb), 0.22);
  padding-left: 0.9rem;
}

.pile-controls {
  display: grid;
  grid-template-columns: 128px 128px 128px;
  grid-template-rows: auto auto;
  grid-template-areas:
    ". used ."
    "resource deck discard";
  align-items: start;
  justify-content: center;
  gap: 0.55rem;
}

.pile-box {
  min-height: 0;
  width: 128px;
  padding: 0.45rem;
}

.pile-box.deck { grid-area: deck; }
.pile-box.resource { grid-area: resource; }
.pile-box.used { grid-area: used; }
.pile-box.discard { grid-area: discard; }

.pile-header {
  min-height: 30px;
}

.pile-header strong {
  font-size: 0.76rem;
}

.pile-top {
  width: 84px;
  height: 118px;
  min-height: 118px;
  margin: 0 auto;
}

.pile-box.used .pile-top {
  width: 108px;
  height: 76px;
  min-height: 76px;
}

.pile-top.face-up {
  min-height: 118px;
  align-items: stretch;
  justify-items: stretch;
}

.pile-top-art {
  width: 74px;
  height: 102px;
  margin-top: 0.2rem;
}

.pile-actions {
  gap: 0.23rem;
}

.pile-actions button {
  font-size: 0.68rem;
  line-height: 1.05;
  min-height: 25px;
}

@media (max-width: 1180px), (max-width: 980px), (max-width: 720px), (max-width: 640px) {
  #app { width: min(var(--playmat-max), calc(100vw - 24px)) !important; }
  .layout { grid-template-columns: 280px minmax(0, 1fr) 300px !important; }
  .deck-console { grid-template-columns: minmax(0, 1fr) 430px !important; }
  .pile-sidebar { border-left: 1px solid rgba(var(--you-rgb), 0.22) !important; border-top: 0 !important; padding-left: 0.9rem !important; padding-top: 0 !important; }
  .pile-controls { grid-template-columns: 128px 128px 128px !important; grid-template-areas: ". used ." "resource deck discard" !important; }
  .damage-row { grid-template-columns: 1fr auto 1fr !important; }
  .damage-divider { display: block !important; }
}

/* v13 Used refresh + enhanced zoom context */
.zoom-card-shell {
  width: min(92vw, 900px);
}

.zoom-content {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 260px;
  gap: 0.85rem;
  align-items: start;
  width: 100%;
}

.zoom-art-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
}


.zoom-art-wrap.defeated {
  filter: grayscale(0.2) brightness(0.9);
}

.zoom-art-wrap .wound-overlay,
.zoom-art-wrap .defeated-overlay {
  z-index: 40;
}

.zoom-info-panel {
  border: 1px solid var(--theme-border, rgba(255,255,255,0.16));
  border-radius: 14px;
  background: linear-gradient(160deg, var(--theme-soft, rgba(255,255,255,0.045)), rgba(255,255,255,0.025));
  padding: 0.7rem;
  display: grid;
  gap: 0.65rem;
  align-self: stretch;
}

.zoom-info-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.zoom-info-header strong {
  color: var(--theme-color, var(--accent));
}

.zoom-info-header span {
  color: var(--muted);
  font-size: 0.78rem;
}

.zoom-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.zoom-stat-grid.compact {
  grid-template-columns: repeat(2, 1fr);
}

.zoom-stat {
  display: grid;
  gap: 0.1rem;
  justify-items: center;
  padding: 0.45rem 0.25rem;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.24);
}

.zoom-stat span {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.zoom-stat strong {
  font-size: 1.35rem;
}

.zoom-stat.wound strong { color: #ff9aa9; }
.zoom-stat.ready strong { color: #a5ffc7; }
.zoom-stat.defeated strong { color: #ffb0b9; font-size: 1rem; }

.zoom-attachment-section {
  display: grid;
  gap: 0.35rem;
}

.zoom-section-title {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.zoom-empty-note {
  color: rgba(255,255,255,0.52);
  font-size: 0.84rem;
  padding: 0.4rem 0;
}

.zoom-attachment-chip {
  position: relative;
  width: 100%;
  padding: 0.45rem 0.55rem;
  text-align: left;
  border-radius: 10px;
  background: rgba(0,0,0,0.24);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
}

.zoom-attachment-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-attachment-chip:hover {
  border-color: var(--theme-border, rgba(255,255,255,0.28));
  filter: none;
}

.zoom-attachment-preview {
  display: none;
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 2147483647;
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(9, 12, 18, 0.98);
  box-shadow: 0 18px 42px rgba(0,0,0,0.62);
  pointer-events: none;
}

.zoom-attachment-chip:hover .zoom-attachment-preview {
  display: block;
}

.zoom-attachment-preview-art {
  position: relative;
  width: 150px;
  aspect-ratio: 2.5 / 3.5;
  overflow: hidden;
  border-radius: 8px;
  background: #0d121d;
}

@media (max-width: 1280px) {
  .zoom-content {
    grid-template-columns: 1fr;
  }

  .zoom-attachment-preview {
    right: auto;
    left: 0;
    top: auto;
    bottom: calc(100% + 8px);
    transform: none;
  }
}

.zoom-attachment-preview-art .card-img,
.zoom-attachment-preview-art img {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
  background: #0d121d;
}

.table-card.defeated {
  filter: grayscale(0.25) brightness(0.82);
}

.table-card.unattuned {
  box-shadow: 0 0 0 2px rgba(170, 149, 255, 0.22), 0 10px 22px rgba(0,0,0,0.48);
}

.table-card.contesting-ship-site {
  box-shadow: 0 0 0 2px rgba(188, 168, 255, 0.28), 0 12px 28px rgba(0,0,0,0.52);
}

.raithe-marked-badge {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 34;
  pointer-events: none;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.42);
  background: rgba(178, 31, 48, 0.88);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 0 10px rgba(255, 80, 100, 0.38);
}

.unattuned-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 33;
  pointer-events: none;
  padding: 0.16rem 0.36rem;
  border-radius: 999px;
  border: 1px solid rgba(205, 194, 255, 0.58);
  background: rgba(46, 39, 77, 0.88);
  color: #e8e2ff;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.75);
}

.contesting-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 33;
  pointer-events: none;
  padding: 0.16rem 0.36rem;
  border-radius: 999px;
  border: 1px solid rgba(198, 183, 255, 0.58);
  background: rgba(38, 33, 60, 0.9);
  color: #eee8ff;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.75);
}

.defeated-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.18);
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.85);
}

.defeated-overlay span {
  display: block;
  font-size: 2.2rem;
  line-height: 1;
}

.defeated-overlay strong {
  display: block;
  margin-top: 0.2rem;
  padding: 0.12rem 0.38rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.66);
  border: 1px solid rgba(255,255,255,0.22);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.starting-site-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(5px);
}

.starting-site-shell {
  width: min(1180px, calc(100vw - 80px));
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(16, 20, 30, 0.98);
  box-shadow: 0 30px 90px rgba(0,0,0,0.65);
}

.starting-site-body {
  display: grid;
  gap: 0.8rem;
  overflow: auto;
}

.modal-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.starting-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.7rem;
}

.starting-choice-card {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  align-content: start;
  min-height: 228px;
  padding: 0.55rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text);
  text-align: center;
}

.starting-choice-card:hover {
  background: rgba(116,212,255,0.12);
  border-color: rgba(116,212,255,0.5);
}

.starting-choice-art {
  position: relative;
  width: 118px;
  height: 165px;
  border-radius: 9px;
  overflow: hidden;
  background: #111722;
  border: 1px solid rgba(255,255,255,0.16);
}

.starting-choice-card strong {
  font-size: 0.84rem;
  line-height: 1.15;
}

.starting-choice-card span {
  color: var(--muted);
  font-size: 0.74rem;
}


.turn-control {
  width: 100%;
  min-width: 0;
  max-width: none;
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr);
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.52rem 0.42rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(12, 16, 24, 0.76);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 8px 18px rgba(0,0,0,0.24);
}

.turn-control.your-active-turn,
.turn-control.inactive-turn {
  grid-template-columns: auto minmax(360px, 1fr);
}

.turn-control.start-turn {
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  max-width: none;
}

.turn-control.your-active-turn {
  border-color: rgba(111, 255, 164, 0.46);
  background: linear-gradient(90deg, rgba(23, 115, 61, 0.52), rgba(12, 16, 24, 0.78));
}

.turn-control.start-turn {
  border-color: rgba(116, 212, 255, 0.46);
  background: linear-gradient(90deg, rgba(18, 70, 92, 0.52), rgba(12, 16, 24, 0.78));
}

.turn-control.inactive-turn {
  border-color: rgba(209,79,109,0.42);
  background: linear-gradient(90deg, rgba(92, 22, 35, 0.48), rgba(12, 16, 24, 0.78));
}

.turn-label-wrap {
  min-width: 0;
  line-height: 1.05;
}

.turn-control .turn-status {
  font-size: 0.88rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.turn-control .phase-tracker.phase-inline {
  position: static;
  z-index: auto;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.turn-eyebrow {
  color: var(--muted);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.turn-status {
  margin-top: 0.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-button {
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.34rem 0.65rem !important;
}

.turn-button.your-active-turn:not(:disabled) {
  background: #15793f;
  border-color: rgba(111, 255, 164, 0.56);
}

.turn-button.start-turn:not(:disabled) {
  background: #12698d;
  border-color: rgba(165, 233, 255, 0.56);
}

.turn-button.inactive-turn,
.turn-button:disabled {
  opacity: 0.68;
  background: #652133;
  border-color: rgba(255, 176, 190, 0.3);
}


.top-row {
  grid-template-columns: minmax(260px, 1fr) auto minmax(420px, 1fr);
}


.top-row {
  display: grid;
  align-items: center;
}

.top-row .toolbar {
  justify-content: flex-end;
}


.first-player-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.first-player-shell {
  width: min(92vw, 760px);
  max-height: 92vh;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(16, 20, 30, 0.98);
  box-shadow: 0 30px 90px rgba(0,0,0,0.65);
}

.first-player-body {
  display: grid;
  gap: 0.9rem;
}

.first-roll-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.first-roll-box {
  display: grid;
  gap: 0.65rem;
  justify-items: center;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
}

.first-roll-box.you-theme {
  border-color: rgba(var(--you-rgb), 0.28);
  background: rgba(var(--you-rgb), 0.07);
}

.first-roll-box.opponent-theme {
  border-color: rgba(var(--opponent-rgb), 0.28);
  background: rgba(var(--opponent-rgb), 0.07);
}

.first-roll-die {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.28);
  background: rgba(0,0,0,0.28);
  font-size: 2rem;
  font-weight: 900;
  box-shadow: inset 0 0 22px rgba(255,255,255,0.06);
}

.setup-result-note {
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.045);
  text-align: center;
  font-weight: 700;
}

.setup-result-note.you-theme {
  border-color: rgba(var(--you-rgb), 0.28);
  color: var(--you-color);
}

.setup-result-note.opponent-theme {
  border-color: rgba(var(--opponent-rgb), 0.28);
  color: var(--opponent-color);
}

.first-player-choice-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.centered-note {
  text-align: center;
}

/* v18: image-only hover previews and landscape site choice cards */
.has-hover-preview {
  cursor: default;
}

.card-hover-preview {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483000;
  pointer-events: none;
  display: block;
}

.card-hover-preview.hidden {
  display: none;
}

.card-hover-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: 360px;
  max-height: 520px;
  object-fit: contain;
  background: transparent;
}

.card-hover-preview.horizontal-preview img {
  max-width: 520px;
  max-height: 360px;
}

.starting-choice-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  align-items: stretch;
}

.starting-choice-card.horizontal-choice {
  min-height: 178px;
}

.starting-choice-card.horizontal-choice .starting-choice-art {
  width: 176px;
  height: 112px;
  aspect-ratio: 3.5 / 2.5;
}

.starting-choice-card.horizontal-choice strong {
  max-width: 190px;
}

.starting-choice-card.horizontal-choice .card-img,
.table-card.horizontal-card .card-img,
.planet-card .card-img {
  object-fit: contain;
}


/* v19 turn-state cleanup and bottom drawer layout */
html,
body {
  height: 100%;
  overflow: hidden !important;
}

body {
  min-height: 100vh;
}

#app {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  padding-bottom: 54px;
}

.game {
  height: calc(100vh - 92px);
  max-height: calc(100vh - 92px);
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.layout {
  min-height: 0;
  overflow: hidden;
}

.left-panel,
.right-panel {
  min-height: 0 !important;
  max-height: 100%;
  overflow: hidden;
}

.board-wrap {
  min-height: 0;
}

.board-stage {
  height: min(640px, calc(100vh - 260px));
  min-height: 520px;
}

.game-log {
  height: min(360px, calc(100vh - 560px)) !important;
  min-height: 150px;
}

.turn-control.start-turn {
  border-color: rgba(111, 255, 164, 0.58) !important;
  background: linear-gradient(90deg, rgba(20, 98, 53, 0.62), rgba(12, 16, 24, 0.78)) !important;
  box-shadow: inset 0 0 0 1px rgba(111, 255, 164, 0.13), 0 8px 18px rgba(0,0,0,0.24);
}

.turn-button.start-turn:not(:disabled) {
  background: #148444 !important;
  border-color: rgba(111, 255, 164, 0.72) !important;
  color: #f1fff6;
}

.turn-control.your-active-turn {
  border-color: rgba(116, 212, 255, 0.54) !important;
  background: linear-gradient(90deg, rgba(18, 70, 124, 0.62), rgba(12, 16, 24, 0.78)) !important;
  box-shadow: inset 0 0 0 1px rgba(116, 212, 255, 0.12), 0 8px 18px rgba(0,0,0,0.24);
}

.turn-button.your-active-turn:not(:disabled) {
  background: #a31f3d !important;
  border-color: rgba(255, 176, 190, 0.72) !important;
  color: #fff5f6;
}

.turn-control.inactive-turn {
  border-color: rgba(209,79,109,0.34) !important;
  background: linear-gradient(90deg, rgba(92, 22, 35, 0.35), rgba(12, 16, 24, 0.72)) !important;
  filter: saturate(0.82);
}

.turn-button.inactive-turn,
.turn-button.inactive-turn:disabled,
.turn-button:disabled {
  opacity: 0.58 !important;
  background: rgba(101, 33, 51, 0.72) !important;
  border-color: rgba(255, 176, 190, 0.24) !important;
  color: rgba(255, 229, 235, 0.72) !important;
  cursor: not-allowed;
}

.hand-panel.bottom-drawer {
  position: fixed !important;
  left: 50%;
  bottom: 0;
  z-index: 900000;
  width: min(var(--playmat-max), calc(100vw - 24px));
  max-width: var(--playmat-max);
  height: 360px;
  padding: 0.82rem 0.85rem 0.85rem;
  border-radius: 18px 18px 0 0;
  border-width: 1px 1px 0;
  transform: translate(-50%, calc(100% - 42px));
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--you-rgb), 0.11);
  overflow: visible;
}

.hand-panel.bottom-drawer:hover,
.hand-panel.bottom-drawer:focus-within,
.hand-panel.bottom-drawer.drawer-open {
  transform: translate(-50%, 0);
  box-shadow: 0 -26px 60px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(var(--you-rgb), 0.2);
}

.drawer-tab {
  position: absolute;
  left: 50%;
  top: -38px;
  transform: translateX(-50%);
  height: 38px;
  min-width: 270px;
  display: grid;
  place-items: center;
  padding: 0 1.25rem;
  border-radius: 16px 16px 0 0;
  border: 1px solid rgba(var(--you-rgb), 0.35);
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(var(--you-rgb), 0.28), rgba(15, 20, 31, 0.98));
  color: #e8fbff;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  box-shadow: 0 -8px 18px rgba(0,0,0,0.34);
  cursor: default;
  user-select: none;
}

.drawer-tab::before,
.drawer-tab::after {
  content: '';
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: rgba(232, 251, 255, 0.56);
  position: absolute;
  top: 7px;
}

.drawer-tab::before { left: 18px; }
.drawer-tab::after { right: 18px; }

.bottom-drawer .deck-console {
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 430px !important;
  align-items: stretch;
}

.bottom-drawer .hand-main-area,
.bottom-drawer .pile-sidebar {
  max-height: 100%;
  overflow: hidden;
}

.bottom-drawer .hand-cards {
  min-height: 260px;
  max-height: 260px;
}

.bottom-drawer .pile-controls {
  transform-origin: top center;
}

@media (max-height: 900px) {
  .hand-panel.bottom-drawer {
    height: 330px;
    transform: translate(-50%, calc(100% - 40px));
  }
  .hand-panel.bottom-drawer:hover,
  .hand-panel.bottom-drawer:focus-within,
  .hand-panel.bottom-drawer.drawer-open {
    transform: translate(-50%, 0);
  }
  .bottom-drawer .hand-cards {
    min-height: 235px;
    max-height: 235px;
  }
  .board-stage {
    min-height: 500px;
  }
}

/* v20 solid bottom drawer + compact private pile layout */
.hand-panel.bottom-drawer {
  background: #142033 !important;
  background-image:
    linear-gradient(180deg, #18263a 0%, #101827 100%) !important;
  border-color: rgba(var(--you-rgb), 0.42) !important;
  height: 330px !important;
  padding: 0.72rem 0.9rem 0.8rem !important;
  transform: translate(-50%, calc(100% - 40px)) !important;
  opacity: 1 !important;
  box-shadow: 0 -16px 42px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(var(--you-rgb), 0.18) !important;
}

.hand-panel.bottom-drawer:hover,
.hand-panel.bottom-drawer:focus-within,
.hand-panel.bottom-drawer.drawer-open {
  transform: translate(-50%, 0) !important;
  box-shadow: 0 -26px 64px rgba(0, 0, 0, 0.86), 0 0 0 1px rgba(var(--you-rgb), 0.32) !important;
}

.drawer-tab {
  top: -40px !important;
  height: 40px !important;
  min-width: 310px !important;
  background: linear-gradient(180deg, #253b57, #142033) !important;
  border-color: rgba(var(--you-rgb), 0.55) !important;
  color: #f1fbff !important;
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255,255,255,0.12) !important;
}

.bottom-drawer .deck-console {
  display: grid !important;
  grid-template-columns: minmax(680px, 1fr) 570px !important;
  gap: 1.1rem !important;
  height: 100% !important;
  min-height: 0 !important;
  align-items: stretch !important;
}

.bottom-drawer .hand-main-area {
  min-width: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
  border: 1px solid rgba(var(--you-rgb), 0.2);
  border-radius: 14px;
  background: #0f1725;
  padding: 0.55rem 0.7rem 0.7rem;
}

.bottom-drawer .hand-heading {
  margin-bottom: 0.35rem !important;
}

.bottom-drawer .hand-cards {
  min-height: 240px !important;
  max-height: 240px !important;
  height: 240px !important;
  overflow: hidden !important;
  padding-top: 0.35rem !important;
}

.bottom-drawer .pile-sidebar {
  width: 570px !important;
  min-width: 570px !important;
  max-width: 570px !important;
  border-left: 0 !important;
  padding: 0.45rem 0.55rem 0.55rem !important;
  border-radius: 14px;
  background: #0f1725;
  border: 1px solid rgba(var(--you-rgb), 0.2);
  align-content: start !important;
  overflow: hidden !important;
}

.bottom-drawer .pile-sidebar h2 {
  font-size: 0.78rem !important;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #dff6ff;
  margin: 0 !important;
}

.bottom-drawer .pile-note {
  display: none !important;
}

.bottom-drawer .pile-controls {
  position: relative !important;
  display: block !important;
  width: 530px !important;
  height: 318px !important;
  margin: 0.25rem auto 0 !important;
  transform: none !important;
}

.bottom-drawer .pile-box {
  position: absolute !important;
  width: 150px !important;
  min-height: 0 !important;
  height: 202px !important;
  padding: 0.42rem !important;
  border-radius: 12px !important;
  background: #1e2b3f !important;
  border-color: rgba(var(--you-rgb), 0.22) !important;
  transition:
    left 0.16s ease,
    top 0.16s ease,
    width 0.16s ease,
    height 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease,
    filter 0.16s ease,
    box-shadow 0.16s ease !important;
  overflow: hidden !important;
}

.bottom-drawer .pile-box.resource { left: 0 !important; top: 42px !important; }
.bottom-drawer .pile-box.deck { left: 190px !important; top: 42px !important; }
.bottom-drawer .pile-box.discard { left: 380px !important; top: 42px !important; }

.bottom-drawer .pile-box.token-bank {
  left: 190px !important;
  top: 292px !important;
  height: 34px !important;
  min-height: 0 !important;
  z-index: 6 !important;
  cursor: pointer;
  background: #243a3d !important;
  border-color: rgba(111, 231, 176, 0.38) !important;
}

.bottom-drawer .pile-box.token-bank:hover,
.bottom-drawer .pile-box.token-bank:focus-visible,
.bottom-drawer .pile-box.token-bank:focus-within {
  box-shadow: 0 0 0 2px rgba(111, 231, 176, 0.24), 0 12px 28px rgba(0,0,0,0.4) !important;
}

.bottom-drawer .pile-box.token-bank .token-bank-preview,
.bottom-drawer .pile-box.token-bank .pile-actions {
  display: none !important;
}

.bottom-drawer .pile-box.used {
  left: 190px !important;
  top: 0 !important;
  height: 34px !important;
  z-index: 5 !important;
  background: #263a57 !important;
  border-color: rgba(var(--you-rgb), 0.45) !important;
  cursor: default;
}

.bottom-drawer .pile-box.used .pile-header {
  min-height: 21px !important;
  height: 21px !important;
}

.bottom-drawer .pile-box.used .pile-top,
.bottom-drawer .pile-box.used .pile-actions {
  opacity: 0;
  pointer-events: none;
}

.bottom-drawer .pile-box.used:hover,
.bottom-drawer .pile-box.used:focus-within {
  top: 0 !important;
  height: 238px !important;
  z-index: 20 !important;
  background: #263a57 !important;
  box-shadow: 0 18px 42px rgba(0,0,0,0.62), 0 0 0 2px rgba(var(--you-rgb), 0.22) !important;
}

.bottom-drawer .pile-box.used:hover .pile-top,
.bottom-drawer .pile-box.used:hover .pile-actions,
.bottom-drawer .pile-box.used:focus-within .pile-top,
.bottom-drawer .pile-box.used:focus-within .pile-actions {
  opacity: 1;
  pointer-events: auto;
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.resource,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.resource {
  width: 116px !important;
  opacity: 0.68;
  filter: saturate(0.75);
  transform: translateX(18px) scale(0.88);
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck {
  top: 204px !important;
  height: 34px !important;
  z-index: 4 !important;
  background: #263a57 !important;
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck .pile-top,
.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck .pile-actions,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck .pile-top,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck .pile-actions {
  opacity: 0;
  pointer-events: none;
}

.bottom-drawer .pile-header {
  min-height: 25px !important;
  gap: 0.35rem !important;
}

.bottom-drawer .pile-header strong {
  font-size: 0.72rem !important;
  letter-spacing: 0.02em;
}

.bottom-drawer .pile-header span {
  min-width: 24px !important;
  font-size: 0.7rem !important;
}

.bottom-drawer .pile-top {
  width: 86px !important;
  height: 112px !important;
  min-height: 112px !important;
  margin: 0.1rem auto 0.28rem !important;
}

.bottom-drawer .pile-box.used .pile-top {
  width: 126px !important;
  height: 82px !important;
  min-height: 82px !important;
}

.bottom-drawer .pile-actions {
  display: grid !important;
  gap: 0.22rem !important;
}

.bottom-drawer .pile-actions button {
  min-height: 23px !important;
  font-size: 0.66rem !important;
  padding: 0.2rem 0.28rem !important;
  line-height: 1.05 !important;
}

.bottom-drawer .pile-top-art {
  width: 78px !important;
  height: 104px !important;
}

.bottom-drawer .pile-top-name {
  font-size: 0.62rem !important;
}

@media (max-height: 900px) {
  .hand-panel.bottom-drawer {
    height: 315px !important;
    transform: translate(-50%, calc(100% - 40px)) !important;
  }
  .hand-panel.bottom-drawer:hover,
  .hand-panel.bottom-drawer:focus-within,
  .hand-panel.bottom-drawer.drawer-open {
    transform: translate(-50%, 0) !important;
  }
  .bottom-drawer .hand-cards {
    min-height: 225px !important;
    max-height: 225px !important;
    height: 225px !important;
  }
  .bottom-drawer .pile-controls {
    height: 236px !important;
  }
  .bottom-drawer .pile-box {
    height: 190px !important;
  }
  .bottom-drawer .pile-box.used:hover,
  .bottom-drawer .pile-box.used:focus-within {
    height: 226px !important;
  }
  .bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck,
  .bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck {
    top: 192px !important;
  }
}

/* v21 top chrome cleanup + private pile action layout */
#app {
  padding-top: 8px !important;
}

.top-row {
  padding: 0.5rem 0.65rem !important;
  min-height: 52px;
  gap: 0.75rem !important;
}

.room-info {
  display: grid;
  gap: 0.18rem;
  min-width: 210px;
}

.room-subline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.room-subline .pill.compact {
  padding: 0.16rem 0.48rem;
  font-size: 0.72rem;
  line-height: 1.1;
  border-radius: 999px;
}

.top-row .toolbar {
  align-items: center;
  flex: 0 0 auto;
}

.top-row .toolbar button {
  min-height: 30px;
  padding: 0.32rem 0.58rem;
  font-size: 0.78rem;
}

/* Pile previews/thumbs are intentionally gone in v21. */
.pile-top,
.pile-top.face-down,
.pile-top.face-up,
.pile-top.empty,
.pile-top-art,
.pile-top-name {
  display: none !important;
}

.bottom-drawer .pile-controls {
  position: relative !important;
  display: block !important;
  width: 530px !important;
  height: 244px !important;
  margin: 0.22rem auto 0 !important;
  transform: none !important;
}

.bottom-drawer .pile-box {
  width: 150px !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0.36rem !important;
  overflow: visible !important;
}

.bottom-drawer .pile-box.resource,
.bottom-drawer .pile-box.deck,
.bottom-drawer .pile-box.discard {
  top: 34px !important;
}

.bottom-drawer .pile-box.resource { left: 0 !important; }
.bottom-drawer .pile-box.deck { left: 190px !important; }
.bottom-drawer .pile-box.discard { left: 380px !important; }

.bottom-drawer .pile-box.token-bank {
  left: 190px !important;
  top: 214px !important;
  height: 29px !important;
}

.bottom-drawer .pile-box.used {
  left: 190px !important;
  top: 0 !important;
  height: 29px !important;
  overflow: hidden !important;
}

.bottom-drawer .pile-box.used:hover,
.bottom-drawer .pile-box.used:focus-within {
  height: auto !important;
  min-height: 105px !important;
  overflow: visible !important;
}

.bottom-drawer .pile-box.used .pile-header {
  min-height: 18px !important;
  height: 18px !important;
}

.bottom-drawer .pile-header {
  min-height: 22px !important;
  gap: 0.3rem !important;
}

.bottom-drawer .pile-header strong {
  font-size: 0.68rem !important;
  line-height: 1.04 !important;
}

.bottom-drawer .pile-header span {
  min-width: 22px !important;
  padding: 0.04rem 0.28rem !important;
  font-size: 0.66rem !important;
}

.bottom-drawer .pile-actions {
  display: grid !important;
  gap: 0.18rem !important;
  margin-top: 0.28rem !important;
}

.bottom-drawer .pile-actions button {
  min-height: 20px !important;
  font-size: 0.61rem !important;
  padding: 0.14rem 0.22rem !important;
  line-height: 1.02 !important;
  white-space: normal !important;
}

.bottom-drawer .pile-box.used .pile-actions {
  opacity: 0;
  pointer-events: none;
}

.bottom-drawer .pile-box.used:hover .pile-actions,
.bottom-drawer .pile-box.used:focus-within .pile-actions {
  opacity: 1;
  pointer-events: auto;
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.resource,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.resource {
  width: 116px !important;
  opacity: 0.68;
  filter: saturate(0.75);
  transform: translateX(18px) scale(0.88);
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck {
  top: 128px !important;
  height: 29px !important;
  overflow: hidden !important;
  z-index: 4 !important;
}

.bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck .pile-actions,
.bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck .pile-actions {
  opacity: 0;
  pointer-events: none;
}

@media (max-height: 900px) {
  .bottom-drawer .pile-controls {
    height: 160px !important;
  }
  .bottom-drawer .pile-actions button {
    min-height: 19px !important;
    font-size: 0.58rem !important;
  }
  .bottom-drawer .pile-controls:has(.pile-box.used:hover) .pile-box.deck,
  .bottom-drawer .pile-controls:has(.pile-box.used:focus-within) .pile-box.deck {
    top: 118px !important;
  }
}

/* v22 drawer/modal stacking + selected card visibility pass */
.hand-panel.bottom-drawer {
  z-index: 2147483647 !important;
}

.zoom-modal,
.ability-check-modal,
.discard-modal,
.token-modal,
.starting-site-modal,
.first-player-modal {
  z-index: 2147483000 !important;
}

.zoom-attachment-preview {
  z-index: 2147483001 !important;
}

/* Player summaries now live beside the battle/aftershock counters. */
.damage-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
  padding: 0.42rem 0.55rem !important;
  gap: 0.45rem !important;
}

.damage-group {
  gap: 0.38rem !important;
  min-width: 0;
}

.player-status-chip {
  display: grid;
  gap: 0.03rem;
  min-width: 205px;
  max-width: 275px;
  padding: 0.28rem 0.48rem;
  border-radius: 10px;
  border: 1px solid var(--theme-border, rgba(255,255,255,0.13));
  background: linear-gradient(160deg, var(--theme-soft, rgba(255,255,255,0.04)), rgba(0,0,0,0.18));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  line-height: 1.08;
  overflow: hidden;
}

.player-status-chip strong {
  color: var(--theme-color, #dff6ff);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status-chip span {
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.damage-counter {
  padding: 0.22rem 0.34rem !important;
  gap: 0.26rem !important;
}

.damage-counter button.tiny {
  min-width: 24px;
  min-height: 24px;
  padding: 0.08rem 0.25rem !important;
}

.damage-label {
  font-size: 0.72rem !important;
}

.damage-value {
  min-width: 1.25rem !important;
  font-size: 0.94rem !important;
}

/* Selected card is now the first thing in the left rail and has stronger actions. */
.selected-first-panel {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.selected-first-panel > h2:first-child {
  color: #dff6ff;
  letter-spacing: 0.03em;
}

#selectedPanel.selected-panel {
  padding: 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(var(--you-rgb), 0.22);
  background: rgba(var(--you-rgb), 0.055);
}

#selectedPanel.selected-panel.muted {
  min-height: 74px;
  display: grid;
  place-items: center start;
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.028);
}

.selected-name {
  color: #f3fbff;
  font-size: 0.98rem;
}

.selected-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.32rem !important;
}

.selected-actions button {
  min-height: 30px;
  padding: 0.26rem 0.38rem !important;
  font-size: 0.72rem !important;
  line-height: 1.05 !important;
  white-space: normal;
}

.layout {
  grid-template-columns: minmax(240px, 265px) minmax(780px, 1fr) minmax(250px, 280px) !important;
}

@media (max-width: 1280px) {
  #app {
    width: calc(100vw - 12px) !important;
  }

  .top-row {
    grid-template-columns: minmax(185px, 0.8fr) minmax(260px, 1fr) auto !important;
  }

  .layout {
    grid-template-columns: 236px minmax(748px, 1fr) !important;
    grid-template-areas:
      "left board"
      "right board";
    align-items: start;
  }

  .left-panel { grid-area: left; }
  .board-wrap { grid-area: board; }
  .right-panel { grid-area: right; }

  .left-panel,
  .right-panel {
    min-height: auto !important;
    padding: 0.62rem !important;
  }

  .board-stage {
    min-width: 748px !important;
    min-height: 600px !important;
  }

  .game-log {
    height: 190px !important;
  }

  .damage-row {
    grid-template-columns: 1fr !important;
  }

  .damage-divider {
    display: none !important;
  }

  .damage-group,
  .damage-group:last-child {
    justify-content: space-between !important;
  }

  .player-status-chip {
    min-width: 225px;
    max-width: 360px;
  }
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "left"
      "board"
      "right";
  }

  .board-wrap {
    overflow-x: auto;
  }

  .board-stage {
    min-width: 820px !important;
  }

  .selected-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .selected-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-status-chip {
    min-width: 100%;
    max-width: 100%;
  }

  .damage-counter {
    width: 100%;
    justify-content: space-between;
  }
}

/* v23 player HUD / center counters / hand hover actions */
.damage-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
  align-items: stretch !important;
  padding: 0.38rem 0.55rem !important;
}

.damage-group {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  min-width: 0;
}

.damage-group.opponent-theme {
  justify-content: flex-start !important;
}

.damage-group.you-theme {
  justify-content: flex-end !important;
}

.damage-counters {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  flex: 0 0 auto;
}

.damage-group.opponent-theme .damage-counters {
  margin-left: auto;
  justify-content: flex-end;
}

.damage-group.you-theme .damage-counters {
  margin-right: auto;
  justify-content: flex-start;
}

.damage-seat {
  display: none !important;
}

.damage-divider {
  align-self: center;
  padding: 0 0.38rem;
  opacity: 0.7;
}

.player-status-chip {
  min-width: 246px !important;
  max-width: 370px !important;
  padding: 0.34rem 0.55rem !important;
  gap: 0.08rem !important;
}

.player-status-chip .player-status-name {
  display: block;
  color: var(--theme-color, #dff6ff);
  font-size: 0.86rem !important;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.player-status-chip .player-status-deck {
  display: block;
  color: #c7d4e8;
  font-size: 0.68rem !important;
  line-height: 1.06;
}

.player-zone-counts {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  flex-wrap: wrap;
  margin-top: 0.14rem;
}

.zone-count,
button.zone-count {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  width: auto;
  min-height: 20px;
  padding: 0.12rem 0.25rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: #edf6ff;
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
}

.zone-count::before {
  content: '';
  flex: 0 0 auto;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(237,246,255,0.72);
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.04));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
}

.zone-count .zone-label {
  color: #c7d4e8;
}

.zone-count .zone-value {
  color: #ffffff;
  font-size: 0.74rem;
  line-height: 1;
}

button.zone-count.discard-zone {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  border-color: rgba(255,255,255,0.28);
}

button.zone-count.discard-zone:hover,
button.zone-count.discard-zone:focus-visible {
  background: rgba(255,255,255,0.12);
  filter: none;
  outline: 1px solid rgba(255,255,255,0.22);
}

.discard-peek {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483647;
  pointer-events: none;
  width: max-content;
  max-width: 340px;
  padding: 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10, 14, 22, 0.96);
  box-shadow: 0 18px 42px rgba(0,0,0,0.62), 0 0 0 1px rgba(var(--you-rgb),0.12);
}

.discard-peek.hidden {
  display: none;
}

.discard-peek > strong {
  display: block;
  color: #f1fbff;
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
}

.discard-peek-grid {
  display: flex;
  gap: 0.32rem;
  max-width: 316px;
  overflow: hidden;
}

.discard-peek-card {
  width: 42px;
  height: 59px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.18);
  background: #0f1420;
}

.discard-peek-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.discard-peek-more {
  margin-top: 0.35rem;
  font-size: 0.68rem;
}

.card-hover-preview {
  z-index: 2147483647 !important;
}

.bottom-drawer .hand-cards {
  overflow: visible !important;
}

.bottom-drawer .hand-card {
  padding: 0.38rem !important;
  overflow: visible !important;
}

.hand-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
}

.hand-card-thumb .hand-art {
  width: 100%;
  height: 100%;
}

.bottom-drawer .hand-card-name {
  margin: 0.28rem 0 0 !important;
  min-height: 2.2em;
  font-size: 0.72rem !important;
  line-height: 1.08 !important;
}

.hand-card-thumb .hand-actions {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  align-content: center;
  gap: 0.22rem;
  padding: 0.38rem;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(4, 8, 14, 0.58), rgba(4, 8, 14, 0.88));
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.hand-card:hover .hand-card-thumb .hand-actions,
.hand-card:focus-within .hand-card-thumb .hand-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.hand-card-thumb .hand-actions button {
  min-height: 24px !important;
  padding: 0.18rem 0.24rem !important;
  font-size: 0.63rem !important;
  line-height: 1.05 !important;
  border-radius: 7px !important;
  background: rgba(30, 43, 63, 0.96);
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 4px 10px rgba(0,0,0,0.34);
}

.hand-card-thumb .hand-actions button:first-child {
  grid-column: 1 / -1;
  background: rgba(20, 106, 143, 0.96);
}

@media (max-width: 1280px) {
  .damage-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
  }

  .damage-divider {
    display: block !important;
  }

  .player-status-chip {
    min-width: 210px !important;
    max-width: 280px !important;
  }

  .damage-counters {
    gap: 0.24rem;
  }

  .damage-label {
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* keep large hands from widening the drawer while allowing hover overlays inside each card */
.bottom-drawer .hand-cards {
  overflow: hidden !important;
}

/* v24 start-turn overlay, opponent-planet order, and opponent-turn drawer notice */
.opponent-planet-stack,
.selected-card-stack {
  display: grid;
  gap: 0.5rem;
}

.opponent-planet-stack {
  position: sticky;
  top: 6px;
  z-index: 6;
}

.opponent-planet-stack + hr {
  margin: 0.75rem 0;
}

.start-turn-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483200;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 50% 46%, rgba(116, 212, 255, 0.22), transparent 26%),
    linear-gradient(180deg, rgba(4, 7, 12, 0.72), rgba(4, 7, 12, 0.88));
  backdrop-filter: blur(3px);
}

.start-turn-overlay-card {
  width: min(520px, calc(100vw - 48px));
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.7rem;
  padding: 2rem;
  border-radius: 24px;
  border: 2px solid rgba(116, 212, 255, 0.72);
  background:
    linear-gradient(160deg, rgba(24, 89, 120, 0.95), rgba(11, 18, 31, 0.98)),
    rgba(14, 22, 34, 0.98);
  box-shadow:
    0 30px 90px rgba(0,0,0,0.74),
    0 0 0 1px rgba(255,255,255,0.14),
    0 0 46px rgba(116, 212, 255, 0.28);
  text-align: center;
  color: #f2fbff;
}

.start-turn-overlay-card:hover,
.start-turn-overlay-card:focus-visible {
  filter: none;
  transform: translateY(-1px);
  border-color: rgba(165, 233, 255, 0.96);
  box-shadow:
    0 34px 100px rgba(0,0,0,0.78),
    0 0 0 1px rgba(255,255,255,0.22),
    0 0 60px rgba(116, 212, 255, 0.36);
}

.start-turn-overlay-card span {
  font-size: clamp(2.4rem, 5vw, 4.75rem);
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 4px 18px rgba(0,0,0,0.55);
}

.start-turn-overlay-card small {
  max-width: 34rem;
  color: #cbefff;
  font-size: clamp(0.9rem, 1.5vw, 1.06rem);
  line-height: 1.35;
}

.hand-panel.bottom-drawer.opponent-turn-drawer {
  border-color: rgba(var(--opponent-rgb), 0.72) !important;
  box-shadow:
    0 -18px 42px rgba(0, 0, 0, 0.68),
    0 0 0 1px rgba(var(--opponent-rgb), 0.38),
    0 -2px 28px rgba(var(--opponent-rgb), 0.2) !important;
}

.hand-panel.bottom-drawer.opponent-turn-drawer .drawer-tab {
  border-color: rgba(var(--opponent-rgb), 0.74) !important;
  background: linear-gradient(180deg, rgba(var(--opponent-rgb), 0.48), #24131c) !important;
  color: #ffe8ee !important;
}

.hand-panel.bottom-drawer.opponent-turn-drawer::before {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 18px 18px 0 0;
  border-top: 3px solid rgba(var(--opponent-rgb), 0.74);
  background:
    linear-gradient(180deg, rgba(var(--opponent-rgb), 0.13), transparent 26%),
    repeating-linear-gradient(135deg, rgba(var(--opponent-rgb),0.08) 0 1px, transparent 1px 12px);
  opacity: 0.94;
}

.hand-panel.bottom-drawer.opponent-turn-drawer::after {
  content: attr(data-turn-notice);
  pointer-events: none;
  position: absolute;
  top: 9px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  padding: 0.22rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(74, 19, 35, 0.94);
  color: #ffd9e2;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  box-shadow: 0 7px 22px rgba(0,0,0,0.38);
}

.hand-panel.bottom-drawer.opponent-turn-drawer .hand-main-area,
.hand-panel.bottom-drawer.opponent-turn-drawer .pile-sidebar {
  border-color: rgba(var(--opponent-rgb), 0.28) !important;
}

.hand-panel.bottom-drawer.your-turn-drawer:not(.opponent-turn-drawer) {
  border-color: rgba(var(--you-rgb), 0.55) !important;
}

/* v25 sliding Selected Card panel over opponent Planet/Echo */
.selected-first-panel {
  position: relative !important;
  overflow: hidden !important;
  --selected-card-rest-top: 350px;
  padding-bottom: 140px;
}

.selected-first-panel .opponent-planet-stack {
  z-index: 4;
}

.selected-card-stack {
  position: absolute !important;
  left: 0.85rem;
  right: 0.85rem;
  top: var(--selected-card-rest-top);
  z-index: 12;
  display: grid;
  gap: 0.5rem;
  transition:
    top 220ms cubic-bezier(.2, .8, .2, 1),
    transform 220ms cubic-bezier(.2, .8, .2, 1),
    filter 180ms ease,
    opacity 180ms ease;
  will-change: top, transform;
}

.selected-card-stack.is-active {
  top: 0.85rem;
  z-index: 80;
  transform: translateY(0);
  filter: drop-shadow(0 22px 40px rgba(0,0,0,0.58));
}

.selected-card-stack.is-active h2 {
  color: #f2fbff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.75);
}

.selected-card-stack.is-active #selectedPanel.selected-panel {
  max-height: min(560px, calc(100vh - 182px));
  overflow: auto;
  border-color: rgba(var(--you-rgb), 0.48);
  background:
    linear-gradient(160deg, rgba(14, 23, 35, 0.97), rgba(12, 17, 28, 0.98)),
    rgba(13, 18, 29, 0.98);
  box-shadow:
    0 18px 48px rgba(0,0,0,0.58),
    0 0 0 1px rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
}

.selected-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.5rem;
}

.selected-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0 !important;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: #f4fbff;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
}

.selected-close:hover,
.selected-close:focus-visible {
  border-color: rgba(var(--you-rgb), 0.62);
  background: rgba(var(--you-rgb), 0.18);
  color: #ffffff;
}

@media (max-width: 1280px) {
  .selected-card-stack {
    left: 0.6rem;
    right: 0.6rem;
  }

  .selected-card-stack.is-active #selectedPanel.selected-panel {
    max-height: min(520px, calc(100vh - 160px));
  }
}

/* v27 discard drawer fix: only Discard gets the most recent face-up thumbnail in private piles. */
.bottom-drawer .pile-box.discard {
  overflow: visible !important;
}

.discard-pile-thumbs {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.34rem 0.28rem;
  border: 1px solid rgba(var(--you-rgb), 0.18);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(var(--you-rgb), 0.075), rgba(4, 8, 14, 0.28));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  cursor: pointer;
}

.discard-pile-thumbs:disabled {
  cursor: default;
  opacity: 0.72;
}

.discard-pile-thumbs:not(:disabled):hover,
.discard-pile-thumbs:not(:disabled):focus-visible {
  border-color: rgba(var(--you-rgb), 0.42);
  box-shadow: 0 0 0 2px rgba(var(--you-rgb), 0.14), inset 0 1px 0 rgba(255,255,255,0.07);
}

.discard-pile-thumb {
  position: relative;
  flex: 0 0 34px;
  width: 34px;
  aspect-ratio: 2.5 / 3.5;
  margin-left: -14px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 6px 12px rgba(0,0,0,0.35);
}

.discard-pile-thumb:first-child {
  margin-left: 0;
}

.discard-pile-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discard-pile-more,
.discard-pile-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 24px;
  margin-left: 0.25rem;
  padding: 0.1rem 0.36rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #dff6ff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.discard-pile-empty {
  margin-left: 0;
  color: var(--muted);
}

@media (max-height: 900px) {
  .discard-pile-thumbs {
    min-height: 52px;
    padding-block: 0.25rem;
  }

  .discard-pile-thumb {
    flex-basis: 30px;
    width: 30px;
    margin-left: -13px;
  }
}


/* v27: show only the newest discarded card in the drawer, not a spreading stack. */
.discard-pile-thumbs {
  gap: 0;
  overflow: hidden;
}

.discard-pile-thumb.discard-pile-top {
  flex: 0 0 38px;
  width: 38px;
  margin-left: 0;
}

@media (max-height: 900px) {
  .discard-pile-thumb.discard-pile-top {
    flex-basis: 34px;
    width: 34px;
    margin-left: 0;
  }
}

/* v28 mobile-scale fork + side flyout drawers */
:root {
  --game-scale: 1;
  --game-left: 0px;
  --game-top: 0px;
  --drawer-layer: 2147482000;
}

body.tabletest-scale-shell {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden !important;
  background: #000 !important;
}

body.tabletest-scale-shell #app {
  width: 100vw !important;
  max-width: none !important;
  height: 100vh !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

body.tabletest-scale-shell #app::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 12%, rgba(var(--you-rgb), 0.18), transparent 28%),
    radial-gradient(circle at 82% 88%, rgba(var(--opponent-rgb), 0.16), transparent 28%),
    #000;
}

body.tabletest-scale-shell .game {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 1920px !important;
  height: 1080px !important;
  max-height: none !important;
  padding: 10px 12px 0 !important;
  gap: 8px !important;
  transform: translate(var(--game-left), var(--game-top)) scale(var(--game-scale));
  transform-origin: top left;
  grid-template-rows: 52px 72px minmax(0, 1fr) !important;
  background:
    radial-gradient(circle at 15% 20%, rgba(116, 212, 255, 0.12), transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(209, 79, 109, 0.13), transparent 25%),
    linear-gradient(140deg, #06070b, #111827 55%, #080a0f);
  overflow: hidden !important;
}

body.tabletest-scale-shell .top-row {
  min-height: 0 !important;
  height: 52px !important;
  padding: 0.42rem 0.55rem !important;
  border-radius: 14px !important;
}

body.tabletest-scale-shell .damage-row {
  height: 72px !important;
  min-height: 0 !important;
  padding: 0.32rem 0.55rem !important;
  border-radius: 14px !important;
}

body.tabletest-scale-shell .layout {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-areas: "board" !important;
  height: 930px !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
}

body.tabletest-scale-shell .board-wrap {
  grid-area: board !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0.5rem !important;
  overflow: hidden !important;
  border-radius: 16px !important;
}

body.tabletest-scale-shell .board-stage {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: none !important;
}

body.tabletest-scale-shell .side-drawer {
  position: fixed !important;
  top: 142px !important;
  bottom: 54px !important;
  width: 372px !important;
  max-width: 372px !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 0.78rem !important;
  z-index: var(--drawer-layer) !important;
  overflow: visible !important;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease, border-color 180ms ease !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 54px rgba(0,0,0,0.62), 0 0 0 1px rgba(255,255,255,0.07) !important;
}

body.tabletest-scale-shell .opponent-side-drawer {
  left: 0 !important;
  right: auto !important;
  transform: translateX(-100%);
  border-radius: 0 18px 18px 0 !important;
  border-left: 0 !important;
  border-color: rgba(var(--opponent-rgb), 0.42) !important;
}

body.tabletest-scale-shell .your-side-drawer {
  right: 0 !important;
  left: auto !important;
  transform: translateX(100%);
  border-radius: 18px 0 0 18px !important;
  border-right: 0 !important;
  border-color: rgba(var(--you-rgb), 0.42) !important;
}

body.tabletest-scale-shell .side-drawer.is-open {
  transform: translateX(0) !important;
  box-shadow: 0 22px 70px rgba(0,0,0,0.74), 0 0 0 1px rgba(255,255,255,0.12) !important;
}

body.tabletest-scale-shell .opponent-side-drawer.is-open,
body.tabletest-scale-shell .opponent-side-drawer.has-selected-card {
  border-color: rgba(var(--opponent-rgb), 0.72) !important;
}

body.tabletest-scale-shell .your-side-drawer.is-open {
  border-color: rgba(var(--you-rgb), 0.72) !important;
}

body.tabletest-scale-shell .side-drawer-content {
  height: 100%;
  min-height: 0;
  overflow: hidden auto;
  padding-right: 0.1rem;
}

body.tabletest-scale-shell .side-drawer-content::-webkit-scrollbar,
body.tabletest-scale-shell .selected-panel::-webkit-scrollbar,
body.tabletest-scale-shell .game-log::-webkit-scrollbar {
  width: 8px;
}

body.tabletest-scale-shell .side-drawer-content::-webkit-scrollbar-thumb,
body.tabletest-scale-shell .selected-panel::-webkit-scrollbar-thumb,
body.tabletest-scale-shell .game-log::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
}

body.tabletest-scale-shell .side-drawer-handle {
  position: absolute;
  top: 50%;
  width: 58px;
  min-height: 176px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.34rem;
  border: 1px solid rgba(255,255,255,0.18);
  color: #f3fbff;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 14px 38px rgba(0,0,0,0.58), inset 0 1px 0 rgba(255,255,255,0.1);
  z-index: calc(var(--drawer-layer) + 1);
}

body.tabletest-scale-shell .opponent-drawer-handle {
  right: -58px;
  border-left: 0;
  border-radius: 0 16px 16px 0;
  background: linear-gradient(180deg, rgba(var(--opponent-rgb), 0.52), rgba(22, 15, 24, 0.98));
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

body.tabletest-scale-shell .your-drawer-handle {
  left: -58px;
  border-right: 0;
  border-radius: 16px 0 0 16px;
  background: linear-gradient(180deg, rgba(var(--you-rgb), 0.44), rgba(13, 21, 32, 0.98));
}

body.tabletest-scale-shell .echo-mini-label,
body.tabletest-scale-shell .echo-mini-foot {
  color: #d7eaff;
  font-size: 0.62rem;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}

body.tabletest-scale-shell .opponent-drawer-handle .echo-mini-label,
body.tabletest-scale-shell .opponent-drawer-handle .echo-mini-foot {
  writing-mode: vertical-rl;
}

body.tabletest-scale-shell .side-drawer-handle strong {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

body.tabletest-scale-shell .opponent-drawer-handle strong {
  writing-mode: horizontal-tb;
}

body.tabletest-scale-shell .echo-mini-readout {
  display: grid;
  place-items: center;
  gap: 0.18rem;
  outline: none;
}

body.tabletest-scale-shell .echo-mini-button {
  width: 38px;
  height: 34px;
  min-height: 34px;
  padding: 0 !important;
  border-radius: 12px;
  background: rgba(10, 18, 28, 0.72);
  border-color: rgba(255,255,255,0.22);
  color: #f6fbff;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 900;
}

body.tabletest-scale-shell .echo-mini-button:hover,
body.tabletest-scale-shell .echo-mini-button:focus-visible,
body.tabletest-scale-shell .side-drawer-handle:hover,
body.tabletest-scale-shell .side-drawer-handle:focus-visible,
body.tabletest-scale-shell .echo-mini-readout:focus-visible {
  filter: none;
  outline: 2px solid rgba(255,255,255,0.22);
  outline-offset: 2px;
}

body.tabletest-scale-shell .selected-first-panel {
  --selected-card-rest-top: auto;
  padding-bottom: 0 !important;
}

body.tabletest-scale-shell .selected-first-panel .opponent-planet-stack {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

body.tabletest-scale-shell .side-drawer .selected-card-stack {
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  z-index: auto !important;
  filter: none !important;
  opacity: 1 !important;
}

body.tabletest-scale-shell .side-drawer #selectedPanel.selected-panel {
  max-height: 344px !important;
  overflow: auto !important;
}

body.tabletest-scale-shell .side-drawer #selectedPanel.selected-panel.muted {
  min-height: 88px;
  display: grid;
  place-items: center;
  text-align: center;
}

body.tabletest-scale-shell .side-drawer .planet-panel {
  max-height: 356px;
  overflow: hidden auto;
}

body.tabletest-scale-shell .your-side-drawer .planet-panel {
  max-height: 350px;
}

body.tabletest-scale-shell .game-log {
  height: 286px !important;
  min-height: 0 !important;
}

body.tabletest-scale-shell .log-input-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
}

/* Bottom drawer still covers the board, but sits below modals/zoom pop-outs. */
body.tabletest-scale-shell .hand-panel.bottom-drawer {
  z-index: var(--drawer-layer) !important;
  width: 1640px !important;
  max-width: none !important;
  height: 330px !important;
  left: 50% !important;
  bottom: 0 !important;
}

body.tabletest-scale-shell .drawer-tab {
  z-index: calc(var(--drawer-layer) + 1) !important;
}

body.tabletest-scale-shell .zoom-modal,
body.tabletest-scale-shell .discard-modal,
body.tabletest-scale-shell .ability-check-modal,
body.tabletest-scale-shell .starting-site-modal,
body.tabletest-scale-shell .first-player-modal,
body.tabletest-scale-shell .start-turn-overlay {
  z-index: 2147483000 !important;
}

body.tabletest-scale-shell .zoom-modal {
  z-index: 2147483600 !important;
}

body.tabletest-scale-shell .discard-peek,
body.tabletest-scale-shell .card-hover-preview {
  z-index: 2147482600 !important;
}

/* Keep the flyout handles reachable on smaller base-width layouts after scaling. */
@media (max-width: 1040px) {
  body.tabletest-scale-shell .layout {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "board" !important;
  }

  body.tabletest-scale-shell .board-wrap {
    overflow: hidden !important;
  }

  body.tabletest-scale-shell .board-stage {
    min-width: 0 !important;
  }
}

/* v29 drawer tab counts + standalone selected-card drawer */
body.tabletest-scale-shell .player-status-chip {
  min-width: 196px !important;
  max-width: 290px !important;
  align-content: center;
}

body.tabletest-scale-shell .player-status-chip .player-zone-counts {
  display: none !important;
}

body.tabletest-scale-shell .side-drawer-handle {
  width: 96px !important;
  min-height: 430px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0.28rem !important;
  padding: 0.52rem 0.42rem !important;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
}

body.tabletest-scale-shell .opponent-drawer-handle {
  right: -96px !important;
  border-left: 0 !important;
}

body.tabletest-scale-shell .your-drawer-handle {
  left: -96px !important;
  border-right: 0 !important;
}

body.tabletest-scale-shell .opponent-drawer-handle .echo-mini-label,
body.tabletest-scale-shell .opponent-drawer-handle .echo-mini-foot,
body.tabletest-scale-shell .your-drawer-handle .echo-mini-label,
body.tabletest-scale-shell .your-drawer-handle .echo-mini-foot {
  writing-mode: horizontal-tb !important;
  text-align: center;
  font-size: 0.58rem !important;
}

body.tabletest-scale-shell .side-drawer-handle strong {
  width: 44px !important;
  min-height: 40px !important;
  font-size: 1.48rem !important;
}

body.tabletest-scale-shell .drawer-mini-counts {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
}

body.tabletest-scale-shell .drawer-mini-counts-inner {
  display: grid;
  width: 100%;
  gap: 0.22rem;
}

body.tabletest-scale-shell .drawer-mini-counts-inner .zone-count,
body.tabletest-scale-shell .drawer-mini-counts-inner button.zone-count {
  width: 100%;
  min-height: 23px;
  justify-content: flex-start;
  gap: 0.14rem;
  padding: 0.13rem 0.22rem;
  border-radius: 6px;
  font-size: 0.58rem;
  line-height: 1;
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255,255,255,0.16);
}

body.tabletest-scale-shell .drawer-mini-counts-inner .zone-count::before {
  width: 7px;
  height: 10px;
  border-radius: 2px;
}

body.tabletest-scale-shell .drawer-mini-counts-inner .zone-count .zone-label {
  color: rgba(226, 239, 255, 0.78);
}

body.tabletest-scale-shell .drawer-mini-counts-inner .zone-count .zone-value {
  margin-left: auto;
  color: #ffffff;
  font-size: 0.68rem;
}

body.tabletest-scale-shell .drawer-mini-counts-inner button.zone-count.discard-zone {
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

body.tabletest-scale-shell .side-drawer .planet-panel,
body.tabletest-scale-shell .your-side-drawer .planet-panel {
  max-height: none !important;
  overflow: visible !important;
}

body.tabletest-scale-shell .planet-panel {
  gap: 0.45rem;
}

body.tabletest-scale-shell .planet-slot {
  min-height: 150px;
}

body.tabletest-scale-shell .opponent-side-drawer.has-selected-card {
  border-color: rgba(var(--opponent-rgb), 0.42) !important;
}

.selected-card-drawer {
  position: fixed !important;
  top: 142px !important;
  bottom: 54px !important;
  right: 0 !important;
  width: 388px !important;
  max-width: 388px !important;
  padding: 0.78rem !important;
  border-radius: 18px 0 0 18px !important;
  border-right: 0 !important;
  border-color: rgba(var(--you-rgb), 0.62) !important;
  background: linear-gradient(160deg, rgba(14, 23, 35, 0.98), rgba(11, 16, 27, 0.985)) !important;
  z-index: calc(var(--drawer-layer) + 560) !important;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease, border-color 180ms ease !important;
  overflow: hidden !important;
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 72px rgba(0,0,0,0.74), 0 0 0 1px rgba(255,255,255,0.08) !important;
}

.selected-card-drawer.is-open {
  transform: translateX(0) !important;
  box-shadow: 0 26px 84px rgba(0,0,0,0.82), 0 0 0 1px rgba(var(--you-rgb),0.22) !important;
}

.selected-card-drawer .selected-card-stack {
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  display: grid;
  gap: 0.5rem;
  transform: none !important;
  filter: none !important;
  opacity: 1 !important;
}

.selected-card-drawer h2 {
  margin: 0;
  color: #dff6ff;
  letter-spacing: 0.03em;
}

.selected-card-drawer #selectedPanel.selected-panel {
  max-height: calc(100vh - 220px);
  overflow: auto;
  border-color: rgba(var(--you-rgb), 0.42);
  background: rgba(var(--you-rgb), 0.055);
}

body.tabletest-scale-shell .selected-card-drawer #selectedPanel.selected-panel {
  max-height: 840px !important;
}

.selected-card-drawer #selectedPanel.selected-panel.muted {
  min-height: 88px;
  display: grid;
  place-items: center;
  text-align: center;
}

/* Let card previews and true modals remain the only layers above the selected-card drawer. */
body.tabletest-scale-shell .discard-peek,
body.tabletest-scale-shell .card-hover-preview {
  z-index: calc(var(--drawer-layer) + 620) !important;
}

body.tabletest-scale-shell .zoom-modal,
body.tabletest-scale-shell .discard-modal,
body.tabletest-scale-shell .ability-check-modal,
body.tabletest-scale-shell .starting-site-modal,
body.tabletest-scale-shell .first-player-modal,
body.tabletest-scale-shell .start-turn-overlay {
  z-index: 2147483000 !important;
}

/* v30: top HUD deck counts, Echo-only side tabs, safer board bounds, column-width Sites */
body.tabletest-scale-shell .game {
  grid-template-rows: 52px 72px 848px !important;
}

body.tabletest-scale-shell .layout {
  height: 848px !important;
}

body.tabletest-scale-shell .board-wrap,
body.tabletest-scale-shell .board-stage {
  height: 100% !important;
  max-height: 100% !important;
}

body.tabletest-scale-shell .damage-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
  gap: 0.55rem !important;
}

body.tabletest-scale-shell .damage-group {
  display: grid !important;
  align-items: center !important;
  gap: 0.55rem !important;
  min-width: 0;
}

body.tabletest-scale-shell .damage-group.opponent-theme {
  grid-template-columns: 205px minmax(0, 1fr) auto !important;
}

body.tabletest-scale-shell .damage-group.you-theme {
  grid-template-columns: auto minmax(0, 1fr) 205px !important;
}

body.tabletest-scale-shell .damage-counters {
  min-width: max-content;
}

body.tabletest-scale-shell .damage-group.opponent-theme .damage-counters,
body.tabletest-scale-shell .damage-group.you-theme .damage-counters {
  margin: 0 !important;
}

body.tabletest-scale-shell .player-status-chip {
  min-width: 0 !important;
  width: 205px !important;
  max-width: 205px !important;
  min-height: 44px !important;
  padding: 0.34rem 0.52rem !important;
  overflow: hidden;
}

body.tabletest-scale-shell .player-status-chip .player-status-name,
body.tabletest-scale-shell .player-status-chip .player-status-deck {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-deck-counts {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  min-width: 0;
  padding: 0.28rem 0.38rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(0,0,0,0.16);
  overflow: hidden;
}

.hud-deck-counts.opponent-theme {
  justify-content: flex-start;
  border-color: rgba(var(--opponent-rgb), 0.16);
}

.hud-deck-counts.you-theme {
  justify-content: flex-end;
  border-color: rgba(var(--you-rgb), 0.16);
}

body.tabletest-scale-shell .hud-deck-counts .zone-count,
body.tabletest-scale-shell .hud-deck-counts button.zone-count {
  min-height: 28px;
  padding: 0.22rem 0.42rem;
  gap: 0.24rem;
  border-radius: 8px;
  font-size: 0.78rem;
  background: rgba(255,255,255,0.065);
  flex: 0 1 auto;
}

body.tabletest-scale-shell .hud-deck-counts .zone-count::before {
  width: 10px;
  height: 15px;
  border-radius: 2px;
}

body.tabletest-scale-shell .hud-deck-counts .zone-value {
  font-size: 0.86rem;
}

body.tabletest-scale-shell .drawer-mini-counts {
  display: none !important;
}

body.tabletest-scale-shell .side-drawer-handle {
  width: 72px !important;
  min-height: 214px !important;
  justify-content: center !important;
  padding: 0.55rem 0.38rem !important;
}

body.tabletest-scale-shell .opponent-drawer-handle {
  right: -72px !important;
}

body.tabletest-scale-shell .your-drawer-handle {
  left: -72px !important;
}

body.tabletest-scale-shell .side-drawer-handle strong {
  width: 48px !important;
  min-height: 44px !important;
}

.board-stage .table-card.horizontal-card {
  width: calc(100% / 6) !important;
  height: auto !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

.board-stage .table-card.horizontal-card .table-card-art {
  aspect-ratio: 3.5 / 2.5 !important;
}

.table-card.dragging.drawer-collapsed-drag {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.2), 0 24px 54px rgba(0,0,0,0.72) !important;
}

.board-content {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.board-stage.board-view-zoomed {
  cursor: zoom-in;
}

body.board-panning,
body.board-panning .board-stage {
  cursor: grabbing !important;
  user-select: none;
}

.board-zoom-readout {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1300;
  max-width: 220px;
  padding: 0.28rem 0.56rem;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: rgba(10, 14, 24, 0.72);
  color: rgba(255,255,255,0.9);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.board-zoom-readout:hover {
  border-color: rgba(255,255,255,0.42);
  background: rgba(28, 36, 56, 0.84);
}

/* v31 top HUD cleanup + 1 Player Playtest lobby mode */
.lobby {
  grid-template-columns: repeat(3, minmax(250px, 1fr));
}

.lobby-card.solo-card {
  border-color: rgba(var(--you-rgb), 0.28);
  background: linear-gradient(160deg, rgba(var(--you-rgb), 0.075), rgba(255,255,255,0.035));
}

.lobby-card.solo-card h2 {
  color: var(--you-color);
}

@media (max-width: 1040px) {
  .lobby { grid-template-columns: 1fr; }
}

body.tabletest-scale-shell .top-row {
  height: 48px !important;
  min-height: 48px !important;
  padding: 0.28rem 0.48rem !important;
  gap: 0.5rem !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}

body.tabletest-scale-shell .room-info {
  min-width: 0 !important;
  gap: 0.06rem !important;
}

body.tabletest-scale-shell .room-line {
  font-size: 0.95rem !important;
  line-height: 1.05 !important;
}

body.tabletest-scale-shell .room-subline {
  gap: 0.32rem !important;
  font-size: 0.74rem !important;
  line-height: 1.05 !important;
}

body.tabletest-scale-shell .room-subline .pill.compact {
  padding: 0.08rem 0.42rem !important;
  font-size: 0.66rem !important;
}

body.tabletest-scale-shell .top-row .toolbar button,
body.tabletest-scale-shell .top-row button.tiny {
  min-height: 24px !important;
  padding: 0.18rem 0.46rem !important;
  border-radius: 8px !important;
  font-size: 0.68rem !important;
  line-height: 1 !important;
}

body.tabletest-scale-shell .damage-row {
  height: 68px !important;
  min-height: 68px !important;
  padding: 0.28rem 0.46rem !important;
  gap: 0.44rem !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  background: rgba(18, 22, 32, 0.88) !important;
}

body.tabletest-scale-shell .damage-group {
  gap: 0.38rem !important;
  height: 100%;
}

body.tabletest-scale-shell .damage-group.opponent-theme {
  grid-template-columns: 176px minmax(0, 1fr) 142px !important;
}

body.tabletest-scale-shell .damage-group.you-theme {
  grid-template-columns: 142px minmax(0, 1fr) 176px !important;
}

body.tabletest-scale-shell .player-status-chip {
  width: 176px !important;
  max-width: 176px !important;
  min-height: 42px !important;
  padding: 0.26rem 0.42rem !important;
  border-radius: 9px !important;
  box-shadow: none !important;
  background: rgba(var(--theme-rgb), 0.065) !important;
}

body.tabletest-scale-shell .player-status-chip .player-status-name {
  font-size: 0.76rem !important;
  line-height: 1.05 !important;
}

body.tabletest-scale-shell .player-status-chip .player-status-deck {
  font-size: 0.58rem !important;
  line-height: 1.05 !important;
}

body.tabletest-scale-shell .hud-deck-counts {
  height: 34px !important;
  align-self: center;
  gap: 0.22rem !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.tabletest-scale-shell .hud-deck-counts.opponent-theme {
  justify-content: flex-start !important;
}

body.tabletest-scale-shell .hud-deck-counts.you-theme {
  justify-content: flex-end !important;
}

body.tabletest-scale-shell .hud-deck-counts .zone-count,
body.tabletest-scale-shell .hud-deck-counts button.zone-count {
  min-height: 24px !important;
  height: 24px !important;
  padding: 0.12rem 0.3rem !important;
  gap: 0.15rem !important;
  border-radius: 6px !important;
  font-size: 0.66rem !important;
  background: rgba(255,255,255,0.055) !important;
  border-color: rgba(255,255,255,0.13) !important;
  box-shadow: none !important;
}

body.tabletest-scale-shell .hud-deck-counts .zone-count::before {
  width: 8px !important;
  height: 12px !important;
}

body.tabletest-scale-shell .hud-deck-counts .zone-value {
  font-size: 0.72rem !important;
}

body.tabletest-scale-shell .damage-counters {
  display: grid !important;
  grid-template-rows: repeat(2, 1fr) !important;
  gap: 0.22rem !important;
  align-self: center;
  min-width: 0 !important;
  width: 142px;
}

body.tabletest-scale-shell .damage-counter,
body.tabletest-scale-shell .damage-counter.aftershock {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 20px 24px 20px !important;
  align-items: center !important;
  gap: 0.16rem !important;
  min-height: 26px !important;
  height: 26px !important;
  padding: 0.12rem 0.18rem !important;
  border-radius: 8px !important;
  background: rgba(var(--theme-rgb), 0.072) !important;
  border-color: rgba(var(--theme-rgb), 0.20) !important;
  box-shadow: none !important;
}

body.tabletest-scale-shell .damage-label {
  min-width: 0 !important;
  max-width: none !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: #bdc9dc !important;
  font-size: 0.61rem !important;
  line-height: 1 !important;
}

body.tabletest-scale-shell .damage-value {
  min-width: 0 !important;
  width: 24px !important;
  text-align: center !important;
  font-size: 0.78rem !important;
  line-height: 1 !important;
}

body.tabletest-scale-shell .damage-counter button.tiny {
  width: 20px !important;
  min-width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  padding: 0 !important;
  border-radius: 7px !important;
  font-size: 0.72rem !important;
  line-height: 1 !important;
  display: grid !important;
  place-items: center !important;
}

body.tabletest-scale-shell .damage-divider {
  align-self: center !important;
  padding: 0 0.24rem !important;
  font-size: 1.05rem !important;
  letter-spacing: 0.12em !important;
}

body.tabletest-scale-shell .turn-control {
  min-width: 0 !important;
}

body.tabletest-scale-shell .game {
  grid-template-rows: 48px 68px 856px !important;
}

body.tabletest-scale-shell .layout {
  height: 856px !important;
}


/* v32: smaller Sites, opponent orientation, and corrected layer bands */
:root {
  --drawer-layer: 1000;
  --played-card-layer: 120;
  --drawer-tab-layer: 1080;
  --open-drawer-layer: 1220;
  --selected-card-layer: 1500;
  --hover-preview-layer: 1800;
  --modal-layer: 2200;
}

body.tabletest-scale-shell .board-stage {
  isolation: isolate;
}

/* Played cards sit above the board but below every drawer tab/drawer. */
body.tabletest-scale-shell .board-stage .table-card {
  z-index: var(--played-card-layer);
}

body.tabletest-scale-shell .table-card.dragging {
  z-index: 940 !important;
}

/* Opponent-owned cards face the active/local player upside down. Tapped combines with the flip. */
body.tabletest-scale-shell .board-stage .table-card.opponent-theme {
  transform: rotate(180deg);
}

body.tabletest-scale-shell .board-stage .table-card.opponent-theme.tapped {
  transform: rotate(270deg);
}

body.tabletest-scale-shell .board-stage .table-card.you-theme.tapped {
  transform: rotate(90deg);
}

body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme {
  transform: rotate(180deg);
}

body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .zoom-mini-button,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .counter-row,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .wound-overlay,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .defeated-overlay {
  transform: rotate(180deg);
}

/* Site and Ship-Site cards are 20% smaller than a board column and centered by their saved position. */
body.tabletest-scale-shell .board-stage .table-card.horizontal-card {
  width: calc((100% / 6) * 0.8) !important;
  height: auto !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

body.tabletest-scale-shell .board-stage .table-card.horizontal-card .table-card-art {
  aspect-ratio: 3.5 / 2.5 !important;
}

/* Drawer tabs are above played cards; opened drawers are above tabs. */
body.tabletest-scale-shell .side-drawer {
  z-index: var(--open-drawer-layer) !important;
}

body.tabletest-scale-shell .side-drawer:not(.is-open) {
  z-index: var(--drawer-tab-layer) !important;
  pointer-events: none;
}

body.tabletest-scale-shell .side-drawer:not(.is-open) .side-drawer-handle {
  pointer-events: auto;
}

body.tabletest-scale-shell .side-drawer.is-open {
  z-index: var(--open-drawer-layer) !important;
}

body.tabletest-scale-shell .side-drawer-handle,
body.tabletest-scale-shell .drawer-tab {
  z-index: var(--drawer-tab-layer) !important;
}

body.tabletest-scale-shell .hand-panel.bottom-drawer {
  z-index: var(--open-drawer-layer) !important;
}

body.tabletest-scale-shell .hand-panel.bottom-drawer .drawer-tab {
  z-index: var(--drawer-tab-layer) !important;
}

body.tabletest-scale-shell .selected-card-drawer {
  z-index: var(--selected-card-layer) !important;
}

body.tabletest-scale-shell .discard-peek,
body.tabletest-scale-shell .card-hover-preview,
body.tabletest-scale-shell .zoom-attachment-preview {
  z-index: var(--hover-preview-layer) !important;
}

body.tabletest-scale-shell .zoom-modal,
body.tabletest-scale-shell .discard-modal,
body.tabletest-scale-shell .ability-check-modal,
body.tabletest-scale-shell .starting-site-modal,
body.tabletest-scale-shell .first-player-modal,
body.tabletest-scale-shell .start-turn-overlay {
  z-index: var(--modal-layer) !important;
}

body.tabletest-scale-shell .zoom-modal {
  z-index: calc(var(--modal-layer) + 20) !important;
}

/* While dragging a selected card, keep every drawer collapsed until pointer-up restores side drawer state. */
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer:hover,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer:focus-within,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer.drawer-open {
  transform: translate(-50%, calc(100% - 40px)) !important;
}

body.tabletest-scale-shell.card-dragging .side-drawer.is-open {
  transform: translateX(-100%) !important;
}

body.tabletest-scale-shell.card-dragging .your-side-drawer.is-open {
  transform: translateX(100%) !important;
}

body.tabletest-scale-shell.card-dragging .selected-card-drawer.is-open {
  transform: translateX(100%) !important;
}

/* v33: board-label cleanup, right-side-up planet drawers, selected-card state preview, attach targeting */
body.tabletest-scale-shell .perspective-note {
  display: none !important;
}

body.tabletest-scale-shell .site-zone .zone-name {
  display: block;
  max-width: 92%;
  margin-inline: auto;
  white-space: normal;
  line-height: 1.05;
  font-size: 0.72rem;
  text-wrap: balance;
}

body.tabletest-scale-shell .site-zone.space .zone-name {
  font-size: 0.62rem;
  letter-spacing: 0.015em;
}

/* Only in-play board cards should flip for the opponent. Planet cards inside drawers stay readable. */
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme.tapped {
  transform: none !important;
}

body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .zoom-mini-button,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .counter-row,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .wound-overlay,
body.tabletest-scale-shell .planet-panel .planet-card.opponent-theme .defeated-overlay {
  transform: none !important;
}

.selected-card-preview {
  display: grid;
  grid-template-columns: minmax(112px, 142px) minmax(0, 1fr);
  gap: 0.62rem;
  align-items: start;
  padding: 0.55rem;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  background: rgba(255,255,255,0.045);
}

.selected-card-preview-art-wrap {
  position: relative;
  min-height: 186px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.30);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.selected-card-preview-art,
.selected-card-preview-art .card-img,
.selected-card-preview-art .card-fallback {
  width: 100%;
  height: auto;
  min-height: 186px;
  aspect-ratio: 2.5 / 3.5;
  border-radius: 12px;
}

.selected-card-preview-face-down {
  min-height: 186px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.74);
  background: linear-gradient(145deg, rgba(18,28,45,0.92), rgba(7,10,18,0.98));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.selected-card-preview .zoom-mini-button {
  width: 30px;
  height: 30px;
}

.selected-card-state-panel.zoom-info-panel {
  min-width: 0;
  padding: 0.48rem;
  gap: 0.44rem;
  background: rgba(0,0,0,0.16);
}

.selected-card-state-panel .zoom-stat-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.38rem;
}

.selected-card-state-panel .zoom-stat {
  padding: 0.42rem;
}

.selected-card-state-panel .zoom-attachment-chip {
  padding: 0.34rem 0.42rem;
}

body.tabletest-scale-shell .selected-card-drawer #selectedPanel.selected-panel {
  max-height: 842px !important;
  overflow: auto !important;
}

body.tabletest-scale-shell .selected-card-drawer.attach-targeting,
body.tabletest-scale-shell .selected-card-drawer:not(.is-open) {
  pointer-events: none;
}

@media (max-width: 900px) {
  .selected-card-preview {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .selected-card-preview-art-wrap,
  .selected-card-preview-art,
  .selected-card-preview-art .card-img,
  .selected-card-preview-art .card-fallback,
  .selected-card-preview-face-down {
    min-height: 148px;
  }
}

.selected-card-preview.horizontal-selected-card {
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
}

.selected-card-preview.horizontal-selected-card .selected-card-preview-art-wrap,
.selected-card-preview.horizontal-selected-card .selected-card-preview-art,
.selected-card-preview.horizontal-selected-card .selected-card-preview-art .card-img,
.selected-card-preview.horizontal-selected-card .selected-card-preview-art .card-fallback {
  min-height: 132px;
  aspect-ratio: 3.5 / 2.5;
}

/* v34: selected card layout, modal actions, and cleaner large-card attachments */
body.tabletest-scale-shell .selected-card-drawer #selectedPanel.selected-panel {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.46rem !important;
  max-height: 100% !important;
  overflow: hidden !important;
  overflow-x: hidden !important;
  min-width: 0 !important;
}

body.tabletest-scale-shell .selected-card-drawer #selectedPanel.selected-panel .subtle {
  flex: 0 0 auto;
  overflow-wrap: anywhere;
}

body.tabletest-scale-shell .selected-card-preview {
  flex: 0 0 auto;
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 0.45rem !important;
  border-radius: 14px;
  overflow: hidden;
}

body.tabletest-scale-shell .selected-card-preview-art-wrap,
body.tabletest-scale-shell .selected-card-preview-art,
body.tabletest-scale-shell .selected-card-preview-art .card-img,
body.tabletest-scale-shell .selected-card-preview-art .card-fallback,
body.tabletest-scale-shell .selected-card-preview-face-down {
  width: min(100%, 260px) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 326px !important;
  aspect-ratio: 2.5 / 3.5 !important;
}

body.tabletest-scale-shell .selected-card-preview.horizontal-selected-card .selected-card-preview-art-wrap,
body.tabletest-scale-shell .selected-card-preview.horizontal-selected-card .selected-card-preview-art,
body.tabletest-scale-shell .selected-card-preview.horizontal-selected-card .selected-card-preview-art .card-img,
body.tabletest-scale-shell .selected-card-preview.horizontal-selected-card .selected-card-preview-art .card-fallback {
  width: min(100%, 326px) !important;
  max-height: 236px !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

body.tabletest-scale-shell .selected-card-detail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.18rem;
}

body.tabletest-scale-shell .selected-card-detail-scroll .zoom-info-panel,
body.tabletest-scale-shell .selected-card-state-panel.zoom-info-panel {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

body.tabletest-scale-shell .selected-card-detail-scroll .zoom-attachment-chip {
  max-width: 100%;
  overflow: hidden;
}

body.tabletest-scale-shell .selected-card-detail-scroll .zoom-attachment-chip span {
  overflow-wrap: anywhere;
}

body.tabletest-scale-shell .zoom-side-stack {
  display: grid;
  gap: 0.65rem;
  align-content: start;
  min-width: 0;
}

.zoom-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.34rem;
  padding: 0.58rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.045);
}

.zoom-card-actions button {
  min-height: 30px;
  padding: 0.25rem 0.34rem !important;
  font-size: 0.72rem !important;
  line-height: 1.05 !important;
  white-space: normal;
}

.zoom-card-actions.hand-modal-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
  border-radius: 8px;
}

.zoom-card-actions.hand-modal-actions .primary-hand-action {
  grid-column: 1 / -1;
  min-height: 46px;
  font-size: 0.95rem !important;
  font-weight: 800;
  background: linear-gradient(180deg, rgba(45, 145, 185, 0.98), rgba(23, 93, 132, 0.98));
  border-color: rgba(166, 232, 255, 0.45);
}

.zoom-card-actions.hand-modal-actions .hand-modal-action-title {
  grid-column: 1 / -1;
  margin-top: 0.1rem;
  padding-top: 0.48rem;
  border-top: 1px solid rgba(255,255,255,0.14);
  color: #b9c8d8;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.zoom-card-actions.hand-modal-actions .hand-pile-action {
  min-height: 34px;
}

body.tabletest-scale-shell .table-card.large-parent-attachment {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 12px 24px rgba(0,0,0,0.48);
}

body.tabletest-scale-shell .table-card.large-parent-attachment .attachment-badge {
  background: rgba(116, 212, 255, 0.92);
  color: #06111d;
}


/* v37: explicit click-to-toggle hand/private drawer, app version, and game timer. */
.lobby-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: -0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lobby-meta strong,
.version-pill,
.game-timer {
  font-variant-numeric: tabular-nums;
}

.game-timer.timer-running {
  border-color: rgba(var(--you-rgb), 0.35) !important;
  color: #e9fbff !important;
}

.hand-panel.bottom-drawer .drawer-tab {
  cursor: pointer !important;
}

.hand-panel.bottom-drawer,
.hand-panel.bottom-drawer:hover,
.hand-panel.bottom-drawer:focus-within {
  transform: translate(-50%, calc(100% - 42px)) !important;
}

.hand-panel.bottom-drawer.drawer-open,
.hand-panel.bottom-drawer.drawer-open:hover,
.hand-panel.bottom-drawer.drawer-open:focus-within {
  transform: translate(-50%, 0) !important;
}

body.tabletest-scale-shell .hand-panel.bottom-drawer,
body.tabletest-scale-shell .hand-panel.bottom-drawer:hover,
body.tabletest-scale-shell .hand-panel.bottom-drawer:focus-within {
  transform: translate(-50%, calc(100% - 42px)) !important;
}

body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open,
body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open:hover,
body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open:focus-within {
  transform: translate(-50%, 0) !important;
}

body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer:hover,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer:focus-within,
body.tabletest-scale-shell.card-dragging .hand-panel.bottom-drawer.drawer-open {
  transform: translate(-50%, calc(100% - 42px)) !important;
}

/* v0.38 card data schema display */
.printed-card-data-section {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  border-top: 1px solid rgba(255,255,255,0.09);
  padding-top: 0.55rem;
}

.printed-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}

.printed-card-chip {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: baseline;
  gap: 0.28rem;
  max-width: 100%;
  padding: 0.28rem 0.42rem;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  background: rgba(0,0,0,0.20);
  color: rgba(255,255,255,0.88);
  font-size: 0.76rem;
  line-height: 1.15;
}

.printed-card-chip small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
}

.printed-card-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.printed-card-chip.traits-chip {
  grid-auto-flow: row;
  justify-items: start;
  align-items: start;
  border-radius: 12px;
  max-width: 100%;
  white-space: normal;
}

.printed-card-chip.traits-chip strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
}

.printed-card-text-block {
  display: grid;
  gap: 0.42rem;
  min-width: 0;
  color: rgba(255,255,255,0.84);
  font-size: 0.83rem;
  line-height: 1.35;
  overflow-x: hidden;
}

.printed-card-text-block p {
  margin: 0;
  overflow-wrap: anywhere;
}

.printed-ability {
  display: grid;
  gap: 0.16rem;
  padding: 0.42rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.035);
  min-width: 0;
}

.printed-ability strong {
  color: var(--theme-color, var(--accent));
  font-size: 0.82rem;
}

.printed-ability em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.printed-card-lore-section {
  display: grid;
  gap: 0.28rem;
  padding-top: 0.1rem;
  min-width: 0;
}

.printed-card-lore {
  margin: 0;
  padding: 0.48rem 0.55rem;
  border-left: 2px solid rgba(115, 211, 255, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(255,255,255,0.025);
  color: rgba(255,255,255,0.66);
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.42;
  overflow-wrap: anywhere;
}


.implemented-errata-section {
  display: grid;
  gap: 0.4rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(115, 211, 255, 0.16);
  min-width: 0;
}

.implemented-errata-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.implemented-errata-badges span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.24rem 0.45rem;
  border: 1px solid rgba(115, 211, 255, 0.22);
  border-radius: 999px;
  background: rgba(115, 211, 255, 0.08);
  color: rgba(220, 245, 255, 0.9);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.implemented-errata-section p {
  margin: 0;
  color: rgba(255,255,255,0.78);
  font-size: 0.8rem;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.implemented-errata-note {
  color: rgba(255,255,255,0.62) !important;
}

/* v39: selected-card drawer scrolling + solo view switch */
body.tabletest-scale-shell .selected-card-drawer {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}

body.tabletest-scale-shell .selected-card-drawer .selected-card-stack {
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

body.tabletest-scale-shell .selected-card-drawer .selected-card-stack h2 {
  flex: 0 0 auto !important;
}

body.tabletest-scale-shell .selected-card-drawer #selectedPanel.selected-panel {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
}

body.tabletest-scale-shell .selected-card-detail-scroll {
  flex: 0 0 auto !important;
  min-height: 0 !important;
  max-width: 100% !important;
  overflow: visible !important;
  overflow-x: hidden !important;
}

.turn-control.has-solo-switch {
  width: min(1080px, calc(100vw - 24px));
  max-width: min(1080px, 100%);
  grid-template-columns: auto minmax(420px, 1fr) auto;
  column-gap: 1rem;
}

.turn-control.setup-turn.has-solo-switch {
  width: auto;
  min-width: 430px;
  max-width: 540px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.turn-control.setup-turn {
  border-color: rgba(255,255,255,0.22);
  background: linear-gradient(90deg, rgba(58, 63, 83, 0.55), rgba(12, 16, 24, 0.78));
}

.solo-switch-button {
  position: relative;
  z-index: 2;
  justify-self: end;
  min-width: 128px;
  min-height: 34px;
  padding-inline: 0.8rem !important;
  background: rgba(255,255,255,0.10) !important;
  border-color: rgba(255,255,255,0.24) !important;
  color: var(--text) !important;
}

.solo-switch-button:hover,
.solo-switch-button:focus-visible {
  background: rgba(116, 212, 255, 0.20) !important;
  border-color: rgba(165, 233, 255, 0.50) !important;
}

/* v40: Quick Ref, keepalive nudge, and true click-only bottom drawer */
.quick-ref-modal {
  position: fixed;
  inset: 0;
  z-index: var(--modal-layer, 2200);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
}

.quick-ref-shell {
  width: min(980px, calc(100vw - 32px));
  max-height: min(880px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  background: rgba(16, 22, 34, 0.98);
  box-shadow: 0 28px 80px rgba(0,0,0,0.62);
}

.quick-ref-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.9rem;
  padding: 0.2rem;
}

.quick-ref-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  text-align: left;
  min-height: 0;
  padding: 0.8rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.13);
}

.quick-ref-card strong {
  font-size: 1rem;
  color: #f4fbff;
}

.quick-ref-art,
.quick-ref-art img,
.quick-ref-art .card-fallback {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  border-radius: 12px;
}

.quick-ref-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
  max-height: 5.2em;
  overflow: hidden;
}

.keepalive-nudge {
  position: fixed;
  right: 18px;
  bottom: 58px;
  z-index: calc(var(--modal-layer, 2200) - 20);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(116, 212, 255, 0.32);
  background: rgba(14, 22, 34, 0.94);
  color: #eaf9ff;
  box-shadow: 0 14px 34px rgba(0,0,0,0.42);
  font-size: 0.86rem;
}

.keepalive-nudge button {
  white-space: nowrap;
}

/* Override older hover/focus drawer open rules. The drawer opens only with .drawer-open. */
.hand-panel.bottom-drawer:not(.drawer-open),
.hand-panel.bottom-drawer:not(.drawer-open):hover,
.hand-panel.bottom-drawer:not(.drawer-open):focus-within,
body.tabletest-scale-shell .hand-panel.bottom-drawer:not(.drawer-open),
body.tabletest-scale-shell .hand-panel.bottom-drawer:not(.drawer-open):hover,
body.tabletest-scale-shell .hand-panel.bottom-drawer:not(.drawer-open):focus-within {
  transform: translate(-50%, calc(100% - 40px)) !important;
}

.hand-panel.bottom-drawer.drawer-open,
.hand-panel.bottom-drawer.drawer-open:hover,
.hand-panel.bottom-drawer.drawer-open:focus-within,
body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open,
body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open:hover,
body.tabletest-scale-shell .hand-panel.bottom-drawer.drawer-open:focus-within {
  transform: translate(-50%, 0) !important;
}

.drawer-tab {
  cursor: pointer !important;
}

body.tabletest-scale-shell .quick-ref-modal {
  z-index: var(--modal-layer) !important;
}

@media (max-width: 720px) {
  .quick-ref-body {
    grid-template-columns: 1fr;
  }
  .keepalive-nudge {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 52px;
  }
}


/* v41: layout.orientation controls card display shape. Portrait Site tokens stay vertical without losing Site behavior. */
.table-card.portrait-site-card,
.table-card.size-site-token,
.table-card.size-token-site {
  width: var(--card-w);
  height: var(--card-h);
  aspect-ratio: auto;
}

.table-card.portrait-site-card .table-card-art,
.table-card.size-site-token .table-card-art,
.table-card.size-token-site .table-card-art {
  aspect-ratio: auto;
}

.starting-choice-card.portrait-site-choice .starting-choice-art {
  aspect-ratio: 2.5 / 3.5;
}

.card-hover-preview:not(.horizontal-preview) img {
  object-fit: contain;
}

body.tabletest-scale-shell .board-stage .table-card.portrait-site-card,
body.tabletest-scale-shell .board-stage .table-card.size-site-token,
body.tabletest-scale-shell .board-stage .table-card.size-token-site {
  width: var(--card-w) !important;
  height: var(--card-h) !important;
  aspect-ratio: auto !important;
}

body.tabletest-scale-shell .board-stage .table-card.portrait-site-card .table-card-art,
body.tabletest-scale-shell .board-stage .table-card.size-site-token .table-card-art,
body.tabletest-scale-shell .board-stage .table-card.size-token-site .table-card-art {
  aspect-ratio: auto !important;
}

/* v42: default lane tokens are landscape Sites, and portrait Site image files rotate clockwise inside landscape frames. */
.table-card.horizontal-card.size-site-token,
.table-card.horizontal-card.size-token-site,
.table-card.horizontal-card.portrait-site-card {
  width: var(--site-card-w);
  height: auto;
  aspect-ratio: 3.5 / 2.5;
}

.table-card.horizontal-card.size-site-token .table-card-art,
.table-card.horizontal-card.size-token-site .table-card-art,
.table-card.horizontal-card.portrait-site-card .table-card-art {
  aspect-ratio: 3.5 / 2.5;
}

body.tabletest-scale-shell .board-stage .table-card.horizontal-card.size-site-token,
body.tabletest-scale-shell .board-stage .table-card.horizontal-card.size-token-site,
body.tabletest-scale-shell .board-stage .table-card.horizontal-card.portrait-site-card {
  width: calc((100% / 6) * 0.8) !important;
  height: auto !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

body.tabletest-scale-shell .board-stage .table-card.horizontal-card.size-site-token .table-card-art,
body.tabletest-scale-shell .board-stage .table-card.horizontal-card.size-token-site .table-card-art,
body.tabletest-scale-shell .board-stage .table-card.horizontal-card.portrait-site-card .table-card-art {
  aspect-ratio: 3.5 / 2.5 !important;
}

.table-card.zoom-only-card {
  cursor: zoom-in;
  box-shadow: 0 12px 26px rgba(0,0,0,0.36);
}

.table-card.zoom-only-card .layer-badge,
.table-card.zoom-only-card .owner-badge {
  opacity: 0.62;
}

.rotate-image-clockwise {
  position: relative;
  overflow: hidden;
}

.rotate-image-counterclockwise {
  position: relative;
  overflow: hidden;
}

.table-card-art.rotate-image-clockwise .card-img,
.planet-card-art.rotate-image-clockwise .card-img,
.starting-choice-art.rotate-image-clockwise .card-img,
.selected-card-preview-art.rotate-image-clockwise .card-img,
.quick-ref-art.rotate-image-clockwise .card-img,
.hand-art.rotate-image-clockwise .card-img,
.card-art.rotate-image-clockwise .card-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  transform-origin: center center !important;
  border-radius: inherit;
}

.table-card-art.rotate-image-counterclockwise .card-img,
.planet-card-art.rotate-image-counterclockwise .card-img,
.starting-choice-art.rotate-image-counterclockwise .card-img,
.selected-card-preview-art.rotate-image-counterclockwise .card-img,
.quick-ref-art.rotate-image-counterclockwise .card-img,
.hand-art.rotate-image-counterclockwise .card-img,
.card-art.rotate-image-counterclockwise .card-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(-90deg) !important;
  transform-origin: center center !important;
  border-radius: inherit;
}

.zoom-art-wrap.rotate-image-clockwise {
  position: relative;
  width: min(78vw, 760px);
  max-width: 100%;
  aspect-ratio: 3.5 / 2.5;
  overflow: hidden;
  border-radius: 14px;
  background: #0d121d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.zoom-art-wrap.rotate-image-clockwise .zoom-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  transform-origin: center center !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.zoom-art-wrap.rotate-image-counterclockwise {
  position: relative;
  width: min(78vw, 760px);
  max-width: 100%;
  aspect-ratio: 3.5 / 2.5;
  overflow: hidden;
  border-radius: 14px;
  background: #0d121d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.zoom-art-wrap.rotate-image-counterclockwise .zoom-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(-90deg) !important;
  transform-origin: center center !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.card-hover-preview.horizontal-preview.rotate-image-clockwise {
  width: min(520px, 42vw);
  aspect-ratio: 3.5 / 2.5;
  overflow: hidden;
  background: transparent;
}

.card-hover-preview.horizontal-preview.rotate-image-clockwise img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  transform-origin: center center !important;
}

.card-hover-preview.horizontal-preview.rotate-image-counterclockwise {
  width: min(520px, 42vw);
  aspect-ratio: 3.5 / 2.5;
  overflow: hidden;
  background: transparent;
}

.card-hover-preview.horizontal-preview.rotate-image-counterclockwise img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(-90deg) !important;
  transform-origin: center center !important;
}


/* v0.44: Quick Ref chooser uses browser UI only; no card-art thumbnails or hover previews. */
.quick-ref-body {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  align-content: start;
}

.quick-ref-card.quick-ref-card-button {
  grid-template-rows: auto auto minmax(0, auto);
  min-height: 150px;
  cursor: pointer;
}

.quick-ref-card.quick-ref-card-button:hover,
.quick-ref-card.quick-ref-card-button:focus-visible {
  background: rgba(116, 212, 255, 0.14);
  border-color: rgba(116, 212, 255, 0.42);
  outline: none;
}

.quick-ref-meta {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.quick-ref-modal .card-hover-preview,
.quick-ref-modal .quick-ref-art {
  display: none !important;
}

/* v46: centered shared keep-alive modal + landscape Site preview fixes */
.keepalive-nudge {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483500 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px !important;
  background: rgba(0, 0, 0, 0.58) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: #eaf9ff !important;
}

.keepalive-nudge.hidden {
  display: none !important;
}

.keepalive-modal {
  width: min(430px, 92vw);
  padding: 24px;
  border-radius: 18px;
  border: 1px solid rgba(116, 212, 255, 0.28);
  background: linear-gradient(160deg, rgba(20, 27, 40, 0.98), rgba(8, 12, 21, 0.985));
  text-align: center;
  box-shadow: 0 22px 72px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255,255,255,0.07);
}

.keepalive-modal h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.keepalive-modal p {
  margin: 0 0 18px;
  color: rgba(234, 249, 255, 0.84);
  line-height: 1.42;
}

.keepalive-modal button {
  min-width: 180px;
  padding: 0.72rem 1.05rem;
  border-radius: 999px;
  font-weight: 800;
}

.card-hover-preview.landscape-preview img,
.card-hover-preview.horizontal-preview img {
  max-width: min(560px, 82vw) !important;
  max-height: min(380px, 72vh) !important;
  object-fit: contain !important;
}

body.tabletest-scale-shell .card-hover-preview.landscape-preview,
body.tabletest-scale-shell .card-hover-preview.horizontal-preview {
  z-index: 2147483200 !important;
}

body.tabletest-scale-shell .selected-card-preview.landscape-selected-card {
  padding: 0.38rem !important;
}

body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art-wrap,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art .card-img,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art .card-fallback {
  width: min(100%, 360px) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 220px !important;
  aspect-ratio: 3.5 / 2.5 !important;
  object-fit: contain !important;
}

body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) .card-img {
  object-fit: contain !important;
}

/* v0.47: site hover hardening, selected landscape sizing, and responsive keep-alive timing */
.card-hover-preview {
  z-index: 2147483647 !important;
  pointer-events: none !important;
}

.card-hover-preview img {
  display: block !important;
  border-radius: 12px !important;
  box-shadow: 0 18px 52px rgba(0,0,0,0.62), 0 0 0 1px rgba(255,255,255,0.16) !important;
}

.card-hover-preview.landscape-preview,
.card-hover-preview.horizontal-preview {
  width: min(560px, 82vw) !important;
  aspect-ratio: 3.5 / 2.5 !important;
  overflow: hidden !important;
  border-radius: 12px !important;
  background: #0d121d !important;
}

.card-hover-preview.landscape-preview:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) img,
.card-hover-preview.horizontal-preview:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) img {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
}

.selected-card-preview.landscape-selected-card,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0.38rem !important;
  border-radius: 14px !important;
  background: rgba(255,255,255,0.045) !important;
}

.selected-card-preview.landscape-selected-card .selected-card-preview-art-wrap,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art-wrap {
  display: block !important;
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 3.5 / 2.5 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  border-radius: 12px !important;
  background: #0d121d !important;
}

.selected-card-preview.landscape-selected-card .selected-card-preview-art,
.selected-card-preview.landscape-selected-card .selected-card-preview-art .card-img,
.selected-card-preview.landscape-selected-card .selected-card-preview-art .card-fallback,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art .card-img,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art .card-fallback {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 3.5 / 2.5 !important;
  padding: 0 !important;
  margin: 0 !important;
  object-fit: contain !important;
}

.selected-card-preview.landscape-selected-card .selected-card-preview-art:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) .card-img,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) .card-img {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
}

.selected-card-preview.landscape-selected-card .selected-card-preview-art.rotate-image-clockwise .card-img,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art.rotate-image-clockwise .card-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  transform-origin: center center !important;
}

.selected-card-preview.landscape-selected-card .selected-card-preview-art.rotate-image-counterclockwise .card-img,
body.tabletest-scale-shell .selected-card-preview.landscape-selected-card .selected-card-preview-art.rotate-image-counterclockwise .card-img {
  position: absolute !important;
  inset: auto !important;
  left: 50% !important;
  top: 50% !important;
  width: calc(100% * 2.5 / 3.5) !important;
  height: calc(100% * 3.5 / 2.5) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: translate(-50%, -50%) rotate(-90deg) !important;
  transform-origin: center center !important;
}

body.tabletest-scale-shell .planet-panel .planet-card.landscape-planet-card,
.planet-panel .planet-card.landscape-planet-card {
  width: min(260px, 100%) !important;
}

body.tabletest-scale-shell .planet-panel .planet-card.landscape-planet-card .planet-card-art,
.planet-panel .planet-card.landscape-planet-card .planet-card-art {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

body.tabletest-scale-shell .planet-panel .planet-card.landscape-planet-card .planet-card-art:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) .card-img,
.planet-panel .planet-card.landscape-planet-card .planet-card-art:not(.rotate-image-clockwise):not(.rotate-image-counterclockwise) .card-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

/* v0.49: hardened Site hover preview and selected-card action controls */
.card-hover-preview,
body.tabletest-scale-shell .card-hover-preview {
  z-index: 2147483647 !important;
  pointer-events: none !important;
}

.card-hover-preview.landscape-preview,
.card-hover-preview.horizontal-preview,
body.tabletest-scale-shell .card-hover-preview.landscape-preview,
body.tabletest-scale-shell .card-hover-preview.horizontal-preview {
  width: min(620px, 86vw) !important;
  aspect-ratio: 3.5 / 2.5 !important;
  overflow: hidden !important;
  border-radius: 14px !important;
  background: #0d121d !important;
  box-shadow: 0 18px 52px rgba(0,0,0,0.68), 0 0 0 1px rgba(255,255,255,0.18) !important;
}

.card-hover-preview.landscape-preview.rotate-image-clockwise,
.card-hover-preview.horizontal-preview.rotate-image-clockwise,
body.tabletest-scale-shell .card-hover-preview.landscape-preview.rotate-image-clockwise,
body.tabletest-scale-shell .card-hover-preview.horizontal-preview.rotate-image-clockwise {
  width: min(620px, 86vw) !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

.card-hover-preview.landscape-preview.rotate-image-counterclockwise,
.card-hover-preview.horizontal-preview.rotate-image-counterclockwise,
body.tabletest-scale-shell .card-hover-preview.landscape-preview.rotate-image-counterclockwise,
body.tabletest-scale-shell .card-hover-preview.horizontal-preview.rotate-image-counterclockwise {
  width: min(620px, 86vw) !important;
  aspect-ratio: 3.5 / 2.5 !important;
}

.card-hover-preview.landscape-preview img,
.card-hover-preview.horizontal-preview img,
body.tabletest-scale-shell .card-hover-preview.landscape-preview img,
body.tabletest-scale-shell .card-hover-preview.horizontal-preview img {
  border-radius: 0 !important;
}

.selected-actions,
.zoom-card-actions {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 0.4rem !important;
  align-items: stretch;
}

.selected-actions button.tiny,
.zoom-card-actions button.tiny,
.selected-actions .action-stepper,
.zoom-card-actions .action-stepper {
  min-height: 31px;
}

.action-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  color: #f4fbff;
}

.action-stepper-label {
  display: flex;
  align-items: center;
  padding: 0 0.55rem;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.action-stepper .action-stepper-button {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
  border-width: 0 0 0 1px;
  border-color: rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.22);
  font-size: 1rem;
  font-weight: 900;
}

.action-stepper .action-stepper-button.plus {
  color: #dff7ff;
}

.action-stepper .action-stepper-button.minus {
  color: #ffd7df;
}

.action-stepper.atk-stepper {
  border-color: rgba(96, 190, 255, 0.46);
  background: rgba(44, 135, 226, 0.16);
}

.action-stepper.grit-stepper {
  border-color: rgba(130, 184, 225, 0.44);
  background: rgba(86, 123, 154, 0.18);
}

.counter.atk { color: #7fd3ff; }
.counter.grit { color: #9fc6e8; }

.stat-mod-overlay-stack {
  position: absolute;
  left: 6px;
  top: 30px;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.stat-mod-overlay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(0,0,0,0.70);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}

.stat-mod-overlay.atk {
  color: #82d8ff;
  border-color: rgba(100, 206, 255, 0.56);
  background: rgba(20, 84, 143, 0.82);
}

.stat-mod-overlay.equipment {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.18), 0 6px 14px rgba(0,0,0,0.35);
}

.stat-mod-overlay.aboard {
  border-style: double;
  box-shadow: 0 0 0 2px rgba(190, 150, 255, 0.22), 0 6px 14px rgba(0,0,0,0.35);
}

.stat-mod-overlay.static {
  border-color: rgba(167, 243, 208, 0.58);
  background: rgba(28, 92, 70, 0.88);
  box-shadow: 0 0 0 2px rgba(167, 243, 208, 0.16), 0 6px 14px rgba(0,0,0,0.35);
}

.stat-mod-overlay.locked::after {
  content: "LOCK";
  margin-left: 0.28rem;
  padding-left: 0.28rem;
  border-left: 1px solid rgba(255,255,255,0.28);
  font-size: 0.46rem;
  letter-spacing: 0.08em;
  opacity: 0.82;
}

.stat-mod-overlay.grit {
  color: #c8e0f6;
  border-color: rgba(157, 198, 232, 0.54);
  background: rgba(58, 79, 99, 0.86);
}

.stat-mod-overlay.echo {
  color: #b7f3ff;
  border-color: rgba(103, 232, 249, 0.58);
  background: rgba(20, 99, 116, 0.88);
}

.enroute-overlay {
  position: absolute;
  inset: 0;
  z-index: 34;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(7, 18, 34, 0.12), rgba(58, 161, 255, 0.18));
  color: #e9f8ff;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.85);
}

.enroute-overlay span {
  display: block;
  font-size: 2.15rem;
  line-height: 1;
  filter: drop-shadow(0 0 7px rgba(105, 197, 255, 0.75));
}

.enroute-overlay strong {
  display: block;
  margin-top: 0.24rem;
  padding: 0.14rem 0.44rem;
  border-radius: 999px;
  background: rgba(6, 22, 38, 0.76);
  border: 1px solid rgba(142, 214, 255, 0.48);
  color: #d8f3ff;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.spotted-overlay {
  position: absolute;
  left: 50%;
  bottom: 0.36rem;
  z-index: 42;
  transform: translateX(-50%);
  pointer-events: none;
}

.spotted-overlay span {
  display: block;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(145, 255, 211, 0.72);
  background: rgba(6, 46, 38, 0.82);
  color: #d9fff1;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 5px rgba(0,0,0,0.74);
  box-shadow: 0 0 14px rgba(88, 255, 184, 0.26);
}

/* v51: start-turn resource snapshot prompt + automatic draw animation */
.start-resource-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483450;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.start-resource-modal.hidden {
  display: none !important;
}

.start-resource-shell {
  width: min(560px, 94vw);
  max-height: min(760px, 90vh);
  overflow: auto;
  border-radius: 22px;
  border: 1px solid rgba(116, 212, 255, 0.36);
  background: linear-gradient(160deg, rgba(20, 27, 40, 0.98), rgba(8, 12, 21, 0.985));
  color: #eaf9ff;
  box-shadow: 0 28px 90px rgba(0,0,0,0.78), 0 0 0 1px rgba(255,255,255,0.08);
  padding: 22px;
}

.start-resource-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.start-resource-header strong {
  font-size: 1.45rem;
  letter-spacing: 0.02em;
}

.start-resource-header span,
.start-resource-note {
  color: rgba(234, 249, 255, 0.76);
  line-height: 1.35;
}

.start-resource-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.start-resource-summary div {
  border: 1px solid rgba(116, 212, 255, 0.22);
  border-radius: 16px;
  padding: 12px;
  background: rgba(116, 212, 255, 0.08);
  display: grid;
  gap: 4px;
}

.start-resource-summary span {
  color: rgba(234, 249, 255, 0.72);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.start-resource-summary strong {
  font-size: 2rem;
  line-height: 1;
}

.start-resource-sources {
  margin: 12px 0 16px;
  padding-left: 1.2rem;
  color: rgba(234, 249, 255, 0.86);
  line-height: 1.45;
}

.start-resource-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 16px;
}

.start-resource-picker input {
  width: 92px;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(116, 212, 255, 0.34);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
}

.start-resource-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.start-draw-toast {
  position: fixed;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483460;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(116, 212, 255, 0.42);
  background: rgba(8, 12, 21, 0.94);
  color: #eaf9ff;
  box-shadow: 0 16px 50px rgba(0,0,0,0.58);
  pointer-events: none;
  animation: startDrawFloat 1.45s ease both;
}

.start-draw-toast.hidden {
  display: none !important;
}

.start-draw-card-back {
  width: 34px;
  height: 48px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  background: linear-gradient(160deg, rgba(116, 212, 255, 0.9), rgba(54, 67, 111, 0.95));
  color: #06111c;
  box-shadow: 0 0 18px rgba(116, 212, 255, 0.35);
}

.start-draw-text {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.start-draw-toast.is-empty .start-draw-card-back {
  background: linear-gradient(160deg, rgba(180, 190, 200, 0.7), rgba(40, 44, 54, 0.95));
  color: #eef3f7;
}

@keyframes startDrawFloat {
  0% { opacity: 0; transform: translate(-50%, -18px) scale(0.96); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(0.985); }
}

body.tabletest-scale-shell .start-resource-modal,
body.tabletest-scale-shell .start-draw-toast {
  z-index: calc(var(--modal-layer, 2200) + 30) !important;
}

/* v54: compact setup starting hand modal fixed containment */
.setup-hand-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 35);
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  padding: 18px;
}
.setup-hand-modal.hidden { display: none; }
.setup-hand-shell {
  width: min(940px, 94vw);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  background: rgba(18, 20, 30, 0.98);
  color: #fff;
  box-shadow: 0 18px 60px rgba(0,0,0,0.5);
  padding: 14px;
}
.setup-hand-body { display: grid; gap: 12px; }
.setup-hand-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 10px;
  align-items: start;
}
.setup-hand-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 8px;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
}
.setup-hand-art {
  position: relative;
  width: clamp(82px, 13vw, 126px);
  aspect-ratio: 2.5 / 3.5;
  border-radius: 9px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.25);
}
.setup-hand-art img,
.setup-hand-art .card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0d121d;
}
.setup-hand-art .card-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 6px;
  text-align: center;
  font-size: 0.7rem;
}
.setup-hand-art .card-img { z-index: 2; }
.setup-hand-card .zoom-mini-button { display: none !important; }
.setup-hand-card strong {
  max-width: 100%;
  font-size: 0.74rem;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}
.setup-hand-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
body.tabletest-scale-shell .setup-hand-modal {
  z-index: calc(var(--modal-layer, 2200) + 35) !important;
}
@media (max-width: 760px) {
  .setup-hand-grid { grid-template-columns: repeat(3, minmax(86px, 1fr)); }
  .setup-hand-art { width: clamp(76px, 24vw, 112px); }
}

.rules-inactive-card {
  filter: saturate(0.55) brightness(0.72);
}
.rules-inactive-card::after {
  content: 'INACTIVE';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-10deg);
  z-index: 18;
  padding: 0.22rem 0.55rem;
  border: 1px solid rgba(255,255,255,0.82);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  pointer-events: none;
}
.rules-inactive-notice {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.25;
}
.rules-inactive-notice.contesting-notice {
  border-color: rgba(198, 183, 255, 0.34);
  background: rgba(72, 61, 112, 0.24);
  color: #f0ebff;
}
.inactive-resource-source {
  opacity: 0.72;
  font-style: italic;
}


/* v0.58.1: client lobby polish only. Board/play space styles intentionally untouched. */
body.client-page #app {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(116, 212, 255, 0.10), transparent 28%),
    radial-gradient(circle at 86% 12%, rgba(209, 79, 109, 0.12), transparent 30%),
    linear-gradient(145deg, #020305 0%, #0b101a 54%, #030406 100%);
}

body.client-page #lobby.lobby {
  width: min(1120px, calc(100vw - 32px));
  margin: clamp(18px, 5vh, 52px) auto;
  padding: clamp(16px, 2.5vw, 28px) !important;
  gap: 1rem !important;
  border-color: rgba(116, 212, 255, 0.16);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
}

body.client-page #lobby .lobby-meta {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(9, 16, 26, 0.92), rgba(18, 22, 34, 0.72));
  color: rgba(244, 247, 255, 0.76);
  text-transform: none;
  letter-spacing: 0.015em;
}

body.client-page #lobby .lobby-meta > span:first-child {
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

body.client-page #lobby .lobby-meta strong {
  margin-right: auto;
  color: #9ee8ff;
  font-size: 0.85rem;
}

body.client-page #lobby .utility-link,
body.client-page .top-row .utility-link {
  border-radius: 999px;
  border-color: rgba(116, 212, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf8ff;
  text-decoration: none;
}

body.client-page #lobby .lobby-card {
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(18, 24, 36, 0.84), rgba(8, 12, 20, 0.90));
  border-color: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 20px 48px rgba(0, 0, 0, 0.32);
}

body.client-page #lobby .lobby-card h2 {
  font-size: 1.12rem;
  letter-spacing: 0.02em;
  color: #f8fbff;
}

body.client-page #lobby .lobby-card label {
  color: rgba(244, 247, 255, 0.74);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

body.client-page #lobby input,
body.client-page #lobby select {
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(0, 0, 0, 0.26);
}

body.client-page #lobby button.primary {
  border-color: rgba(116, 212, 255, 0.48);
  background: linear-gradient(135deg, rgba(22, 118, 158, 0.98), rgba(22, 70, 106, 0.96));
  box-shadow: 0 14px 34px rgba(45, 166, 220, 0.18);
}

body.client-page #lobby button.secondary {
  background: linear-gradient(135deg, rgba(69, 75, 96, 0.95), rgba(41, 46, 62, 0.95));
}

body.client-page #lobby .hint {
  line-height: 1.45;
}

@media (max-width: 760px) {
  body.client-page #lobby.lobby {
    width: min(100vw - 20px, 680px);
    grid-template-columns: 1fr !important;
  }
  body.client-page #lobby .lobby-meta {
    justify-content: center;
    text-align: center;
  }
  body.client-page #lobby .lobby-meta strong {
    margin-right: 0;
    width: 100%;
  }
}

/* v0.58.3: scoped client lobby error messaging. Board/play space styles intentionally untouched. */
body.client-page #lobby .client-error-banner {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 112, 112, 0.42);
  background: linear-gradient(135deg, rgba(95, 20, 27, 0.92), rgba(41, 12, 18, 0.94));
  color: #ffe8e8;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}
body.client-page #lobby .client-error-banner strong {
  color: #ffffff;
  letter-spacing: 0.04em;
}
body.client-page #lobby .client-error-banner span,
body.client-page #lobby .client-error-banner small {
  color: rgba(255, 235, 235, 0.88);
  line-height: 1.35;
}
body.client-page #lobby .client-error-banner small {
  font-size: 0.78rem;
}


/* v0.58.4: viewport-pinned side drawer hotfix for scaled/smaller screens.
   The game board scales as one 1920x1080 surface, but these flyout drawers need
   to stay attached to the visible viewport edges instead of inheriting the scaled
   game container position. */
body.tabletest-scale-shell .viewport-pinned-drawer.side-drawer,
body.tabletest-scale-shell .viewport-pinned-drawer.selected-card-drawer {
  position: fixed !important;
  box-sizing: border-box !important;
}

body.tabletest-scale-shell .viewport-pinned-drawer.opponent-side-drawer {
  left: 0 !important;
  right: auto !important;
  transform: translateX(-100%) !important;
}

body.tabletest-scale-shell .viewport-pinned-drawer.opponent-side-drawer.is-open {
  transform: translateX(0) !important;
}

body.tabletest-scale-shell .viewport-pinned-drawer.your-side-drawer {
  right: 0 !important;
  left: auto !important;
  transform: translateX(100%) !important;
}

body.tabletest-scale-shell .viewport-pinned-drawer.your-side-drawer.is-open {
  transform: translateX(0) !important;
}

body.tabletest-scale-shell.card-dragging .viewport-pinned-drawer.opponent-side-drawer.is-open {
  transform: translateX(-100%) !important;
}

body.tabletest-scale-shell.card-dragging .viewport-pinned-drawer.your-side-drawer.is-open,
body.tabletest-scale-shell.card-dragging .viewport-pinned-drawer.selected-card-drawer.is-open {
  transform: translateX(100%) !important;
}

/* Top HUD three-row cleanup: room/game info, phase tracker, player trackers. */
body.tabletest-scale-shell .game {
  grid-template-rows: 44px 44px 64px 894px !important;
}

body.tabletest-scale-shell .top-row {
  height: 44px !important;
  min-height: 44px !important;
  display: grid !important;
  padding: 0.42rem 0.55rem !important;
  border-radius: 12px !important;
}

body.tabletest-scale-shell .turn-control-row {
  height: 44px !important;
  min-height: 44px !important;
  display: grid !important;
  align-items: center !important;
  padding: 0.28rem 0.55rem !important;
  border-radius: 12px !important;
}

body.tabletest-scale-shell .room-game-row {
  display: grid !important;
  grid-template-columns: minmax(520px, 1fr) minmax(max-content, auto) minmax(max-content, auto) !important;
  gap: 0.75rem !important;
  align-items: center !important;
  min-width: 0 !important;
  width: 100% !important;
}

body.tabletest-scale-shell .room-info,
body.tabletest-scale-shell .room-subline {
  min-width: 0 !important;
}

body.tabletest-scale-shell .room-line {
  font-size: 0.9rem !important;
  line-height: 1 !important;
}

body.tabletest-scale-shell .room-subline {
  display: block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 0.7rem !important;
}

body.tabletest-scale-shell .game-info-strip {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  justify-self: center !important;
  gap: 0.35rem !important;
  white-space: nowrap !important;
}

body.tabletest-scale-shell .top-row .toolbar {
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  justify-self: end !important;
  margin-left: auto !important;
  min-width: max-content !important;
}

body.tabletest-scale-shell .turn-control {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  gap: 0.65rem !important;
  padding: 0.28rem 0.42rem !important;
  border-radius: 10px !important;
}

body.tabletest-scale-shell .turn-control.inactive-turn {
  grid-template-columns: auto minmax(0, 1fr) !important;
}

body.tabletest-scale-shell .turn-control.inactive-turn.has-solo-switch {
  grid-template-columns: auto minmax(0, 1fr) auto !important;
}

body.tabletest-scale-shell .turn-control.start-turn {
  grid-template-columns: minmax(0, 1fr) auto !important;
}

body.tabletest-scale-shell .turn-control .phase-tracker.phase-inline {
  width: 100% !important;
}

body.tabletest-scale-shell .damage-row {
  height: 64px !important;
  min-height: 64px !important;
}

body.tabletest-scale-shell .layout {
  height: 894px !important;
}

.undo-play-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* v0.59.0 unit deployment target feedback */
.board-stage.unit-play-target-mode {
  cursor: crosshair;
}

.board-stage.unit-play-target-mode .site-zone {
  pointer-events: auto;
  cursor: crosshair;
  outline: 2px solid rgba(255, 255, 255, 0.16);
  outline-offset: -4px;
}

.board-stage.unit-play-target-mode .site-zone:hover,
.table-card.unit-play-target-card:hover {
  box-shadow: inset 0 0 0 3px rgba(116, 212, 255, 0.58), 0 0 18px rgba(116, 212, 255, 0.22);
}

.hand-card.pending-unit-play {
  outline: 2px solid rgba(116, 212, 255, 0.82);
  outline-offset: 3px;
  box-shadow: 0 0 20px rgba(116, 212, 255, 0.28);
}

.invalid-play-overlay {
  position: absolute;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(196, 24, 45, 0.9);
  color: #fff;
  font-weight: 900;
  font-size: 0.86rem;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  pointer-events: none;
  animation: invalidPlayFade 1.2s ease-out forwards;
}

.invalid-play-shake {
  animation: invalidPlayShake 0.38s ease-in-out;
}

@keyframes invalidPlayShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-8px); }
  36% { transform: translateX(7px); }
  54% { transform: translateX(-5px); }
  72% { transform: translateX(4px); }
}

@keyframes invalidPlayFade {
  0% { opacity: 0; transform: scale(0.98); }
  12% { opacity: 1; transform: scale(1); }
  72% { opacity: 0.95; }
  100% { opacity: 0; transform: scale(1.02); }
}

/* v0.59.1: keep side and selected-card drawers full viewport height after scale-shell overrides. */
body.tabletest-scale-shell .viewport-pinned-drawer.side-drawer,
body.tabletest-scale-shell .viewport-pinned-drawer.selected-card-drawer,
body.tabletest-scale-shell .side-drawer,
body.tabletest-scale-shell .selected-card-drawer,
.selected-card-drawer {
  top: 0 !important;
  bottom: 0 !important;
  height: 100vh !important;
  max-height: 100vh !important;
}


/* v0.59.4: duplicate Site / Ship-Site resource modal */
.duplicate-site-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 40);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.duplicate-site-modal.hidden { display: none; }

.duplicate-site-shell {
  width: min(92vw, 560px);
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(16, 20, 30, 0.98);
  box-shadow: 0 30px 90px rgba(0,0,0,0.65);
}

.duplicate-site-body {
  display: grid;
  gap: 0.6rem;
  color: rgba(255,255,255,0.88);
}

.duplicate-site-question {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: white;
}

.duplicate-site-empty-note {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  color: white;
  background: rgba(185, 28, 28, 0.78);
  border: 1px solid rgba(255,255,255,0.22);
  font-weight: 700;
}

.duplicate-site-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

body.tabletest-scale-shell .duplicate-site-modal {
  z-index: calc(var(--modal-layer, 2200) + 40) !important;
}

/* v0.61.1 lane battle math strips */
.lane-battle-math {
  position: absolute;
  z-index: 90;
  pointer-events: none;
  min-height: 24px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(42, 99, 179, 0.58);
  color: rgba(255,255,255,0.95);
  font-size: 9.5px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0,0,0,0.32);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-radius: 999px;
  backdrop-filter: blur(2px);
}

.lane-battle-math.opponent-theme {
  background: rgba(195, 63, 83, 0.55);
}

.lane-battle-math .lane-math-seat {
  opacity: 0.78;
  font-weight: 700;
  margin-right: 2px;
}

.lane-battle-math .lane-math-divider {
  opacity: 0.55;
}

.lane-battle-math strong {
  color: inherit;
  font-size: 10.5px;
  font-weight: 800;
}

.lane-battle-math .aftershock-pulse {
  margin-left: 2px;
  color: #ffdce5;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.085em;
  animation: aftershockMathPulse 1.45s ease-in-out infinite;
}

@keyframes aftershockMathPulse {
  0%, 100% { opacity: 0.52; text-shadow: 0 0 0 rgba(255, 126, 165, 0); }
  50% { opacity: 1; text-shadow: 0 0 8px rgba(255, 126, 165, 0.9); }
}

.site-battle-button {
  position: absolute;
  z-index: 960;
  transform: translate(-50%, -50%);
  min-width: 104px;
  min-height: 28px;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.26);
  background: rgba(22, 112, 154, 0.82);
  color: #f0fbff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 7px 18px rgba(0,0,0,0.34);
}

.site-battle-button.end-battle {
  background: rgba(158, 68, 96, 0.86);
}

.site-battle-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.site-battle-progress-hint {
  top: 52px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 955;
  border-color: rgba(255, 214, 121, 0.36);
  background: rgba(60, 39, 12, 0.76);
  color: #ffeab8;
  animation: siteBattleHintPulse 1.8s ease-in-out infinite;
}

@keyframes siteBattleHintPulse {
  0%, 100% { opacity: 0.72; box-shadow: 0 0 0 rgba(255, 214, 121, 0); }
  50% { opacity: 1; box-shadow: 0 0 14px rgba(255, 214, 121, 0.22); }
}

.phase-chip[data-phase="attack"] .phase-chip-short {
  font-size: 7.2px;
  letter-spacing: 0.035em;
}

.site-battle-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 70);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,0.58);
}

.site-battle-modal.hidden {
  display: none;
}

.site-battle-card {
  width: min(720px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(13, 17, 27, 0.98);
  color: var(--text);
  box-shadow: 0 22px 70px rgba(0,0,0,0.58);
}

.site-battle-card h3 {
  margin: 0;
}

.site-battle-card p {
  margin: 0.3rem 0;
}

.site-battle-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.battle-cleanup-steps {
  display: grid;
  gap: 0.55rem;
}

.battle-cleanup-steps section {
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
}

.battle-cleanup-steps h4 {
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  color: rgba(255,255,255,0.9);
}

.battle-cleanup-steps button,
.cleanup-inline button {
  margin: 0.18rem 0.28rem 0.18rem 0;
}

.cleanup-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.battle-cleanup-phase {
  display: grid;
  gap: 0.65rem;
}

.battle-cleanup-phase section {
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
}

.battle-cleanup-phase h4 {
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  color: rgba(255,255,255,0.9);
}

.cleanup-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.cleanup-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.55rem;
}

.cleanup-ability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.cleanup-ability-choice {
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.25rem;
  justify-items: start;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(12, 18, 30, 0.82);
  color: var(--text);
  text-align: left;
}

.cleanup-ability-choice.selected {
  border-color: rgba(89, 199, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(89, 199, 255, 0.18), 0 0 18px rgba(89, 199, 255, 0.22);
}

.cleanup-ability-choice:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.cleanup-ability-choice span,
.cleanup-ability-choice small {
  font-size: 0.74rem;
  line-height: 1.2;
}

.cleanup-ability-choice small {
  color: rgba(235,242,255,0.68);
}

.echo-burst {
  position: absolute;
  width: 1px;
  height: 1px;
  pointer-events: none;
  z-index: 1500;
}

.echo-burst-icon {
  position: absolute;
  left: -50px;
  top: -50px;
  width: 100px;
  height: 100px;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 0 9px rgba(255, 38, 24, 0.42));
  transform: translate(var(--burst-x, 0), 0) scale(var(--burst-scale, 0.6));
  animation: ironCrownedEchoBurst 1.85s ease-out var(--burst-delay, 0ms) forwards;
}

@keyframes ironCrownedEchoBurst {
  0% {
    opacity: 0;
    transform: translate(var(--burst-x, 0), 14px) scale(calc(var(--burst-scale, 0.6) * 0.62));
  }
  18% {
    opacity: 0.68;
  }
  74% {
    opacity: 0.4;
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--burst-x, 0) * 1.42), calc(-1 * var(--burst-travel, 160px))) scale(calc(var(--burst-scale, 0.6) * 1.02));
  }
}

.cleanup-card-choice {
  position: relative;
  min-height: 0;
  padding: 0.35rem;
  display: grid;
  gap: 0.25rem;
  justify-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(12, 18, 30, 0.82);
  color: var(--text);
}

.cleanup-card-choice.selected {
  border-color: rgba(89, 199, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(89, 199, 255, 0.18), 0 0 18px rgba(89, 199, 255, 0.22);
}

.cleanup-card-stack {
  display: grid;
  justify-items: center;
  gap: 0;
  min-width: 92px;
}

.cleanup-card-stack .cleanup-card-choice {
  width: 100%;
}

.cleanup-card-stack .cleanup-card-choice:nth-child(1) {
  z-index: 1;
}

.cleanup-card-stack .cleanup-card-choice + .cleanup-card-choice {
  margin-top: -58px;
  transform: translateY(18px);
  z-index: 2;
}

.cleanup-card-stack .cleanup-card-choice:nth-child(3) {
  transform: translateY(36px);
  z-index: 3;
}

.cleanup-card-stack .cleanup-card-choice:nth-child(4) {
  transform: translateY(54px);
  z-index: 4;
}

.cleanup-card-parent {
  opacity: 0.78;
}

.cleanup-card-choice img {
  width: 62px;
  height: 86px;
  object-fit: cover;
  border-radius: 6px;
}

.cleanup-card-choice span,
.cleanup-card-choice strong {
  max-width: 100%;
  font-size: 0.7rem;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.cleanup-pile-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .cleanup-two-col {
    grid-template-columns: 1fr;
  }
}

/* v0.61.3 phase tracker polish + phase hint toast */
.phase-tracker {
  position: absolute;
  left: 12px;
  top: 6px;
  z-index: calc(var(--drawer-layer, 2147482000) + 2);
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: min(560px, calc(100vw - 28px));
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(8, 10, 20, 0.88);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 5px 16px rgba(0,0,0,0.30);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  transition: top 0.18s ease, bottom 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.phase-tracker.setup-phase {
  grid-template-columns: 1fr;
  width: 148px;
  text-align: center;
}

.phase-tracker.phase-opponent {
  opacity: 0.86;
}

.phase-arrow {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.92);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.phase-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.phase-domino-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}

.phase-chip {
  min-width: 0;
  min-height: 24px;
  padding: 3px 5px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.68);
  display: grid;
  align-content: center;
  gap: 1px;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.phase-chip:disabled {
  cursor: not-allowed;
}

.phase-chip.complete {
  background: rgba(142, 109, 255, 0.12);
  color: rgba(255,255,255,0.78);
}

.phase-chip.active {
  background: rgba(142, 109, 255, 0.92);
  color: #fff;
  border-color: rgba(255,255,255,0.34);
  box-shadow: 0 0 13px rgba(142, 109, 255, 0.42);
}

.phase-chip-short {
  display: block;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.075em;
  line-height: 1;
}

.phase-chip-full {
  display: none;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1;
  opacity: 0.86;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-title {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.58);
  line-height: 1;
}

.phase-tracker.setup-phase strong {
  display: block;
  font-size: 12px;
  line-height: 1.02;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stay visible when the collapsed drawer is hovered. Only move the tracker when the drawer is actually expanded. */
.hand-panel.bottom-drawer.drawer-open .phase-tracker {
  top: auto;
  bottom: 8px;
  transform: translateY(0);
}

.hand-panel.bottom-drawer.drawer-open .phase-tracker {
  grid-template-columns: minmax(430px, 1fr) auto;
  width: min(720px, calc(100vw - 28px));
}

.hand-panel.bottom-drawer.drawer-open .phase-chip-full {
  display: block;
}

body.tabletest-scale-shell .phase-tracker {
  z-index: calc(var(--drawer-layer, 2147482000) + 2) !important;
}

.client-notice-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: calc(var(--modal-layer, 2147483000) + 20);
  transform: translate(-50%, -50%) translateY(12px);
  max-width: min(680px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(22, 18, 9, 0.94);
  color: rgba(255,255,255,0.94);
  box-shadow: 0 12px 30px rgba(0,0,0,0.38);
  font-size: 13px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.client-notice-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
}

@media (max-width: 760px) {
  .phase-tracker,
  .hand-panel.bottom-drawer.drawer-open .phase-tracker {
    grid-template-columns: auto minmax(220px, 1fr) auto;
    width: min(410px, calc(100vw - 18px));
    left: 8px;
  }
  .phase-chip {
    padding-inline: 3px;
  }
  .phase-chip-short {
    font-size: 8px;
  }
  .phase-chip-full {
    display: none !important;
  }
}

/* v0.61.4 Attune phase help modal */
.phase-help-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2147483000) + 30);
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
}

.phase-help-modal.hidden {
  display: none !important;
}

.phase-help-shell {
  width: min(460px, calc(100vw - 32px));
  max-height: min(72vh, 560px);
  overflow: auto;
  padding: 14px 16px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(10, 9, 22, 0.96);
  color: rgba(255,255,255,0.94);
  box-shadow: 0 22px 70px rgba(0,0,0,0.48);
}

.phase-help-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.phase-help-topbar strong {
  font-size: 18px;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.phase-help-intro {
  margin: 12px 0 10px;
  color: rgba(255,255,255,0.78);
  font-size: 13px;
  line-height: 1.42;
}

.phase-help-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 7px;
  color: rgba(255,255,255,0.88);
  font-size: 13px;
  line-height: 1.38;
}

.phase-chip {
  cursor: help;
}


/* v0.61.5 phase flow polish */
.phase-arrow {
  min-width: 36px;
  padding-inline: 8px;
  white-space: nowrap;
}
.phase-next-button {
  width: auto;
  min-width: 88px;
  height: 30px;
  padding-inline: 14px;
  border-radius: 9px;
  font-size: 0.78rem !important;
  font-weight: 900;
  letter-spacing: 0;
  background: linear-gradient(180deg, rgba(57, 147, 187, 0.98), rgba(22, 88, 129, 0.98));
  border-color: rgba(170, 232, 255, 0.42);
  box-shadow: 0 5px 12px rgba(0,0,0,0.34);
}
.phase-tracker:not(.setup-phase) .phase-arrow {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}
.hand-panel:not(:hover):not(.drawer-open) .phase-tracker .phase-arrow:not(.phase-next-button) {
  max-width: 34px;
  overflow: hidden;
  text-indent: 0;
}
.hand-panel:not(:hover):not(.drawer-open) .phase-tracker .phase-arrow:not(.phase-next-button)::first-letter {
  font-size: 0.9rem;
}

/* v0.61.7 unit move prompt */
.move-unit-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 18, 0.34);
  backdrop-filter: blur(2px);
}
.move-unit-modal.hidden {
  display: none;
}
.move-unit-card {
  width: min(420px, calc(100vw - 32px));
  padding: 18px 18px 16px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  background: rgba(20, 24, 38, 0.94);
  box-shadow: 0 20px 70px rgba(0,0,0,0.45);
  color: #f6f7fb;
  text-align: left;
}
.move-unit-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.move-unit-card p {
  margin: 8px 0;
  line-height: 1.35;
}
.move-unit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.move-unit-actions button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}
.move-unit-actions button.secondary {
  background: rgba(255,255,255,0.12);
  color: #f6f7fb;
}
.move-unit-actions button:not(.secondary) {
  background: #e8f0ff;
  color: #111827;
}
.move-unit-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.lane-choice-actions {
  justify-content: flex-start;
}
.emergency-takeoff-card {
  width: min(760px, calc(100vw - 32px));
}
.emergency-takeoff-card .lane-choice-actions {
  display: grid;
  gap: 14px;
}
.emergency-takeoff-section-title {
  display: block;
  width: 100%;
  color: rgba(246,247,251,0.84);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.emergency-takeoff-destinations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
.emergency-takeoff-destinations .emergency-takeoff-section-title {
  grid-column: 1 / -1;
}
.move-unit-actions button.emergency-takeoff-destination {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 8px;
  align-content: start;
  min-height: 148px;
  padding: 10px;
  border: 1px solid rgba(170,232,255,0.26);
  border-radius: 10px;
  background: rgba(255,255,255,0.075);
  color: #f6f7fb;
  text-align: left;
}
.move-unit-actions button.emergency-takeoff-destination:hover,
.move-unit-actions button.emergency-takeoff-destination:focus-visible {
  border-color: rgba(170,232,255,0.58);
  background: rgba(96,165,250,0.16);
  outline: none;
}
.emergency-takeoff-site-art-wrap {
  display: block;
  width: 100%;
  aspect-ratio: 3.5 / 2.5;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(0,0,0,0.24);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}
.emergency-takeoff-site-art,
.emergency-takeoff-site-art .card-img,
.emergency-takeoff-site-art .card-fallback {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 3.5 / 2.5;
  border-radius: 8px;
}
.emergency-takeoff-destination-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.emergency-takeoff-destination-meta strong {
  font-size: 0.88rem;
  line-height: 1.08;
}
.emergency-takeoff-destination-meta span {
  color: rgba(246,247,251,0.70);
  font-size: 0.74rem;
  line-height: 1.2;
}
.emergency-takeoff-embark {
  width: 100%;
}
@media (max-width: 640px) {
  .emergency-takeoff-destinations {
    grid-template-columns: 1fr;
  }
}
.ship-site-lane-action {
  background: rgba(168, 139, 250, 0.18) !important;
  border-color: rgba(196, 181, 253, 0.42) !important;
}


/* v0.61.8 Manifest / Pressure and Battle Damage modal */
.manifest-action {
  background: rgba(125, 211, 252, 0.18) !important;
  border-color: rgba(125, 211, 252, 0.38) !important;
}
.pressure-action {
  background: rgba(248, 113, 113, 0.18) !important;
  border-color: rgba(248, 113, 113, 0.42) !important;
}
.battle-damage-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 18, 0.38);
  backdrop-filter: blur(2px);
}
.battle-damage-modal.hidden {
  display: none;
}
.battle-damage-card {
  width: min(440px, calc(100vw - 32px));
  padding: 18px 18px 16px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  background: rgba(20, 24, 38, 0.96);
  box-shadow: 0 20px 70px rgba(0,0,0,0.48);
  color: #f6f7fb;
}
.battle-damage-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.battle-damage-card p {
  margin: 8px 0;
  line-height: 1.35;
}
.battle-damage-options {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}
.battle-damage-options button {
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
  color: #f6f7fb;
  background: rgba(255,255,255,0.1);
}
.battle-damage-options button:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
}
.battle-damage-options button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


/* v0.61.8 Edorach Embassy Agent Leverage modal */
.leverage-manifest-modal {
  position: fixed;
  inset: 0;
  z-index: 10062;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 18, 0.38);
  backdrop-filter: blur(2px);
}
.leverage-manifest-modal.hidden {
  display: none;
}
.leverage-manifest-card {
  width: min(460px, calc(100vw - 32px));
  padding: 18px 18px 16px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  background: rgba(20, 24, 38, 0.96);
  box-shadow: 0 20px 70px rgba(0,0,0,0.48);
  color: #f6f7fb;
}
.leverage-manifest-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.leverage-manifest-preview {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
}
.leverage-manifest-preview strong {
  grid-column: 2;
  grid-row: 1;
}
.leverage-manifest-art {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  width: 84px;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
  background: #0d121d;
}
.leverage-manifest-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 12px;
}
.leverage-manifest-actions button {
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
  color: #111827;
  background: #e8f0ff;
}
.leverage-manifest-actions button.secondary {
  color: #f6f7fb;
  background: rgba(255,255,255,0.1);
}

/* v0.61.10: attack/block modal and targeting affordances */
.attack-block-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 55);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px);
}
.attack-block-modal.hidden { display: none; }
.defeated-discard-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--modal-layer, 2200) + 58);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(3px);
}
.defeated-discard-modal.hidden { display: none; }
.defeated-discard-card {
  width: min(92vw, 760px);
  max-height: min(88vh, 760px);
  overflow: auto;
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(15, 18, 28, 0.97);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 24px 80px rgba(0,0,0,0.62);
}
.defeated-discard-card h3,
.defeated-discard-card p {
  margin: 0;
}
.defeated-discard-body {
  display: grid;
  gap: 0.75rem;
}
.defeated-discard-entry {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.7rem;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.1);
}
.defeated-discard-entry > img {
  width: 84px;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 6px;
  background: #101624;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.defeated-discard-detail {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-width: 0;
}
.defeated-discard-detail > strong {
  color: #fff;
  overflow-wrap: anywhere;
}
.defeated-discard-detail > span,
.defeated-discard-empty {
  color: rgba(255,255,255,0.72);
  font-size: 0.86rem;
}
.defeated-discard-attachments {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.defeated-discard-attachment {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}
.defeated-discard-attachment img {
  width: 42px;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 4px;
}
.defeated-discard-attachment div {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}
.defeated-discard-attachment strong {
  color: #fff;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}
.defeated-discard-attachment span {
  color: rgba(255,255,255,0.68);
  font-size: 0.78rem;
}
.defeated-discard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
.defeated-discard-actions button {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 0.58rem 0.9rem;
  background: #f3f7ff;
  color: #121827;
  font-weight: 900;
  cursor: pointer;
}
.attack-block-card {
  width: min(94vw, 1080px);
  max-height: min(88vh, 780px);
  overflow: auto;
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(15, 18, 28, 0.96);
  color: rgba(255,255,255,0.92);
  box-shadow: 0 24px 80px rgba(0,0,0,0.62);
}
.attack-block-card h3 { margin: 0; color: #fff; }
.attack-block-card p { margin: 0; }
.combat-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.combat-modal-kicker {
  color: rgba(255,255,255,0.62);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.combat-modal-summary {
  color: rgba(255,255,255,0.82);
  line-height: 1.4;
}
.combat-modal-body {
  min-height: 260px;
}
.combat-modal-grid {
  display: grid;
  gap: 1.1rem;
  align-items: center;
}
.combat-modal-grid.attacker-view {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
}
.combat-modal-grid.defender-view {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
}
.combat-modal-grid h4,
.combat-info-panel h4 {
  margin: 0 0 0.5rem;
  color: rgba(255,255,255,0.78);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.combat-feature-section,
.combat-target-strip-section,
.combat-defense-section {
  min-width: 0;
}
.combat-feature-section {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
}
.combat-card-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 96px;
  gap: 0.55rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0.25rem 0.15rem 0.55rem;
  min-height: 162px;
}
.combat-modal-card {
  display: grid;
  gap: 0.42rem;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  padding: 0.42rem;
  background: rgba(255,255,255,0.065);
  color: rgba(255,255,255,0.9);
  text-align: left;
  cursor: pointer;
}
.combat-modal-card:hover:not(:disabled),
.combat-modal-card.selected {
  border-color: rgba(255, 236, 142, 0.82);
  box-shadow: 0 0 0 2px rgba(255, 236, 142, 0.18), 0 12px 34px rgba(0,0,0,0.28);
}
.combat-modal-card:disabled {
  cursor: default;
}
.combat-modal-card.large {
  width: min(100%, 260px);
}
.combat-modal-art {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border-radius: 6px;
  background: #0d121d;
}
.combat-modal-art .card-img,
.combat-modal-art .card-fallback {
  width: 100%;
  height: 100%;
}
.combat-modal-card.small .combat-modal-art {
  min-height: 118px;
}
.combat-modal-card-meta {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
  font-size: 0.72rem;
}
.combat-modal-card-meta strong,
.combat-modal-card-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combat-modal-card-meta span {
  color: rgba(255,255,255,0.68);
  font-weight: 800;
}
.combat-info-panel {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.055);
}
.combat-info-panel ul {
  margin: 0;
  padding-left: 1rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  line-height: 1.35;
}
.combat-empty-note {
  align-self: center;
  width: 260px;
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 8px;
  color: rgba(255,255,255,0.64);
}
.attack-block-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.table-card.block-target-card {
  outline: 3px solid rgba(255, 236, 142, 0.88);
  outline-offset: 4px;
  box-shadow: 0 0 20px rgba(255, 236, 142, 0.24);
  cursor: crosshair;
}
.table-card.spot-check-source {
  outline: 3px solid rgba(95, 220, 255, 0.88);
  outline-offset: 4px;
  box-shadow: 0 0 22px rgba(95, 220, 255, 0.28);
}
.table-card.spot-check-target-card {
  outline: 3px solid rgba(95, 255, 180, 0.9);
  outline-offset: 4px;
  box-shadow: 0 0 22px rgba(95, 255, 180, 0.3);
  cursor: crosshair;
}
.selected-actions .attack-action,
.selected-actions .block-action,
.selected-actions .spot-check-action {
  border-color: rgba(255, 236, 142, 0.42);
  background: rgba(255, 236, 142, 0.14);
}
.selected-actions .unattuned-action {
  border-color: rgba(205, 194, 255, 0.42);
  background: rgba(74, 62, 125, 0.22);
  color: #ddd6ff;
}


/* v0.61.11: attack/block modal behavior and combat direction arrows */
.attack-block-modal.board-review-hidden {
  display: none;
}
.combat-board-prompt {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.combat-board-prompt-button {
  border: 1px solid rgba(255,255,255,0.26);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
  background: rgba(12, 16, 28, 0.72);
  cursor: pointer;
}
.combat-board-prompt-button.attacking {
  border-color: rgba(255, 112, 112, 0.52);
  background: rgba(122, 32, 38, 0.66);
}
.combat-board-prompt-button.blocking {
  border-color: rgba(255, 225, 116, 0.54);
  background: rgba(122, 88, 18, 0.66);
}
.combat-board-prompt-button:hover {
  filter: brightness(1.14);
}
.combat-arrow-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1180;
  overflow: visible;
}
.combat-arrow-trail,
.combat-arrow-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.combat-arrow-trail {
  stroke-width: 18;
  opacity: 0.26;
  filter: blur(1px) drop-shadow(0 4px 8px rgba(0,0,0,0.58));
}
.combat-arrow-line {
  stroke-width: 6;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.62));
  opacity: 0.72;
}
.combat-arrow-line.attack {
  stroke: rgba(255, 92, 92, 0.72);
}
.combat-arrow-line.block {
  stroke: rgba(255, 225, 116, 0.76);
}
.combat-arrow-trail.attack {
  stroke: rgba(255, 58, 58, 0.62);
}
.combat-arrow-trail.block {
  stroke: rgba(255, 210, 84, 0.66);
}
.combat-arrow-line.dashed,
.combat-arrow-trail.dashed {
  stroke-dasharray: 16 13;
}
.combat-arrow-line.dashed {
  opacity: 0.36;
}
.combat-arrow-trail.dashed {
  opacity: 0.14;
}
.combat-arrow-head.attack {
  fill: rgba(255, 92, 92, 0.74);
  stroke: rgba(255, 230, 230, 0.42);
  stroke-width: 0.8;
}
.combat-arrow-head.block {
  fill: rgba(255, 225, 116, 0.78);
  stroke: rgba(255, 249, 214, 0.46);
  stroke-width: 0.8;
}
.combat-arrow-label {
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.06em;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.58);
  stroke-width: 4px;
  stroke-linejoin: round;
  opacity: 0.72;
}
.combat-arrow-label.attack {
  fill: rgba(255, 232, 232, 0.82);
}
.combat-arrow-label.block {
  fill: rgba(255, 246, 198, 0.86);
}
.combat-arrow-label.pending {
  animation: combatPendingLabelPulse 1.35s ease-in-out infinite;
}
.combat-prompt-reopen {
  position: absolute;
  z-index: 1190;
  transform: translate(-50%, -50%);
  padding: 0.16rem 0.48rem;
  border: 1px solid rgba(255,255,255,0.26);
  border-radius: 999px;
  background: rgba(12, 16, 28, 0.58);
  color: rgba(255,255,255,0.9);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.72);
  cursor: pointer;
  animation: combatPendingLabelPulse 1.35s ease-in-out infinite;
}
.combat-prompt-reopen:hover {
  background: rgba(42, 48, 70, 0.82);
  border-color: rgba(255,255,255,0.48);
}
.combat-arrow-line.pending {
  animation: combatPendingLinePulse 1.35s ease-in-out infinite;
}
.combat-arrow-trail.pending {
  animation: combatPendingTrailPulse 1.35s ease-in-out infinite;
}
@keyframes combatPendingLabelPulse {
  0%, 100% {
    opacity: 0.5;
    fill: rgba(255, 232, 232, 0.72);
  }
  50% {
    opacity: 0.96;
    fill: rgba(255, 255, 255, 0.96);
  }
}
@keyframes combatPendingLinePulse {
  0%, 100% {
    opacity: 0.5;
    stroke-width: 5.5;
  }
  50% {
    opacity: 0.86;
    stroke-width: 7;
  }
}
@keyframes combatPendingTrailPulse {
  0%, 100% {
    opacity: 0.14;
  }
  50% {
    opacity: 0.34;
  }
}
.table-card.combat-block-nudge {
  transform: translateY(-14px) scale(1.03);
  transition: transform 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 0 22px rgba(255, 226, 118, 0.35), var(--card-shadow, 0 10px 24px rgba(0,0,0,0.35));
}

@media (max-width: 780px) {
  .attack-block-card {
    width: min(96vw, 640px);
    max-height: 90vh;
  }
  .combat-modal-header {
    align-items: stretch;
    flex-direction: column;
  }
  .combat-modal-grid.attacker-view,
  .combat-modal-grid.defender-view {
    grid-template-columns: 1fr;
  }
  .combat-card-strip {
    grid-auto-columns: 88px;
  }
  .combat-modal-card.large {
    width: min(100%, 220px);
  }
}
