:root {
  --wood: #3d2914;
  --wood-light: #5c4228;
  --text: #f5f0e6;
  --muted: #c4b59a;
  --accent: #c9a227;
  --accent-dark: #8a6d1a;
  --danger: #8b1e1e;
  --panel: rgba(20, 14, 8, 0.82);
  --zone-border: rgba(255, 255, 255, 0.35);
  --card-w-field: 72px;
  --card-h-field: 100px;
  --card-w-hand: 88px;
  --card-h-hand: 122px;
  --card-w-mini: 48px;
  --card-h-mini: 66px;
  --card-w-life: 52px;
  --card-h-life: 72px;
  --don-token-w: 48px;
  --don-token-h: 66px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--wood);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }

/* --- Home / replay --- */
.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 2px solid var(--accent-dark);
}

.site-header h1 {
  margin: 0;
  min-width: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}
.site-header a { color: var(--text); }

.site-menu {
  position: relative;
  flex: none;
}

.site-menu-button {
  display: inline-flex;
  width: 2.35rem;
  height: 2.35rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.23rem;
  padding: 0;
  background: rgba(10, 7, 4, 0.58);
  border: 1px solid rgba(201, 162, 39, 0.54);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.site-menu-button:hover,
.site-menu-button[aria-expanded="true"] {
  background: rgba(34, 23, 12, 0.9);
  border-color: rgba(201, 162, 39, 0.88);
}

.site-menu-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-menu-button-line {
  display: block;
  width: 1.08rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.site-menu-popup {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 50;
  display: flex;
  min-width: 12.5rem;
  padding: 0.45rem;
  flex-direction: column;
  gap: 0.15rem;
  background: rgba(20, 14, 8, 0.97);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

.site-menu-popup[hidden] {
  display: none;
}

.site-menu-popup a {
  display: flex;
  min-height: 2.25rem;
  align-items: center;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 750;
}

.site-menu-popup a:hover,
.site-menu-popup a:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  color: #fff6cf;
  outline: none;
}

.site-menu--play .site-menu-button {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 4px;
  background: linear-gradient(180deg, #c9a227, #8a6d1a);
  border: 2px solid #5c4a12;
  color: #1a1208;
}

.toolbar-site-menu {
  margin-left: auto;
}

.container {
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.home-container {
  max-width: 1120px;
  margin: clamp(1.5rem, 7vh, 4.5rem) auto;
  padding: 0 clamp(0.9rem, 2.5vw, 2rem);
}

.changelog-container {
  max-width: 720px;
  margin: clamp(1.5rem, 7vh, 4.5rem) auto;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
}

.deck-page-container {
  max-width: 1320px;
  margin: 1.5rem auto;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
}

.settings-container {
  max-width: 560px;
  margin: clamp(1.5rem, 7vh, 4.5rem) auto;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
}

.home-layout {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.home-primary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(26rem, 1fr));
  gap: 1.2rem;
  align-items: stretch;
}

.home-panel,
.replay-panel {
  background: linear-gradient(180deg, rgba(34, 23, 12, 0.94), rgba(20, 14, 8, 0.94));
  padding: 1.75rem;
  border: 1px solid rgba(201, 162, 39, 0.4);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.home-panel {
  min-width: 0;
}

.home-panel h2,
.replay-panel h2 {
  margin: 0 0 1.25rem;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
}

.home-panel-copy {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.5;
}

.home-panel--human {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.home-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.home-human-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.35rem;
}

.home-human-controls .home-field {
  margin-bottom: 0;
}

.home-human-actions {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: stretch;
}

.home-human-form {
  min-width: 0;
}

.home-human-form .home-start-button {
  margin-top: 0;
}

.home-human-or {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  color: rgba(196, 181, 154, 0.82);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-align: center;
}

.home-human-or::before,
.home-human-or::after {
  content: "";
  height: 1px;
  background: rgba(201, 162, 39, 0.24);
}

.home-human-join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: end;
}

.home-back-link {
  width: fit-content;
  color: var(--muted);
  font-weight: 750;
  font-size: 0.9rem;
}

.home-back-link:hover {
  color: var(--accent);
}

.home-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.home-field {
  display: block;
  margin-bottom: 1rem;
  color: var(--muted);
  min-width: 0;
}

.home-field span,
.home-field-title {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.home-field-label-link {
  color: var(--accent);
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 0.16rem;
}

.home-field-label-link:hover {
  color: #f8ecb8;
}

.home-field input,
.home-field select,
.home-select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: rgba(10, 7, 4, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-field select,
select.home-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.35rem;
  background-color: rgba(10, 7, 4, 0.6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23f5f0e6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.85rem;
  color-scheme: dark;
}

.home-field select option,
select.home-select option {
  background: #1a1208;
  color: var(--text);
}

.home-field input:focus,
.home-field select:focus,
.home-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

.home-field input::placeholder {
  color: rgba(196, 181, 154, 0.55);
}

.home-start-button {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid #1a5c34;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 22px rgba(45, 138, 78, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.home-start-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(45, 138, 78, 0.32);
}

.home-start-button:active {
  transform: translateY(0);
}

.home-start-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.home-error {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.28);
  color: #fecaca;
  font-weight: 650;
}

.home-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(201, 162, 39, 0.42);
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.12);
  color: #ead89d;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.35;
}

.home-warning span {
  flex: 1 1 18rem;
}

.home-warning-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(234, 216, 157, 0.58);
  border-radius: 6px;
  color: #fff7d1;
  text-decoration: none;
  white-space: nowrap;
}

.home-warning-link:hover {
  background: rgba(201, 162, 39, 0.18);
}

.home-nav-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.home-nav-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 2.4rem 0.9rem 1.1rem;
  background: rgba(20, 14, 8, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: 12px;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.home-nav-tile::after {
  content: "→";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  opacity: 0.75;
  transition: transform 0.15s ease;
}

.home-nav-tile:hover {
  border-color: rgba(201, 162, 39, 0.6);
  background: rgba(34, 23, 12, 0.8);
  transform: translateY(-1px);
}

.home-nav-tile:hover::after {
  transform: translateY(-50%) translateX(3px);
}

.home-nav-tile-title {
  font-weight: 800;
  font-size: 0.95rem;
}

.home-nav-tile-hint {
  font-size: 0.78rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.changelog-panel {
  padding-bottom: 1.35rem;
}

.changelog-heading {
  margin-bottom: 0.85rem;
  min-width: 0;
}

.changelog-heading h2 {
  margin-bottom: 0.35rem;
}

.changelog-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.changelog-item {
  display: grid;
  grid-template-columns: 6.6rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.85rem 0;
  border-top: 1px solid rgba(201, 162, 39, 0.16);
}

.changelog-item time {
  color: rgba(196, 181, 154, 0.72);
  font-size: 0.73rem;
  font-weight: 800;
  line-height: 1.45;
  text-transform: uppercase;
}

.changelog-item strong {
  display: block;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.3;
}

.changelog-item p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.changelog-credit {
  margin-top: 1.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(201, 162, 39, 0.16);
  color: rgba(196, 181, 154, 0.82);
  font-size: 0.82rem;
  text-align: center;
}

.changelog-credit a {
  font-weight: 800;
}

/* Botones fantasma de navegación en cabeceras de páginas de menú
   (Configuración/Mazos): misma familia visual que .home-nav-tile. */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.95rem;
  background: rgba(201, 162, 39, 0.14);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 8px;
  color: #eeda92;
  font-weight: 700;
  font-size: 0.83rem;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease,
    transform 0.12s ease;
}

.btn-ghost:hover {
  border-color: rgba(201, 162, 39, 0.85);
  background: rgba(201, 162, 39, 0.28);
  color: #f8ecb8;
  transform: translateY(-1px);
}

/* --- Settings --- */
.settings-rows {
  display: flex;
  flex-direction: column;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.05rem 0;
  margin: 0;
  border-top: 1px solid rgba(201, 162, 39, 0.14);
}

.settings-rows .settings-row:first-child {
  border-top: 0;
  padding-top: 0.25rem;
}

.settings-rows .settings-row:last-child {
  padding-bottom: 0.25rem;
}

label.settings-row {
  cursor: pointer;
}

.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 14rem;
}

.settings-row-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.settings-row-hint {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.settings-row .home-select {
  width: auto;
  min-width: 11rem;
  flex: none;
}

.settings-toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: rgba(10, 7, 4, 0.7);
  border: 1px solid rgba(201, 162, 39, 0.35);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.settings-toggle::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.15s ease;
}

.settings-toggle:checked {
  background: linear-gradient(180deg, #d8b53a, #a07f1d);
  border-color: var(--accent);
}

.settings-toggle:checked::before {
  transform: translateX(20px);
  background: #fff8e6;
}

.settings-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.screen-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.screen-actions .btn-toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.screen-header h2 {
  margin-bottom: 0;
}

.deck-page-panel {
  min-width: 0;
}

.deck-browser {
  display: grid;
  grid-template-columns: minmax(8.5rem, 20%) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.deck-builder {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.deck-builder-sidebar {
  min-width: 0;
}

.deck-builder-sidebar .home-field {
  margin-bottom: 0.8rem;
}

.deck-builder-sidebar input,
.deck-builder-sidebar textarea {
  width: 100%;
}

.deck-builder-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.deck-builder-actions .btn,
.deck-import-panel .btn {
  min-height: 2.35rem;
  padding-inline: 0.55rem;
  font-size: 0.74rem;
}

.deck-import-panel {
  display: flex;
  width: min(100%, 30rem);
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0;
}

.deck-import-panel .home-field {
  margin-bottom: 0;
}

.deck-import-panel textarea {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  max-height: min(15rem, 42vh);
  padding: 0.75rem;
  resize: vertical;
  background: rgba(10, 7, 4, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 8px;
  color: var(--text);
  font: 0.86rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.deck-import-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

.deck-modal[hidden] {
  display: none;
}

.deck-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.deck-modal-backdrop {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.68);
  cursor: pointer;
}

.deck-modal-dialog {
  position: relative;
  width: min(100%, 34rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(34, 23, 12, 0.98), rgba(20, 14, 8, 0.98));
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.deck-modal-dialog.deck-import-panel {
  width: min(100%, 30rem);
}

.deck-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.deck-modal-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.2;
}

.deck-modal-close {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.62);
  color: var(--text);
  cursor: pointer;
}

.deck-modal-close::before,
.deck-modal-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.9rem;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.deck-modal-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.deck-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.deck-card-preview-dialog {
  width: min(100%, 23rem);
}

.deck-card-preview-img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

.deck-builder-status {
  margin-top: 0.8rem;
  padding: 0.65rem;
  min-height: 3.2rem;
  background: rgba(10, 8, 6, 0.42);
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.deck-builder-status[data-tone="error"] {
  border-color: rgba(220, 72, 72, 0.75);
  color: #ffd2d2;
}

.deck-builder-status[data-tone="ok"] {
  border-color: rgba(110, 186, 118, 0.65);
  color: #d8f5dc;
}

.deck-builder-status p {
  margin: 0 0 0.35rem;
}

.deck-builder-status p:last-child {
  margin-bottom: 0;
}

.deck-builder-main {
  min-width: 0;
}

.deck-builder-toolbar {
  min-height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.deck-builder-toolbar h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.deck-builder-counter {
  flex-shrink: 0;
  min-width: 4.6rem;
  padding: 0.32rem 0.55rem;
  background: rgba(10, 8, 6, 0.62);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.deck-builder-current,
.deck-card-results {
  --deck-builder-card-w: 4.4rem;
  --deck-builder-card-h: 6.15rem;
  min-height: 13.5rem;
  max-height: 44vh;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.65rem, 1fr));
  gap: 0.9rem 0.7rem;
  align-content: start;
  padding: 0.8rem;
  background:
    linear-gradient(rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08)),
    rgba(10, 8, 6, 0.42);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
}

.deck-card-results {
  min-height: 18rem;
  max-height: none;
}

.deck-builder-card {
  position: relative;
  width: calc(var(--deck-builder-card-w) + 1.35rem);
  min-height: calc(var(--deck-builder-card-h) + 2.35rem);
  color: inherit;
}

.deck-card-action {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: block;
  width: 100%;
  min-height: calc(var(--deck-builder-card-h) + 2.35rem);
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.deck-card-action:disabled {
  cursor: default;
}

.deck-builder-actions .btn:disabled {
  opacity: 0.55;
}

.deck-builder-card-img {
  display: block;
  width: var(--deck-builder-card-w);
  height: var(--deck-builder-card-h);
  background: #1a1208;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  box-shadow: 0 5px 13px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.deck-builder-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.deck-builder-card-img span {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  font-size: 0.62rem;
  line-height: 1.2;
  text-align: center;
}

.deck-builder-card-name {
  display: block;
  width: var(--deck-builder-card-w);
  margin-top: 0.32rem;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.15;
}

.deck-card-zoom {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 0.25rem;
  left: calc(var(--deck-builder-card-w) - 1.65rem);
  z-index: 4;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.78);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.deck-card-zoom::before {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 0.34rem;
  width: 0.48rem;
  height: 0.48rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.deck-card-zoom::after {
  content: "";
  position: absolute;
  left: 0.87rem;
  top: 0.9rem;
  width: 0.42rem;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.deck-card-zoom:hover:not(:disabled),
.deck-card-zoom:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.deck-card-zoom:disabled {
  opacity: 0.45;
  cursor: default;
}

.deck-builder-card--leader .deck-builder-card-img {
  border-color: rgba(201, 162, 39, 0.92);
  box-shadow:
    0 0 0 1px rgba(201, 162, 39, 0.35),
    0 5px 13px rgba(0, 0, 0, 0.5);
}

.deck-builder-card.is-pending .deck-builder-card-img,
.deck-search-card.is-pending .deck-builder-card-img {
  filter: grayscale(1);
  opacity: 0.62;
}

.deck-builder-empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.deck-builder-toolbar--search {
  margin-top: 1rem;
}

.deck-search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: min(100%, 19rem);
}

.deck-search-field span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.deck-search-field input {
  flex: 1 1 auto;
  min-width: 0;
}

.deck-color-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.deck-color-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-height: 2rem;
  padding: 0.32rem 0.52rem;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.42);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.deck-color-filter input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.deck-color-filter--red { border-color: rgba(202, 64, 64, 0.55); }
.deck-color-filter--green { border-color: rgba(80, 160, 90, 0.55); }
.deck-color-filter--blue { border-color: rgba(67, 135, 210, 0.55); }
.deck-color-filter--purple { border-color: rgba(149, 98, 205, 0.55); }
.deck-color-filter--black { border-color: rgba(190, 190, 190, 0.42); }
.deck-color-filter--yellow { border-color: rgba(220, 188, 74, 0.62); }

.deck-card-action:hover:not(:disabled) .deck-builder-card-img,
.deck-card-action:focus-visible .deck-builder-card-img {
  border-color: rgba(201, 162, 39, 0.8);
}

.deck-search-card .deck-builder-card-name {
  color: var(--text);
}

.deck-browser-controls {
  min-width: 0;
}

.deck-editable-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.deck-hover-preview {
  margin-top: 1rem;
  padding: 0.65rem;
  min-height: 13.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(10, 8, 6, 0.42);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
}

.deck-hover-preview-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
}

.deck-hover-preview-img {
  width: 100%;
  max-width: 13rem;
  height: auto;
  border-radius: 5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
}

.deck-hover-preview-title {
  width: 100%;
  color: var(--accent);
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: center;
}

.deck-preview-surface {
  --deck-card-w: 4.5rem;
  --deck-card-h: 6.25rem;
  min-width: 0;
  max-height: calc(100vh - 9rem);
  overflow: auto;
  padding: 0.85rem;
  background:
    linear-gradient(rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.08)),
    rgba(10, 8, 6, 0.42);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
}

.deck-preview[hidden] {
  display: none;
}

.deck-preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.deck-preview-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.2;
}

.deck-preview-header span {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}

.deck-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.7rem, 1fr));
  gap: 1.05rem 0.8rem;
  align-items: start;
}

