/* ═══════════════════════════════════════════
   ECLIPSORIAN BATTLE LINES — STYLES V3
   ═══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:     #07070f;
  --bg2:    #0d0d1a;
  --bg3:    #14142a;
  --border: #1e1e35;
  --gold:   #c9a227;
  --gold2:  #6a4e0f;
  --text:   #ccc8e0;
  --dim:    #555370;
  --r:      8px;
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden; user-select: none;
}
.hidden { display: none !important; }


/* ════════════════════════════════════════════
   DECK BUILDER
   ════════════════════════════════════════════ */

#screen-builder {
  display: flex; flex-direction: column; height: 100vh;
  position: relative; overflow: hidden;
}

/* ─── Pool controls (filtros + orden) ─── */
#pool-controls {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 14px 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.filter-bar { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.filter-btn {
  padding: 4px 11px; border: 1px solid var(--border); background: var(--bg3);
  color: var(--dim); font-size: .7rem; border-radius: 20px; cursor: pointer; transition: all .15s;
}
.filter-btn:hover, .filter-btn.active { border-color: var(--gold); color: var(--gold); }

.sort-bar { display: flex; align-items: center; gap: 6px; }
.sort-label { font-size: .62rem; color: var(--dim); letter-spacing: .06em; }
.sort-btn {
  padding: 3px 10px; border: 1px solid var(--border); background: var(--bg3);
  color: var(--dim); font-size: .63rem; border-radius: 20px; cursor: pointer; transition: all .15s;
}
.sort-btn:hover, .sort-btn.active { border-color: var(--gold2); color: var(--gold); }

/* ═══════════ FILTROS NUEVOS (#6) — barra grande + radial móvil ═══════════ */
.pf-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem 1.4rem; width: 100%; }
.pf-grp { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.pf-lbl { font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.pf-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.pf-sort, .pf-reg {
  padding: .5rem .95rem; border: 1px solid var(--border); background: var(--bg3);
  color: #cfc9b6; font-size: .8rem; border-radius: 9px; cursor: pointer;
  transition: all .15s; font-family: inherit; letter-spacing: .02em;
}
.pf-sort:hover, .pf-reg:hover { border-color: rgba(201,162,39,.55); color: #e8dcc8; }
.pf-sort.active { background: rgba(201,162,39,.18); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.pf-reg { display: inline-flex; align-items: center; gap: .4rem; }
.pf-reg[data-r]:not([data-r="all"])::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--rc, #888); box-shadow: 0 0 6px var(--rc, #888);
}
.pf-reg.active { border-color: var(--rc, var(--gold)); color: #fff; background: rgba(255,255,255,.06); box-shadow: 0 0 10px -2px var(--rc, var(--gold)); }

/* Radial flotante — oculto en escritorio */
.pf-radial { display: none; }

@media (max-width: 600px) {
  .pf-bar { display: none; }
  #pool-controls { padding: 0; border: none; margin: 0; min-height: 0; }

  .pf-radial { display: block; position: fixed; right: 34px; top: 46%; z-index: 6000; width: 0; height: 0; }
  .pf-fab {
    position: absolute; left: -27px; top: -27px; width: 54px; height: 54px; border-radius: 50%;
    background: radial-gradient(circle at 34% 28%, #f5e07a, #c9a227 72%);
    border: 1px solid rgba(245,224,122,.7); color: #07070d; cursor: pointer; z-index: 3;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 18px rgba(201,162,42,.55), 0 4px 14px rgba(0,0,0,.55);
    transition: transform .25s, box-shadow .2s;
  }
  .pf-fab svg { width: 24px; height: 24px; }
  .pf-radial.open .pf-fab { transform: rotate(90deg); }
  .pf-radial.filtered .pf-fab { box-shadow: 0 0 26px rgba(245,224,122,.9), 0 4px 14px rgba(0,0,0,.55); }

  .pf-opt {
    position: absolute; left: -23px; top: -23px; width: 46px; height: 46px; border-radius: 50%;
    background: rgba(18,16,28,.96); border: 1px solid rgba(201,162,39,.5); color: var(--gold);
    font-size: .56rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
    display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer;
    opacity: 0; pointer-events: none; transform: translate(0,0) scale(.4);
    transition: transform .3s cubic-bezier(.34,1.45,.5,1), opacity .2s, background .15s, border-color .15s;
    backdrop-filter: blur(6px); box-shadow: 0 0 12px rgba(0,0,0,.6); z-index: 2;
  }
  .pf-radial.open .pf-opt { opacity: 1; pointer-events: auto; }
  .pf-radial.open.regions .pf-opt { opacity: 0; pointer-events: none; transform: translate(0,0) scale(.4); }
  .pf-radial.open .pf-opts .pf-opt:nth-child(1) { transform: translate(-60px, -82px); }
  .pf-radial.open .pf-opts .pf-opt:nth-child(2) { transform: translate(-92px, -42px); }
  .pf-radial.open .pf-opts .pf-opt:nth-child(3) { transform: translate(-104px, 0); }
  .pf-radial.open .pf-opts .pf-opt:nth-child(4) { transform: translate(-92px, 42px); }
  .pf-radial.open .pf-opts .pf-opt:nth-child(5) { transform: translate(-60px, 82px); }
  .pf-opt.pf-sort.active { background: rgba(201,162,39,.3); border-color: var(--gold); color: #fff; }
  .pf-opt.pf-tipo { border-color: rgba(245,224,122,.7); color: #f5e07a; }

  .pf-regs {
    position: absolute; right: 30px; top: -118px; width: 170px; padding: 12px;
    display: none; flex-wrap: wrap; gap: 7px; justify-content: center;
    background: rgba(14,12,20,.98); border: 1px solid rgba(201,162,39,.45); border-radius: 14px;
    box-shadow: 0 0 24px rgba(0,0,0,.7); z-index: 4;
  }
  .pf-radial.regions .pf-regs { display: flex; }
  .pf-regs .pf-reg { padding: .4rem .55rem; font-size: .64rem; border-radius: 7px; }
}

/* ─── Deck Slots Bar ─── */
#deck-slots-bar {
  padding: 10px 16px 6px; background: var(--bg2);
  border-bottom: none; flex-shrink: 0;
  overflow-x: auto;
}

#deck-slots {
  display: flex; gap: 6px;
  justify-content: center;
  min-width: max-content; margin: 0 auto;
}

/* ─── Cost bar row ─── */
#cost-bar-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px 10px; background: var(--bg2);
  border-bottom: 2px solid var(--border); flex-shrink: 0;
  justify-content: center;
}
#cost-bar-wrap {
  width: min(360px, 55vw); height: 8px;
  background: var(--bg3); border-radius: 4px; overflow: hidden;
  flex-shrink: 0;
}
#cost-bar-fill {
  height: 100%; width: 0%;
  border-radius: 4px;
  transition: width .35s ease, background .4s ease;
  background: linear-gradient(90deg,#388e3c,#66bb6a);
}
#meta-cost { font-size: .75rem; color: var(--dim); white-space: nowrap; flex-shrink: 0; }

.deck-slot {
  width: 86px; height: 118px; border-radius: var(--r);
  border: 2px dashed var(--border); background: var(--bg3);
  position: relative; overflow: hidden; flex-shrink: 0;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.deck-slot.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--border); font-size: 1.1rem;
}
.deck-slot.filled { border-style: solid; cursor: pointer; }
.deck-slot.filled:hover {
  transform: translateY(-18px) scale(1.22);
  z-index: 20;
  box-shadow: 0 14px 32px rgba(0,0,0,.8), 0 0 14px var(--c, transparent);
}
.deck-slot.filled:hover::after {
  content: '✕'; position: absolute; inset: 0;
  background: rgba(120,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #ef9a9a; font-weight: 700;
}
.deck-slot img {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
}
.deck-slot-stats {
  position: absolute; top: 3px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 4px;
  font-size: .48rem; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.deck-slot-stats span:first-child { color: #ef9a9a; }
.deck-slot-stats span:last-child  { color: #ffb74d; }
.deck-slot-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.9));
  padding: 8px 3px 2px; font-size: .5rem; color: #fff;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#btn-listo {
  padding: 9px 24px; background: var(--gold2); border: 1px solid var(--gold);
  color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .15em;
  border-radius: 6px; cursor: pointer; transition: all .2s; white-space: nowrap;
}
#btn-listo:hover:not(:disabled) { background: var(--gold); color: #000; }
#btn-listo:disabled { opacity: .3; cursor: not-allowed; }

/* ─── Card Pool ─── */
#pool-scroll { flex: 1; overflow-y: auto; padding: 0 14px 14px; }
#card-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

/* Pool card — gira solo al pulsar el ojo (no hover) */
.pool-card {
  width: 100%; aspect-ratio: 9/13; border-radius: var(--r);
  border: 2px solid var(--border);
  position: relative; cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4,0,.2,1), box-shadow .2s;
}
.pool-card:not(.flipped):not(.in-deck):hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 26px rgba(0,0,0,.7), 0 0 10px var(--c, transparent);
}
.pool-card.flipped {
  transform: rotateY(180deg) translateY(-6px);
  box-shadow: 0 14px 32px rgba(0,0,0,.9), 0 0 18px var(--c, transparent);
}
/* En el mazo: claramente más grises que las disponibles */
.pool-card.in-deck { opacity: .6; filter: grayscale(.82); }
.pool-card.in-deck:hover { opacity: .95; filter: grayscale(.15); }
/* Sin puntos suficientes: casi negras (máximo contraste con las usables) */
.pool-card.blocked {
  filter: grayscale(1) brightness(.2);
  opacity: .6; pointer-events: none;
}
.pool-card.dimmed {
  filter: grayscale(.65) brightness(.55);
  opacity: .45;
}
.pool-card.dimmed:hover { opacity: .7; filter: grayscale(.4) brightness(.7); }

/* Caras */
.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: calc(var(--r) - 1px);
  overflow: hidden;
}
.card-front { display: flex; flex-direction: column; background: var(--bg2); }
.card-back  { transform: rotateY(180deg); }

