/* overlays.css — modals, target banner, scry, mulligan, game over, discard */

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(4, 7, 18, 0.78); backdrop-filter: blur(3px);
}
.modal {
  position: relative;   /* anchors the corner close (×) button */
  background: linear-gradient(160deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--gold); border-radius: 16px;
  box-shadow: var(--shadow); padding: 22px 26px;
  max-width: min(880px, 92vw); max-height: 90vh; overflow-y: auto;
}
.modal.narrow { max-width: 420px; }
.modal.wide { max-width: min(1000px, 94vw); }
.modal.center { text-align: center; }

/* Card-selection dialogs dock to the left so the hover preview stays visible on
   the right (see #card-preview). The dialog is width-capped to keep the right
   side of the screen clear for the enlarged card. */
/* Card-selection dialogs sit just to the LEFT of the fixed hover preview, with a
   ~25px gap, so the dialog and the enlarged card read as a pair and the player's
   eye barely moves. The preview spans 360px ending 320px from the right edge
   (left edge = 100vw − 680px); the dialog's right edge lands 25px before it. */
.modal-overlay.dock-left { justify-content: flex-end; padding-right: calc(320px + 360px + 25px); }
.modal-overlay.dock-left > .modal { max-width: clamp(280px, calc(100vw - 721px), 880px); }
.modal-overlay.dock-left .card-grid,
.modal-overlay.dock-left .scry-list { justify-content: flex-start; max-width: 100%; }
.modal h1 { font-size: 2.2rem; color: var(--gold-bright); margin-bottom: 8px; }
.modal h2 { color: var(--gold-bright); margin-bottom: 8px; font-size: 1.25rem; }
.modal p { color: #cdd3ee; margin-bottom: 14px; line-height: 1.45; }
/* Leave room on the right so a long title never runs under the corner × button. */
.modal-head { display: flex; justify-content: space-between; align-items: center; padding-right: 28px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

.primary-btn {
  background: linear-gradient(180deg, var(--gold-bright), #c8941f); color: #2a1c00;
  border: none; border-radius: 9px; padding: 10px 22px; font-weight: 700; font-size: 0.95rem;
  box-shadow: var(--shadow);
}
.primary-btn:hover { filter: brightness(1.08); }
.ghost-btn {
  background: transparent; color: var(--parch);
  border: 1px solid var(--muted); border-radius: 9px; padding: 9px 18px; font-size: 0.9rem;
}
.ghost-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
/* Close (×) pinned to the modal's top-right corner, equal gap from top & right. */
.x-btn {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1; padding: 0 4px;
}
.x-btn:hover { color: var(--bad); }

/* Card grids (mulligan, discard) */
.card-grid {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  margin: 8px 0; max-width: 1040px;
}
.card-grid .card { width: 138px; height: 193px; cursor: pointer; transition: transform 0.12s; }
.card-grid .card:hover { transform: translateY(-8px); }
/* Mulligan: selected cards go to the BOTTOM of the deck → "↩ back". */
.card-grid .card.mull-selected { outline: 3px solid var(--bad); transform: translateY(-10px); }
.card-grid .card.mull-selected::after {
  content: '↩ back'; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  background: var(--bad); color: #fff; font-size: 0.72rem; padding: 2px 8px; border-radius: 8px;
}

/* Card-picker (openChoose): the selected card is the one you ACT ON. For most
   effects you KEEP/take it (the rest leave) → green "✓ keep"; for discard effects
   (e.g. Ransack) the selected card is the one you DISCARD → red "✗ discard". */
.card-grid .choose-card.picked { outline: 3px solid var(--good); transform: translateY(-10px); }
.card-grid .choose-card.picked::after {
  content: '✓ keep'; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  background: var(--good); color: #08210f; font-weight: 700; font-size: 0.72rem; padding: 2px 8px; border-radius: 8px;
}
#choose-grid.mode-discard .choose-card.picked { outline-color: var(--bad); }
#choose-grid.mode-discard .choose-card.picked::after { content: '✗ discard'; background: var(--bad); color: #fff; }

/* Target banner */
#target-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 14px; z-index: 70;
  background: linear-gradient(90deg, #6a1f1f, #3a1010);
  border: 1px solid var(--bad); border-radius: 30px; padding: 8px 18px;
  box-shadow: var(--shadow); color: #ffe3e3; font-size: 0.92rem;
}

/* Scry */
.scry-list { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.scry-item {
  width: 158px; border-radius: 12px; overflow: hidden;
  border: 2px solid transparent; background: var(--ink-0);
}
.scry-item.chosen { border-color: var(--gold-bright); box-shadow: 0 0 12px var(--gold); }
.scry-item img { width: 100%; display: block; }
.scry-ctl { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px; }
.scry-pos { font-size: 0.72rem; font-weight: 700; color: var(--gold-bright); min-width: 42px; }
.scry-ctl button { background: var(--ink-3); border: none; color: var(--parch); border-radius: 5px; padding: 2px 8px; }
.scry-item[data-uid] { cursor: pointer; }

#gameover .modal { padding: 36px 48px; }