.deck-card-stack {
  position: relative;
  justify-self: start;
  width: calc(var(--deck-card-w) + 1.45rem);
  height: calc(var(--deck-card-h) + 2.05rem);
  cursor: pointer;
}

.deck-card-img,
.deck-card-fallback {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--deck-card-w);
  height: var(--deck-card-h);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  box-shadow: 0 5px 13px rgba(0, 0, 0, 0.5);
  transform: translate(calc(var(--stack-i) * 0.38rem), calc(var(--stack-i) * 0.28rem));
}

.deck-card-img {
  object-fit: cover;
}

.deck-card-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: #1a1208;
  color: var(--text);
  font-size: 0.62rem;
  line-height: 1.2;
  text-align: center;
}

.deck-card-stack--leader .deck-card-img,
.deck-card-stack--leader .deck-card-fallback {
  border-color: rgba(201, 162, 39, 0.92);
  box-shadow:
    0 0 0 1px rgba(201, 162, 39, 0.35),
    0 5px 13px rgba(0, 0, 0, 0.5);
}

.deck-copy-badge,
.deck-role-badge {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: 900;
}

.deck-copy-badge {
  right: 0;
  bottom: 0.15rem;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.25rem;
  background: linear-gradient(180deg, #ffe082, #c9a227);
  border: 2px solid #5c4a12;
  color: #1a1208;
  font-size: 1.05rem;
  line-height: 1;
}

.deck-role-badge {
  left: 0.2rem;
  top: 0.15rem;
  max-width: calc(var(--deck-card-w) - 0.4rem);
  padding: 0.15rem 0.3rem;
  background: rgba(26, 18, 8, 0.88);
  border: 1px solid rgba(201, 162, 39, 0.75);
  color: var(--accent);
  font-size: 0.55rem;
  line-height: 1;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-builder-card .deck-copy-badge {
  right: 1.1rem;
  bottom: 2.05rem;
}

.deck-builder-card .deck-role-badge {
  max-width: calc(var(--deck-builder-card-w) - 0.4rem);
}

@media (max-width: 1100px) {
  .deck-page-container {
    margin: 1rem auto;
  }

  .deck-preview-surface {
    max-height: none;
  }
}

@media (max-width: 960px) {
  .home-primary-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  .home-primary-grid,
  .home-nav-row {
    grid-template-columns: 1fr;
  }

  .home-panel,
  .replay-panel {
    padding: 1.25rem;
  }

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

  .changelog-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .settings-row {
    flex-wrap: wrap;
  }

  .settings-row .home-select {
    flex: 1 1 100%;
  }

  .screen-header {
    display: block;
  }

  .screen-actions {
    margin-top: 0.75rem;
  }

  .screen-actions .btn-toolbar,
  .screen-actions .btn-ghost {
    flex: 1 1 8rem;
  }

  .deck-browser {
    grid-template-columns: 1fr;
  }

  .deck-builder {
    grid-template-columns: 1fr;
  }

  .deck-preview-surface {
    --deck-card-w: 3.8rem;
    --deck-card-h: 5.3rem;
    padding: 0.65rem;
  }

  .deck-builder-current,
  .deck-card-results {
    --deck-builder-card-w: 3.8rem;
    --deck-builder-card-h: 5.3rem;
    grid-template-columns: repeat(auto-fill, minmax(4.9rem, 1fr));
  }

  .deck-hover-preview {
    display: none;
  }

  .deck-modal {
    padding: 0.75rem;
  }

  .deck-import-panel {
    max-height: calc(100dvh - 1.5rem);
    padding: 0.9rem;
  }

  .deck-import-panel textarea {
    min-height: 9rem;
    max-height: min(13rem, 38dvh);
  }

  .deck-modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .deck-modal-actions .btn {
    width: 100%;
  }

  .deck-builder-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .deck-search-field {
    width: 100%;
  }

  .deck-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(4.85rem, 1fr));
    gap: 0.85rem 0.5rem;
  }

  .deck-preview-header {
    display: block;
  }

  .deck-preview-header span {
    display: block;
    margin-top: 0.2rem;
  }
}