/* Frente */
.card-front img {
  width: 100%; flex: 1; object-fit: cover; object-position: top; display: block;
}
.pool-card-footer { padding: 5px 6px; background: rgba(0,0,0,.85); flex-shrink: 0; }
.pool-card-name {
  font-size: .65rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pool-card-stats { display: flex; justify-content: space-between; margin-top: 2px; font-size: .6rem; }
.pool-card-rango {
  position: absolute; top: 5px; left: 5px;
  font-size: .5rem; font-weight: 700; padding: 2px 5px;
  border-radius: 4px; color: #000; letter-spacing: .04em; text-transform: uppercase;
}
.pool-card-cost {
  position: absolute; top: 5px; right: 5px;
  font-size: .7rem; font-weight: 700;
  width: 19px; height: 19px; background: rgba(0,0,0,.75);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.card-remove-overlay {
  position: absolute; inset: 0;
  background: rgba(120,0,0,.78); color: #ef9a9a;
  font-size: .8rem; font-weight: 700; letter-spacing: .05em;
  display: none; align-items: center; justify-content: center;
}
.pool-card.in-deck:hover .card-remove-overlay { display: flex; }

/* Dorso */
.card-back {
  background: linear-gradient(155deg, #0a0a18 0%, #16082a 60%, #0a0a18 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 8px; gap: 5px; text-align: center;
}
.card-back-name {
  font-size: .68rem; font-weight: 700; color: var(--gold); letter-spacing: .06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
.card-back-region { font-size: .52rem; color: var(--dim); letter-spacing: .04em; }
.card-back-divider { width: 55%; height: 1px; background: var(--border); margin: 2px 0; flex-shrink: 0; }
.card-back-stats {
  display: flex; align-items: center; gap: 4px;
  font-size: .62rem; font-weight: 700; letter-spacing: .04em;
}
.cbstat-sep { color: var(--dim); font-weight: 400; }
.card-back-pattern {
  font-size: .64rem; font-weight: 800; letter-spacing: .04em; text-align: center; width: 100%;
}
.card-back-pdetail {
  font-size: .5rem; color: var(--dim); letter-spacing: .05em;
}
.card-back-ability {
  font-size: .56rem; color: var(--text); line-height: 1.5; text-align: center;
  padding: 0 4px;
}
.card-back-unlock {
  font-size: .48rem; color: var(--dim); font-style: italic; margin-top: 1px;
}
.card-enlarge-btn {
  margin-top: 5px; padding: 3px 10px; font-size: .6rem;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); border-radius: 12px; cursor: pointer; transition: all .15s;
}
.card-enlarge-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ─── Botón ojo — solo en cartas con habilidades únicas ─── */
.card-eye-btn {
  position: absolute;
  bottom: 28px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,.7);
  border: 1px solid currentColor;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: .65;
  transition: opacity .15s, background .15s, transform .15s;
  z-index: 10;
}
.card-eye-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,.92);
  transform: scale(1.15);
}

/* ─── Card Viewer cinemático ─── */
.card-viewer-overlay { }   /* solo para selector */

.card-viewer-card .card-back-name   { font-size: 1rem;  }
.card-viewer-card .card-back-region { font-size: .72rem; }
.card-viewer-card .card-back-divider{ margin: 4px 0; }
.card-viewer-card .cb-unique-list   { gap: 10px; }
.card-viewer-card .cb-unique-type   { font-size: .62rem; }
.card-viewer-card .cb-unique-name   { font-size: .82rem; }
.card-viewer-card .cb-unique-desc   { font-size: .68rem; line-height: 1.5; }
.card-viewer-card .card-enlarge-btn { display: none; }

/* ─── Dorso con habilidades únicas ─── */
.cb-unique-list {
  width: 100%; display: flex; flex-direction: column; gap: 5px;
  overflow-y: auto; flex: 1;
  scrollbar-width: none;
}
.cb-unique-list::-webkit-scrollbar { display: none; }
.cb-unique-block { text-align: left; width: 100%; }
.cb-unique-head {
  display: flex; align-items: baseline; gap: 4px;
  margin-bottom: 1px;
}
.cb-unique-type {
  font-size: .42rem; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
  flex-shrink: 0;
}
.cb-unique-name {
  font-size: .52rem; font-weight: 700;
  color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cb-unique-desc {
  font-size: .44rem; color: var(--dim);
  line-height: 1.45; padding-left: 1px;
}

/* ─── Modal — habilidades únicas ─── */
.modal-ab-list {
  width: 100%; display: flex; flex-direction: column;
  gap: 10px; padding: 6px 0; overflow-y: auto;
  max-height: 100%; flex: 1;
}
.modal-ab-block { text-align: left; width: 100%; }
.modal-ab-head {
  display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px;
}
.modal-ab-type {
  font-size: .5rem; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; flex-shrink: 0;
}
.modal-ab-name {
  font-size: .7rem; font-weight: 700; color: var(--text);
}
.modal-ab-desc {
  font-size: .6rem; color: var(--dim); line-height: 1.5;
}

/* Ghost card — vuela por la pantalla */
.flying-ghost {
  position: fixed; border-radius: var(--r); overflow: hidden;
  border: 2px solid; pointer-events: none; z-index: 1000;
  transition: left .32s cubic-bezier(.4,0,.2,1),
              top  .32s cubic-bezier(.4,0,.2,1),
              width  .32s cubic-bezier(.4,0,.2,1),
              height .32s cubic-bezier(.4,0,.2,1),
              opacity .32s;
  background: var(--bg2);
}
.flying-ghost img { width: 100%; height: 100%; object-fit: cover; object-position: top; }


/* ════════════════════════════════════════════
   GAME SCREEN
   ════════════════════════════════════════════ */

#screen-game { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Top bar */
#game-top {
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 16px 8px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#round-label {
  text-align: center; font-size: .72rem; font-weight: 800;
  letter-spacing: .25em; color: var(--gold); text-transform: uppercase;
}
#hp-row { display: flex; align-items: center; gap: 12px; }
.bar-track {
  flex: 1; height: 8px; background: var(--bg3);
  border-radius: 4px; overflow: hidden; min-width: 80px;
}
.bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.player-fill { background: linear-gradient(90deg, #1a5c2a, #43a047); }
.enemy-fill  { background: linear-gradient(90deg, #7a0000, #e53935); }
.hp-label { font-size: .62rem; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
#e-hp-num, #p-hp-num { font-size: .8rem; font-weight: 700; color: var(--gold); min-width: 24px; }
#enemy-hpbar, #player-hpbar { display: flex; align-items: center; gap: 8px; flex: 1; }
/* Barra del jugador: se vacía de derecha a izquierda */
#player-hpbar .bar-track { transform: scaleX(-1); }

/* Body */
#game-body { flex: 1; display: flex; overflow: hidden; }

/* Enemy hand — oculta (no se muestra la mano del enemigo) */
#enemy-hand-wrap { display: none !important; }
.side-label {
  font-size: .55rem; letter-spacing: .15em; color: var(--dim);
  text-transform: uppercase; text-align: center;
  padding-bottom: 5px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.enemy-card-back {
  width: 52px; height: 70px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: .9rem; flex-shrink: 0;
}

/* Board */
#board-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 12px;
}
#turn-banner {
  font-size: .72rem; letter-spacing: .12em; color: var(--gold);
  text-transform: uppercase; min-height: 18px;
}
#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  width: min(calc(100% - 16px), 400px);
  aspect-ratio: 3 / 4;
  max-height: 66vh;
}

/* Board cell */
.board-cell {
  border-radius: var(--r); border: 2px solid var(--border);
  background: var(--bg2); position: relative; overflow: hidden;
  transition: border-color .2s;
}
.board-cell.empty { cursor: pointer; }
.board-cell.empty:hover {
  border-color: var(--gold);
  background: var(--bg3);
}
.board-cell.drag-over {
  border-color: var(--gold) !important;
  border-style: dashed !important;
  background: rgba(201,162,39,.1) !important;
  animation: player-hover-pulse .6s ease-in-out infinite;
}
@keyframes player-hover-pulse {
  0%,100% { box-shadow: inset 0 0 10px rgba(201,162,39,.15); }
  50%      { box-shadow: inset 0 0 24px rgba(201,162,39,.45); }
}
.board-cell.player-cell { border-color: #43a047; }
.board-cell.enemy-cell  { border-color: #e53935; }

/* Carta boca abajo (turno simultáneo) */
.board-cell.face-down {
  border-color: #c62828; border-style: dashed;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  animation: facedown-pulse 1.4s ease-in-out infinite;
}
.cell-facedown {
  font-size: 1.8rem; color: #c62828; opacity: .7;
  text-shadow: 0 0 12px rgba(198,40,40,.6);
}
@keyframes facedown-pulse {
  0%, 100% { box-shadow: inset 0 0 10px rgba(198,40,40,.1); }
  50%       { box-shadow: inset 0 0 22px rgba(198,40,40,.35); }
}

/* HP damage overlay */
.cell-img-wrap { position: absolute; inset: 0; overflow: hidden; }
.cell-img-wrap img {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
}
.cell-damage-layer {
  position: absolute; top: 0; left: 0; right: 0;
  background: rgba(15,15,30,.82);
  pointer-events: none; transition: height .35s;
}

.cell-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.9));
  padding: 10px 4px 3px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.cell-name { font-size: .48rem; color: #ccc; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-hp   { font-size: .58rem; color: #ef9a9a; font-weight: 700; }
.cell-atk  { font-size: .58rem; color: #ffb74d; font-weight: 700; }

.cell-hit { animation: hit-flash .2s ease; }
@keyframes hit-flash {
  0%   { filter: none;                       transform: translateX(0); }
  18%  { filter: brightness(3.5) saturate(0); transform: translateX(-4px); }
  40%  { filter: brightness(2.2) saturate(.3); transform: translateX(4px); }
  62%  { transform: translateX(-3px); }
  82%  { transform: translateX(2px); }
  100% { filter: none;                       transform: translateX(0); }
}

/* Glow de color sobre una celda cuando recibe daño / cura / buff (showFloatText).
   Capa fija independiente del re-render del tablero; no cubre la carta. */
.cell-glow-pulse {
  position: fixed; pointer-events: none; z-index: 170; border-radius: 10px;
  border: 1.5px solid var(--glow, #fff);
  box-shadow: 0 0 22px 5px var(--glow, #fff);
  animation: cellGlowPulse .55s ease-out forwards;
}
@keyframes cellGlowPulse {
  0%   { opacity: 0;  transform: scale(.92); }
  25%  { opacity: .9; }
  100% { opacity: 0;  transform: scale(1.14); }
}

/* Watchdog de barrera: aviso en pantalla cuando la sincronización tarda/cuelga.
   Solo visible al añadir .show (en cuelgues) → cero impacto en partidas sanas. */
#sync-watchdog {
  position: fixed; left: 50%; top: 7%; transform: translateX(-50%);
  z-index: 6000; pointer-events: none;
  background: rgba(20,10,30,.92); color: #fde68a;
  border: 1px solid rgba(251,191,36,.5); border-radius: 8px;
  padding: 8px 16px; font-size: .8rem; letter-spacing: .04em; white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .3s;
}
#sync-watchdog.show { opacity: 1; }

/* ─── Insignia de dueño (▲ jugador / ▼ enemigo) ─── */
.cell-badge {
  position: absolute; z-index: 8;
  width: 15px; height: 15px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .42rem; font-weight: 900;
  border: 1.5px solid rgba(0,0,0,.45);
  pointer-events: none;
}
.badge-player {
  bottom: 22px; left: 3px;
  background: rgba(56,142,60,.92);
  color: #c8e6c9;
  box-shadow: 0 0 6px rgba(67,160,71,.55);
}
.badge-enemy {
  top: 3px; right: 3px;
  background: rgba(183,28,28,.92);
  color: #ffcdd2;
  box-shadow: 0 0 6px rgba(229,57,53,.55);
}

/* ─── Cartas bloqueadas en mano (despertar por ronda) ─── */
.hand-card.locked {
  opacity: .32; filter: grayscale(.85); pointer-events: none;
}
.hand-lock-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.62);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.hand-lock-icon { font-size: .9rem; }
.hand-lock-round { font-size: .52rem; font-weight: 700; color: var(--gold); letter-spacing: .08em; }

/* Timer bar */
#timer-bar-wrap {
  width: min(calc(100% - 16px), 400px); height: 5px;
  background: var(--bg3); border-radius: 3px; overflow: hidden;
  opacity: 0; transition: opacity .3s;
}
#timer-bar-wrap.visible { opacity: 1; }
#timer-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  border-radius: 3px; transition: width .05s linear;
}
#timer-bar.quick   { transition: width .28s ease-out; }
#timer-bar.warning { background: linear-gradient(90deg, #e65100, #ff9800); }
#timer-bar.critical {
  background: #f44336;
  animation: timer-blink .45s ease-in-out infinite;
}
@keyframes timer-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: .25; }
}

