/* ============================================================
   AQW Card Game — game.css
   Extends base.css (copia do style.css do site). Paleta idêntica (vars já carregadas).
   ============================================================ */

/* ── Mobile info sidebar (hidden on desktop) ───────────────── */
.mob-info { display: none; }
/* Transparent wrapper so desktop battle-zone is unaffected */
.battle-zone-center { display: contents; }
/* Mobile card preview overlay: hidden on desktop */
.card-ghost { display: none; }
/* Card action buttons: hidden on mobile (touch uses ghost card instead) */
.is-mobile .card .card-actions { display: none !important; }

/* ── Card ghost overlay (mobile hold gesture) ────────────────── */
#cardGhostEl {
  position: fixed;
  z-index: 9000;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10,10,18,0.97);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 10px 12px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.75);
  max-width: 90vw;
  user-select: none;
  -webkit-user-select: none;
}
#cardGhostEl.visible {
  display: flex;
}
#cardGhostEl .ghost-card-img {
  width: 160px;
  height: auto;
  border-radius: 4px;
  display: block;
}
#cardGhostEl .ghost-caption {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
}
#cardGhostEl .ghost-caption.warn { color: var(--red); }
#cardGhostEl .ghost-caption.note { color: var(--text-dim); }
#cardGhostEl .ghost-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  pointer-events: auto;
}
/* Tooltip de ação: aparece fora do ghost, posicionado por JS */
#ghostBtnTooltip {
  position: fixed;
  z-index: 9001;
  transform: translate(-50%, -100%);
  background: rgba(10,10,18,0.97);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: "Cinzel", serif;
  color: var(--gold);
  white-space: nowrap;
  pointer-events: none;
  display: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
#ghostBtnTooltip.visible {
  display: block;
}
.ghost-action-btn {
  pointer-events: auto;
  font-size: 1.4rem;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: rgba(20,20,30,0.9);
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ghost-action-btn.ghost-active {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
  transform: scale(1.12);
}
.ghost-action-btn--warn {
  border-color: var(--red);
  color: var(--red);
}
.ghost-action-btn--warn.ghost-active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ── Board grid ─────────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: auto 1fr auto auto;
  height: 100dvh;
  overflow: clip; /* clip blocks scrolling but lets scale() overflow visually */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* impede menu "Salvar Imagem" no iOS */
}

.zone-p2    { grid-column: 1; grid-row: 1; z-index: 2; } /* above battle-zone on hover */
.battle-zone{ grid-column: 1; grid-row: 2; z-index: 1; }
.zone-p1    { grid-column: 1; grid-row: 3; z-index: 2; } /* above battle-zone on hover */
.action-bar { grid-column: 1; grid-row: 4; z-index: 3; } /* above everything */
#rightPanel { grid-column: 2; grid-row: 1 / 5; display: flex; flex-direction: column; border-left: 1px solid var(--border); min-width: 0; }

/* P2 perspective: swap zones so "me" is always at the bottom */
.board.perspective-p2 .zone-p2 { grid-row: 3; }
.board.perspective-p2 .zone-p1 { grid-row: 1; }
.board.perspective-p2 .zone-p2 {
  flex-direction: row;
  border-top: none;
  border-bottom: 1px solid var(--border);
}
.board.perspective-p2 .zone-p2 .player-info { align-items: flex-start; }
.board.perspective-p2 .zone-p1 {
  flex-direction: row-reverse;
  border-bottom: none;
  border-top: 1px solid var(--border);
}
.board.perspective-p2 .zone-p1 .player-info { align-items: flex-end; }

/* ── Player zones ────────────────────────────────────────────── */
.player-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  min-height: 0;
  overflow: visible; /* allow hovered cards to scale outside the zone */
}

.zone-p2 {
  flex-direction: row;
  border-bottom: none;
  border-top: 1px solid var(--border);
}

/* ── Player info ─────────────────────────────────────────────── */
.player-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 160px;
}

.zone-p2 .player-info { align-items: flex-start; }

.player-name {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  color: var(--gold);
}

.hp-wrap {
  position: relative;
  width: 140px;
  height: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4bc870, #3aa05a);
  transition: width 0.4s ease, background 0.4s ease;
}