/* --- Play page full screen --- */
body.page-play {
  overflow: hidden;
  height: 100vh;
  background:
    linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15)),
    repeating-linear-gradient(
      92deg,
      #4a3520 0px,
      #5a4228 8px,
      #3d2914 16px,
      #4a3520 24px
    );
}

.main-play {
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
}

#board {
  height: 100%;
}

.tcg-table {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0.5rem;
  gap: 0.5rem;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--panel);
  border: 2px solid var(--accent-dark);
  border-radius: 4px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.turn-pill, .phase-pill, .seed-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  color: var(--muted);
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge.human { background: #1a5c34; color: #9ef0b8; }
.badge.bot { background: #6b4f0a; color: #ffe08a; }

.table-body {
  flex: 1;
  display: grid;
  /* Escritorio base (<=1600px): el mat se capa a 700px y el sobrante queda
     para manos + historial. En pantallas mayores se escala más abajo. */
  grid-template-columns: minmax(330px, 1fr) minmax(0, 700px) minmax(180px, 18vw);
  gap: 0.5rem;
  min-height: 0;
}

.side-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-right {
  gap: 0.35rem;
}

/* --- Card preview (above action dock) --- */
.card-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.4rem;
  background: rgba(10, 8, 6, 0.88);
  border: 2px solid var(--accent-dark);
  border-radius: 6px;
  overflow: hidden;
}

.card-preview-placeholder {
  margin: auto;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem;
  line-height: 1.35;
}

.card-preview--active .card-preview-placeholder {
  display: none;
}

.card-preview-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: calc(100% - 4.5rem);
  object-fit: contain;
  image-rendering: auto;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}

.card-preview-meta {
  width: 100%;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  line-height: 1.25;
}

.card-preview-text {
  width: 100%;
  margin: 0.25rem 0 0;
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
  max-height: 3.2rem;
  overflow-y: auto;
}

.card-preview-source {
  cursor: help;
}

.card-preview-source:hover {
  outline: 1px solid rgba(201, 162, 39, 0.85);
  outline-offset: 1px;
}

/* --- Action dock --- */
.action-dock {
  flex: 0 0 auto;
  max-height: 48vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #c9a227 0%, #8a6d1a 100%);
  border: 2px solid #5c4a12;
  border-radius: 6px;
  padding: 0.55rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.dock-title {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  text-transform: uppercase;
  color: #1a1208;
  text-align: center;
  letter-spacing: 0.04em;
}

.dock-muted {
  color: #3d2914;
  font-size: 0.68rem;
  text-align: center;
  margin: 0;
}

.counter-step-summary {
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.4rem;
  background: rgba(26, 18, 8, 0.18);
  border: 1px solid rgba(26, 18, 8, 0.35);
  border-radius: 4px;
}

.counter-step-line {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.35;
  color: #1a1208;
}

.counter-step-bonus {
  margin-top: 0.2rem;
  font-weight: 700;
  color: #0d4f6e;
}

.replacement-summary {
  margin: 0 0 0.45rem;
  padding: 0.45rem 0.5rem;
  background: rgba(26, 18, 8, 0.2);
  border: 1px solid rgba(26, 18, 8, 0.38);
  border-radius: 4px;
}

.replacement-summary-title {
  margin: 0 0 0.25rem;
  color: #1a1208;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.replacement-summary-text {
  margin: 0;
  color: #1a1208;
  font-size: 0.68rem;
  line-height: 1.35;
}

.replacement-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.context-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.context-panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1208;
  line-height: 1.35;
  text-align: center;
}

.context-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-dock-default {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#board.has-action-selection #action-dock-default,
#board.don-pick-mode #action-dock-default,
#board.attack-pick-mode #action-dock-default,
#board.effect-pick-mode #action-dock-default,
#board.board-replace-pick-mode #action-dock-default,
#board.replacement-bottom-deck-pick-mode #action-dock-default,
#board.replacement-rest-card-pick-mode #action-dock-default,
.tcg-table.has-action-selection #action-dock-default,
.tcg-table.don-pick-mode #action-dock-default,
.tcg-table.attack-pick-mode #action-dock-default,
.tcg-table.effect-pick-mode #action-dock-default,
.tcg-table.board-replace-pick-mode #action-dock-default,
.tcg-table.replacement-bottom-deck-pick-mode #action-dock-default,
.tcg-table.replacement-rest-card-pick-mode #action-dock-default {
  display: none;
}

.btn-context-cancel {
  background: linear-gradient(180deg, #d8d0c0, #b8b0a0);
}

.card-action-target {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.card-action-target.is-selected {
  overflow: visible;
  z-index: 20;
  transform: scale(1.04);
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.5));
}

.card-action-target.is-selected::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 7px;
  border: 3px solid #f8f3e0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9),
    0 0 14px 3px rgba(255, 252, 235, 0.85),
    0 0 24px 6px rgba(255, 230, 160, 0.55);
  pointer-events: none;
  z-index: 15;
}

.card-action-target.is-selected::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  pointer-events: none;
  z-index: 16;
}

.card-slot--hand.card-action-target.is-selected {
  transform: scale(1.03);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.card-slot--hand.card-action-target.is-selected::before {
  inset: -4px;
  border-width: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.85),
    0 0 12px 2px rgba(255, 252, 235, 0.75),
    0 0 18px 4px rgba(255, 230, 160, 0.5);
}