/* Combat flash */
#combat-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; text-align: center; padding: 0 20px;
}
#combat-flash.show { animation: cflash 1.4s ease forwards; }
#combat-flash-text {
  font-size: 2.4rem; font-weight: 900; letter-spacing: .25em;
  color: var(--gold); text-transform: uppercase;
  text-shadow: 0 0 40px rgba(201,162,39,.9), 0 0 80px rgba(201,162,39,.4);
  max-width: 100%; word-break: break-word; line-height: 1.2;
}
@keyframes cflash {
  0%   { opacity: 0; transform: scale(.82); }
  18%  { opacity: 1; transform: scale(1.04); }
  60%  { opacity: 1; transform: scale(1);   }
  100% { opacity: 0; transform: scale(1.08); }
}

#btn-pass {
  padding: 5px 18px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); font-size: .72rem; border-radius: 6px; cursor: pointer; transition: all .2s;
}
#btn-pass:hover { border-color: var(--gold); color: var(--gold); }

/* Log */
#log-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 168px;
  background: rgba(14,12,10,.96);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,.55);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .28s ease, padding .28s ease;
  z-index: 200;
}
#log-panel.collapsed { width: 28px; }
#log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 4px; flex-shrink: 0; gap: 6px;
}
#log-panel.collapsed #log-header { padding: 8px 4px 4px; }
#log-toggle {
  padding: 2px 5px; font-size: .66rem; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer; border-radius: 4px; transition: all .15s;
  line-height: 1;
}
#log-toggle:hover { border-color: var(--gold); color: var(--gold); }
#log-entries {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px;
  padding: 0 8px 8px; opacity: 1; transition: opacity .2s;
}
#log-panel.collapsed #log-entries { opacity: 0; pointer-events: none; }
#log-panel.collapsed .side-label { display: none; }
.log-entry { font-size: .63rem; color: var(--dim); border-bottom: 1px solid var(--border); padding-bottom: 3px; line-height: 1.4; }
.log-entry.dmg { color: #ef9a9a; }
.log-entry.key { color: var(--gold); }

/* Player hand */
#game-bottom {
  flex-shrink: 0;
  padding: 6px 14px 4px;
  display: flex; flex-direction: row; flex-wrap: wrap;
  align-items: flex-end; justify-content: center; gap: 5px;
  position: relative;
}
#player-hand {
  display: flex; justify-content: center; align-items: flex-end;
  position: relative; height: 128px; width: 100%;
}
#phase-label { width: 100%; text-align: center; font-size: .62rem; color: var(--dim); letter-spacing: .06em; }

/* Hand card — más grande, hover más dramático */
.hand-card {
  width: 82px; height: 116px; border-radius: 8px; border: 2px solid;
  position: relative; overflow: hidden; cursor: grab; flex-shrink: 0;
  transition: transform .22s cubic-bezier(.2,0,.2,1.4), box-shadow .22s;
  transform-origin: bottom center;
}
.hand-card img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.hand-card-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.92));
  padding: 10px 3px 3px; font-size: .52rem; color: #fff;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* "Sacar carta de la mano" — se endereza y sube sobre las demás */
.hand-card:not(.inactive):not(.dragging):hover {
  transform: rotate(calc(var(--rot, 0deg) * 0.12)) translateY(calc(var(--dy, 0px) - 84px));
  z-index: 50 !important;
  filter: brightness(1.1);
  box-shadow:
    0 34px 56px rgba(0,0,0,.96),
    0 8px 20px rgba(0,0,0,.72),
    0 0 28px var(--c, transparent),
    0 0 0 1px rgba(255,255,255,.07);
  transition: transform .24s cubic-bezier(.18,.08,.14,1.55), box-shadow .24s, filter .24s;
}
.hand-card.dragging { opacity: .3; transform: scale(.95); }
.hand-card.inactive { pointer-events: none; opacity: .45; }

/* ─── Sinergia potencial: parpadeo dorado en mano ─── */
@keyframes synergyHint {
  0%, 100% { box-shadow: 0 0 0 0 transparent;            border-color: rgba(251,191,36,0); }
  50%       { box-shadow: 0 0 9px 3px rgba(251,191,36,.65); border-color: rgba(251,191,36,.8); }
}
.hand-card.synergy-hint {
  animation: synergyHint 1.1s ease-in-out infinite;
  border-color: rgba(251,191,36,.5) !important;
}


/* ════════════════════════════════════════════
   GAME OVER
   ════════════════════════════════════════════ */

#screen-gameover {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.over-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 48px 64px; text-align: center;
}
#over-title { font-size: 3rem; letter-spacing: .3em; font-weight: 900; margin-bottom: 10px; }
#over-title.victoria { color: var(--gold); }
#over-title.derrota  { color: #e53935; }
#over-title.empate   { color: var(--dim); }
#over-score { font-size: .88rem; color: var(--dim); margin-bottom: 28px; }
.over-box button {
  padding: 11px 30px; background: var(--bg3); border: 1px solid var(--gold);
  color: var(--gold); font-size: .8rem; letter-spacing: .12em;
  border-radius: 6px; cursor: pointer; transition: all .2s;
}
.over-box button:hover { background: var(--gold); color: #000; }

/* Toast */
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 7px 18px; border-radius: 20px; font-size: .76rem;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 500;
}
#toast.show { opacity: 1; }

