/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f14;
  --bg2:      #1a1a24;
  --bg3:      #252535;
  --border:   #35354a;
  --text:     #e8e8f0;
  --muted:    #888899;
  --accent:   #7c6df2;
  --accent2:  #a78bfa;
  --danger:   #e05555;
  --success:  #4ade80;
  --warning:  #fbbf24;

  /* Ink colors */
  --amber:    #f59e0b;
  --amethyst: #a855f7;
  --emerald:  #10b981;
  --ruby:     #ef4444;
  --sapphire: #3b82f6;
  --steel:    #94a3b8;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
}
button:hover { opacity: .88; }
button:active { transform: scale(.97); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-icon      { padding: 5px 8px; background: transparent; border: 1px solid var(--border); color: var(--muted); }

input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 12px;
  font-size: 14px;
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }

/* ===== Nav ===== */
.nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 52px;
}
.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent2);
  margin-right: 12px;
}
.nav a {
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--bg3); text-decoration: none; }

/* ===== Layout ===== */
.page { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }

.row { display: flex; gap: 16px; }
.col { flex: 1; min-width: 0; }

/* ===== Card Component ===== */
.card-img-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 139.5%;  /* 488:681 ratio */
  background: var(--bg3);
  border-radius: 8px;
  overflow: hidden;
}
.card-img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.card-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.card-tile {
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  position: relative;
}
.card-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-tile.selected { border-color: var(--success); }

.card-tile-name {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 4px 4px 2px;
  line-height: 1.3;
  color: var(--text);
}
.card-tile-sub {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
}
.card-tile-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 5px;
}

/* ===== Ink color dots ===== */
.ink-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ink-Amber    { background: var(--amber); }
.ink-Amethyst { background: var(--amethyst); }
.ink-Emerald  { background: var(--emerald); }
.ink-Ruby     { background: var(--ruby); }
.ink-Sapphire { background: var(--sapphire); }
.ink-Steel    { background: var(--steel); }

/* ===== Panel / Card Detail ===== */
.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.card-detail-img { width: 160px; flex-shrink: 0; }
.card-detail-body { flex: 1; min-width: 0; }
.card-detail-name { font-size: 18px; font-weight: 700; }
.card-detail-sub  { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.card-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.stat-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  display: flex; align-items: center; gap: 5px;
}
.rules-text {
  font-size: 13px;
  white-space: pre-wrap;
  background: var(--bg3);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.flavor-text {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ===== Deck List ===== */
.deck-list { display: flex; flex-direction: column; gap: 8px; }
.deck-entry {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s;
}
.deck-entry:hover { border-color: var(--accent); }
.deck-entry-name { font-weight: 600; flex: 1; }
.deck-entry-count { font-size: 12px; color: var(--muted); }

.deck-slot-list { display: flex; flex-direction: column; gap: 4px; max-height: 500px; overflow-y: auto; }
.deck-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
}
.deck-slot-qty {
  font-weight: 700;
  font-size: 12px;
  background: var(--bg2);
  border-radius: 4px;
  padding: 1px 6px;
  min-width: 24px;
  text-align: center;
}
.deck-slot-name { flex: 1; }
.deck-slot-cost { color: var(--muted); font-size: 11px; }

/* ===== Search Bar ===== */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
}
#toast.show { opacity: 1; }

/* ===== Game Board ===== */
.board {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 8px;
  height: calc(100vh - 60px);
  padding: 10px;
}

.board-zone {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.board-zone-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.play-area {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
  align-items: flex-start;
  overflow-y: auto;
  padding: 8px;
}

.play-card {
  width: 110px;
  aspect-ratio: 488/681;
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s, transform .25s, margin .25s, box-shadow .2s;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg3);
}
.play-card:hover { 
  border-color: var(--accent); 
  box-shadow: 0 0 12px rgba(255, 180, 0, 0.6);
  transform: translateY(-5px);
  z-index: 10;
}
/* Items are spaced further away from other cards */
.play-card.is-item {
  margin-left: 24px;
  margin-right: 24px;
}
/* Exerted: rotate 90°. The layout box stays 90px wide but the visual card is now
   ~126px wide (card height). Add horizontal margins of (126-90)/2 = 18px on each
   side so neighbouring cards are pushed clear and don't overlap. */