.hp-bar.low  { background: linear-gradient(90deg, var(--red), #a03a3a); }
.hp-bar.mid  { background: linear-gradient(90deg, #c8a84b, #9a7a30); }

.hp-num {
  position: absolute;
  right: 5px;
  top: 0;
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  line-height: 14px;
  pointer-events: none;
}

/* ── Equip slots ─────────────────────────────────────────────── */
.equip-row {
  display: flex;
  gap: 5px;
}

.equip-slot {
  width: 72px;
  height: 100px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.equip-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slot-lbl {
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.2;
  padding: 2px;
}

.slot-clickable {
  cursor: pointer;
}

@media (hover: hover) {
  .slot-clickable:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.05);
  }
  /* Equip slot com carta: eleva e acende dourado */
  .equip-slot.slot-clickable:has(img):hover {
    border-color: var(--gold-dim);
    border-style: solid;
    transform: translateY(-3px) scale(1.07);
    box-shadow: 0 4px 12px rgba(200,168,75,0.4);
    z-index: 10;
    overflow: visible;
  }
}

/* Armor slot with build guide available */
.has-build-guide {
  border-color: rgba(255,200,60,0.35) !important;
  position: relative;
}
.has-build-guide::after {
  content: '📖';
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 10px;
  opacity: 0.8;
  pointer-events: none;
}

/* Armor anytime hover button */
.equip-slot {
  position: relative;
}
/* Overlay buttons nos equip slots — mesmo padrão das cartas da mão */
/* Gradiente no slot ao hover (como .card-actions) */
@media (hover: hover) {
  .equip-slot:has(.armor-anytime-btn):hover::before,
  .equip-slot:has(.pet-attack-btn):hover::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 55%;
    background: linear-gradient(to bottom, rgba(10,10,18,0.72) 50%, transparent);
    border-radius: 3px 3px 0 0;
    pointer-events: none;
    z-index: 9;
  }
}

/* Botão pill opaco — igual a .card-action-btn */
.armor-anytime-btn,
.pet-attack-btn {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0 8px;
  height: 22px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10,10,18,0.92);
  color: rgba(255,255,255,0.9);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s, border-color 0.1s;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
}

.armor-anytime-btn:hover,
.pet-attack-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

@media (hover: hover) {
  .equip-slot:hover .armor-anytime-btn,
  .equip-slot:hover .pet-attack-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.deck-count {
  font-size: 10px;
  color: var(--text-dim);
}

/* ── Hand ────────────────────────────────────────────────────── */
.hand-row {
  display: flex;
  gap: 0;
  justify-content: center;
  /* overflow-x:clip does NOT create a scroll container (unlike auto/hidden),
     so overflow-y:visible is NOT coerced to auto by the browser.
     This allows scaled cards to overflow upward without being clipped. */
  overflow-x: clip;
  overflow-y: visible;
  padding: 4px 8px 6px;
  flex: 1;
  align-items: flex-end;
}

/* Sobreposição de cartas: cada carta encobre parcialmente a anterior */
.hand-row .card        { margin-right: -22px; }
.hand-row .card:last-child { margin-right: 0; }

.zone-p2 .hand-row { align-items: flex-start; padding: 6px 8px 4px; }

/* Hovered/selected card rises above its neighbors */
@media (hover: hover) {
  .hand-row .card:hover { z-index: 20; }
}
.hand-row .card.selected { z-index: 21; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  width: 96px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: default;
  transition: transform 0.18s ease, border-color 0.15s, box-shadow 0.15s, z-index 0s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}


.card img {
  width: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.card-name {
  display: none;
}

/* Leve hover em todas as cartas — só em dispositivos com ponteiro real (mouse) */
@media (hover: hover) {
  .hand-row .card:hover {
    transform: translateY(-8px) scale(1.08);
    z-index: 20;
  }

  .card.playable:hover {
    border-color: var(--gold);
    box-shadow: 0 6px 18px rgba(200,168,75,0.5);
  }
}

/* Cartas jogáveis: brilho dourado em repouso (todos os dispositivos) */
.card.playable {
  cursor: default;
  border-color: var(--gold-dim);
  overflow: visible;
  box-shadow: 0 0 6px rgba(200,168,75,0.25);
}

.card.playable .card-inner {
  overflow: hidden;
  border-radius: 2px;
}

/* Action overlay — gradiente no topo da carta, sem moldura */
.card-actions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  transform: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 4px;
  padding: 5px 4px 6px;
  background: linear-gradient(to bottom, rgba(10,10,18,0.72) 50%, transparent);
  border: none;
  border-radius: 3px 3px 0 0;
  z-index: 20;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

@media (hover: hover) {
  .card:hover .card-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.card-action-btn {
  font-size: 0.78rem;
  line-height: 1;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10,10,18,0.92);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: color 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.card-action-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: rgba(10,10,18,0.92);
}

.card-action-btn--warn {
  color: rgba(200,168,75,0.85);
  border-color: rgba(200,168,75,0.25);
}

.card-action-btn--warn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
}

.card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue);
  transform: translateY(-8px) scale(1.08);
  z-index: 11;
}

/* Mobile: short tap mostra carta levemente elevada */
.card.card-zoomed {
  transform: translateY(-8px) scale(1.1) !important;
  z-index: 25 !important;
  border-color: var(--gold) !important;
  box-shadow: 0 6px 18px rgba(200,168,75,0.5) !important;
}

/* Feedback visual ao pressionar um slot no mobile */
.slot-zoomed {
  transform: scale(1.08) !important;
  border-color: var(--gold-dim) !important;
  border-style: solid !important;
  z-index: 25 !important;
  overflow: visible !important;
  box-shadow: 0 4px 14px rgba(200,168,75,0.4) !important;
}

/* ── Hover preview (floating 2× card in corner) ──────────────── */
#cardHoverSlot {
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 320px;
}
#cardHoverPlaceholder {
  font-size: 0.68rem;
  color: var(--text-dim);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}
#cardHoverPreview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
  background: transparent;
  transition: opacity 0.1s ease;
  opacity: 0;
  pointer-events: none;
}
#cardHoverPreview.visible { opacity: 1; }
#cardHoverPreview.visible ~ #cardHoverPlaceholder { opacity: 0; }
#cardHoverPreview img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  display: block;
}
#cardHoverPreviewCaption {
  flex-shrink: 0;
  font-size: 0.75rem;
  text-align: center;
  padding: 4px 8px;
  background: rgba(10,10,18,0.88);
  color: var(--text-dim);
  min-height: 1.6em;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cardHoverPreviewCaption:empty { display: none; }
#cardHoverPreviewCaption.warn  { color: var(--red); }
#cardHoverPreviewCaption.note  { color: var(--gold); }

/* Card back — opponent's hidden hand */
.card.card-back {
  height: 133px;  /* same ratio as normal card (96px wide × ~1.38) */
  cursor: default;
  border-color: #2a3a5a;
  background-image: url('./assets/card_back.webp');
  background-size: cover;
  background-position: center;
}