/* ── Botón pantalla completa ── */
#corner-btns {
  position: fixed; bottom: 10px; right: 10px; z-index: 8000;
  display: flex; gap: 6px; align-items: center;
}
#corner-btns button {
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(13,13,26,.75); border: 1px solid var(--border);
  color: var(--dim); font-size: 1rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
  backdrop-filter: blur(4px);
}
#corner-btns button:hover { color: var(--gold); border-color: var(--gold); background: rgba(13,13,26,.92); }
#btn-fullscreen.is-fullscreen { color: var(--gold); border-color: var(--gold); }
#btn-pause.is-paused { color: #f87171; border-color: #f87171; }
/* Pausa: solo visible estando en partida (pantalla de juego activa) */
#corner-btns #btn-pause { display: none; }
body:has(#screen-game:not(.hidden)) #corner-btns #btn-pause { display: flex; }

/* ── Overlay de pausa ── */
#pause-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
#pause-overlay.hidden { display: none; }
.pause-box {
  text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center;
}
.pause-title {
  font-family: var(--font-display, serif); font-size: 2rem; letter-spacing: .3em;
  color: var(--gold); text-shadow: 0 0 24px var(--gold);
}
.pause-box button {
  padding: 10px 28px; border-radius: 8px; font-size: .9rem; letter-spacing: .1em;
  background: rgba(255,255,255,.06); border: 1px solid var(--gold);
  color: var(--gold); cursor: pointer; transition: background .15s;
}
.pause-box button:hover { background: rgba(255,255,255,.14); }

/* ─── Texto flotante de daño / curación / armadura ─── */
@keyframes floatUp {
  0%   { transform: translateX(-50%) translateY(0);    opacity: 1; }
  100% { transform: translateX(-50%) translateY(-38px); opacity: 0; }
}
@keyframes floatDown {
  0%   { transform: translateX(-50%) translateY(0);   opacity: 1; }
  100% { transform: translateX(-50%) translateY(32px); opacity: 0; }
}
.float-text {
  position: fixed;
  pointer-events: none;
  z-index: 6000;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-shadow: 0 1px 5px rgba(0,0,0,.85);
  animation: floatUp .85s ease-out forwards;
  white-space: nowrap;
}
.float-text.down { animation: floatDown .85s ease-out forwards; }

/* ─── Tríada Primordial — glow pulsante en cartas ─── */
@keyframes triadaPulse {
  from { box-shadow: 0 0 18px 6px rgba(251,191,36,.5), 0 0 40px 12px rgba(251,191,36,.2); }
  to   { box-shadow: 0 0 32px 14px rgba(251,191,36,.9), 0 0 70px 24px rgba(251,191,36,.5); }
}

/* ─── Indicadores de ataque en cartas enemigas ─── */

/* Naranja: ya será atacada por cartas propias en tablero */
.board-cell.existing-target {
  border-color: #f97316 !important;
  border-style: solid !important;
  animation: existing-target-pulse .85s ease-in-out infinite;
}
@keyframes existing-target-pulse {
  0%,100% { box-shadow: inset 0 0 8px rgba(249,115,22,.22), 0 0 8px rgba(249,115,22,.28); }
  50%      { box-shadow: inset 0 0 16px rgba(249,115,22,.42), 0 0 14px rgba(249,115,22,.45); }
}

/* Rojo: será atacada por la carta nueva que arrastro — MÁXIMA prioridad visual */
.board-cell.attackable,
.board-cell.existing-target.attackable,
.board-cell.in-zone.attackable,
.board-cell.in-zone.existing-target.attackable {
  border-color: #ff1744 !important;
  border-style: solid !important;
  border-width: 3px !important;
  background: rgba(255,23,68,.18) !important;
  animation: attackable-pulse .32s ease-in-out infinite !important;
  outline: 2px solid rgba(255,23,68,.6) !important;
  outline-offset: 1px !important;
  z-index: 10;
}
@keyframes attackable-pulse {
  0%,100% {
    border-color: #ff1744;
    box-shadow: inset 0 0 14px rgba(255,23,68,.5), 0 0 18px rgba(255,23,68,.55);
    background: rgba(255,23,68,.12);
  }
  50% {
    border-color: #ff4569;
    box-shadow: inset 0 0 28px rgba(255,23,68,.8), 0 0 28px rgba(255,23,68,.75);
    background: rgba(255,23,68,.26);
  }
}

/* ─── AI deliberación en tablero ─── */
.board-cell.ai-hover {
  border-color: #888 !important; border-style: dashed !important;
  background: rgba(120,120,120,.12) !important;
  transition: border-color .15s, background .15s;
}
.board-cell.ai-placing {
  border-color: #e53935 !important; border-style: solid !important;
  background: rgba(229,57,53,.18) !important;
  animation: ai-place-pulse .25s ease infinite;
}
@keyframes ai-place-pulse {
  0%,100% { box-shadow: inset 0 0 10px rgba(229,57,53,.2); }
  50%      { box-shadow: inset 0 0 24px rgba(229,57,53,.55); }
}

/* ─── Custom drag ghost ─── */
.drag-custom-ghost {
  position: fixed; left: -9999px; top: -9999px;
  border-radius: 8px; overflow: hidden; border: 2px solid;
  box-shadow: 0 10px 30px rgba(0,0,0,.9);
  pointer-events: none;
}
.drag-custom-ghost img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* ─── Modal carta ampliada ─── */
#card-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  z-index: 800; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
#card-modal.hidden { display: none !important; }
#modal-inner { position: relative; cursor: default; }

#modal-card {
  width: 280px; height: 400px;
  border-radius: 16px; border: 3px solid;
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.4,0,.2,1);
}
#modal-card.modal-flipped { transform: rotateY(180deg); }

.modal-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: 14px; overflow: hidden;
}
.modal-front { background: var(--bg2); }
.modal-front img { width: 100%; height: 70%; object-fit: cover; object-position: top; display: block; }
.modal-front .modal-info {
  padding: 12px 14px; background: var(--bg2);
}
.modal-front .modal-name { font-size: .9rem; font-weight: 700; color: var(--gold); }
.modal-front .modal-rango { font-size: .62rem; color: var(--dim); margin-top: 2px; }
.modal-front .modal-stats { font-size: .72rem; color: var(--text); margin-top: 6px; letter-spacing: .06em; }

.modal-back {
  transform: rotateY(180deg);
  background: linear-gradient(155deg, #0a0a18, #1a082e);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 28px; gap: 14px; text-align: center;
}
.modal-ability-label {
  font-size: .9rem; font-weight: 900; letter-spacing: .08em;
  text-align: center;
}
.modal-ability-detail {
  font-size: .6rem; color: var(--dim); letter-spacing: .1em;
  text-transform: uppercase; margin-top: -4px;
}
.modal-ability-divider {
  width: 60%; height: 1px; background: var(--border); margin: 4px 0;
}
.modal-ability-text {
  font-size: .82rem; color: var(--text); line-height: 1.7;
  text-align: center; padding: 0 8px;
}
.modal-ability-unlock {
  font-size: .62rem; color: var(--dim); font-style: italic; margin-top: 6px;
}

.modal-close-btn {
  position: absolute; top: -14px; right: -14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close-btn:hover { border-color: var(--gold); color: var(--gold); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* ════════════════════════════════════════════
   COMBAT PROMPT (overlay al completar mazo)
   ════════════════════════════════════════════ */

#combat-prompt {
  position: fixed; inset: 0; background: rgba(0,0,0,.86);
  z-index: 400; display: flex; align-items: center; justify-content: center;
}
#combat-prompt.hidden { display: none !important; }
.cp-box {
  background: var(--bg2); border: 1px solid var(--gold);
  border-radius: 14px; padding: 42px 56px; text-align: center;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
  box-shadow: 0 0 80px rgba(201,162,39,.2);
  max-width: 90vw;
}
.cp-title { font-size: 1.6rem; font-weight: 900; color: var(--gold); letter-spacing: .22em; }
.cp-info  { font-size: .8rem; color: var(--dim); letter-spacing: .06em; }
.cp-btn-go {
  width: 100%; padding: 13px 0;
  background: var(--gold2); border: 1px solid var(--gold);
  color: var(--gold); font-size: .82rem; font-weight: 700; letter-spacing: .12em;
  border-radius: 6px; cursor: pointer; transition: all .2s;
}
.cp-btn-go:hover { background: var(--gold); color: #000; }
.cp-btn-back {
  padding: 8px 24px; background: transparent; border: 1px solid var(--border);
  color: var(--dim); font-size: .72rem; border-radius: 6px; cursor: pointer;
  transition: all .15s;
}
.cp-btn-back:hover { border-color: var(--gold); color: var(--gold); }

/* ════════════════════════════════════════════
   PASS OVERLAY (cartas bloqueadas en turno)
   ════════════════════════════════════════════ */

#pass-overlay {
  position: absolute; inset: 0;
  background: rgba(7,7,15,.88);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  z-index: 30; border-radius: var(--r);
}
#pass-overlay.hidden { display: none !important; }
.pass-ov-label {
  font-size: .68rem; color: var(--dim); letter-spacing: .06em; text-align: center;
}
#pass-ov-bar-wrap {
  width: 160px; height: 4px; background: var(--bg3);
  border-radius: 2px; overflow: hidden;
}
#pass-ov-bar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #e65100, #ff9800);
  border-radius: 2px; transition: width .05s linear;
}
.pass-ov-btn {
  padding: 7px 22px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); font-size: .72rem; border-radius: 6px; cursor: pointer;
  transition: all .2s;
}
.pass-ov-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ════════════════════════════════════════════
   PASS NOTICE (notificación de turno pasado)
   ════════════════════════════════════════════ */

