/* Shared single-player + multiplayer styles. Loaded by both
   cli/static/index.html and cli/static_mp/index.html *before*
   each mode's /static/style.css, so per-mode rules can override
   shared ones via normal CSS cascade. */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #1c1f24;
  color: #e8e8e8;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #0f1116;
  border-bottom: 1px solid #2a2e36;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { margin: 0; font-size: 16px; flex: 0 0 auto; }
header button {
  padding: 6px 12px;
  background: #3a82f7;
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
header button:hover:not(:disabled) { background: #2c6ad8; }
header button:disabled { opacity: 0.4; cursor: not-allowed; }
header button.danger { background: #e35d5d; }
header button.danger:hover:not(:disabled) { background: #b94646; }
#phase { color: #f6c14b; font-size: 14px; }
#phase-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

#root { padding: 16px; }


/* ----- Setup screen ----- */

.setup-wrap { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; }

.setup-section {
  background: #20242c;
  border-radius: 8px;
  padding: 16px;
}
.setup-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #cfd6e3;
}
.setup-section .muted {
  margin: 0 0 12px;
  font-size: 12px;
  color: #9aa3b1;
}

.setup-row {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.setup-row .character-desc {
  flex-basis: 100%;
  font-size: 12px;
  line-height: 1.5;
  margin: 4px 0 0;
  padding: 6px 8px;
  background: #1f242c;
  border-left: 3px solid #4a90e2;
  border-radius: 0 4px 4px 0;
}
.setup-row .character-desc strong { color: #e8e8e8; }
.setup-row label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #9aa3b1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  gap: 4px;
}
.setup-row input[type="text"], .setup-row select {
  background: #2a2f38;
  border: 1px solid #3a3f48;
  color: #e8e8e8;
  padding: 6px 8px;
  font: inherit;
  border-radius: 4px;
  min-width: 200px;
}

.setup-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.setup-btn {
  padding: 8px 16px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.setup-btn.primary { background: #3a82f7; color: white; }
.setup-btn.primary:hover { background: #2c6ad8; }
.setup-btn.secondary { background: #555f70; color: white; }
.setup-btn.secondary:hover { background: #6b7790; }
.setup-btn.tiny {
  padding: 4px 10px;
  background: #555f70;
  color: white;
  font-weight: normal;
  font-size: 12px;
}
.setup-btn.tiny:hover { background: #6b7790; }

.rarity-picker { margin-bottom: 14px; }
.rarity-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.rarity-count {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 8px;
  border-radius: 12px;
}
.rarity-count.ok  { background: #2e5a3e; color: #b9f0c9; }
.rarity-count.bad { background: #5a3636; color: #f0bdbd; }

.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px;
}
.set-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #2a2f38;
  border: 1px solid #3a3f48;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.set-cell.selected {
  background: #2e3950;
  border-color: #3a82f7;
}
.set-cell:hover { border-color: #6b7790; }


/* ----- Deckbuilding -----

   Layout is a top bar (stage controls + meta chips), an opponent strip,
   then a 2-column grid: shared market on the left, viewer panel sticky
   on the right. Cards in this phase render compact (160px) so the binder
   shows ~4 per row in the right column. Falls back to a single column
   under 1100px. */

.db-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meta-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  background: #20242c;
  border-radius: 8px;
  padding: 8px 12px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #2a2f38;
  border: 1px solid #3a3f48;
  border-radius: 999px;
  font-size: 11.5px;
  color: #cfd6e3;
}
.meta-chip.revealed { border-color: #6c8ec9; background: #2c3340; }
.meta-chip strong { color: #e6eaf2; font-weight: 700; }
.meta-chip-axis {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa3b1;
}
.meta-chip-rp { color: #f6c14b; font-weight: 600; font-size: 10.5px; }
.meta-chip-deck { color: #6b7180; font-size: 10px; }
.meta-chip.empty em { color: #6b7180; font-style: italic; }
/* Re-tint the left edge for revealed element chips, matching the card frame. */
.meta-chip.el-fire { border-left: 3px solid #ef5350; }
.meta-chip.el-water { border-left: 3px solid #4ea7ff; }
.meta-chip.el-earth { border-left: 3px solid #8d6e44; }
.meta-chip.el-air { border-left: 3px solid #a8d8b2; }
.meta-chip.el-light { border-left: 3px solid #f6c14b; }
.meta-chip.el-dark { border-left: 3px solid #6a4c93; }

.db-opponents {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.opp-strip-card {
  flex: 1 1 320px;
  min-width: 280px;
  background: #1a1d23;
  border: 1px solid #2a2e36;
  border-radius: 8px;
  padding: 8px 12px;
}
.opp-strip-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #b9bfca;
}
.opp-strip-head .opp-name {
  font-weight: 700;
  color: #e8e8e8;
  margin-right: 4px;
}
.opp-toggle {
  margin-left: auto;
  background: transparent;
  border: 1px solid #3a3f48;
  color: #cfd6e3;
  font: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.opp-toggle:hover { background: #2a2f38; }
.opp-strip-card .cards { margin-top: 8px; }

.db-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 16px;
  align-items: start;
}
.db-market {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.db-viewer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.db-viewer .player {
  margin: 0;
  min-width: 0;
}

/* Compact card width inside the deckbuilding screen. The store/fusion grids
   override their own slot widths via flex/grid sizing, so this only affects
   binder, deck, aftermarket, and collection cards. */
.db-wrap .binder-card,
.db-wrap .deck-card,
.db-wrap .am-cell .card {
  width: 190px;
}
/* Shorter fixed height for the compact deckbuilding cards — matches the
   narrower width so the aspect ratio stays close to a physical MB card. */
.db-wrap .card { height: 275px; }

@media (max-width: 1100px) {
  .db-grid { grid-template-columns: 1fr; }
  .db-viewer {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 600px) {
  header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  header h1 { width: 100%; }
  #phase {
    flex: 1 1 100%;
    min-width: 0;
  }
  #phase-controls {
    margin-left: 0;
    flex-wrap: wrap;
  }
  #root { padding: 8px; }
  .db-zone { padding: 10px; }
  .top-btn { min-width: 0; }
}

.db-zone {
  background: #20242c;
  border-radius: 8px;
  padding: 12px 16px;
}
.db-zone h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cfd6e3;
}
.db-zone h2 small { color: #9aa3b1; font-size: 11px; text-transform: none; letter-spacing: 0; margin-left: 8px; }

.store-area {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.slot-cell { display: flex; }
/* Store-area face-down cards only show $cost + set name, so they don't
   need the full card height. Override the deckbuilding default and scale
   the cost/set fonts down to keep the 3x3 grid compact. */
.slot-cell .card { flex: 1; width: auto; min-width: 0; height: 110px; }
.slot-cell .face-down .card-body { padding: 6px 6px; }
.slot-cell .face-down .back-cost { font-size: 20px; }
.slot-cell .face-down .back-set { font-size: 11px; margin-top: 3px; }
.slot-cell .face-down .card-banner { padding: 3px 6px; min-height: 22px; }
.slot-cell .face-down .card-name { font-size: 11px; }
.slot-cell .face-down .card-footer { padding: 2px 6px; font-size: 9px; }
.slot-cell.empty {
  border: 1px dashed #3a3f48;
  color: #6b7180;
  font-size: 12px;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 600px) {
  .store-area { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.store-tops {
  display: flex;
  gap: 8px;
}
.top-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #2a2f38;
  border: 1px solid #3a3f48;
  border-radius: 6px;
  color: #e8e8e8;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.top-btn:hover:not(:disabled) {
  border-color: #f6c14b;
  background: #34394a;
}
.top-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.top-btn-label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b1;
  flex: 0 0 auto;
}
.top-btn-cost {
  font-size: 22px;
  font-weight: 800;
  color: #f6c14b;
  flex: 0 0 auto;
  min-width: 32px;
}
.top-btn-set {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #e8e8e8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-btn-remaining {
  font-size: 10.5px;
  color: #6b7180;
  flex: 0 0 auto;
}
.top-btn-empty {
  flex: 1;
  font-style: italic;
  color: #6b7180;
}

.db-players {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.collection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2a2f38;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #cfd6e3;
}
.collection-bar button {
  padding: 4px 10px;
  font-size: 12px;
  background: #3a82f7;
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.collection-bar button:disabled { opacity: 0.4; cursor: not-allowed; }


/* ----- Cards (shared between deckbuilding & tournament) -----

   The card frame mimics the physical Millennium Blades card layout:
   - .card-banner: element-themed top band with the star badge and name
   - .card-typeline: type · element row just below the banner
   - .card-body: framed effect blocks (one per trigger)
   - .card-runtime / .card-price: optional overlay strip for runtime state
   - .card-footer: set name + rarity badge, pinned to the bottom

   The same frame is used everywhere a .card is rendered (binder, deck,
   hand, arena, deckbox, store/aftermarket, collection). Per-zone classes
   like .hand-card or .arena-card layer behavior on top. */

.cards {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: #20242c;
  border: 1px solid #3a3f48;
  border-radius: 8px;
  width: 240px;
  height: 340px;
  display: flex;
  flex-direction: column;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
  /* So the embossed banner reads as part of the card edge. */
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4) inset, 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* ----- Top banner (name + star) ----- */
.card-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #4a5160, #353c48);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  color: #f4f6fa;
  min-height: 32px;
}
.card-name {
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.15;
  flex: 1;
  /* Long names wrap to a second line rather than truncate, so the player
     can still read the whole thing — physical cards wrap too. */
  word-break: break-word;
}

/* ----- Star badge (single star with number inside) -----

   The star shape lives on a ::before pseudo-element so the clip-path
   only crops the gold fill — the digit on top is rendered in normal
   flow and isn't clipped by the star's inner valleys (which would chop
   the tops/sides of glyphs). */
.star-badge {
  flex: 0 0 auto;
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 12px;
  font-weight: 800;
  color: #1c1f25;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.star-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 35% 30%, #ffe27a 0%, #f4c33a 60%, #c79a18 100%);
  /* Geometrically correct 5-point star, outer R=50%, inner r≈19.1%,
     centered at (50%, 50%). The inner pentagon (where the digit sits)
     is centered at the box center. */
  clip-path: polygon(
    50% 0%, 61.23% 34.55%, 97.55% 34.55%, 68.16% 55.91%, 79.4% 90.45%,
    50% 69.1%, 20.6% 90.45%, 31.84% 55.91%, 2.45% 34.55%, 38.77% 34.55%
  );
  /* Two-stop drop-shadow gives the star a dark outline that reads on any
     banner color — without it, gold stars blend into earth/light banners. */
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.9))
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}
/* Earth and Light banners are themselves yellow/brown, so swap the star
   to a silver fill on those elements for a clean color contrast. */
.el-earth .star-badge::before,
.el-light .star-badge::before {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d8dde4 55%, #8a8f99 100%);
}
.star-badge.unknown::before {
  background: radial-gradient(circle at 35% 30%, #888 0%, #555 60%, #333 100%);
}
.star-badge.unknown {
  color: #e8e8e8;
  text-shadow: none;
}

/* ----- Type line ----- */
.card-typeline {
  font-size: 10.5px;
  color: #b6bdcc;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  background: #2a2f38;
  border-bottom: 1px solid #3a3f48;
}

/* ----- Body: stack of framed effect blocks ----- */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  flex: 1;
  /* The parent .card has a fixed height, so the body flexes to fill the
     remaining vertical space (banner + typeline + footer subtracted).
     Long effect text scrolls within the body via overflow-y. */
  min-height: 0;
  overflow-y: auto;
}
/* Image-bodied card: the scanned card art replaces the HTML effect blocks.
   We center the image inside the body with object-fit: contain so the whole
   card scan is visible regardless of zone size (240×340 hand frame, 275px
   deckbox, 110px slot strip). pointer-events:none on the img lets clicks
   reach the parent button. */
.card-body-image {
  padding: 0;
  background: #15171c;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-art {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.card-effect {
  background: #262b34;
  border: 1px solid #353c48;
  border-radius: 4px;
  padding: 4px 6px;
}
.card-effect.db {
  background: #232830;
  border-style: dashed;
}
.card-effect .trigger {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f6c14b;
  margin-bottom: 2px;
}
.card-effect.db .trigger { color: #9bb6ef; }
.card-effect .effect-text {
  font-size: 11px;
  line-height: 1.35;
  color: #d6dbe4;
  white-space: pre-wrap;
  word-break: break-word;
}
.card-flavor {
  font-size: 10.5px;
  font-style: italic;
  color: #9aa3b1;
  padding: 2px 2px 0;
  border-top: 1px dashed #353c48;
  margin-top: 2px;
}

/* ----- Runtime overlays (bonus power, tokens, AM seller note) ----- */
.card-runtime {
  font-size: 10.5px;
  color: #f6c14b;
  padding: 3px 8px;
  background: rgba(246, 193, 75, 0.08);
  border-top: 1px solid #3a3f48;
}
.card-runtime.tiny { font-size: 9.5px; opacity: 0.85; color: #b9bfca; }
.card-price {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #1f2630;
  color: #f6c14b;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid #3a3f48;
}
.card { position: relative; }

/* ----- Footer (set + rarity) ----- */
.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #1a1e25;
  border-top: 1px solid #3a3f48;
  font-size: 10px;
  margin-top: auto;
}
.card-footer .set-name {
  color: #cfd6e3;
  font-style: italic;
  letter-spacing: 0.02em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-footer .rarity {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 8px;
  background: #353c48;
  color: #cfd6e3;
  flex: 0 0 auto;
}
.rarity.rarity-starter   { background: #4a5160; color: #e8e8e8; }
.rarity.rarity-core      { background: #2c4d3a; color: #c8efd5; }
.rarity.rarity-expansion { background: #2c3f5a; color: #c8d8ef; }
.rarity.rarity-premium   { background: #4a3760; color: #d8c8ef; }
.rarity.rarity-master    { background: #5a3636; color: #f0bdbd; }
.rarity.rarity-bronze    { background: #6e3e1f; color: #f0c8a0; }
.rarity.rarity-silver    { background: #4a4a4a; color: #e0e0e0; }
.rarity.rarity-gold      { background: #6e591f; color: #f0dca0; }

/* ----- Element-themed banners -----

   Each element gets its own banner background. Duals use a horizontal
   gradient that splits the two parents, matching how the physical cards
   ink the frame. The card body / footer stay neutral so effect text
   remains readable across the deck. */
.el-fire .card-banner  { background: linear-gradient(180deg, #c44539, #8a2a22); }
.el-water .card-banner { background: linear-gradient(180deg, #3777b8, #234a7d); }
.el-earth .card-banner { background: linear-gradient(180deg, #8d6e44, #5e472a); }
.el-air .card-banner   { background: linear-gradient(180deg, #4a8e5a, #2c5a38); }
.el-light .card-banner { background: linear-gradient(180deg, #c79a3a, #8c6a1f); color: #1c1f25; }
.el-light .card-name   { color: #1c1f25; }
.el-dark .card-banner  { background: linear-gradient(180deg, #574067, #2f2342); }
.el-dual-water-fire .card-banner {
  background: linear-gradient(90deg, #3777b8 0%, #6a4f73 50%, #c44539 100%);
}
.el-dual-light-air .card-banner {
  background: linear-gradient(90deg, #c79a3a 0%, #88924a 50%, #4a8e5a 100%);
}

/* Also tint the left edge subtly so face-down or no-element neighbours
   still read as different from element cards in zone overviews. */
.el-fire  { border-left: 3px solid #ef5350; }
.el-water { border-left: 3px solid #4ea7ff; }
.el-earth { border-left: 3px solid #8d6e44; }
.el-air   { border-left: 3px solid #a8d8b2; }
.el-light { border-left: 3px solid #f6c14b; }
.el-dark  { border-left: 3px solid #6a4c93; }
.el-dual-water-fire { border-left: 3px solid #a4647a; }
.el-dual-light-air  { border-left: 3px solid #d4b378; }

/* ----- Zone-specific behavior ----- */
.hand-card { color: inherit; cursor: pointer; }
.hand-card:disabled { cursor: not-allowed; opacity: 0.5; }
.hand-card:not(:disabled):hover {
  border-color: #f6c14b;
  box-shadow: 0 0 0 1px #f6c14b inset, 0 2px 6px rgba(246, 193, 75, 0.25);
}

.binder-card.clickable, .deck-card { cursor: default; }
.binder-card.clickable { cursor: pointer; }
.binder-card.clickable:hover { border-color: #6a7388; }
.binder-card.selected { outline: 2px solid #f6c14b; outline-offset: -2px; }

.btn-row {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: #1a1e25;
  border-top: 1px solid #3a3f48;
}
.mini {
  flex: 1;
  font-size: 10px;
  padding: 3px 4px;
  background: #3a82f7;
  color: white;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}
.mini:hover:not(:disabled) { background: #2c6ad8; }
.mini:disabled { opacity: 0.4; cursor: not-allowed; }

/* ----- Face-down store/aftermarket back ----- */
.face-down .card-banner {
  background: repeating-linear-gradient(
    135deg, #2a2f38 0 6px, #353c48 6px 12px
  );
  color: #cfd6e3;
}
.face-down .card-body {
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
}
.face-down .back-cost {
  font-size: 26px;
  font-weight: 800;
  color: #f6c14b;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.face-down .back-set {
  font-size: 14px;
  font-weight: 700;
  color: #e8e8e8;
  line-height: 1.15;
  text-align: center;
  margin-top: 6px;
  word-break: break-word;
}
.face-down .card-footer { justify-content: center; }

/* ----- Character card (image-based) -----

   Characters are the only kind that use the actual scanned art. The
   image already contains name, art, and printed power text, so we drop
   the typeline / body / footer and just frame the image. */
.character-card {
  width: 260px;
  /* Character cards size to their scanned art rather than the fixed
     height of regular cards — the image-based frame has its own aspect
     ratio printed in the asset. */
  height: auto;
  padding: 0;
}
.character-image {
  display: block;
  width: 100%;
  height: auto;
}

/* Tournament view wraps the character card with usage notes; keep the
   wrapper styling minimal so the new frame shines through. */
.tourney-character.character-card {
  align-self: flex-start;
}

/* ----- Metagame zone (rules/03:65) ----- */
.metagame-zone .meta-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 320px));
  gap: 12px;
}
.meta-slot {
  background: #2a2f38;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #3a3f48;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meta-slot.revealed {
  border-color: #6c8ec9;
  background: linear-gradient(180deg, #2c3340 0%, #242832 100%);
}
.meta-slot.empty {
  border-style: dashed;
  color: #6b7180;
}
.meta-axis {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9aa3b1;
}
.meta-value {
  font-size: 18px;
  font-weight: 700;
  color: #e6eaf2;
}
.meta-text {
  font-size: 12px;
  color: #cfd6e3;
  line-height: 1.3;
}
.meta-empty {
  font-size: 14px;
  font-style: italic;
  color: #6b7180;
}
.meta-deck {
  font-size: 11px;
  color: #6b7180;
  margin-top: 2px;
}

.muted { color: #6b7180; font-size: 12px; margin: 0; }


/* ----- Player panels (used in both phases) ----- */

.player {
  flex: 1;
  min-width: 360px;
  background: #20242c;
  border-radius: 8px;
  padding: 16px;
  border: 2px solid transparent;
}
.player.active {
  border-color: #f6c14b;
  box-shadow: 0 0 12px rgba(246, 193, 75, 0.25);
}
.player h2 { margin: 0 0 12px; font-size: 18px; }
.player h2 small { font-weight: normal; color: #9aa3b1; font-size: 13px; }

.zone { margin-top: 12px; }
.zone h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b1;
  margin: 0 0 6px;
}
.zone h3.binder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.binder-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.binder-page {
  font-size: 11px;
  color: #cfd6e3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.binder-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 8px;
}
.binder-control {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b1;
}
.binder-control select {
  background: #2a2f38;
  border: 1px solid #3a3f48;
  color: #e8e8e8;
  padding: 3px 6px;
  font: inherit;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 4px;
}
.binder-control-reset {
  background: transparent;
  border: 1px solid #3a3f48;
  color: #cfd6e3;
  padding: 3px 8px;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.binder-control-reset:hover { background: #2a2f38; }


/* ----- Round-end / Game-over results screen ----- */

.round-results {
  max-width: 720px;
  margin: 0 auto;
  background: #20242c;
  border-radius: 8px;
  padding: 20px 24px;
}
.round-results h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: #f6c14b;
}
.round-results .muted { margin: 0 0 16px; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.results-table th,
.results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #2a2e36;
  text-align: left;
}
.results-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b1;
}
.results-table td:nth-child(2),
.results-table td:nth-child(3),
.results-table th:nth-child(2),
.results-table th:nth-child(3) {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.results-table tr.winner td { color: #f6c14b; font-weight: 600; }


/* ----- Log ----- */

#log-section { padding: 0 16px 16px; }
#log-section h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa3b1;
  margin: 12px 0 6px;
}
#log-list {
  background: #0f1116;
  border-radius: 6px;
  padding: 8px 24px;
  max-height: 220px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 0;
}
#log-list li { margin: 2px 0; }


/* ----- Reaction prompt modal ----- */

.prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.prompt-box {
  background: #20242c;
  border: 1px solid #3a3f48;
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 320px;
  max-width: 460px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.prompt-box h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #f6c14b;
}
.prompt-context {
  font-size: 12px;
  color: #9aa3b1;
  margin-bottom: 16px;
}
.prompt-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.prompt-target-pick {
  min-width: 360px;
  max-width: 560px;
}
.prompt-pick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
  max-height: 320px;
  overflow-y: auto;
}
.prompt-pick-card {
  padding: 8px 12px;
  background: #2a3140;
  color: #d8dde7;
  border: 1px solid #3a3f48;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.prompt-pick-card:hover { background: #353e52; }
.prompt-pick-card.selected {
  background: #3a82f7;
  color: white;
  border-color: #2c6ad8;
}
.prompt-pick-card.selected:hover { background: #2c6ad8; }
.tourney-character button.mini { margin: 6px 8px; }

.deckbox-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.deckbox-card {
  background: #232936;
  border-left: 3px solid #f6c14b;
  min-width: 160px;
  max-width: 220px;
}

/* Face-down arena cards: dim, neutral banner, and a card-back hatch in
   the body so the slot reads as a hidden card without leaking element. */
.arena-card.face-down-arena {
  opacity: 0.7;
}
.arena-card.face-down-arena .card-banner {
  background: linear-gradient(180deg, #3a4150, #232830);
  font-style: italic;
}
.arena-card.face-down-arena .card-body {
  background: repeating-linear-gradient(
    135deg, #1a1d22 0 6px, #232830 6px 12px
  );
  min-height: 60px;
}

/* Aftermarket cell: pairs the buy button with optional Shur freebie. */
.am-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.freebie-btn {
  background: #4a3a82;
  color: white;
  border-color: #2c2c6a;
}
.freebie-btn:hover { background: #5b4ba0; }

/* Card Fusion Area (rules/04:114): three rarity-colored promo piles
   plus a control bar that drives the FUSION_BUILDER selection mode. */
.fusion-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #cfd6e3;
}
.fusion-piles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.fusion-pile {
  background: #2a2f38;
  border-radius: 6px;
  padding: 10px;
  border-top: 3px solid #555;
}
.fusion-pile h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.fusion-bronze { border-top-color: #b87333; }
.fusion-silver { border-top-color: #c0c0c0; }
.fusion-gold   { border-top-color: #d4af37; }
/* Face-down promo top card — disabled until binder selection matches the
   required spend, at which point it lights up like a buyable store slot. */
.promo-back:not(:disabled):hover { outline: 2px solid #d4af37; }