.card.card-back::after {
  display: none;
}

/* ── Rules overlay ──────────────────────────────────────────── */
.btn-rules {
  background: rgba(80, 50, 120, 0.35);
  border-color: #8a60c8;
  color: #c8a8f8;
}
.btn-rules:hover {
  background: rgba(80, 50, 120, 0.6);
  border-color: #b080f0;
}

.rules-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.rules-overlay.hidden { display: none; }
/* ── Rules tabs ──────────────────────────────────────────────── */
.rules-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 20px;
  gap: 4px;
}
.rules-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: "Cinzel", serif;
  padding: 10px 14px;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
}
.rules-tab:hover { color: var(--text); }
.rules-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── Playbook panel ──────────────────────────────────────────── */
.pb-section { display: flex; flex-direction: column; gap: 8px; }
.pb-section h3 {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  color: var(--gold);
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Armor grid */
.pb-armor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pb-armor-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
}
.pb-armor-card img {
  width: 68px;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
  cursor: zoom-in;
}
.pb-armor-name {
  font-family: "Cinzel", serif;
  font-size: 0.7rem;
  color: var(--gold);
  line-height: 1.2;
}
.pb-armor-class {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-style: italic;
}
.pb-armor-bonus {
  font-size: 0.67rem;
  color: var(--text);
  line-height: 1.4;
}

/* Quest combos */
.pb-quest-list { display: flex; flex-direction: column; gap: 8px; }
.pb-quest {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  flex-wrap: nowrap;
}
.pb-quest img {
  width: 52px;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}
.pb-quest-sep {
  font-size: 1rem;
  color: var(--text-dim);
  flex-shrink: 0;
  padding: 0 2px;
}
.pb-quest-result {
  flex: 1;
  text-align: right;
  min-width: 0;
}
.pb-quest-dmg {
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  color: var(--gold);
  display: block;
}
.pb-quest-label {
  font-size: 0.67rem;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

/* Block guide */
.pb-block-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pb-block-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.pb-block-group h5 {
  font-size: 0.72rem;
  color: var(--gold);
  font-family: "Cinzel", serif;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pb-block-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pb-block-group li {
  font-size: 0.72rem;
  color: var(--text);
  line-height: 1.4;
}
.pb-block-group li span {
  color: var(--text-dim);
  font-size: 0.65rem;
}

/* Card strip (small cards in a row) */
.pb-card-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}
.pb-card-strip figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.pb-card-strip img {
  width: 54px;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
}
.pb-card-strip figcaption { display: none; }

.pb-card-strip figure {
  cursor: zoom-in;
}

/* ── Armor card — clickable to open build modal ─────────────── */
.pb-armor-card { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.pb-armor-card:hover { border-color: var(--gold); box-shadow: 0 0 8px rgba(255,200,60,0.25); }

/* ── Build detail modal ─────────────────────────────────────── */
.build-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.build-modal.hidden { display: none; }
.build-modal-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 680px; width: 100%;
  max-height: 88dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
.build-modal-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.build-modal-topbar span { font-size: 0.95rem; }
.build-modal-body {
  overflow-y: auto;
  padding: 16px 20px 24px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  display: flex; flex-direction: column; gap: 16px;
}
.bm-header { display: flex; gap: 16px; align-items: flex-start; }
.bm-armor-img { width: 130px; border-radius: 6px; flex-shrink: 0; }
.bm-armor-info { display: flex; flex-direction: column; gap: 5px; }
.bm-armor-name { font-family: "Cinzel", serif; font-size: 1.1rem; color: var(--gold); }
.bm-armor-class { font-size: 0.78rem; color: var(--text-dim); font-style: italic; }
.bm-bonus-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.bm-chip {
  background: rgba(255,200,60,0.12);
  border: 1px solid rgba(255,200,60,0.3);
  color: var(--gold); font-size: 0.68rem;
  padding: 2px 7px; border-radius: 20px;
}
.bm-quest-banner {
  background: rgba(255,200,60,0.1);
  border: 1px solid rgba(255,200,60,0.35);
  border-radius: var(--radius);
  padding: 8px 12px; font-size: 0.78rem; color: var(--text); line-height: 1.5;
}
.bm-section { display: flex; flex-direction: column; gap: 8px; }
.bm-section h4 {
  font-family: "Cinzel", serif; font-size: 0.76rem;
  color: var(--gold); text-transform: uppercase;
  letter-spacing: 0.04em; margin: 0;
}
.bm-weapon-list { display: flex; flex-direction: column; gap: 5px; }
.bm-weapon-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 10px 5px 5px;
}
.bm-card-thumb { width: 44px; height: auto; border-radius: 4px; flex-shrink: 0; cursor: zoom-in; }
.bm-weapon-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bm-weapon-name { font-size: 0.78rem; color: var(--text); font-weight: 600; }
.bm-note        { font-size: 0.68rem; color: var(--text-dim); font-style: italic; }
.bm-quest-tag {
  background: var(--gold); color: #000;
  font-size: 0.6rem; padding: 1px 5px; border-radius: 3px;
  font-weight: 700; margin-left: 4px; vertical-align: middle;
}
.bm-dmg-badge { display: flex; align-items: center; gap: 4px; flex-shrink: 0; font-size: 0.82rem; }
.bm-dmg-base  { color: var(--text-dim); }
.bm-dmg-arrow { color: var(--text-dim); font-size: 0.7rem; }
.bm-dmg-total { color: var(--gold); font-weight: 700; font-size: 1rem; }
.bm-enh-group { display: flex; flex-direction: column; gap: 4px; }
.bm-enh-label { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; }
.bm-pet-list  { display: flex; flex-direction: column; gap: 6px; }
.bm-pet-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 10px 5px 5px;
}
.bm-pet-label { font-size: 0.75rem; color: var(--text); line-height: 1.4; }