#pass-notice {
  position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
  background: rgba(13,13,26,.92); border: 1px solid var(--gold);
  color: var(--gold); font-size: .82rem; font-weight: 700; letter-spacing: .1em;
  padding: 10px 28px; border-radius: 8px; z-index: 250;
  pointer-events: none;
  animation: pass-notice-in .25s ease;
}
#pass-notice.hidden { display: none !important; }
@keyframes pass-notice-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ════════════════════════════════════════════
   MOBILE — rediseño completo ≤ 600 px
   ════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Builder: step screens (móvil) ── */
  .step-screen { gap: 28px; padding: 40px 18px 32px; }
  .step-brand-sub   { font-size: .4rem;  letter-spacing: .38em; }
  .brand-ornament { gap: 12px; margin-bottom: 10px; }
  .brand-ornament span { width: 56px; }
  .brand-ornament i { font-size: 15px; }
  .step-section-tag { font-size: .5rem; letter-spacing: .24em; }
  .step-back-btn { top: 14px; left: 14px; font-size: .6rem; padding: 4px 10px; }
  .step-opt { padding: 16px 18px 16px 24px; border-radius: 9px; }
  .step-opt-name { font-size: .8rem; }
  .step-opt-info { font-size: .56rem; }
  .step-options { gap: 10px; max-width: 100%; }

  /* ── Builder: slots del mazo ── */
  #deck-slots-bar { padding: 5px 8px 3px; }
  #deck-slots { gap: 4px; }
  .deck-slot { width: 54px; height: 74px; border-radius: 6px; }
  .deck-slot-stats { font-size: .4rem; padding: 0 3px; }
  .deck-slot-name  { font-size: .42rem; padding: 5px 2px 2px; }
  .deck-slot.filled:hover { transform: translateY(-12px) scale(1.18); }

  /* ── Builder: barra de costo ── */
  #cost-bar-row { padding: 3px 10px 5px; gap: 8px; }
  #cost-bar-wrap { width: min(140px, 36vw); height: 7px; }
  #meta-cost { font-size: .65rem; }
  #btn-listo { padding: 7px 14px; font-size: .68rem; letter-spacing: .08em; }

  /* ── Builder: build topbar ── */
  #build-topbar { padding: 5px 10px 6px; gap: 8px; }
  #build-topbar #meta-cost { font-size: .66rem; }

  /* ── Builder: filtros — scroll horizontal ── */
  #pool-controls { padding: 5px 0 4px; gap: 3px; align-items: stretch; }
  .filter-bar {
    flex-wrap: nowrap; overflow-x: auto; gap: 4px;
    padding: 0 6px 3px; justify-content: flex-start;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; padding: 3px 7px; font-size: .58rem; }
  .sort-bar { padding: 0 6px; gap: 5px; justify-content: center; }
  .sort-btn  { padding: 2px 7px; font-size: .56rem; }
  .sort-label { font-size: .54rem; }

  /* ── Combat prompt (móvil) ── */
  .cp-box { padding: 30px 22px; gap: 13px; }
  .cp-title { font-size: 1.3rem; letter-spacing: .15em; }
  .cp-info  { font-size: .72rem; }
  .cp-btn-go   { padding: 12px 0; font-size: .76rem; }
  .cp-btn-back { padding: 8px 18px; font-size: .67rem; }

  /* ── Pass overlay (móvil) ── */
  .pass-ov-label { font-size: .6rem; }
  .pass-ov-btn { padding: 6px 18px; font-size: .66rem; }

  /* ── Builder: grid de cartas → 4 columnas ── */
  #pool-scroll { padding: 0 6px 12px; }
  #card-pool {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 6px;
  }

  /* Contenido carta del pool */
  .pool-card-rango { font-size: .4rem; padding: 1px 3px; top: 3px; left: 3px; }
  .pool-card-cost  { font-size: .58rem; width: 15px; height: 15px; top: 3px; right: 3px; }
  .pool-card-footer { padding: 3px 4px; }
  .pool-card-name   { font-size: .56rem; }
  .pool-card-stats  { font-size: .52rem; margin-top: 1px; }

  /* Dorso carta pool: también más pequeño */
  .card-back-name    { font-size: .58rem; }
  .card-back-region  { font-size: .46rem; }
  .card-back-stats   { font-size: .54rem; gap: 3px; }
  .card-back-pattern { font-size: .56rem; }
  .card-back-pdetail { font-size: .44rem; }
  .card-back-ability { font-size: .48rem; }
  .card-back-unlock  { font-size: .42rem; }
  .card-enlarge-btn  { font-size: .52rem; padding: 2px 7px; }

  /* ── Juego: top bar ── */
  #game-top { padding: 4px 10px 4px; gap: 2px; }
  #round-label { font-size: .58rem; letter-spacing: .1em; }
  .wc { font-size: .66rem; }
  #hp-row { gap: 7px; }
  .hp-label { font-size: .5rem; letter-spacing: .05em; }
  #e-hp-num, #p-hp-num { font-size: .68rem; min-width: 18px; }
  .bar-track { height: 6px; min-width: 55px; }

  /* ── Juego: cadena flex → los contenedores deben poder encogerse ── */
  #game-body  { min-height: 0; }
  #board-wrap {
    min-height: 0; overflow: hidden;
    padding: 5px; gap: 4px;
    justify-content: flex-start; align-items: center;
  }

  /* ── Juego: tablero móvil ────────────────────────────────────────
     La ALTURA la maneja el flex (flex:1 → llena el espacio que queda
     en board-wrap después de banner y timer).
     El ANCHO lo calcula fitBoard() para forzar ratio 9:16:
       width = height × (9/16)
     Así el tablero siempre ocupa todo el largo disponible de pantalla.
  ── */
  #turn-banner { font-size: .58rem; min-height: 13px; letter-spacing: .08em; }
  #board {
    flex: 1;           /* ← llena el alto restante en board-wrap  */
    min-height: 0;
    align-self: center;/* ← se centra cuando JS reduce el ancho    */
    width: 100%;       /* punto de partida; JS sobreescribe         */
    aspect-ratio: unset !important;
    max-height: unset !important;
    max-width:  unset !important;
    gap: 3px;
  }
  #timer-bar-wrap { width: calc(100% - 4px); height: 4px; }

  /* Celda del tablero */
  .cell-info { padding: 7px 3px 2px; }
  .cell-name { font-size: .38rem; }
  .cell-hp, .cell-atk { font-size: .46rem; }
  .cell-facedown { font-size: 1.4rem; }

  /* ── Juego: log oculto en móvil ── */
  #log-panel { display: none; }

  /* ── Juego: bottom (mano + siguiente) ── */
  #game-bottom { padding: 4px 8px 3px; gap: 3px; }
  #player-hand { height: 94px; min-width: 170px; }
  .hand-card {
    width: 58px; height: 82px; border-radius: 6px;
  }
  .hand-card:not(.inactive):not(.dragging):hover {
    transform: rotate(calc(var(--rot, 0deg) * 0.12)) translateY(calc(var(--dy, 0px) - 56px));
    transition: transform .22s cubic-bezier(.18,.08,.14,1.55), box-shadow .22s, filter .22s;
  }
  .hand-card-label { font-size: .42rem; padding: 7px 2px 2px; }
  .hand-lock-icon  { font-size: .7rem; }
  .hand-lock-round { font-size: .4rem; }

  /* Siguiente carta */
  #next-card-mini { width: 34px; height: 48px; border-radius: 5px; }
  .next-label { font-size: .4rem; }

  /* Phase label y pass */
  #phase-label { font-size: .56rem; }
  #btn-pass { padding: 4px 12px; font-size: .6rem; }

  /* ── Combat flash (móvil) ── */
  #combat-flash-text { font-size: 1.6rem; letter-spacing: .15em; }

  /* ── Game Over ── */
  .over-box { padding: 28px 18px; border-radius: 10px; }
  #over-title { font-size: 2rem; letter-spacing: .18em; margin-bottom: 8px; }
  #over-score { font-size: .75rem; margin-bottom: 20px; }
  .over-box button { padding: 9px 18px; font-size: .7rem; }

  /* ── Modal carta ampliada ── */
  #modal-card { width: 220px; height: 314px; }
  .modal-front .modal-name  { font-size: .78rem; }
  .modal-front .modal-stats { font-size: .62rem; }
  .modal-ability-label { font-size: .78rem; }
  .modal-ability-text  { font-size: .72rem; }
}


/* ════════════════════════════════════════════
   STEP SCREENS (modo → dificultad → mazo)
   ════════════════════════════════════════════ */

.step-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 36px; padding: 48px 28px;
  background:
    radial-gradient(ellipse 90% 50% at 50% 18%, rgba(201,162,39,.13) 0%, transparent 68%),
    var(--bg);
}
.step-screen.hidden { display: none !important; }

/* Marca en paso 1 */
.step-brand { text-align: center; max-width: 100%; overflow: visible; padding: 6px 18px; }
.brand-ornament { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.brand-ornament span { display: block; height: 1px; width: 100px; background: linear-gradient(to right, transparent, var(--gold)); }
.brand-ornament span:last-child { background: linear-gradient(to left, transparent, var(--gold)); }
.brand-ornament i { font-style: normal; color: var(--gold); font-size: 18px; }
.step-brand-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.2rem, 7vw, 2.6rem); letter-spacing: .1em; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, #c9a22a 0%, #f5e07a 40%, #c9a22a 70%, #f0c84a 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 30px rgba(201,162,42,.4));
}
.step-brand-sub {
  font-family: 'Cinzel', serif;
  font-size: .52rem; letter-spacing: .68em; color: var(--dim);
  margin-top: 10px; text-transform: uppercase;
}

/* Botón volver en paso 2 */
.step-back-btn {
  position: absolute; top: 18px; left: 18px;
  padding: 5px 12px; background: transparent;
  border: 1px solid var(--border); color: var(--dim);
  font-size: .65rem; border-radius: 6px; cursor: pointer; transition: all .15s;
}
.step-back-btn:hover { border-color: var(--gold); color: var(--gold); }

/* Etiqueta de sección */
.step-section-tag {
  font-size: .56rem; letter-spacing: .34em; color: var(--gold);
  text-transform: uppercase; font-weight: 700; opacity: .72;
}

/* Contenedor de opciones */
.step-options { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 420px; }

/* Botón de opción */
.step-opt {
  width: 100%; padding: 20px 24px 20px 30px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; text-align: left;
  position: relative; overflow: hidden;
  transition: border-color .18s, background .18s, transform .18s;
}
/* Línea dorada izquierda */
.step-opt::before {
  content: ''; position: absolute; left: 0; top: 12%; bottom: 12%;
  width: 2px; background: var(--gold); border-radius: 1px;
  transform: scaleY(0); transform-origin: center;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.step-opt:hover::before { transform: scaleY(.6); }
.step-opt.active::before { transform: scaleY(1); }
.step-opt:hover {
  border-color: rgba(201,162,39,.4);
  background: rgba(201,162,39,.04);
  transform: translateX(5px);
}
.step-opt.active {
  border-color: rgba(201,162,39,.65);
  background: rgba(201,162,39,.07);
}
.step-opt-name {
  font-size: .88rem; font-weight: 700; letter-spacing: .08em;
  color: var(--text); margin-bottom: 4px;
  transition: color .18s;
}
.step-opt.active .step-opt-name { color: var(--gold); }
.step-opt-info { font-size: .6rem; color: var(--dim); letter-spacing: .04em; }

/* ── Build panel ── */
#build-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#build-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 8px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#build-topbar #cost-bar-wrap { flex: 1; }
#build-topbar #meta-cost { font-size: .75rem; color: var(--dim); white-space: nowrap; flex-shrink: 0; }

.build-back-btn {
  padding: 4px 10px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); font-size: .68rem; border-radius: 6px; cursor: pointer;
  transition: all .15s; flex-shrink: 0; white-space: nowrap;
}
.build-back-btn:hover { border-color: var(--gold); color: var(--gold); }



/* ════════════════════════════════════════════
   ROUND ROW + WIN CIRCLES
   ════════════════════════════════════════════ */