/* En el abanico el slot puede ser mas estrecho que la carta: los halos de
   seleccion se dimensionan contra la carta, no contra el slot. */
.hand-row .card-slot--hand.card-action-target.is-selected::before {
  inset: auto;
  top: -4px;
  left: -4px;
  width: calc(var(--card-w-hand) + 8px);
  height: calc(var(--card-h-hand) + 8px);
  box-sizing: border-box;
}

.hand-row .card-slot--hand.card-action-target.is-selected::after {
  inset: auto;
  top: -2px;
  left: -2px;
  width: calc(var(--card-w-hand) + 4px);
  height: calc(var(--card-h-hand) + 4px);
}

.don-action-source {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  border-radius: 4px;
}

.don-action-source.is-selected {
  transform: scale(1.14);
  outline: 4px solid #f8f3e0;
  outline-offset: 3px;
  filter:
    drop-shadow(0 0 10px rgba(255, 252, 235, 0.98))
    drop-shadow(0 0 22px rgba(255, 230, 160, 0.85));
}

.tcg-table.don-pick-mode .card-action-target[data-action-target="unit"].is-attach-viable:not(.is-selected),
.don-pick-mode .card-action-target[data-action-target="unit"].is-attach-viable:not(.is-selected) {
  outline: 2px dashed #7dd3fc;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(125, 211, 252, 0.55);
  cursor: crosshair;
}

.tcg-table.attack-pick-mode .card-attack-target[data-action-target="attack-target"].is-attack-viable:not(.is-selected),
.attack-pick-mode .card-attack-target[data-action-target="attack-target"].is-attack-viable:not(.is-selected) {
  outline: 2px dashed #fca5a5;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 165, 165, 0.55);
  cursor: crosshair;
}

.card-attack-target {
  transition: transform 0.15s ease, filter 0.15s ease;
}

.tcg-table.effect-pick-mode .card-effect-target[data-action-target="effect-target"].is-effect-viable:not(.is-selected),
.tcg-table.effect-pick-mode .battle-unit.is-effect-viable:not(.is-selected),
.effect-pick-mode .card-effect-target[data-action-target="effect-target"].is-effect-viable:not(.is-selected),
.effect-pick-mode .battle-unit.is-effect-viable:not(.is-selected) {
  outline: 2px dashed #86efac;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(134, 239, 172, 0.55);
  cursor: crosshair;
  pointer-events: auto;
}

.tcg-table.board-replace-pick-mode .card-board-replace-target[data-action-target="board-replace"].is-board-replace-viable:not(.is-selected),
.tcg-table.board-replace-pick-mode .battle-unit.is-board-replace-viable:not(.is-selected),
.board-replace-pick-mode .card-board-replace-target[data-action-target="board-replace"].is-board-replace-viable:not(.is-selected),
.board-replace-pick-mode .battle-unit.is-board-replace-viable:not(.is-selected) {
  outline: 2px dashed #6ecf8a;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(110, 207, 138, 0.55);
  cursor: pointer;
}

.tcg-table.replacement-bottom-deck-pick-mode .card-replacement-cost-target[data-action-target="replacement-bottom-deck"].is-replacement-bottom-deck-viable:not(.is-selected),
.tcg-table.replacement-bottom-deck-pick-mode .battle-unit.is-replacement-bottom-deck-viable:not(.is-selected),
.replacement-bottom-deck-pick-mode .card-replacement-cost-target[data-action-target="replacement-bottom-deck"].is-replacement-bottom-deck-viable:not(.is-selected),
.replacement-bottom-deck-pick-mode .battle-unit.is-replacement-bottom-deck-viable:not(.is-selected) {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: pointer;
}

.tcg-table.replacement-rest-card-pick-mode .card-replacement-rest-target[data-action-target="replacement-rest-card"].is-replacement-rest-card-viable:not(.is-selected),
.tcg-table.replacement-rest-card-pick-mode [data-action-target="replacement-rest-card"].is-replacement-rest-card-viable:not(.is-selected),
.replacement-rest-card-pick-mode .card-replacement-rest-target[data-action-target="replacement-rest-card"].is-replacement-rest-card-viable:not(.is-selected),
.replacement-rest-card-pick-mode [data-action-target="replacement-rest-card"].is-replacement-rest-card-viable:not(.is-selected) {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: pointer;
}

.card-effect-target,
.card-replacement-cost-target,
.card-replacement-rest-target {
  transition: transform 0.15s ease, filter 0.15s ease;
}

.tcg-table.rested-don-pick-mode .don-token--rested.is-rested-don-viable,
.rested-don-pick-mode .don-token--rested.is-rested-don-viable {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: crosshair;
}

.tcg-table.return-don-pick-mode .don-token[data-return-don-pick],
.return-don-pick-mode .don-token[data-return-don-pick] {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: crosshair;
  pointer-events: auto;
  position: relative;
  z-index: 6;
}

.tcg-table.replacement-rest-card-pick-mode .don-token.don-rest-card-pick.is-replacement-rest-card-viable,
.replacement-rest-card-pick-mode .don-token.don-rest-card-pick.is-replacement-rest-card-viable {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 6;
}

.return-don-pick-mode .don-stack:has([data-return-don-pick]) {
  pointer-events: auto;
  z-index: 5;
}

/* En modo return-don, los DON adjuntos al líder/personajes viven dentro de
   `.don-stack`, solapado por `.card-inner` (z-index 2). Sin esto la carta
   captura el clic antes de que llegue al token DON (los DON del área de coste
   funcionan porque no tienen carta encima). Hacemos transparente al puntero la
   carta cuyo slot contiene un DON seleccionable para que el clic alcance el token. */
.return-don-pick-mode .card-slot--field:has([data-return-don-pick]) .card-inner {
  pointer-events: none;
}

.replacement-rest-card-pick-mode .don-stack:has(.don-rest-card-pick.is-replacement-rest-card-viable) {
  pointer-events: auto;
  z-index: 5;
}

.replacement-rest-card-pick-mode .card-slot--field:has(.don-rest-card-pick.is-replacement-rest-card-viable) .card-inner {
  pointer-events: none;
}

.tcg-table.return-don-pick-mode .don-return-pick.is-return-don-viable,
.return-don-pick-mode .don-return-pick.is-return-don-viable,
.tcg-table.return-don-pick-mode .don-attached.don-return-pick.is-return-don-viable,
.return-don-pick-mode .don-attached.don-return-pick.is-return-don-viable {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: crosshair;
  pointer-events: auto;
}

.tcg-table.replacement-rest-card-pick-mode .don-attached.don-rest-card-pick.is-replacement-rest-card-viable,
.replacement-rest-card-pick-mode .don-attached.don-rest-card-pick.is-replacement-rest-card-viable {
  outline: 2px dashed #fcd34d;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(252, 211, 77, 0.55);
  cursor: pointer;
  pointer-events: auto;
}

.don-return-pick {
  transition: transform 0.15s ease, filter 0.15s ease;
}

.tcg-table.discard-pick-mode .card-slot--hand.card-action-target.is-discard-viable,
.discard-pick-mode .card-slot--hand.card-action-target.is-discard-viable {
  outline: 2px dashed #f87171;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.45);
  cursor: crosshair;
}

.tcg-table.reveal-pick-mode .card-slot--hand.card-action-target.is-reveal-viable,
.reveal-pick-mode .card-slot--hand.card-action-target.is-reveal-viable {
  outline: 2px dashed #38bdf8;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
  cursor: crosshair;
}

.tcg-table.hand-to-life-pick-mode .card-slot--hand.card-action-target.is-hand-to-life-viable,
.hand-to-life-pick-mode .card-slot--hand.card-action-target.is-hand-to-life-viable {
  outline: 2px dashed #34d399;
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.45);
  cursor: crosshair;
}

.don-rested-pick {
  transition: transform 0.15s ease, filter 0.15s ease;
}

.wizard-target-hint {
  margin: 0 0 0.75rem;
  color: #e8e0d0;
  font-size: 0.95rem;
}

.cost-row--attachable .don-action-source:hover {
  transform: scale(1.06);
}

.action-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-hotkey-hint {
  display: none;
}

.action-hotkey {
  display: none;
}