/* ── Build modal: compact image strip ── */
.bm-thumb-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.bm-thumb-strip .bm-card-thumb { width: 62px; }

/* ── Playbook card zoom popup ────────────────────────────────── */
#pbCardZoom {
  position: fixed;
  z-index: 800;
  pointer-events: none;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.85);
}
#pbCardZoom img {
  width: 190px;
  height: auto;
  display: block;
  border-radius: 5px;
}
#pbCardZoomInfo {
  padding: 6px 4px 2px;
  font-size: 0.72rem;
  color: var(--text);
  text-align: center;
  line-height: 1.45;
  max-width: 190px;
}
#pbCardZoomInfo .zoom-dmg  { color: var(--gold); font-weight: 700; display: block; }
#pbCardZoomInfo .zoom-note { color: var(--text-dim); font-style: italic; font-size: 0.66rem; display: block; }
#pbCardZoom.hidden { display: none; }

/* Discard tips */
.pb-tips { display: flex; flex-direction: column; gap: 6px; }
.pb-tip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.5;
}
.pb-tip-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.rules-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rules-header h2 { margin: 0; font-size: 1.1rem; }

.rules-body {
  overflow-y: auto;
  padding: 16px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rules-section h3 {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  color: var(--gold);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rules-section h4 {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 8px 0 4px;
  font-weight: 600;
}
.rules-section p,
.rules-section li {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
}
.rules-section ul {
  padding-left: 18px;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 6px;
}
.rules-table th {
  color: var(--gold-dim);
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.rules-table td {
  padding: 5px 8px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
}
.rules-table td:first-child { color: var(--text-dim); white-space: nowrap; }

/* ── Battle zone ─────────────────────────────────────────────── */
.battle-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  background: radial-gradient(ellipse at center, rgba(40,30,15,0.7) 0%, var(--bg) 70%);
  border-top: 1px solid rgba(200,168,75,0.12);
  border-bottom: 1px solid rgba(200,168,75,0.12);
  position: relative;
  min-height: 0;
}

.battle-cards {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-slot {
  width: 80px;
  height: 110px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  flex-shrink: 0;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

@media (hover: hover) {
  .battle-slot:has(img):hover {
    border-style: solid;
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(0,0,0,0.6);
    z-index: 10;
    overflow: visible;
  }
  .atk-slot:has(img):hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(200,168,75,0.4); }
  .blk-slot:has(img):hover { border-color: #5a8aaa; }
  .ctr-slot:has(img):hover { border-color: var(--red); box-shadow: 0 6px 18px rgba(180,50,50,0.4); }
}

.battle-slot img {
  width: 100%;
  display: block;
}

.atk-slot { border-color: var(--gold-dim); overflow: visible; position: relative; }
.blk-slot { border-color: #3a5a7a; }
.ctr-slot { border-color: var(--red); }

.ctr-arrow {
  font-size: 0.85rem;
  color: var(--red);
  opacity: 0.8;
  flex-shrink: 0;
  display: none;
}

/* Hidden by default; shown when .ctr-active is added to #battleCards */
#ctrSlot { display: none; }
#battleCards.ctr-active .ctr-arrow,
#battleCards.ctr-active #ctrSlot { display: flex; }

.vs-divider {
  font-family: "Cinzel", serif;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.enh-strip { display: none; }

.enh-stack-card {
  position: absolute;
  top: 0;
  width: 80px;
  height: 110px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.enh-stack-card:hover {
  box-shadow: 0 0 0 2px var(--gold-dim);
}

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

.phase-pill {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Cinzel", serif;
  font-size: 0.65rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
  z-index: 5;
}

.phase-pill.phase-action   { border-color: var(--gold);  color: var(--gold); }
.phase-pill.phase-response { border-color: var(--blue);  color: var(--blue); }
.phase-pill.phase-counter  { border-color: var(--red);   color: var(--red);  }
.phase-pill.phase-resolve  { border-color: var(--green); color: var(--green); }

.damage-pop {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Cinzel", serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--red);
  text-shadow: 0 0 10px rgba(200,75,75,0.8);
  animation: pop-in 0.35s ease;
  pointer-events: none;
}

@keyframes pop-in {
  0%   { transform: translateY(-50%) scale(0.4); opacity: 0; }
  60%  { transform: translateY(-50%) scale(1.15); opacity: 1; }
  100% { transform: translateY(-50%) scale(1); }
}

/* ── Action bar ──────────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.action-who {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-right: 4px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-timer {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
  transition: color 0.3s;
}

.turn-timer.urgent {
  color: var(--red);
  font-weight: 700;
  animation: timer-pulse 0.6s ease infinite alternate;
}

@keyframes timer-pulse {
  from { opacity: 1; }
  to   { opacity: 0.45; }
}

/* ── Buttons (game-specific overrides) ───────────────────────── */
.btn-dim {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
}

.btn-dim:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--gold-dim);
  color: var(--text);
  filter: none;
}

.btn-gold {
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
}

/* ── Event log ───────────────────────────────────────────────── */
.event-log {
  background: var(--bg-alt);
  overflow-y: auto;
  padding: 6px;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.log-item {
  color: var(--text-dim);
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1.4;
  animation: fade-in 0.2s ease;
}

.log-item.highlight {
  color: var(--gold);
  background: rgba(200,168,75,0.07);
}

.log-item.dmg {
  color: var(--red);
}

.log-item.heal {
  color: var(--green);
}

.log-item.quest {
  color: var(--gold);
  font-weight: 700;
}

.log-item.error {
  color: var(--red);
  background: rgba(200,75,75,0.1);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Card popup ──────────────────────────────────────────────── */
.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 190;
}

.card-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg);
  padding: 16px;
  z-index: 200;
  width: min(380px, 94vw);
  box-shadow: var(--shadow), 0 0 24px rgba(200,168,75,0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.popup-header img {
  width: 200px;
  height: 275px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.popup-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.popup-name {
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.3;
}

.popup-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.popup-special {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
  overflow-y: auto;
  max-height: 90px;
}

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

.popup-actions .btn-dim {
  flex: 1 1 auto;
  text-align: center;
}

.popup-cancel {
  align-self: flex-end;
  margin-top: -4px;
}

.popup-no-actions {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}

.popup-counter-warn {
  display: block;
  font-size: 0.72rem;
  color: var(--gold);
  background: rgba(200, 160, 0, 0.08);
  border: 1px solid rgba(200, 160, 0, 0.3);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
}

/* ── Discard picker / discard view ─────────────────────────── */

/* "Discard: N" part of deck-count is clickable */
.deck-count-discard {
  cursor: pointer;
  color: var(--text-dim);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.deck-count-discard:hover { color: var(--gold); }

/* Discard view grid: images are hover-zoomable but not selectable */
.discard-view-grid .card { cursor: default; }
.discard-view-grid .card:hover { border-color: var(--gold); }

/* Empty state */
.discard-view-empty {
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 20px 0;
  text-align: center;
  width: 100%;
}

.discard-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg);
  padding: 14px;
  z-index: 200;
  width: min(560px, 96vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow), 0 0 24px rgba(200,168,75,0.12);
}

.discard-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
}

.discard-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.discard-picker-grid .card {
  width: 72px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.discard-picker-grid .card:hover {
  border-color: var(--gold);
}

/* ── Full-screen overlays ────────────────────────────────────── */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,18,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

/* Start screen: SWF faixa no topo, dialog translúcido por cima */
#startScreen {
  background: transparent;
  align-items: center;
  justify-content: center;
}

#startScreen .dialog-box {
  background: rgba(10,10,18,0.72);
  border: 1px solid rgba(200,160,60,0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

.swf-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: 950 / 400;
  z-index: 0;
  overflow: hidden;
  background: #000;
  transform: scale(1.3);
  transform-origin: center center;
}

.swf-bg object {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.swf-bg.swf-ready object,
.swf-bg.swf-ready ruffle-embed {
  opacity: 1;
}

/* Logo overlay sobre o SWF sem estar embutido (mais leve).
   Oculto por padrão — aparece com fade quando o Ruffle terminar de carregar.
   O .swf-bg tem scale(1.3) com transform-origin center; o logo é filho dele,
   então também é escalado. left/top são relativos ao layout box do pai.
   Ajuste --swf-logo-top e --swf-logo-height para fine-tuning. */
.swf-logo-overlay {
  position: absolute;
  left: var(--swf-logo-left, 12%);
  top: var(--swf-logo-top, 24%);
  height: var(--swf-logo-height, 45%);
  width: auto;
  z-index: 1;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.9)) drop-shadow(0 0 16px rgba(0,0,0,0.7));
}
.swf-logo-overlay.swf-logo-visible {
  opacity: 1;
}

.dialog-box {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 280px;
  max-width: 660px;
  width: 100%;
}

/* Área dos controles: estreita e centralizada */
.menu-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 340px;
  width: 100%;
  margin: 24px auto 0;
}

.dialog-box h1 { font-size: 1.6rem; }
.dialog-box .dim { color: var(--text-dim); font-size: 0.85rem; }

/* ── Cover banner (start screen) ───────────────────────────── */
.cover-banner {
  position: relative;
  width: calc(100% + 64px);   /* bleed over dialog padding */
  margin: -32px -32px 0 -32px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  min-height: 140px;
  background: #1a0d05;
}

/* Art loaded via CSS var — no broken-image icon possible */
.cover-banner {
  background-image: var(--cover-img, none);
  background-size: cover;
  background-position: center 20%;
}

/* Gradient so text is always readable over the art */
.cover-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(10,8,4,0.15) 0%,
    rgba(10,8,4,0.55) 60%,
    rgba(10,8,4,0.85) 100%
  );
  pointer-events: none;
}

.cover-banner-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 1;
  padding: 16px;
  text-align: center;
}