#round-row {
  display: flex; align-items: center; justify-content: center;
}
/* Círculos de victoria — inline junto a la barra de vida de cada jugador */
.wc-group { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.wc-group.hidden { display: none !important; }
.wc {
  font-size: .78rem; font-weight: 700; line-height: 1;
  transition: color .3s, text-shadow .3s;
}
.wc-enemy  { color: #e53935; }
.wc-player { color: #43a047; }
.wc.filled.wc-enemy  { text-shadow: 0 0 6px rgba(229,57,53,.8); }
.wc.filled.wc-player { text-shadow: 0 0 6px rgba(67,160,71,.8); }


/* ════════════════════════════════════════════
   NEXT CARD PREVIEW
   ════════════════════════════════════════════ */

#next-card-wrap {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.next-label {
  font-size: .48rem; color: var(--dim);
  letter-spacing: .12em; text-transform: uppercase;
}
#next-card-mini {
  width: 46px; height: 64px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg3);
  overflow: hidden; position: relative;
}
.next-card-img {
  width: 100%; height: 100%; object-fit: cover; object-position: top; display: block;
}
.next-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--border); font-size: .8rem;
}


/* ════════════════════════════════════════════
   ATTACK ZONE INDICATOR (gris = rango alcanza)
   ════════════════════════════════════════════ */

.board-cell.in-zone {
  border-color: rgba(200,200,220,.35) !important;
  border-style: dashed !important;
  background: rgba(140,140,180,.07) !important;
}
/* in-zone + existente → naranja */
.board-cell.in-zone.existing-target {
  border-color: #f97316 !important;
  border-style: solid !important;
  background: transparent !important;
  animation: existing-target-pulse .85s ease-in-out infinite;
}
/* in-zone real objetivo → manejado por el bloque atacable de arriba */

/* Dorado Solmira: celda donde caerá el "dúo del alba" de Helior (Llamado del
   Alba). Análogo al gris (zona) y rojo (objetivo): telegrafía temáticamente el
   slot antes de materializar al aliado. Amarillo brillante muy "Solmira". */
.board-cell.cell-dawn-target {
  border-color: #ffd54a !important;
  border-style: solid !important;
  border-width: 3px !important;
  background: rgba(255,213,74,.16) !important;
  animation: dawn-target-pulse .5s ease-in-out infinite !important;
  outline: 2px solid rgba(255,213,74,.55) !important;
  outline-offset: 1px !important;
  z-index: 12;
}
@keyframes dawn-target-pulse {
  0%,100% {
    border-color: #ffe082;
    box-shadow: inset 0 0 14px rgba(255,213,74,.5), 0 0 18px rgba(255,193,7,.55);
    background: rgba(255,213,74,.12);
  }
  50% {
    border-color: #fff3c4;
    box-shadow: inset 0 0 22px rgba(255,213,74,.8), 0 0 30px rgba(255,193,7,.85);
    background: rgba(255,213,74,.24);
  }
}

/* Helior "llama al alba": su propia celda irradia dorado mientras invoca al dúo. */
.board-cell.cell-dawn-caller {
  animation: dawn-caller-glow .7s ease-in-out;
  z-index: 30;
}
@keyframes dawn-caller-glow {
  0%,100% { box-shadow: 0 0 0 rgba(255,213,74,0); transform: scale(1); }
  45%     { box-shadow: 0 0 26px 6px rgba(255,213,74,.85), inset 0 0 18px rgba(255,236,150,.7); transform: scale(1.07); }
}

/* Rayo dorado de Helior → celda del dúo (origen anclado en el centro de Helior). */
.dawn-beam {
  position: fixed; height: 4px; z-index: 180; pointer-events: none;
  transform-origin: 0 50%; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,236,150,.95), rgba(255,213,74,.6), rgba(255,213,74,0));
  box-shadow: 0 0 12px rgba(255,213,74,.85);
  animation: dawn-beam-fade .7s ease-out forwards;
}
@keyframes dawn-beam-fade {
  0%   { opacity: 0; filter: brightness(1.6); }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Juicio Radiante (fase 1): baño de luz Solmira sobre cada enemigo golpeado. */
.board-cell.cell-solmira-judge {
  animation: solmira-judge .62s ease-out;
}
@keyframes solmira-judge {
  0%   { box-shadow: inset 0 0 0 rgba(255,213,74,0); }
  35%  { box-shadow: inset 0 0 26px 6px rgba(255,213,74,.9), 0 0 22px rgba(255,193,7,.8); filter: brightness(1.5) saturate(1.2); }
  100% { box-shadow: inset 0 0 0 rgba(255,213,74,0); filter: none; }
}

/* 🔒 Protección de Padre (Vharokh cubre a Khetu) — café Khar-Dur */
.father-slot-reserved {
  position: fixed; z-index: 150; pointer-events: none; border-radius: 8px;
  border: 2px dashed var(--cafe, #5d4037);
  background: rgba(93,64,55,.38);
  box-shadow: inset 0 0 18px var(--cafe,#5d4037), 0 0 12px var(--cafe,#5d4037);
  animation: father-slot-pulse 1s ease-in-out infinite;
}
@keyframes father-slot-pulse { 0%,100%{opacity:.55;} 50%{opacity:.9;} }
.father-shield-clone {
  position: fixed; z-index: 185; pointer-events: none; border-radius: 8px;
  overflow: hidden; border: 2px solid var(--cafe,#5d4037);
  box-shadow: 0 0 20px var(--cafe,#5d4037), 0 6px 18px rgba(0,0,0,.6);
}
.father-shield-clone img { width:100%; height:100%; object-fit:cover; object-position:top; }

/* ☀ Helior — Juicio Radiante: destello de sol que crece desde el centro del tablero */
.helior-sun-flare {
  position: fixed; z-index: 178; pointer-events: none;
  width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,236,150,.95) 0%, rgba(255,213,74,.6) 35%, rgba(255,193,7,.18) 65%, transparent 75%);
  animation: helior-flare .9s ease-out forwards;
}
@keyframes helior-flare {
  0%   { transform: scale(.2); opacity: 0; }
  22%  { opacity: 1; }
  100% { transform: scale(14); opacity: 0; }
}

/* ════════════════════════════════════════════
   REGION BOARD EFFECTS — ambiente por región
   ════════════════════════════════════════════ */
.region-board-flash {
  position: fixed; pointer-events: none; z-index: 55;
  border-radius: 10px; opacity: 0;
  animation: regionBoardFlash .7s ease-out forwards;
}
@keyframes regionBoardFlash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ════════════════════════════════════════════
   SYNERGY EFFECTS — tiers 1-4
   ════════════════════════════════════════════ */

/* Tier 1 — Chispa: borde de celda */
/* ── Sinergia de región: parpadeo en color de región ── */
.board-cell.cell-syn-region {
  border-color: var(--syn-color, #c9a227) !important;
  border-width: 2px !important;
  animation: synRegionPulse 0.5s ease-in-out 3 !important;
}
@keyframes synRegionPulse {
  0%,100% {
    box-shadow: 0 0 6px 2px var(--syn-color, #c9a227),
                inset 0 0 8px rgba(255,255,255,.04);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 20px 7px var(--syn-color, #c9a227),
                inset 0 0 16px rgba(255,255,255,.1);
    filter: brightness(1.25);
  }
}

/* ── Sinergia de línea/posición: parpadeo dorado ── */
.board-cell.cell-syn-line {
  border-color: #fbbf24 !important;
  border-width: 2px !important;
  animation: synLinePulse 0.55s ease-in-out 3 !important;
}
@keyframes synLinePulse {
  0%,100% {
    box-shadow: 0 0 8px 3px rgba(251,191,36,.4),
                inset 0 0 8px rgba(251,191,36,.08);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 22px 8px rgba(251,191,36,.72),
                inset 0 0 18px rgba(251,191,36,.18);
    filter: brightness(1.3);
  }
}

/* Legado — clases antiguas (se conservan por si se referencian) */
.cell-synergy-glow {
  box-shadow: 0 0 0 3px var(--syn-color, #c9a227),
              0 0 18px var(--syn-color, #c9a227),
              inset 0 0 8px rgba(255,255,255,.05) !important;
  transition: box-shadow .15s !important;
}
.cell-synergy-lift {
  transform: translateY(-5px) scale(1.04) !important;
  transition: transform .18s cubic-bezier(.2,.8,.3,1.4) !important;
  z-index: 15 !important;
}
.cell-synergy-burst {
  animation: cellBurst .4s ease-out forwards;
}
@keyframes cellBurst {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(2.2); }
  100% { filter: brightness(1); }
}

/* Anillo expansivo desde celda */
.synergy-ring {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 160;
  transform: translate(-50%, -50%) scale(0);
  border: 3px solid;
  animation: synergyRingExpand .8s ease-out forwards;
}
@keyframes synergyRingExpand {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: .95; }
  100% { transform: translate(-50%,-50%) scale(5); opacity: 0; }
}

/* Label de sinergia */
.synergy-label {
  position: fixed; pointer-events: none; z-index: 210;
  font-size: .68rem; letter-spacing: .14em; font-weight: 700; text-transform: uppercase;
  white-space: nowrap; text-align: center;
  animation: synergyLabelAnim .9s ease-out forwards;
}
@keyframes synergyLabelAnim {
  0%   { opacity: 0; transform: translate(-50%, 6px); }
  25%  { opacity: 1; transform: translate(-50%, 0); }
  70%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* Rayo SVG entre cartas */
.synergy-svg-ray {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 165;
  animation: synRayFade .6s ease-out forwards;
}
@keyframes synRayFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Flash de bordes de pantalla */
.screen-edge-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  animation: screenEdge .5s ease-out forwards;
}
@keyframes screenEdge {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Overlay épico Tier 4 */
.synergy-epic-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 155;
  background: rgba(0,0,0,.78);
  animation: epicOverlayAnim 1.7s ease-out forwards;
}
@keyframes epicOverlayAnim {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  60%  { opacity: .75; }
  100% { opacity: 0; }
}

/* Board shake */
@keyframes boardShakeAnim {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-4px, 2px); }
  30% { transform: translate(4px,-3px); }
  45% { transform: translate(-3px, 4px); }
  60% { transform: translate(3px,-2px); }
  80% { transform: translate(-2px, 1px); }
}
@keyframes boardShakeHeavy {
  0%,100% { transform: translate(0,0); }
  10% { transform: translate(-6px, 4px); }
  25% { transform: translate(6px,-5px); }
  40% { transform: translate(-5px, 6px); }
  55% { transform: translate(5px,-4px); }
  70% { transform: translate(-3px, 3px); }
  85% { transform: translate(2px,-2px); }
}
.board-shake       { animation: boardShakeAnim  .32s ease-in-out; }
.board-shake-heavy { animation: boardShakeHeavy .45s ease-in-out; }

/* ════════════════════════════════════════════
   PRIMORDIAL REVEAL — carta sale en 3D
   ════════════════════════════════════════════ */
#primordial-reveal {
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  background: transparent;
  transition: background .28s ease;
}
#primordial-reveal.darkened { background: rgba(0,0,0,.82); }

#primordial-card-clone {
  position: fixed; z-index: 9001; pointer-events: none;
  border-radius: 10px; overflow: hidden;
  transform-origin: center center;
  will-change: transform, left, top, width, height;
}

/* Ondas de impacto desde celda Primordial */
.primordial-impact-ring {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 9002;
  transform: translate(-50%,-50%) scale(0);
  animation: primordialRing .7s ease-out forwards;
}
@keyframes primordialRing {
  0%   { transform: translate(-50%,-50%) scale(0); opacity: .9; }
  100% { transform: translate(-50%,-50%) scale(8); opacity: 0; }
}

/* Flash de celda Primordial al colocar */
.primordial-cell-flash {
  animation: primordialCellFlash .3s ease-out;
}
@keyframes primordialCellFlash {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(3); }
  100% { filter: brightness(1); }
}

/* Celda bloqueada por Nyrakk — grieta permanente */
/* Grieta de Nyrakk — base limpia (relleno morado profundo + marco). El efecto de
   "células" lo aporta Vanta CELLS por encima (ver initNyrakkVantaGrietas en game.js).
   Si Vanta no cargara, queda este relleno como respaldo limpio (sin el CSS recargado). */
.cell-nyrakk-crack {
  position: relative;
  overflow: hidden;
}
.cell-nyrakk-crack::before {
  content: ''; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 45%, #2a0a45 0%, #160322 70%, #0d0118 100%);
}
.cell-nyrakk-crack::after {
  content: ''; position: absolute; inset: 0; z-index: 7; pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(192,132,252,.55);
  box-shadow: inset 0 0 13px rgba(123,31,162,.85), 0 0 9px rgba(123,31,162,.5);
}
.cell-nyrakk-crack.empty { pointer-events: none !important; cursor: not-allowed !important; }

/* Capa de lienzos Vanta (uno por grieta) — sobrevive a los re-render del tablero */
#vanta-grieta-layer {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
}
.vanta-grieta {
  position: fixed; pointer-events: none; overflow: hidden;
  border-radius: 8px;
  box-shadow: inset 0 0 12px rgba(123,31,162,.85), 0 0 8px rgba(123,31,162,.5);
}
.vanta-grieta canvas { border-radius: 8px; display: block; }