.play-card.exerted {
  transform: rotate(90deg);
  transform-origin: center center;
  margin-left: 18px;
  margin-right: 18px;
}
.play-card.drying { border-color: var(--muted); opacity: 0.65; }
.play-card.drying::after { content: '💧'; position: absolute; top: 2px; right: 4px; font-size: 12px; pointer-events: none; }
.play-card.selected-atk { border-color: var(--danger) !important; }
.play-card.selected-def { border-color: var(--warning) !important; }

.play-card-damage {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 4px;
}

.hand-area {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px;
  align-items: center;
}
.hand-card {
  width: 95px;
  aspect-ratio: 488/681;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s, transform .15s, box-shadow .2s;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
}
.hand-card:hover { 
  border-color: var(--accent); 
  transform: translateY(-8px);
  box-shadow: 0 4px 12px rgba(255, 180, 0, 0.5);
  z-index: 100;
}
.hand-card.selected { border-color: var(--success); }

.inkwell-area {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ink-chip {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.ink-chip:hover { border-color: var(--accent); }
.ink-chip.exerted { opacity: .4; cursor: default; }
.ink-chip.selected { border-color: var(--success); }
.ink-chip.opp-ink { background: var(--bg3); }

.ink-chip .card-img-wrap {
  padding-bottom: 140% !important;
}

/* Discard pile styles */
.discard-pile-area {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 56px;
  gap: 2px;
}
.discard-pile-area:hover {
  background: rgba(124, 109, 242, 0.1);
  border-radius: 6px;
}
.discard-pile-preview {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.discard-pile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.discard-pile-count-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.8);
  color: var(--text);
  font-size: 10px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 3px;
}
.discard-empty {
  color: var(--muted);
  font-size: 11px;
}

/* Discard viewer modal */
.discard-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.discard-viewer-header {
  color: var(--text);
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
}
.discard-viewer-content {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  justify-content: center;
  padding: 10px;
  background: var(--bg2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.discard-viewer-card {
  width: 120px;
  height: 168px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.discard-viewer-card:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}
.discard-viewer-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.discard-viewer-close {
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.discard-viewer-close:hover {
  opacity: 0.9;
}

/* ===== Card Selection Popup ===== */
.card-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card-popup-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-popup-header {
  color: var(--text);
  font-size: 18px;
  font-weight: bold;
  text-align: center;
}

.card-popup-subtitle {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: -8px;
}

.card-popup-content {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  justify-content: center;
  padding: 10px;
  background: var(--bg3);
  border-radius: 8px;
  min-height: 100px;
}

.card-popup-card {
  width: 120px;
  height: 168px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  flex-shrink: 0;
}

.card-popup-card:hover:not(.disabled) {
  transform: scale(1.05);
  border-color: var(--accent);
}

.card-popup-card.selected {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.5);
}

.card-popup-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.card-popup-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-popup-card .card-popup-checkmark {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: var(--success);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: bold;
}

.card-popup-card.selected .card-popup-checkmark {
  display: flex;
}

.card-popup-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-top: 8px;
}

.card-popup-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: opacity 0.15s;
}

.card-popup-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.card-popup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-popup-btn-confirm {
  background: var(--success);
  color: white;
}

.card-popup-btn-cancel {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.card-popup-empty {
  color: var(--muted);
  padding: 40px;
  text-align: center;
}

.card-popup-selection-info {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.lore-display {
  font-size: 32px;
  font-weight: 900;
  color: var(--warning);
  text-align: center;
}
.lore-label { font-size: 11px; color: var(--muted); text-align: center; }

.game-log {
  font-size: 11px;
  line-height: 1.5;
  overflow-y: auto;
  color: var(--muted);
  padding: 6px 10px;
}
.game-log p { margin-bottom: 2px; }
.game-log p:last-child { color: var(--text); }

/* Hoverable card name links in the game log */
.log-card-link {
  color: var(--accent2);
  text-decoration: underline dotted;
  cursor: help;
  font-weight: 600;
  border-radius: 2px;
  padding: 0 1px;
  white-space: nowrap;
}
.log-card-link:hover {
  background: rgba(167, 139, 250, 0.18);
  text-decoration: underline solid;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
}
.player-header.active-turn { border-color: var(--success); }
.player-header.opponent   { border-color: var(--border); opacity: .85; }

/* Side player panels */
.player-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
}
.player-panel.active-turn { border-color: var(--success); }
.player-panel.opponent    { border-color: var(--border); opacity: .9; }

/* Active player board highlight (yellow) */
.active-board {
  box-shadow: 0 0 0 3px rgba(251,191,36,0.18), 0 8px 30px rgba(251,191,36,0.06);
  border-color: var(--warning) !important;
}

/* Debug overlay shown during local testing */
.debug-overlay {
  position: fixed;
  left: 12px;
  bottom: 12px;
  width: 320px;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px;
  font-size: 12px;
  color: #fff;
  z-index: 99999;
  border-radius: 8px;
}
.debug-overlay div { padding: 2px 0; border-bottom: 1px dashed rgba(255,255,255,0.03); }

.action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(500px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== Lobby ===== */
.lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 60px);
}
.lobby-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: min(480px, 95vw);
  text-align: center;
}
.lobby-title { font-size: 26px; font-weight: 800; margin-bottom: 8px; color: var(--accent2); }
.lobby-room-code {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .2em;
  color: var(--warning);
  margin: 16px 0;
}