.cover-title {
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9), 0 0 24px rgba(200,150,30,0.5);
  line-height: 1.1;
}

.cover-subtitle {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #e8d8b0;
  text-shadow: 0 1px 6px rgba(0,0,0,0.95);
}

/* Fallback when image is missing */
.cover-banner--no-img {
  background: linear-gradient(160deg, #2a1208 0%, #150d22 60%, #0e0a18 100%);
  min-height: 160px;
}

.cover-banner--no-img::after {
  background: none;
}

.name-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  text-align: center;
}

.name-input:focus { border-color: var(--gold-dim); }

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Highlight whose zone is active */
.zone-active { background: rgba(200,168,75,0.04); }

/* ── Online mode UI ──────────────────────────────────────────── */
.online-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.divider-or {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-code-input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.room-code {
  font-size: 2.2rem;
  letter-spacing: 0.3em;
  padding: 12px 24px;
  background: var(--bg);
  border: 2px solid var(--gold-dim);
  border-radius: var(--radius);
  align-self: center;
  user-select: all;
}

.dialog-box .small { font-size: 0.75rem; }

.resume-code {
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.quick-match-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.quick-match-label input[type="checkbox"] {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.btn-blue {
  background: rgba(123,179,212,0.12);
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-blue:hover:not(:disabled) {
  background: rgba(123,179,212,0.22);
}

.btn-bot {
  background: rgba(100,180,100,0.1);
  border: 1px solid #5aaa5a;
  color: #7aca7a;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-bot:hover:not(:disabled) {
  background: rgba(100,180,100,0.22);
}

.btn-tutorial {
  background: rgba(138,43,226,0.1);
  border: 1px solid #9b59b6;
  color: #c07ee8;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-tutorial:hover:not(:disabled) {
  background: rgba(138,43,226,0.22);
}

.btn-sandbox {
  background: rgba(255,180,0,0.1);
  border: 1px solid #b8860b;
  color: #f0c040;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-sandbox:hover:not(:disabled) {
  background: rgba(255,180,0,0.22);
}
.btn-sandbox:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Sandbox modal ─────────────────────────────────────────── */
.sandbox-box {
  width: min(820px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.sandbox-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 6px;
  flex-shrink: 0;
}
.sandbox-toolbar .name-input {
  flex: 1;
  min-width: 0;
}
.sandbox-options {
  display: flex;
  gap: .75rem;
  padding: .2rem .1rem .5rem;
  font-size: .8rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.sb-opt-label {
  display: flex;
  align-items: center;
  gap: .3rem;
  cursor: pointer;
  color: #d4b96a;
  user-select: none;
}
.sb-opt-label input[type=checkbox] { accent-color: #c9a227; cursor: pointer; }
.sb-target-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .1rem .1rem .35rem;
  flex-shrink: 0;
}
.sb-target-label { font-size: .78rem; color: #888; white-space: nowrap; }
.sb-target-btn {
  font-size: .78rem;
  padding: .2rem .65rem;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.05);
  color: #888;
  cursor: pointer;
  transition: all .15s;
}
#sbTargetP1.active { background: rgba(240,192,64,.15); border-color: #c9a227; color: #f0c040; }
#sbTargetP2.active { background: rgba(220,80,60,.15); border-color: #d04830; color: #ff8070; }
.sb-p2-sel .sb-chip { background: rgba(200,60,50,.15); border: 1px solid rgba(200,80,70,.5); color: #ff9070; }
.sb-p2-sel .sb-chip:hover { background: rgba(220,80,60,.25); border-color: #c04030; color: #ff6050; }
.sandbox-card.sel-p2   { outline: 2px solid #e05040; border-radius: 4px; opacity: 1; }
.sandbox-card.sel-both { outline: 2px solid #f0c040; box-shadow: 0 0 0 3px #e05040; border-radius: 4px; opacity: 1; }
.sandbox-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  padding: 4px 0 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.sandbox-selected .sb-chip {
  background: rgba(255,180,0,0.15);
  border: 1px solid #b8860b;
  color: #f0c040;
  font-size: 0.72rem;
  padding: 2px 8px 2px 6px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sandbox-selected .sb-chip:hover { background: rgba(255,100,100,0.2); border-color: #c0504040; color: #f08080; }
.sandbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 90px);
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding: 4px 2px 8px;
}
.sandbox-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.1s, transform 0.1s;
}
.sandbox-card:hover { opacity: 1; transform: translateY(-2px); }
.sandbox-card.selected { outline: 2px solid #f0c040; border-radius: 4px; opacity: 1; }
.sandbox-card.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.sandbox-card img { width: 90px; border-radius: 4px; display: block; }
.sandbox-card .sb-label {
  font-size: 0.62rem;
  color: #aaa;
  text-align: center;
  margin-top: 3px;
  line-height: 1.2;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-fullscreen {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  z-index: 600;
  background: rgba(14,10,28,0.55);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  opacity: 0.5;
}
.btn-fullscreen:hover {
  background: rgba(14,10,28,0.85);
  color: var(--gold);
  border-color: var(--gold-dim);
  opacity: 1;
}

.fullscreen-ios-hint {
  position: fixed;
  top: 44px;
  right: 8px;
  z-index: 700;
  background: rgba(14,10,28,0.95);
  border: 1px solid var(--gold-dim);
  color: var(--text);
  font-size: 0.75rem;
  padding: 10px 14px;
  border-radius: var(--radius);
  max-width: 220px;
  text-align: center;
  pointer-events: none;
  animation: fsHintFade 5s ease forwards;
}

@keyframes fsHintFade {
  0%   { opacity: 0; transform: translateY(-4px); }
  10%  { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

.btn-quit {
  background: transparent;
  border: 1px solid #7a3a3a;
  color: #b06060;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  margin-left: auto;
}

.btn-quit:hover {
  background: rgba(180,60,60,0.18);
  color: #e08080;
  border-color: #b06060;
}

/* ─── Tutorial panel ─────────────────────────────────── */

.tutorial-panel {
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14,10,28,0.97);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 440px;
  width: calc(100% - 32px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6), 0 0 0 1px rgba(212,175,55,0.15);
}

.tutorial-step-heading {
  font-family: 'Cinzel', serif;
  font-size: 0.88rem;
  color: var(--gold);
  font-weight: 700;
}

.tutorial-step-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tutorial-step-text strong {
  color: #e8d5a0;
}

.tutorial-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  justify-content: flex-end;
  align-items: center;
}

/* Pulsing glow applied to highlighted elements */
@keyframes tutorialPulse {
  0%,100% { box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(212,175,55,0.4); }
  50%      { box-shadow: 0 0 0 4px var(--gold), 0 0 22px rgba(212,175,55,0.8); }
}

.tutorial-highlight {
  animation: tutorialPulse 1.2s ease-in-out infinite;
  border-radius: 6px;
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE  ≤ 600px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Bloqueia seleção de texto e callout em toda a tela do jogo no mobile */
  body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: pan-x pan-y; /* bloqueia pinch-zoom no nivel do browser */
  }

  /* Board: single column, 4 rows. Battle zone fills all middle space. */
  .board {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
  }
  /* Prevent grid items from expanding beyond 1fr track (min-width:auto default) */
  .zone-p2, .battle-zone, .zone-p1, .action-bar { min-width: 0; }
  .zone-p2     { grid-column: 1; grid-row: 1; }
  .battle-zone { grid-column: 1; grid-row: 2; }
  .zone-p1     { grid-column: 1; grid-row: 3; }
  .action-bar  { grid-column: 1; grid-row: 4; }

  /* Right panel: hidden in mobile (log accessible via popup) */
  #rightPanel { display: none; }

  /* Botões de ação ficam ocultos no mobile (interação via ghost card) */
  .card .card-actions { display: none !important; }

  /* Remove transição de transform no mobile: carta volta ao lugar instantaneamente ao soltar */
  /* touch-action:none: impede o browser de interpretar toque na carta como scroll */
  .card {
    transition: border-color 0.15s, box-shadow 0.15s;
    touch-action: none;
  }
  /* Imagens dentro de cartas: sem drag, sem seleção, sem callout */
  .card img {
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    user-drag: none;
  }

  /* Player zones: flex-column no mobile (hand + mob-info empilhados) */
  .player-zone {
    padding: 0;
    gap: 0;
    flex-direction: column;
    align-items: stretch;
  }
  .player-zone .player-info { display: none; }
  /* Mobile hand: horizontal scroll.
     padding-top: 16px cria espaço interno (padding box) para o card-zoomed
     usar translateY(-8px) scale(1.1) sem clipar — overflow-x:auto força
     overflow-y a ser auto (CSS spec), então compensamos com padding. */
  .hand-row {
    touch-action: pan-x;
    flex: 1;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    padding: 16px 6px 4px;
  }

  /* Battle zone: coluna vertical (mob-info-p2 → arena → mob-info-p1) */
  .battle-zone {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
  }
  /* Center column: full width, column */
  .battle-zone-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 4px 0;
    gap: 4px;
    position: relative;
  }

  /* Mobile info bars: barra horizontal full-width, colada na mão */
  .mob-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
    padding: 4px 8px;
    gap: 6px;
    border: none;
    background: var(--bg-alt);
    overflow: hidden;
  }
  /* P2 mob-info: borda inferior (separa da arena abaixo) */
  #mob-info-p2 {
    border-bottom: 1px solid var(--border);
  }
  /* P1 mob-info: borda superior (separa da arena acima) */
  #mob-info-p1 {
    border-top: 1px solid var(--border);
  }
  .mob-info-name {
    font-size: 0.6rem;
    color: var(--gold);
    font-family: "Cinzel", serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62px;
  }
  .mob-info-hp-row {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
  }
  .mob-info-hp-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
  }
  .mob-info-hp-bar {
    height: 100%;
    background: linear-gradient(90deg, #4bc870, #3aa05a);
    transition: width 0.4s ease, background 0.4s ease;
  }
  .mob-info-hp-bar.low { background: linear-gradient(90deg, var(--red), #a03a3a); }
  .mob-info-hp-bar.mid { background: linear-gradient(90deg, #c8a84b, #9a7a30); }
  .mob-info-hp-num {
    font-size: 0.6rem;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
  }
  .mob-info-equip {
    display: flex;
    flex-direction: row;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
  }
  .mob-info-slot {
    width: 38px;
    height: 52px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
  }
  .mob-info-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .mob-info-slot .slot-lbl {
    font-size: 8px;
    color: var(--text-dim);
  }

  /* Cards: menores no mobile + sobreposição para caber 8 na mão */
  .hand-row .card        { margin-right: -26px; }
  .hand-row .card:last-child { margin-right: 0; }
  .card           { width: 68px; }
  .card.card-back { height: 94px; } /* 68 × 1.38 */

  /* Battle slots: tamanho de carta da mão */
  .battle-slot { width: 68px; height: 94px; }

  /* Battle cards: linha horizontal (padrão) */
  .battle-cards {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }

  /* Phase pill: in-flow no mobile */
  .phase-pill {
    position: static;
    transform: none;
    align-self: center;
    margin: 2px 0;
  }

  /* VS divider: separador da arena */
  .vs-divider {
    font-size: 0.8rem;
  }

  /* Equip slots */
  .equip-slot { width: 36px; height: 50px; }
  .slot-lbl   { font-size: 7px; }

  /* Mob-info equip slots: 75% do tamanho da carta da mão (68×94 × 0.75 ≈ 51×71) */
  .mob-info-slot { width: 51px; height: 71px; }

  /* Action bar: single row of buttons (no wrap) — action-who hidden on mobile */
  .action-who { display: none; }
  .turn-timer {
    flex: 0 0 38px;
    text-align: right;
    font-size: 0.7rem;
    min-width: 0;
  }
  .action-bar {
    padding: 4px 6px;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
  }
  .btn-dim, .btn-gold, .btn-blue {
    flex: 1 1 0;
    min-height: 34px;
    padding: 4px 4px;
    font-size: 0.68rem;
    text-align: center;
  }
  .btn-quit {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 4px 8px;
    font-size: 0.7rem;
    margin-left: 0;
  }

  /* Card popup */
  .card-popup { width: min(340px, 96vw); padding: 12px; }
  .popup-header img { width: 150px; height: 207px; }

  /* Discard picker: full-width, smaller cards */
  .discard-picker { width: 96vw; }
  .discard-picker-grid .card { width: 62px; }

  /* Dialog boxes: full width */
  .dialog-box { min-width: 0; width: 92vw; max-width: none; padding: 20px; }
  .menu-form { max-width: 100%; margin-top: 18px; }
  .room-code  { font-size: 1.6rem; letter-spacing: 0.2em; padding: 8px 16px; }

  /* Sandbox: smaller grid */
  .sandbox-grid {
    grid-template-columns: repeat(auto-fill, 80px);
  }
  .sandbox-card img       { width: 80px; }
  .sandbox-card .sb-label { max-width: 80px; }
}

/* ── Rotate overlay (mobile landscape blocker) ──────────────── */
#rotateOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #0a0a14;
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
#rotateOverlay .rotate-icon {
  font-size: 3rem;
  animation: rotate-hint 1.8s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%   { transform: rotate(0deg); }
  40%  { transform: rotate(90deg); }
  60%  { transform: rotate(90deg); }
  100% { transform: rotate(90deg) scale(1.05); }
}
/* Show only on mobile-sized screens in landscape */
@media (orientation: landscape) and (max-height: 600px) {
  #rotateOverlay { display: flex; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE LANDSCAPE  — short-height screens (≤ 430px tall)
   Keep desktop 2-column layout but shrink everything vertically.
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 430px) and (orientation: landscape) {
  .board {
    grid-template-columns: 1fr 180px;
    grid-template-rows: auto 1fr auto auto;
    height: 100dvh;
  }
  #rightPanel { grid-column: 2; grid-row: 1 / 5; }
  #cardHoverSlot { height: 160px; }

  .player-zone { padding: 2px 6px; gap: 4px; }
  .player-info { min-width: 70px; gap: 2px; }
  .hp-wrap     { width: 64px; height: 10px; }
  .equip-slot  { width: 30px; height: 42px; }
  .card        { width: 58px; }
  .card.card-back { height: 80px; }
  .battle-zone { padding: 2px 6px; }
  .battle-slot { width: 48px; height: 66px; }
  .action-bar  { padding: 2px 8px; gap: 3px; }
  .btn-dim, .btn-gold, .btn-blue { min-height: 28px; padding: 2px 6px; font-size: 0.67rem; }
  .btn-quit    { min-height: 28px; padding: 2px 8px; font-size: 0.67rem; }
}

/* ── Simple pause overlay (vs Bot + Online — freeze only) ───── */

.simple-pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 340;
  display: flex;
  align-items: center;
  justify-content: center;
}
.simple-pause-overlay.hidden { display: none; }

.sp-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 40px;
  text-align: center;
}
.sp-section.hidden { display: none; }

.sp-heading {
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  color: var(--gold);
  margin: 0;
}
.sp-sub {
  font-size: 0.8rem;
  color: var(--dim);
  margin: 0;
}
.sp-actions {
  display: flex;
  gap: 12px;
}

/* ── Inspector overlay (sandbox / bot-vs-bot pause) ─────────── */

.inspector-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 350;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.inspector-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  flex-shrink: 0;
}

.inspector-header h2 {
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  color: var(--gold);
  margin: 0;
  flex: 1;
}

.inspector-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.inspector-col {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--border);
}

.inspector-col:last-child { border-right: none; }

.inspector-col-title {
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.inspector-zone {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inspector-zone-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inspector-hp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inspector-hp-row input[type="number"] {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 3px 6px;
  font-size: 0.88rem;
  text-align: center;
  font-family: "Cinzel", serif;
  outline: none;
}

.inspector-hp-row input[type="number"]:focus {
  border-color: var(--gold-dim);
}

.inspector-slot-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.inspector-slot-name {
  font-size: 0.77rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-slot-name.empty {
  color: var(--text-dim);
  font-style: italic;
}

.inspector-btn {
  font-size: 0.67rem;
  padding: 2px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.12s, color 0.12s;
}

.inspector-btn:hover {
  border-color: var(--gold-dim);
  color: var(--text);
}

.inspector-btn.danger {
  border-color: rgba(200, 75, 75, 0.4);
  color: #c87878;
}

.inspector-btn.danger:hover {
  background: rgba(200, 75, 75, 0.12);
  border-color: var(--red);
  color: var(--red);
}

.inspector-btn.primary {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.inspector-btn.primary:hover {
  background: rgba(200, 168, 75, 0.1);
}

.inspector-hand-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.inspector-card-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 5px;
  border-radius: 3px;
  background: var(--bg);
}

.inspector-card-row:hover { background: var(--bg-card); }

.inspector-card-name {
  flex: 1;
  font-size: 0.72rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Inspector card picker */
.inspector-picker {
  position: fixed;
  inset: 0;
  z-index: 450;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}

.inspector-picker.hidden { display: none; }

.inspector-picker-box {
  background: var(--bg-card);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-lg);
  padding: 14px;
  width: min(640px, 96vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow), 0 0 24px rgba(200, 168, 75, 0.12);
}

.inspector-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.inspector-picker-search {
  flex: 1;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 4px 10px;
  outline: none;
  font-family: inherit;
}

.inspector-picker-search:focus { border-color: var(--gold-dim); }

.inspector-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.inspector-picker-grid .card {
  width: 72px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.inspector-picker-grid .card:hover {
  border-color: var(--gold);
}