.action-dock .btn-action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1rem 0.85rem;
  min-height: 3.4rem;
  background: linear-gradient(180deg, #e8c96a, #c9a227);
  border: 2px solid #5c4a12;
  border-radius: 6px;
  color: #1a1208;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.btn-action {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  text-align: left;
  padding: 0.38rem 0.45rem;
  background: linear-gradient(180deg, #e8c96a, #c9a227);
  border: 1px solid #5c4a12;
  border-radius: 3px;
  color: #1a1208;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
}

.action-dock .action-label {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.action-dock .btn-primary {
  background: linear-gradient(180deg, #ffe082, #ffb300);
  border-color: #7a5a00;
}

.action-dock .btn-context-cancel {
  font-size: 0.95rem;
}

.action-label {
  flex: 1;
  min-width: 0;
}

.side-left { gap: 0.4rem; }

.hand-panel {
  background: var(--panel);
  border: 2px solid var(--accent-dark);
  border-radius: 4px;
  padding: 0.35rem;
  flex-shrink: 0;
}

.hand-panel--opp .hand-row {
  --card-w-hand: 62px;
  --card-h-hand: 86px;
}

/* La mano propia ya no crece (una sola fila con solape): el alto sobrante
   de la columna lo absorbe el historial (.game-log, flex: 1). */
.hand-panel--you { flex: 0 0 auto; display: flex; flex-direction: column; }

.hand-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.hand-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  align-content: flex-start;
  padding: 10px;
  box-sizing: border-box;
}

/* Abanico: cada slot reserva carta + hueco; cuando no caben, los slots
   encogen (flex-shrink) y las cartas — de ancho fijo dentro del slot — se
   solapan en horizontal (las siguientes pintan encima por orden DOM). */
.hand-row .card-slot--hand {
  flex: 0 1 calc(var(--card-w-hand) + 0.3rem);
  width: auto;
  min-width: 20px;
  overflow: visible;
  box-shadow: none;
}

.hand-row .card-slot--hand .card-inner {
  width: var(--card-w-hand);
  height: var(--card-h-hand);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* Al pasar el raton NO se levanta la carta (taparia a su vecina derecha):
   la carta completa ya se ve en el preview de la columna derecha. */

/* La última carta no encoge: evita que sobresalga del panel por la derecha. */
.hand-row .card-slot--hand:last-child {
  flex-shrink: 0;
  min-width: var(--card-w-hand);
}

/* El diálogo de la mano rival (móvil / fin de partida) sigue en cuadrícula. */
.hand-row--opp-dialog {
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hand-row--opp-dialog .card-slot--hand {
  flex: 0 0 auto;
}

.hand-panel--you .hand-row {
  flex: none;
  min-height: calc(var(--card-h-hand) + 20px);
}

.game-log {
  --log-you-color: #9bd7ff;
  --log-opponent-color: #ffd166;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 80px;
  min-width: 0;
  overflow: hidden;
  background: rgba(40, 40, 40, 0.75);
  border: 2px solid #555;
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 0.72rem;
  line-height: 1.35;
}

.game-log-header {
  flex: 0 0 auto;
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #666;
}

.game-log-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: auto;
  padding-top: 0.4rem;
}

.game-log-anchor {
  height: 1px;
  overflow: hidden;
}

.log-line { margin-bottom: 0.2rem; color: #ddd; }

.log-player {
  color: #ddd;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
}

.log-player--you {
  color: var(--log-you-color);
}

.log-player--opponent {
  color: var(--log-opponent-color);
}

.log-player-label {
  font-weight: 800;
}

.history-list {
  margin: 0;
  padding-left: 1rem;
  color: #ccc;
}

.history-list li { margin-bottom: 0.25rem; }

.history-list li.log-player--you::marker {
  color: var(--log-you-color);
}

.history-list li.log-player--opponent::marker {
  color: var(--log-opponent-color);
}

/* --- Playmat column --- */
.mat-column {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 0;
}

.battle-arrow-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

.battle-unit--attacker,
.battle-unit--defender {
  position: relative;
  z-index: 21;
}

.battle-unit--attacker {
  outline: 2px solid #ff6b6b;
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.65);
}

.battle-unit--defender {
  outline: 2px solid #ffd166;
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.65);
}

.battle-auto-resolve {
  display: none;
}

.mat-half {
  flex: 1;
  min-height: 0;
  border: 3px solid rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  overflow: hidden;
  background-color: #2a2a2a;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.22));
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
}

.mat-half--flipped {
  transform: rotate(180deg);
}

.mat-half--flipped .mat-inner {
  transform: rotate(180deg);
  /* En el mat rival la banda de DON!!/cost area va primero (arriba). */
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "don   cost  cost  cost"
    "life  chars chars deck"
    ".     chars chars trash";
}

.mat-inner {
  height: 100%;
  display: grid;
  grid-template-columns: 64px 1fr 64px 64px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "life  chars chars deck"
    ".     chars chars trash"
    "don   cost  cost  cost";
  gap: 0.25rem;
  padding: 0.35rem;
}

@media (min-width: 1601px) {
  :root {
    --card-w-field: clamp(72px, 4.5vw, 108px);
    --card-h-field: clamp(100px, 6.25vw, 150px);
    --card-w-hand: clamp(88px, 5.5vw, 132px);
    --card-h-hand: clamp(122px, 7.625vw, 183px);
    --card-w-mini: clamp(48px, 3vw, 72px);
    --card-h-mini: clamp(66px, 4.125vw, 99px);
    --card-w-life: clamp(52px, 3.25vw, 78px);
    --card-h-life: clamp(72px, 4.5vw, 108px);
    --don-token-w: clamp(48px, 3vw, 72px);
    --don-token-h: clamp(66px, 4.125vw, 99px);
  }

  .tcg-table {
    max-width: 2400px;
    margin: 0 auto;
  }

  .table-body {
    grid-template-columns:
      minmax(clamp(330px, 20.625vw, 495px), clamp(580px, 36.25vw, 870px))
      minmax(0, clamp(700px, 43.75vw, 1050px))
      minmax(clamp(180px, 11.25vw, 270px), clamp(288px, 18vw, 432px));
  }

  .hand-panel--opp .hand-row {
    --card-w-hand: clamp(62px, 3.875vw, 93px);
    --card-h-hand: clamp(86px, 5.375vw, 129px);
  }

  .mat-column {
    gap: clamp(0.35rem, 0.35vw, 0.525rem);
  }

  .mat-inner {
    grid-template-columns:
      clamp(64px, 4vw, 96px)
      1fr
      clamp(64px, 4vw, 96px)
      clamp(64px, 4vw, 96px);
  }

  .char-row--units {
    gap: clamp(1rem, 1vw, 1.5rem);
  }

  .char-row--leader {
    gap: clamp(0.35rem, 0.35vw, 0.525rem);
  }
}

.zone {
  position: relative;
  border: 2px dashed var(--zone-border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.zone-label {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  padding: 0.15rem 0.3rem;
  text-transform: uppercase;
}

.zone-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  min-height: 0;
  overflow: hidden;
}

.zone-trash { grid-area: trash; }

.zone-trash .zone-content {
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.15rem;
  /* Altura estable con o sin cartas. */
  min-height: calc(var(--card-h-mini) + 0.4rem);
}

.zone-trash-trigger {
  all: unset;
  position: relative;
  display: inline-flex;
  cursor: pointer;
  border-radius: 4px;
}

.zone-trash .card-image {
  object-fit: cover;
  object-position: top center;
}

.zone-trash-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
}

.zone-trash-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trash-dialog {
  border: none;
  padding: 0;
  max-width: min(92vw, 760px);
  width: min(92vw, 760px);
  max-height: 85vh;
  background: transparent;
  color: inherit;
}

.trash-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.trash-dialog-panel {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 1rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trash-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.trash-dialog-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.trash-dialog-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  gap: 0.5rem;
  overflow-y: auto;
  padding: 0.25rem;
}

.trash-dialog .card-image {
  object-fit: cover;
  object-position: top center;
}

.trash-card-zoom {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 1.05rem;
  right: 0.25rem;
  z-index: 4;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.8);
  color: var(--text);
  cursor: zoom-in;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.46);
}

.trash-card-zoom::before {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 0.35rem;
  width: 0.48rem;
  height: 0.48rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.trash-card-zoom::after {
  content: "";
  position: absolute;
  left: 0.88rem;
  top: 0.9rem;
  width: 0.43rem;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.trash-card-zoom:hover,
.trash-card-zoom:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.trash-card-zoom:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92), 0 5px 14px rgba(0, 0, 0, 0.46);
}

.trash-dialog-close {
  flex-shrink: 0;
}

.zone-life { grid-area: life; }

.zone-life .zone-content {
  overflow: visible;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.15rem;
}
.zone-deck { grid-area: deck; }
.zone-don-deck { grid-area: don; }