/* Oleada de Aquarokh — overlay Vanta CELLS azul, SOLO sobre el tablero (posición
   y tamaño los fija game.js con el rect del tablero), barrido izq→der. */
.aquarokh-wave-vanta {
  position: fixed;         /* left/top/width/height los pone game.js */
  z-index: 175;            /* sobre el tablero y FX, bajo cinemáticas y modales */
  pointer-events: none;
  overflow: hidden;
  border-radius: 12px;
  opacity: .85;
  /* Barrido horizontal con borde de avance SUAVE — game.js anima mask-position */
  -webkit-mask-image: linear-gradient(to right, #000 46%, transparent 56%);
          mask-image: linear-gradient(to right, #000 46%, transparent 56%);
  -webkit-mask-size: 200% 100%;
          mask-size: 200% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;
          mask-position: 100% 0;
}
/* Viñeta: oscurece hacia las orillas para que no se vean duras sobre el tablero */
.aquarokh-wave-vanta::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  border-radius: 12px;
  background: radial-gradient(ellipse 118% 112% at 50% 50%, transparent 52%, rgba(2,10,25,.9) 100%);
}
.aquarokh-wave-vanta canvas { display: block; border-radius: 12px; }

/* Carta aturdida — Aquarokh Oleada */
.cell-stunned::after {
  content: ''; position: absolute; top: 3px; right: 4px;
  width: 10px; height: 10px; z-index: 7;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230ea5e9'%3E%3Cpath d='M13 2 4.5 13.5H11l-1 8.5 8.5-11.5H12z'/%3E%3C/svg%3E") no-repeat center / contain;
  filter: drop-shadow(0 0 4px #0ea5e9);
  pointer-events: none;
}

/* Bloqueada por Enredadera (Eldrian) */
.cell-blocked-vine {
  position: relative; pointer-events: none;
}
.cell-blocked-vine::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(
    45deg, rgba(46,125,50,.35) 0px, rgba(46,125,50,.35) 4px,
    transparent 4px, transparent 10px
  );
  pointer-events: none; z-index: 5;
}

/* Passive heal visual on card */
@keyframes cardHealPulse {
  0%   { box-shadow: 0 0 0 0 rgba(67,160,71,.7); }
  60%  { box-shadow: 0 0 0 8px rgba(67,160,71,0); }
  100% { box-shadow: 0 0 0 0 rgba(67,160,71,0); }
}
.card-heal-pulse { animation: cardHealPulse .5s ease-out; }

/* ══════════════════════════════════════════════════════
   TITLE SCREEN — VS IA / MULTIJUGADOR
   ══════════════════════════════════════════════════════ */
#screen-title {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh;
  background: var(--bg-deep, #0a0a0f);
  gap: 2.5rem;
}
.title-mode-btns {
  display: flex; gap: 1.4rem; flex-wrap: wrap; justify-content: center;
}
.title-mode-btn {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 1.6rem 2rem; width: 220px; cursor: pointer;
  text-align: center; transition: background .2s, border-color .2s, transform .15s;
  color: var(--text-primary, #e8dcc8);
}
.title-mode-btn:hover {
  background: rgba(255,255,255,.08); border-color: rgba(201,162,39,.5);
  transform: translateY(-2px);
}
.title-mode-mp { border-color: rgba(99,102,241,.35); }
.title-mode-mp:hover { border-color: rgba(99,102,241,.7); }
.title-mode-icon { font-size: 2rem; margin-bottom: .6rem; }
.title-mode-name { font-size: .85rem; font-weight: 700; letter-spacing: .06em; margin-bottom: .4rem; }
.title-mode-info { font-size: .65rem; opacity: .55; }

/* ══════════════════════════════════════════════════════
   LOBBY
   ══════════════════════════════════════════════════════ */
#screen-lobby {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: 100vh; background: var(--bg-deep, #0a0a0f);
  padding: 2rem 1rem;
}
/* ════════ LOBBY / SALAS — rediseño móvil apilado ════════ */
.lobby-wrap { width: 100%; max-width: 480px; margin: 0 auto; }
.lobby-header {
  display: flex; align-items: center; justify-content: center; gap: .8rem; margin-bottom: 1.2rem;
}
.lobby-brand { margin-bottom: 1rem; }
.lobby-title {
  font-family: 'Cinzel', var(--font-display, serif); font-size: .95rem;
  letter-spacing: .2em; color: var(--gold, #c9a227); opacity: .8;
}
.lobby-section { margin-bottom: 1.4rem; }
.lobby-section-label {
  font-size: .65rem; letter-spacing: .14em; opacity: .5;
  margin-bottom: .55rem; text-transform: uppercase;
}
.lobby-name-input-row { display: flex; gap: .6rem; }
.lobby-input {
  flex: 1; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; padding: .75rem .9rem; color: #e8dcc8;
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.lobby-input:focus { border-color: rgba(201,162,39,.6); }
.lobby-name-btn {
  background: rgba(201,162,39,.15); border: 1px solid rgba(201,162,39,.4);
  border-radius: 10px; padding: .75rem 1.3rem; color: #c9a227;
  font-size: .82rem; letter-spacing: .08em; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .2s;
}
.lobby-name-btn:hover, .lobby-name-btn:active { background: rgba(201,162,39,.28); }

/* Layout apilado (una columna, mobile-first) */
.lobby-columns { display: flex; flex-direction: column; gap: 1.5rem; }
.lobby-col-title {
  font-size: .66rem; letter-spacing: .14em; opacity: .55;
  margin-bottom: .7rem; text-transform: uppercase;
}

/* CTA: Crear sala — estilo Eclipsorian dorado resplandeciente, al fondo */
.lobby-create-btn {
  order: 5; width: 100%; margin: .2rem 0 0; display: flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .95rem; border-radius: 13px;
  background: linear-gradient(135deg, #c9a22a 0%, #f0c84a 50%, #c9a22a 100%);
  border: 1px solid rgba(245,224,122,.6); color: #07070d;
  font-family: 'Cinzel', var(--font-display, serif); font-size: .9rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; cursor: pointer; transition: all .18s;
  box-shadow: 0 0 22px rgba(201,162,42,.45), 0 4px 14px rgba(0,0,0,.4);
}
.lobby-create-btn:hover, .lobby-create-btn:active {
  box-shadow: 0 0 34px rgba(245,224,122,.75), 0 4px 14px rgba(0,0,0,.4); transform: translateY(-1px);
}
.lobby-create-btn svg { width: 18px; height: 18px; stroke: #07070d; }

/* Lista de salas: tarjetas apiladas */
.lobby-rooms {
  background: none; border: none; padding: 0; min-height: 0; max-height: none;
  overflow: visible; display: flex; flex-direction: column; gap: .6rem;
}
.lobby-room-row {
  cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.035);
  border-radius: 13px; padding: .8rem .85rem; margin: 0; font-size: .8rem;
  transition: transform .15s, background .15s, border-color .15s;
}
.lobby-room-row::before {
  content: ''; flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
  background: rgba(129,140,248,.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b4fc' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M12 2 21 7v10l-9 5-9-5V7z'/%3E%3C/svg%3E") no-repeat center / 20px;
}
.lobby-room-row:hover, .lobby-room-row:active {
  background: rgba(99,102,241,.14); border-color: rgba(129,140,248,.55); transform: translateY(-1px);
}
.lobby-room-row > div:not([class]) { flex: 1; min-width: 0; }
.lobby-room-name { font-weight: 700; color: #ece2cf; font-size: .92rem; }
.lobby-room-mode { font-size: .72rem; opacity: .55; margin-top: 2px; }
.lobby-room-join {
  flex-shrink: 0; display: flex; align-items: center;
  font-size: .72rem; color: #07070d; font-weight: 700; letter-spacing: .04em;
  background: #818cf8; padding: .45rem .8rem; border-radius: 9px; text-transform: uppercase;
}
.lobby-empty {
  opacity: .4; font-size: .76rem; padding: 1rem; text-align: center;
  border: 1px dashed rgba(255,255,255,.1); border-radius: 12px;
}

/* En línea: chips horizontales */
.lobby-players {
  background: none; border: none; padding: 0; min-height: 0; max-height: none;
  overflow: visible; display: flex; flex-wrap: wrap; gap: .5rem;
}
.lobby-player-row {
  width: auto; margin: 0; padding: .42rem .8rem; gap: .45rem; font-size: .76rem;
  display: flex; align-items: center; color: #c8d8c0;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); border-radius: 20px;
}
.lobby-player-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #4ade80; flex-shrink: 0;
  box-shadow: 0 0 5px #4ade80;
}
.lobby-player-me { border-color: rgba(251,191,36,.5); background: rgba(251,191,36,.1); color: #fde68a; }
.lobby-player-me .lobby-player-dot { background: #fbbf24; box-shadow: 0 0 5px #fbbf24; }

/* Esperando rival */
#lobby-waiting { margin-top: 0; display: flex; justify-content: center; }
.lobby-waiting-box {
  width: 100%; background: rgba(255,255,255,.04); border: 1px solid rgba(201,162,39,.25);
  border-radius: 14px; padding: 1.8rem 1.5rem; text-align: center;
}
.lobby-waiting-title {
  font-size: .9rem; font-weight: 700; letter-spacing: .12em; color: #c9a227; margin-bottom: .4rem;
}
.lobby-waiting-info { font-size: .78rem; opacity: .55; margin-bottom: .6rem; }
.lobby-waiting-dots span {
  display: inline-block; animation: dotPulse 1.2s infinite;
  font-size: 1.6rem; color: #c9a227; margin: 0 2px;
}
.lobby-waiting-dots span:nth-child(2) { animation-delay: .2s; }
.lobby-waiting-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotPulse { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }
.lobby-cancel-btn {
  margin-top: 1.2rem; padding: .6rem 1.4rem; background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3); border-radius: 9px; color: #f87171;
  font-size: .78rem; cursor: pointer; transition: background .2s;
}
.lobby-cancel-btn:hover, .lobby-cancel-btn:active { background: rgba(239,68,68,.2); }

/* ══════════════════════════════════════════════════════
   HOVER DEL OPONENTE — celda que está considerando
   ══════════════════════════════════════════════════════ */
.board-cell.opponent-hover {
  border-color: rgba(255,255,255,.55) !important;
  border-style: dashed !important;
  border-width: 2px !important;
  animation: opponentHoverPulse .7s ease-in-out infinite !important;
}
@keyframes opponentHoverPulse {
  0%,100% { box-shadow: 0 0 5px 1px rgba(255,255,255,.2); }
  50%      { box-shadow: 0 0 14px 4px rgba(255,255,255,.45); }
}

/* ══════════════════════════════════════════════════════
   MP — Overlay "esperando rival"
   ══════════════════════════════════════════════════════ */
#mp-waiting-overlay {
  position: fixed; inset: 0; z-index: 6000;
  background: rgba(0,0,0,.82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.mp-waiting-box { text-align: center; }
.mp-waiting-title {
  font-family: var(--font-display, serif); font-size: 1.1rem;
  letter-spacing: .2em; color: var(--gold, #c9a227);
  margin-bottom: .6rem;
}
.mp-waiting-sub { font-size: .8rem; opacity: .6; margin-bottom: 1rem; }

/* ══════════════════════════════════════════════════════
   MP — Cuenta regresiva épica
   ══════════════════════════════════════════════════════ */
#mp-countdown-overlay {
  position: fixed; inset: 0; z-index: 7000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.mp-countdown-inner { text-align: center; }
#mp-countdown-title {
  font-family: var(--font-display, serif);
  font-size: clamp(1rem, 4vw, 1.6rem);
  letter-spacing: .22em; color: #fbbf24;
  text-shadow: 0 0 30px #fbbf24, 0 0 60px #f59e0b;
  margin-bottom: 1.2rem;
  animation: mpTitlePulse 1s ease-in-out infinite alternate;
}
@keyframes mpTitlePulse {
  from { text-shadow: 0 0 20px #fbbf24, 0 0 40px #f59e0b; }
  to   { text-shadow: 0 0 40px #fbbf24, 0 0 80px #f59e0b, 0 0 120px #d97706; }
}
#mp-countdown-num {
  font-family: var(--font-display, serif);
  font-size: clamp(4rem, 16vw, 9rem); font-weight: 900;
  color: #fff; line-height: 1;
  text-shadow: 0 0 40px rgba(255,255,255,.6);
  transition: transform .15s, opacity .15s;
}
#mp-countdown-vs {
  font-size: clamp(.65rem, 2vw, .9rem); letter-spacing: .18em;
  color: rgba(255,255,255,.45); margin-top: .8rem;
}

/* MP dentro del combat prompt */
.cp-mp-waiting {
  text-align: center; padding: .4rem 0;
}
.cp-mp-waiting-text {
  font-size: .8rem; color: rgba(232,220,200,.65);
  margin-bottom: .2rem;
}
.cp-mp-rival-ready {
  font-size: .7rem; color: #4ade80;
  text-align: center; margin-bottom: .5rem;
  animation: rivalReadyPulse 1.2s ease-in-out infinite alternate;
}
@keyframes rivalReadyPulse {
  from { opacity: .7; } to { opacity: 1; }
}

/* ═══════════════════════════════════════════════════
   MP: Lobby polish — abandon overlay, rematch, room status
   ═══════════════════════════════════════════════════ */

/* ── Overlay de abandono y notificaciones ── */
#mp-abandon-overlay {
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(0,0,0,.85); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
#mp-abandon-overlay.hidden { display: none; }
.mp-abandon-box {
  text-align: center; display: flex; flex-direction: column;
  gap: 16px; align-items: center;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px 56px;
  min-width: 280px;
}
.mp-abandon-title { font-size: 1rem; letter-spacing: .12em; color: #f87171; }
.mp-abandon-num {
  font-size: 3.5rem; font-weight: 900; color: var(--gold);
  font-family: var(--font-display, serif); line-height: 1;
}
.mp-abandon-cancel {
  padding: 8px 28px; border-radius: 6px; font-size: .8rem; letter-spacing: .1em;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer; transition: background .15s, color .15s;
}
.mp-abandon-cancel:hover { background: rgba(255,255,255,.14); color: var(--text); }

/* ── Game over MP: zona revancha ── */
#over-mp-zone { width: 100%; margin-top: 10px; }
.mp-go-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px;
}
.mp-go-rematch {
  padding: 11px 26px; background: rgba(250,189,0,.1);
  border: 1px solid var(--gold); color: var(--gold);
  font-size: .8rem; letter-spacing: .12em; border-radius: 6px;
  cursor: pointer; transition: background .2s;
}
.mp-go-rematch:hover:not(:disabled) { background: var(--gold); color: #000; }
.mp-go-rematch:disabled { opacity: .5; cursor: default; pointer-events: none; }
.mp-go-lobby {
  padding: 11px 26px; background: var(--bg3); border: 1px solid var(--border);
  color: var(--dim); font-size: .8rem; letter-spacing: .12em;
  border-radius: 6px; cursor: pointer; transition: background .2s;
}
.mp-go-lobby:hover { background: rgba(255,255,255,.08); color: var(--text); }

/* ── Invitación a revancha recibida ── */
.mp-go-invite-box {
  background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.3);
  border-radius: 8px; padding: 16px 22px; margin-top: 4px;
}
.mp-go-invite-title { font-size: .82rem; color: var(--text); margin-bottom: 6px; }
.mp-go-invite-countdown {
  font-size: 1.6rem; font-weight: 800; color: var(--gold); margin-bottom: 12px;
}
.mp-go-invite-btns { display: flex; gap: 10px; justify-content: center; }
.mp-go-accept {
  padding: 8px 22px; background: rgba(74,222,128,.1); border: 1px solid #4ade80;
  color: #4ade80; border-radius: 6px; cursor: pointer; font-size: .78rem;
  transition: background .15s;
}
.mp-go-accept:hover { background: rgba(74,222,128,.22); }
.mp-go-decline {
  padding: 8px 22px; background: rgba(239,68,68,.07); border: 1px solid #ef4444;
  color: #ef4444; border-radius: 6px; cursor: pointer; font-size: .78rem;
  transition: background .15s;
}
.mp-go-decline:hover { background: rgba(239,68,68,.18); }
.mp-go-waiting {
  font-size: .78rem; color: var(--dim); margin-top: 6px;
  font-style: italic;
}

/* ── Lobby: salas activas (en juego) ── */
.lobby-room-active { opacity: .75; cursor: default !important; }
.lobby-room-active:hover { background: var(--bg2) !important; border-color: var(--border) !important; }
.lobby-room-status {
  font-size: .68rem; padding: 3px 9px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  color: #f87171; border-radius: 10px; white-space: nowrap;
}