/* ===== Context Menu ===== */
.ctx-menu {
  position: fixed;
  z-index: 9000;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: menuIn .12s ease-out;
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(.93) translateY(4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.ctx-item {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .1s, border-color .1s;
  width: 100%;
}
.ctx-item:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctx-primary { background: var(--accent); color: #fff; }
.ctx-primary:hover { background: var(--accent2); }
.ctx-danger { background: rgba(224,85,85,.2); border-color: var(--danger); color: var(--danger); }
.ctx-danger:hover { background: var(--danger); color: #fff; }
.ctx-disabled { opacity: .45; cursor: default; }
.ctx-disabled:hover { background: var(--bg3); border-color: transparent; color: var(--text); }
.ctx-cancel { color: var(--muted); font-size: 12px; }
.ctx-cancel:hover { background: var(--bg3); color: var(--text); }

/* Opponent card back fallback styling */
.card-back-wrap { background: linear-gradient(135deg, #1a1a3a 0%, #2d1b4e 50%, #1a1a3a 100%); }
.card-back-fallback { background: linear-gradient(135deg, #1a1a3a, #2d1b4e); }

/* Card back in opponent inkwell */
.opp-ink { overflow: hidden; }

/* ===== Card Hover Preview ===== */
#cardPreview {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  width: 200px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.7);
  overflow: hidden;
  opacity: 0;
  transition: opacity .1s;
}
#cardPreview.visible { opacity: 1; }
#cardPreview .cp-img {
  width: 100%;
  aspect-ratio: 488/681;
  object-fit: cover;
  display: block;
}
#cardPreview .cp-fallback {
  width: 100%;
  aspect-ratio: 488/681;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  font-size: 12px;
  text-align: center;
}
#cardPreview .cp-stats {
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
#cardPreview .cp-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
  color: var(--text);
}
#cardPreview .cp-sub {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 4px;
}
#cardPreview .cp-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Utility ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-4 { gap: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================
   BOARD VIEW — Tabletop Redesign (.bv-* namespace)
   =================================================== */

#boardView {
  height: calc(100vh - 52px);
  overflow: hidden;
  gap: 0;
  padding: 0;
}

.bv-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bv-right {
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* ── Lore bar (top of the right panel) ── */
.bv-lore-bar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid var(--border);
  background: var(--bg3);
}

.bv-lore-bar-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  gap: 1px;
}

.bv-lore-bar-opp { border-right: 1px solid var(--border); }

.bv-lore-bar-name {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.bv-lore-bar-count {
  font-size: 36px;
  font-weight: 900;
  color: var(--warning);
  line-height: 1;
}

.bv-lore-bar-unit {
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.bv-lore-bar-divider {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 14px;
  color: var(--muted);
  opacity: .5;
}

.bv-log-header {
  padding: 6px 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.bv-game-log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  font-size: 10px;
  line-height: 1.5;
}

.bv-chat-row {
  display: flex;
  gap: 4px;
  padding: 5px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.bv-player-board {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-bottom: 2px solid var(--border);
}

.bv-opp-board { background: color-mix(in srgb, var(--bg2) 70%, var(--bg) 30%); }
.bv-my-board  { background: var(--bg); }

.bv-player-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.bv-my-header { border-bottom: none; border-top: 1px solid var(--border); }

.bv-player-name { font-weight: 700; font-size: 12px; min-width: 60px; }

.bv-lore-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
}
.bv-lore-label-sm { font-size: 7px; color: var(--muted); text-transform: uppercase; }
.bv-lore-count-sm { font-size: 16px; font-weight: 900; color: var(--warning); line-height: 1; }

.bv-player-stats { display: flex; gap: 10px; flex: 1; }
.bv-stat { font-size: 10px; color: var(--muted); }

.bv-turn-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(74,222,128,.1);
  border: 1px solid rgba(74,222,128,.25);
}

.bv-header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bv-selection-hint { font-size: 9px; color: var(--muted); max-width: 130px; text-align: right; }

.bv-zones {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bv-zone-row {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.bv-zone-row:last-child { border-bottom: none; }

.bv-zone {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 4px 6px;
  border-right: 1px solid var(--border);
}
.bv-zone:last-child { border-right: none; }

/* play-area inside a field zone fills available height */
.bv-zone .play-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 8px;
  padding: 2px;
  align-content: flex-start;
}

/* deck zone: center contents */
.bv-deck-zone { align-items: center; gap: 6px; }

.bv-deck-visual {
  position: relative;
  width: 58px;
  aspect-ratio: 488/681;
  border-radius: 5px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.bv-deck-visual:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(124,109,242,.4);
}

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

.bv-deck-count-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  border-radius: 3px;
  padding: 1px 4px;
  min-width: 18px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.12);
}

.bv-lore-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 100%;
  max-width: 70px;
  margin-top: 6px;
}
.bv-lore-label-text { font-size: 8px; color: var(--muted); font-style: italic; }
.bv-lore-number { font-size: 26px; font-weight: 900; color: var(--warning); line-height: 1; }

/* hand strip pinned at the bottom of the left column */
.bv-hand-strip {
  flex-shrink: 0;
  background: var(--bg2);
  border-top: 2px solid var(--border);
  padding: 3px 8px 5px;
}

.bv-my-hand-area {
  overflow-x: auto;
  overflow-y: visible;
  flex-wrap: nowrap;
  padding: 3px 0 6px;
  gap: 6px;
}

/* opponent hand cards smaller — face-down, decorative only */
#oppHand .hand-card { width: 44px; border-radius: 4px; }

/* active-turn highlight on board containers */
.bv-my-board.active-board  { box-shadow: inset 0 0 0 2px rgba(251,191,36,.35); }
.bv-opp-board.active-board { box-shadow: inset 0 0 0 2px rgba(251,191,36,.35); }