.zone-don-deck .zone-content {
  /* Altura estable con o sin cartas. */
  min-height: calc(var(--card-h-mini) + 0.4rem);
}

.zone-characters { grid-area: chars; }

.zone-characters .zone-content {
  overflow: visible;
}
.zone-cost { grid-area: cost; }

.zone-cost .zone-content {
  /* Altura estable con o sin DON!! en juego. */
  min-height: calc(var(--don-token-h) + 0.4rem);
}

.char-row, .cost-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.char-row--units {
  --don-base: 14px;
  --don-fan-step: 5px;
  gap: 1rem;
  flex-wrap: nowrap;
  align-items: flex-end;
  overflow: visible;
}

.char-area {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.25rem;
}

.mat-half--flipped .char-area {
  flex-direction: column-reverse;
}

.char-row--leader {
  --don-base: 16px;
  --don-fan-step: 6px;
  flex: 0 0 auto;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow: visible;
}

.leader-line-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.slot-label {
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
}

.cost-row {
  justify-content: flex-start;
  padding: 0 0.35rem;
  flex-wrap: wrap;
}

.cost-stat, .cost-rested {
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 0.35rem;
}

.don-token {
  width: var(--don-token-w);
  height: var(--don-token-h);
  object-fit: contain;
  flex-shrink: 0;
}

.don-token--rested {
  transform: rotate(90deg);
}

.life-stack, .deck-stack {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.life-stack-pile {
  --life-step: 12px;
  --life-card-h: var(--card-h-life);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--card-w-life);
}

.life-stack-pile > .stack-count--life {
  top: 2px;
  bottom: auto;
  z-index: 5;
}

.life-stack-card {
  position: relative;
  width: var(--card-w-life);
  height: var(--life-card-h);
  flex-shrink: 0;
}

.life-stack-card + .life-stack-card {
  margin-top: calc(-1 * (var(--life-card-h) - var(--life-step)));
}

.stack-count, .zone-count {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.zone-empty {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Cards --- */
.card-slot {
  position: relative;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.card-slot--field {
  width: var(--card-w-field);
  height: var(--card-h-field);
}

.card-slot--field:has(.don-stack),
.card-slot--field:has(.status-badges),
.card-slot--has-don {
  overflow: visible;
}

.card-slot--hand {
  width: var(--card-w-hand);
  height: var(--card-h-hand);
}

.card-slot--hand.card-action-target.is-selected {
  z-index: 25;
}

.card-slot--mini {
  width: var(--card-w-mini);
  height: var(--card-h-mini);
}

.card-slot--life {
  width: var(--card-w-life);
  height: var(--card-h-life);
}

.card-slot--leader {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.card-slot--leader.card-action-target.is-selected {
  outline: none;
}

.card-slot--empty {
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.12);
  box-shadow: none;
}

.card-slot.rested {
  overflow: visible;
}

.card-slot.rested .card-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.char-row--units .card-slot--field.rested {
  width: var(--card-h-field);
  height: var(--card-w-field);
}

.char-row--units .card-slot--field.rested .card-inner {
  width: var(--card-w-field);
  height: var(--card-h-field);
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.card-slot--field .card-inner {
  z-index: 2;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-text-fallback {
  padding: 0.25rem;
  font-size: 0.55rem;
  height: 100%;
  background: #1a1208;
}

.don-stack {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.don-attached {
  --don-base: 14px;
  --don-fan-step: 5px;
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--card-w-field);
  height: var(--card-h-field);
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transform: translate(
    calc(-1 * (var(--don-base) + var(--don-i) * var(--don-fan-step))),
    calc(var(--don-base) + var(--don-i) * var(--don-fan-step))
  );
  z-index: calc(0 - var(--don-i));
}

.don-count-label {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  color: #ff4dad;
  -webkit-text-stroke: 0.6px #fff;
  paint-order: stroke fill;
  text-shadow:
    0 0 2px #fff,
    1px 0 0 #fff,
    -1px 0 0 #fff,
    0 1px 0 #fff,
    0 -1px 0 #fff;
  z-index: 3;
  white-space: nowrap;
  pointer-events: none;
}

.power-badge {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.05rem 0.25rem;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.8);
  color: #9ef0b8;
  z-index: 2;
  bottom: 1px;
  right: 1px;
}

/* Coste efectivo cuando un static lo modifica (p. ej. Reiju +5). */
.cost-badge {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.05rem 0.25rem;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffd24d;
  z-index: 2;
  top: 1px;
  left: 1px;
}

.status-badges {
  position: absolute;
  top: 1px;
  right: 1px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  pointer-events: none;
}

.status-badge {
  padding: 0.08rem 0.35rem;
  border-radius: 2px;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge--freeze {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.95), rgba(14, 165, 233, 0.95));
  color: #0f172a;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.45);
}

.status-badge--negate {
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(100, 116, 139, 0.95));
  color: #0f172a;
  box-shadow: 0 0 8px rgba(148, 163, 184, 0.45);
}

.status-badge--cannot_attack {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.95), rgba(220, 38, 38, 0.95));
  color: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.45);
}

.status-badge--cannot_rested {
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.95), rgba(190, 18, 60, 0.95));
  color: #fff;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.45);
}

.status-badge--rush {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.95), rgba(22, 163, 74, 0.95));
  color: #052e16;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.45);
}

.status-badge--rush_character {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.95), rgba(13, 148, 136, 0.95));
  color: #042f2e;
  box-shadow: 0 0 8px rgba(20, 184, 166, 0.45);
}

.status-badge--blocker {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.95), rgba(217, 119, 6, 0.95));
  color: #1c1000;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.45);
}

.status-badge--unblockable {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.95), rgba(124, 58, 237, 0.95));
  color: #fff;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.45);
}

.status-badge--double_attack {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.95), rgba(37, 99, 235, 0.95));
  color: #eff6ff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.45);
}

.status-badge--attack_active {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.95), rgba(20, 184, 166, 0.95));
  color: #112018;
  box-shadow: 0 0 8px rgba(20, 184, 166, 0.4);
}

.btn {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-action:hover, .btn-toolbar:hover { filter: brightness(1.05); }

.btn-primary { background: linear-gradient(180deg, #6ecf8a, #2d8a4e); border-color: #1a5c34; color: #fff; }

.btn-toolbar {
  padding: 0.35rem 0.75rem;
  background: linear-gradient(180deg, #c9a227, #8a6d1a);
  border: 2px solid #5c4a12;
  border-radius: 4px;
  color: #1a1208;
  font-weight: 700;
  font-size: 0.75rem;
}

.btn-danger { background: linear-gradient(180deg, #c44, #822); color: #fff; border-color: #511; }

.action-dock .btn-action.btn-danger {
  background: linear-gradient(180deg, #c44, #822);
  color: #fff;
  border-color: #511;
}

.inline-form { display: inline; }

.wizard-panel h4 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: #1a1208;
  text-align: center;
}

.wizard-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 100%;
  overflow-y: auto;
}

.wizard-pass-action {
  margin-top: 0.65rem;
}

.confirm-panel p {
  font-size: 0.95rem;
  color: #1a1208;
  margin: 0 0 0.65rem;
  text-align: center;
  line-height: 1.35;
}

/* --- Overlays --- */
.flash.error {
  background: #5a1515;
  color: #ffb4b4;
  padding: 0.5rem;
  border-radius: 4px;
}

.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 3, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.game-over {
  width: min(90vw, 32rem);
  max-height: min(88vh, 42rem);
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(40, 29, 17, 0.97), rgba(17, 12, 7, 0.97)),
    var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 8px;
  padding: 1.15rem;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.game-over-header {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
  text-align: center;
}

.game-over-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-over .result {
  margin: 0;
  color: #9ef0b8;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.1;
}

.ai-feedback-form {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  background: rgba(10, 7, 4, 0.52);
  border: 1px solid rgba(201, 162, 39, 0.24);
  border-radius: 8px;
}

.ai-rating-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ai-rating-field legend,
.ai-comments-field span {
  display: block;
  margin-bottom: 0.38rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ai-rating-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(2.25rem, 1fr));
  gap: 0.38rem;
}

.ai-rating-option {
  position: relative;
  min-width: 0;
}

.ai-rating-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.ai-rating-option span {
  display: grid;
  min-height: 2.15rem;
  place-items: center;
  border: 1px solid rgba(201, 162, 39, 0.32);
  border-radius: 6px;
  background: rgba(245, 240, 230, 0.07);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.ai-rating-option:hover span,
.ai-rating-option input:focus-visible + span {
  border-color: rgba(158, 240, 184, 0.75);
  background: rgba(158, 240, 184, 0.12);
}

.ai-rating-option input:focus-visible + span {
  outline: 3px solid rgba(158, 240, 184, 0.2);
  outline-offset: 2px;
}

.ai-rating-option input:checked + span {
  border-color: #1a5c34;
  background: linear-gradient(180deg, #6ecf8a, #2d8a4e);
  color: #fff;
  transform: translateY(-1px);
}

.ai-comments-field {
  display: block;
  min-width: 0;
}

.ai-comments-field textarea {
  width: 100%;
  min-height: 4.6rem;
  resize: vertical;
  padding: 0.65rem 0.75rem;
  background: rgba(5, 4, 3, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.ai-comments-field textarea:focus {
  outline: none;
  border-color: rgba(158, 240, 184, 0.8);
  box-shadow: 0 0 0 3px rgba(158, 240, 184, 0.15);
}

.ai-comments-field textarea::placeholder {
  color: rgba(196, 181, 154, 0.62);
}

.ai-feedback-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ai-feedback-saved,
.ai-feedback-saving,
.ai-feedback-error {
  font-size: 0.78rem;
  font-weight: 800;
}

.ai-feedback-saved {
  color: #9ef0b8;
}

.ai-feedback-saving {
  color: var(--muted);
}

.ai-feedback-error {
  color: #ffb4b4;
}

.game-over-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.game-over .btn {
  min-height: 2.25rem;
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.1;
}

.game-over-save {
  border: 1px solid #1a5c34;
}

.game-over-secondary {
  background: rgba(245, 240, 230, 0.08);
  border: 1px solid rgba(201, 162, 39, 0.32);
  color: var(--text);
}

.turn-order-dialog {
  border: none;
  padding: 0;
  width: min(92vw, 26rem);
  max-width: min(92vw, 26rem);
  background: transparent;
}

.turn-order-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.turn-order-dialog-panel {
  width: 100%;
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 8px;
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.turn-order-dialog-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: #ffe08a;
}

.turn-order-result {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  color: #9ef0b8;
}

.turn-order-detail {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #d8ccb8;
}

.turn-order-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(158, 240, 184, 0.15);
  color: #9ef0b8;
  border: 1px solid rgba(158, 240, 184, 0.35);
}

.life-stack-card--revealed .card-image {
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.deck-top--revealed .card-image {
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.hand-panel--revealed .hand-label {
  color: #9ef0b8;
}

.game-over-overlay.is-dismissed {
  display: none;
}

.board-shell {
  position: relative;
}

.ai-thinking-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  backdrop-filter: blur(2px);
}

.ai-thinking-overlay[hidden]:not(.is-visible) {
  display: none;
}

.ai-thinking-overlay.is-visible,
body.ai-thinking-active .ai-thinking-overlay {
  display: flex;
}

.ai-thinking-panel {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 1.5rem 2rem;
  text-align: center;
  min-width: min(92vw, 18rem);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.ai-thinking-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 3px solid rgba(255, 224, 138, 0.25);
  border-top-color: #ffe08a;
  border-radius: 50%;
  animation: ai-thinking-spin 0.9s linear infinite;
}

.ai-thinking-text {
  margin: 0;
  font-size: 1.05rem;
  color: #ffe08a;
  letter-spacing: 0.02em;
}

@keyframes ai-thinking-spin {
  to {
    transform: rotate(360deg);
  }
}

.turn-order-dialog-panel .btn {
  min-width: 7rem;
}

.primary {
  padding: 0.5rem 1rem;
  background: #2d8a4e;
  color: #fff;
  border-radius: 4px;
  font-weight: 700;
}

/* --- Look (búsqueda en el mazo) --- */
.look-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 1rem;
}

.look-panel {
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: min(96vw, 60rem);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
}

.look-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.look-hint {
  margin: 0 0 1rem;
  color: #d8c9a8;
  font-size: 0.95rem;
}

.look-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: center;
}

.look-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 7.5rem;
}

.look-card-img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.look-card--disabled .look-card-img {
  filter: grayscale(0.85) brightness(0.6);
}

.look-card-zoom {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  top: 1.05rem;
  right: 0.28rem;
  z-index: 3;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.8);
  color: var(--text);
  cursor: zoom-in;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.46);
}

.look-card-zoom::before {
  content: "";
  position: absolute;
  left: 0.47rem;
  top: 0.41rem;
  width: 0.55rem;
  height: 0.55rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.look-card-zoom::after {
  content: "";
  position: absolute;
  left: 1rem;
  top: 1.02rem;
  width: 0.5rem;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.look-card-zoom:hover,
.look-card-zoom:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.look-card-zoom:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92), 0 5px 14px rgba(0, 0, 0, 0.46);
}

.btn-look {
  width: 100%;
  font-size: 0.8rem;
}

.look-return-same-order {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
}

.btn-look-wide {
  width: auto;
  max-width: 100%;
  min-width: min(100%, 16rem);
  justify-content: center;
  text-align: center;
  font-size: 0.85rem;
}

.look-finish {
  margin-top: 1rem;
}

.look-destinations {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.look-tray {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.look-tray-label {
  font-size: 0.85rem;
  color: #9ef0b8;
}

.look-tray-img {
  width: 3.2rem;
  border-radius: 4px;
}

/* --- Burbuja de aviso (toast, partials/toast.html) --- */
/* Notificación no bloqueante y reutilizable: aparece arriba y se desvanece
   sola a los var(--toast-duration). La de jugadas del bot (.bot-toast) va
   acompañada de .bot-ack-auto-continue, que reanuda al bot en el mismo plazo;
   su X (opcional) permite saltarse la espera. Sobre el spinner de IA (90)
   para seguir leyéndose si el bot tarda en calcular. */
.toast {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 92vw;
  padding: 0.45rem 1.2rem;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 999px;
  font-size: 0.95rem;
  color: #d8ccb8;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation:
    toast-in 0.25s ease-out,
    toast-out 0.45s ease-in calc(var(--toast-duration, 2000ms) - 450ms) forwards;
}

.toast-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-strong {
  color: #ffe08a;
}

/* X de cierre anticipado: anillo que se rellena en sentido horario durante
   var(--toast-duration). Clicable aunque el resto de la burbuja no lo sea. */
.toast-close {
  position: relative;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  background: none;
  color: #d8ccb8;
  cursor: pointer;
  pointer-events: auto;
}

.toast-close-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
}

.toast-close:hover .toast-close-x {
  color: #ffe08a;
}

.toast-close-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* la cuenta empieza a las 12 */
}

.toast-close-track,
.toast-close-fill {
  fill: none;
  stroke-width: 2;
}

.toast-close-track {
  stroke: rgba(216, 204, 184, 0.25);
}

.toast-close-fill {
  stroke: #ffe08a;
  /* perímetro 2·π·r con r=8.5 (viewBox 20×20) */
  stroke-dasharray: 53.41;
  stroke-dashoffset: 53.41;
  animation: toast-ring-fill var(--toast-duration, 2000ms) linear forwards;
}

@keyframes toast-ring-fill {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -0.6rem);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -0.6rem);
    visibility: hidden;
  }
}

/* --- Replay --- */
.replay-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 1rem 0; }
.replay-step pre {
  background: #1a1208;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.75rem;
}

.card-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1rem;
  border: none;
  background: rgba(0, 0, 0, 0.88);
  color: inherit;
  cursor: zoom-out;
}

.card-zoom-overlay::backdrop {
  background: transparent;
}

.card-zoom-overlay[hidden],
.card-zoom-overlay:not([open]) {
  display: none;
}

.card-zoom-image {
  max-width: min(96vw, 28rem);
  max-height: 92dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* --- Mobile layout (<= 1100px) --- */
.mobile-only {
  display: none;
}

@media (min-width: 1101px) {
  .mobile-menu-dialog,
  .opp-hand-dialog {
    display: none !important;
  }
}

@media (max-width: 1100px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only.mobile-menu-trigger,
  .mobile-only.mobile-card-zoom-toggle {
    display: inline-flex;
    flex-shrink: 0;
    min-width: 2.25rem;
    padding: 0.35rem 0.55rem;
    font-size: 1.1rem;
    line-height: 1;
  }

  .mobile-only.toolbar-site-menu {
    display: block;
    flex-shrink: 0;
  }

  .mobile-card-zoom-toggle.is-active {
    background: linear-gradient(180deg, #ffe082, #ffb300);
    outline: 2px solid #fff;
    outline-offset: 1px;
  }

  .mobile-only.toolbar-compact {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    overflow: hidden;
  }

  .toolbar-compact .turn-pill,
  .toolbar-compact .phase-pill {
    font-size: 0.65rem;
    white-space: nowrap;
  }

  .toolbar-compact .badge {
    margin-left: auto;
    flex-shrink: 0;
  }

  .tcg-table {
    height: 100vh;
    height: 100dvh;
    padding: 0.25rem;
    gap: 0.25rem;
  }

  .table-toolbar {
    flex-shrink: 0;
    padding: 0.3rem 0.45rem;
    gap: 0.4rem;
  }

  .table-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    gap: 0.25rem;
  }

  .side-left {
    display: contents;
  }

  .side-left > .game-log {
    display: none;
  }

  /* La mano del rival vive en el toolbar (boton que abre su dialogo): el
     panel entero desaparece y su altura pasa a los mats. */
  .hand-panel--opp {
    display: none;
  }

  .toolbar-compact .opp-hand-trigger {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--accent-dark);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    cursor: pointer;
  }

  .toolbar-compact .opp-hand-trigger:active,
  .toolbar-compact .opp-hand-trigger:focus-visible {
    color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .mat-column {
    order: 2;
    flex: 1;
    min-height: 0;
    gap: 0.25rem;
  }

  .mat-half {
    min-height: 0;
  }

  .mat-half--flipped {
    transform: none;
  }

  .mat-half--flipped .mat-inner {
    transform: none;
    /* En movil la banda DON!!/cost del rival vuelve ABAJO: si falta altura se
       recorta esa banda, nunca las cartas (lider y personajes van primero). */
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "life  chars chars deck"
      ".     chars chars trash"
      "don   cost  cost  cost";
  }

  .mat-half--flipped .char-area {
    flex-direction: column;
    /* El aire sobrante queda al fondo: las cartas suben y no se recortan. */
    justify-content: flex-start;
  }

  /* El lider rival va arriba del area de personajes: con poca altura lo que
     se recorta es la fila de personajes/huecos, nunca el lider. */
  .mat-half--flipped .char-row--leader {
    order: -1;
  }

  /* La banda de DON!! no envuelve a otra linea (robaria altura al mat): los
     tokens encogen en una sola fila y se recortan por la derecha. */
  .cost-row {
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .cost-row .don-token {
    flex: 0 1 var(--don-token-w);
    min-width: 10px;
    object-fit: cover;
    object-position: left center;
  }

  /* Dock de acciones compacto: cada px ahorrado es altura para los mats.
     (El tope de altura vive en la regla del breakpoint de 700px.) */
  .action-dock {
    padding: 0.35rem;
  }

  .dock-title {
    display: none;
  }

  .action-dock .btn-action {
    padding: 0.5rem 0.75rem;
    min-height: 2.4rem;
    font-size: 0.9rem;
  }

  .counter-step-summary {
    margin: 0 0 0.2rem;
  }

  .counter-step-line {
    font-size: 0.62rem;
  }

  .table-toolbar {
    padding: 0.2rem 0.4rem;
  }

  .hand-panel {
    padding: 0.25rem;
  }

  .hand-panel--you {
    order: 3;
    flex-shrink: 0;
    max-height: 16vh;
    flex: none;
    min-height: 0;
    padding-top: 0.25rem;
  }

  .hand-panel--you .hand-label {
    display: none;
  }

  .hand-panel--you .hand-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    flex: none;
    --card-w-hand: 56px;
    --card-h-hand: 78px;
    /* Padding minimo: la altura sobrante pasa a los mats. */
    padding: 3px 4px;
    min-height: calc(var(--card-h-hand) + 6px);
  }

  .side-right {
    display: contents;
  }

  #card-preview {
    display: none;
  }

  .action-dock {
    order: 4;
    flex-shrink: 0;
    /* Tope: un menu contextual largo scrollea dentro del dock en vez de
       aplastar los mats (cartas recortadas). */
    max-height: 32vh;
    overflow-y: auto;
    padding: 0.35rem;
  }

  /* (El menu contextual compacto se ajusta mas abajo, en las reglas
     existentes de .action-dock .btn-action / .context-panel-title.) */

  .action-dock .dock-title {
    display: none;
  }

  .action-list,
  .context-panel-actions,
  .replacement-actions,
  .wizard-options,
  .action-dock-default {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    overflow: visible;
    max-height: none;
  }

  .wizard-panel,
  .confirm-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }

  .wizard-options {
    grid-column: 1 / -1;
  }

  .action-dock-default:empty {
    display: none;
  }

  .action-list form,
  .action-dock-default form,
  .confirm-panel form,
  .wizard-options form {
    display: contents;
  }

  .action-dock .btn-action {
    width: 100%;
    min-height: 2rem;
    font-size: 0.78rem;
    line-height: 1.25;
    padding: 0.4rem 0.5rem;
  }

  .context-panel {
    margin-bottom: 0.25rem;
  }

  .context-panel-title {
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
  }

  .counter-step-summary {
    grid-column: 1 / -1;
  }

  .replacement-summary {
    grid-column: 1 / -1;
    margin-bottom: 0.25rem;
    padding: 0.35rem 0.45rem;
  }

  .replacement-summary-title {
    font-size: 0.62rem;
  }

  .replacement-summary-text {
    font-size: 0.62rem;
  }

  .wizard-panel h4,
  .confirm-panel p {
    grid-column: 1 / -1;
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
  }

  .wizard-target-hint {
    grid-column: 1 / -1;
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
  }

  :root {
    --card-w-field: 40px;
    --card-h-field: 56px;
    --card-w-mini: 36px;
    --card-h-mini: 50px;
    --card-w-life: 40px;
    --card-h-life: 56px;
    --don-token-w: 36px;
    --don-token-h: 50px;
  }

  .char-row--units,
  .char-row--leader {
    --don-base: 9px;
    --don-fan-step: 3px;
    gap: 0.3rem;
  }

  .char-row--units {
    gap: 0.35rem;
  }

  .card-slot--field .power-badge,
  .card-slot--field .cost-badge {
    font-size: 0.45rem;
    padding: 0.02rem 0.15rem;
  }

  .card-slot--field .don-count-label {
    font-size: 0.48rem;
    -webkit-text-stroke: 0.4px #fff;
  }

  .card-slot--empty {
    width: var(--card-w-field);
    height: var(--card-h-field);
  }

  .mat-inner {
    grid-template-columns: 40px 1fr 40px 40px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 0.25rem;
    gap: 0.15rem;
    align-items: start;
  }

  .zone-life,
  .zone-deck,
  .zone-trash,
  .zone-don-deck {
    align-self: start;
    height: auto;
    min-height: 0;
  }

  .zone-life .zone-content,
  .zone-deck .zone-content,
  .zone-trash .zone-content,
  .zone-don-deck .zone-content {
    flex: 0 0 auto;
    padding: 0.1rem;
  }

  .life-stack-pile {
    --life-step: 4px;
    max-height: calc(var(--card-h-life) + var(--life-step));
    overflow: hidden;
  }

  .zone-characters {
    min-height: 0;
  }

  .zone-label,
  .slot-label {
    display: none;
  }

  .tcg-table.card-zoom-mode .card-slot {
    cursor: zoom-in;
  }

  .opp-hand-dialog {
    border: none;
    padding: 0;
    max-width: min(96vw, 32rem);
    width: min(96vw, 32rem);
    max-height: 85vh;
    background: transparent;
    color: inherit;
  }

  .opp-hand-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
  }

  .opp-hand-dialog-panel {
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1rem;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .opp-hand-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .opp-hand-dialog-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
  }

  .opp-hand-dialog-close {
    min-width: 2rem;
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
  }

  .hand-row--opp-dialog {
    flex-wrap: wrap;
    justify-content: center;
    overflow-y: auto;
    max-height: 60vh;
    --card-w-hand: 72px;
    --card-h-hand: 100px;
  }

  .mobile-menu-dialog {
    border: none;
    padding: 0;
    max-width: min(92vw, 26rem);
    width: min(92vw, 26rem);
    max-height: 85vh;
    background: transparent;
    color: inherit;
  }

  .mobile-menu-dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
  }

  .mobile-menu-panel {
    background: var(--panel);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 1rem;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .mobile-menu-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
  }

  .mobile-menu-close {
    min-width: 2rem;
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
  }

  .mobile-menu-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .mobile-menu-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 0;
  }

  .mobile-menu-section-title {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .mobile-menu-section .game-log {
    flex: 1;
    min-height: 8rem;
    max-height: 40vh;
    overflow: hidden;
  }
}
