/* ====================================================================
   PYRE STYLES — TABLE OF CONTENTS

   1.   Theme variables (root + .light-theme)
   2.   Base / reset
   3.   Lobby + auth + deck form
   4.   Board layout
   5.   Game log (strip + sidebar)
   6.   Mobile player bar
   7.   Number input
   8.   Peek modal
   9.   Responsive breakpoints (tablet, phone, touch)
   10.  Draft UI (pack open, deck builder, land panel)
   11.  Touch preview (inline zoom + quick actions)
   12.  Coin/dice animation overlay
   13.  Rulings modal
   14.  Eliminated player
   15.  Cube draft
   16.  Turn notification
   17.  Combat (states + buttons)
   ==================================================================== */

/* === Theme Variables === */
:root {
  /* Dark theme (default) */
  --bg-body: #0a0a0a;
  --bg-zone: #131313;
  --bg-zone-alt: #111111;
  --bg-surface: #1a1a1a;
  --bg-elevated: rgba(255,255,255,0.04);
  --bg-elevated-active: rgba(255,255,255,0.06);
  --bg-hover: rgba(255,255,255,0.08);
  --bg-input: #1a1a1a;
  --border: #222222;
  --border-subtle: #1e1e1e;
  --border-interactive: #2a2a2a;
  --border-input: #2a2a2a;
  --border-focus: #8b77dd;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --text-muted: #888888;
  --text-dim: #555555;
  --text-ghost: #444444;
  --text-on-primary-btn: #0a0a0a;
  --btn-primary-bg: #ffffff;
  --btn-primary-hover: #e0e0e0;
  --btn-secondary-bg: #1a1a1a;
  --btn-secondary-hover: #2a2a2a;
  --btn-secondary-border: #2a2a2a;
  --danger: #c0321a;
  --success: #2a8a2a;
  --accent: #8b77dd;
  --accent-bg: rgba(139,119,221,0.1);
  --card-bg: #1a1a1a;
  --card-border: rgba(255,255,255,0.10);
  --card-shadow: 0 2px 8px rgba(0,0,0,0.5);
  --overlay-bg: rgba(0,0,0,0.5);
  --panel-bg: #141414;
  --panel-border: #222222;
  --divider: #1e1e1e;
  --toast-bg: #ffffff;
  --toast-text: #0a0a0a;
  --card-back-from: #6a5acd;
  --card-back-to: #483d8b;
  --card-back-border: #7b68ee;
  --ring-you-bg: rgba(255,255,255,0.06);
  --ring-you-border: rgba(255,255,255,0.15);
  --ring-other-bg: rgba(255,255,255,0.03);
  --ring-other-border: rgba(255,255,255,0.08);
  --ring-viewing-bg: rgba(139,119,221,0.08);
  --ring-viewing-border: rgba(139,119,221,0.25);
  --cmd-bg: #1a1a18;
  --cmd-border: #333328;
  --cmd-text: #a09870;
  --draft-pack-from: #8b77dd;
  --draft-pack-to: #6a5acd;
  --banner-warn-bg: #2a2000;
  --banner-warn-border: #4a3a00;
  --banner-warn-text: #f0c860;
  --banner-info-bg: #001a33;
  --banner-info-border: #003366;
  --banner-info-text: #6aa8d8;
  --banner-reset-bg: #2a2000;
  --banner-reset-border: #4a3a00;
  --spinner-border: rgba(255,255,255,0.3);
  --spinner-top: #ffffff;
}

/* Light theme override */
:root.light-theme {
  --bg-body: #f5f4f0;
  --bg-zone: #ffffff;
  --bg-zone-alt: #fafaf8;
  --bg-surface: #f5f4f0;
  --bg-elevated: #ffffff;
  --bg-elevated-active: #ffffff;
  --bg-hover: #f0ece4;
  --bg-input: #ffffff;
  --border: #e0ddd6;
  --border-subtle: #f0ece4;
  --border-interactive: #d0ccc4;
  --border-input: #d0ccc4;
  --border-focus: #8b77dd;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --text-dim: #aaaaaa;
  --text-ghost: #cccccc;
  --text-on-primary-btn: #ffffff;
  --btn-primary-bg: #1a1a1a;
  --btn-primary-hover: #333333;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-hover: #f0ece4;
  --btn-secondary-border: #d0ccc4;
  --danger: #c0321a;
  --success: #2a8a2a;
  --accent: #8b77dd;
  --accent-bg: rgba(139,119,221,0.08);
  --card-bg: #eeeeee;
  --card-border: transparent;
  --card-shadow: none;
  --overlay-bg: rgba(0,0,0,0.3);
  --panel-bg: #ffffff;
  --panel-border: #e0ddd6;
  --divider: #e0ddd6;
  --toast-bg: #1a1a1a;
  --toast-text: #ffffff;
  --card-back-from: #6a5acd;
  --card-back-to: #483d8b;
  --card-back-border: #7b68ee;
  --ring-you-bg: #f0f5ff;
  --ring-you-border: #b8ccf8;
  --ring-other-bg: #ffffff;
  --ring-other-border: #e0ddd6;
  --ring-viewing-bg: #f5f0ff;
  --ring-viewing-border: #8b77dd;
  --cmd-bg: #fffcf0;
  --cmd-border: #c8b060;
  --cmd-text: #8a7a40;
  --deck-tab-track: #ebe8e2;
  --deck-tab-hover: #e5e1da;
  --draft-pack-from: #8b77dd;
  --draft-pack-to: #6a5acd;
  --banner-warn-bg: #fff3e0;
  --banner-warn-border: #f0c860;
  --banner-warn-text: #8a6a00;
  --banner-info-bg: #eef5ff;
  --banner-info-border: #b8ccf8;
  --banner-info-text: #3a6ea5;
  --banner-reset-bg: #fff3e0;
  --banner-reset-border: #f0c860;
  --spinner-border: rgba(0,0,0,0.15);
  --spinner-top: #333333;
}

/* === Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg-body); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }
body:has(.lobby) { min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; }

/* === Lobby === */
.lobby { max-width: 480px; margin: 0 auto; padding: 60px 16px 24px; display: flex; flex-direction: column; gap: 16px; position: relative; }
.lobby-title { font-size: 32px; font-weight: 700; text-align: center; color: var(--text-primary); }
.lobby-sub { font-size: 14px; color: var(--text-muted); text-align: center; }
.lobby-form { display: flex; flex-direction: column; gap: 10px; }
.lobby-input { padding: 12px; border: 1px solid var(--border-input); border-radius: 8px; background: var(--bg-input); color: var(--text-primary); font-size: 16px; outline: none; }
.lobby-input:focus { border-color: var(--border-focus); }
.lobby-textarea { padding: 12px; border: 1px solid var(--border-input); border-radius: 8px; background: var(--bg-input); color: var(--text-primary); font-size: 13px; font-family: monospace; outline: none; resize: vertical; min-height: 200px; width: 100%; box-sizing: border-box; }
.lobby-textarea:focus { border-color: var(--border-focus); }
.lobby-btn { padding: 14px; border: none; border-radius: 8px; background: var(--btn-primary-bg); color: var(--text-on-primary-btn); font-size: 16px; font-weight: 600; cursor: pointer; }
.lobby-btn:hover { background: var(--btn-primary-hover); }
.lobby-btn-start { background: var(--success); }
.lobby-btn-start:hover { background: #3aaa3a; }
.lobby-players { display: flex; flex-direction: column; gap: 6px; }
.lobby-section { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.lobby-player { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; }
.lobby-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.lobby-deck { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.lobby-player-name { font-weight: 500; }
.lobby-loading { font-size: 11px; color: var(--accent); margin-left: auto; display: flex; align-items: center; gap: 6px; }
.lobby-ready { font-size: 11px; color: var(--success); margin-left: auto; font-weight: 600; }
.lobby-waiting { font-size: 11px; color: var(--text-ghost); margin-left: auto; }
.lobby-player.ready { border-color: #b8e8b8; background: rgba(42,138,42,0.1); }
.lobby-player.loading { border-color: var(--accent); background: var(--accent-bg); }
.lobby-btn.loading { background: var(--text-dim); cursor: wait; }
.lobby-btn.disabled { background: var(--text-ghost); cursor: not-allowed; color: var(--text-muted); }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.btn-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--spinner-border); border-top-color: var(--spinner-top); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; }
.lobby-loading .btn-spinner { width: 12px; height: 12px; border-color: rgba(139,119,221,0.3); border-top-color: var(--accent); }

/* Lobby enter animation */
.lobby-player { transition: background 0.3s, border-color 0.3s, opacity 0.3s; animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Mode selector */
.mode-selector { display: flex; gap: 6px; justify-content: center; }
.mode-btn { flex: 1; padding: 10px 12px; border: 1px solid var(--border-interactive); border-radius: 8px; background: var(--bg-elevated); color: var(--text-dim); font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.mode-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.mode-btn.active { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--text-on-primary-btn); }

/* Draft config */
.draft-config { display: flex; flex-direction: column; gap: 14px; padding: 14px; background: var(--bg-zone-alt); border: 1px solid var(--border); border-radius: 8px; }
.draft-config-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.draft-config-label { font-size: 13px; font-weight: 500; color: var(--text-dim); white-space: nowrap; }
.draft-set-input { width: 100px; text-align: center; text-transform: uppercase; padding: 8px 12px; }
#set-draft-config, #cube-draft-config { display: flex; flex-direction: column; gap: 12px; }
.pack-count-controls { display: flex; align-items: center; gap: 8px; }
.pack-count-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-interactive); background: var(--bg-elevated); color: var(--text-primary); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; transition: background 0.15s; }
.pack-count-btn:hover { background: var(--bg-hover); }
.pack-count-value { font-size: 18px; font-weight: 600; min-width: 24px; text-align: center; }

/* Set preview */
.set-preview { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.set-icon { width: 20px; height: 20px; vertical-align: middle; }
.set-preview-name { font-weight: 600; color: var(--text-primary); }
.set-preview-cards { color: var(--text-muted); font-size: 12px; margin-left: auto; }
.set-preview-error { color: var(--danger); font-size: 12px; }

/* Commander indicator in lobby */
.lobby-commander { font-size: 11px; color: var(--accent); margin-left: auto; margin-right: 8px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

/* === Board layout === */
.board-layout { display: flex; gap: 12px; max-width: 1400px; margin: 0; width: 100%; min-height: 100vh; padding: 10px 16px; }
.board { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; overflow-x: hidden; }

.card-back { width: 30px; height: 42px; background: linear-gradient(135deg, var(--card-back-from), var(--card-back-to)); border: 1px solid var(--card-back-border); border-radius: 4px; flex-shrink: 0; }
.hand-count { font-size: 10px; color: var(--text-muted); margin-left: 6px; }

/* Battlefield zones */
.bf-zone { background: var(--bg-zone); border: 1px solid var(--border); border-radius: 10px; padding: 30px 8px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; align-items: flex-start; position: relative; min-height: 60px; transition: background 0.2s; }
.bf-zone.opp-lands { background: var(--bg-zone-alt); }
.bf-zone.opp-creatures { min-height: 100px; }
.bf-zone.my-creatures { min-height: 100px; }
.bf-zone.my-lands { background: var(--bg-zone-alt); }
.bf-label { position: absolute; top: 8px; left: 12px; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Combat zone divider */
.combat-zone { height: 1px; background: var(--border); margin: 4px 0; }

/* Cards */
.card { width: 100px; height: 140px; border-radius: 6px; overflow: visible; cursor: pointer; position: relative; border: 2px solid var(--card-border); flex-shrink: 0; background: var(--card-bg); transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.15s ease; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.card:hover { border-color: var(--accent); z-index: 20; }
/* Tapped cards rotate 90°: visual bounds are 140w × 100h but the element's
   layout bounds stay 100w × 140h. Negative vertical margin pulls the row
   height closer to the visual height so a row of all-tapped cards doesn't
   reserve the extra ~40px of portrait-orientation space below them. */
.card.tapped { transform: rotate(90deg); margin: -20px 22px 0 22px; opacity: 0.8; }
.card-inner { width: 100%; height: 100%; position: relative; overflow: hidden; border-radius: 4px; }
.card-art-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 4px; -webkit-user-drag: none; user-drag: none; -webkit-touch-callout: none; pointer-events: none; }
.card { -webkit-user-drag: none; user-drag: none; }
.card-art { width: 100%; height: 100%; border-radius: 4px; }
.card-pt { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,0.7); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.card-counters { position: absolute; top: -6px; right: -6px; color: white; font-size: 10px; font-weight: bold; min-width: 22px; height: 22px; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 2px; padding: 0 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.4); border: 2px solid var(--panel-bg); cursor: pointer; z-index: 5; }
.counter-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.counter-popup { position: fixed; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.6); z-index: 2000; min-width: 100px; }
.counter-popup-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.counter-popup-type { font-size: 10px; color: var(--text-secondary); }
.counter-popup-count { font-size: 11px; color: var(--text-primary); font-weight: bold; margin-left: auto; }
.player-counter-pills { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px; }
.player-counter-pill { background: var(--bg-zone); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 11px; font-weight: bold; color: var(--text-secondary); cursor: pointer; white-space: nowrap; min-height: 28px; display: inline-flex; align-items: center; gap: 3px; }
.player-counter-add { background: var(--bg-zone); border: 1px dashed var(--border); border-radius: 6px; padding: 4px 8px; font-size: 11px; color: var(--text-secondary); cursor: pointer; min-height: 28px; display: inline-flex; align-items: center; }
.card-name-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.7)); padding: 16px 6px 4px; }
.card-name-text { font-size: 8px; font-weight: 600; color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }

/* Card stacking */
.card-stack { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; }
.card-stack-layer { position: relative; }
.card-stack-layer:not(.card-stack-host) { margin-bottom: -120px; }
.card-stack-layer .card.tapped { margin: 0; }
.card-stack .card:hover { z-index: 20; transform: translateY(-6px); }
.card-stack .card.tapped:hover { transform: rotate(90deg) translateY(-6px); }

/* Double-faced card badge */
.dfc-badge { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,0.6); color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 4px; z-index: 3; pointer-events: none; }

/* Card flip animation */
@keyframes cardFlip {
  0% { transform: perspective(600px) rotateY(0deg); }
  50% { transform: perspective(600px) rotateY(90deg); }
  100% { transform: perspective(600px) rotateY(0deg); }
}
.card-flipping { animation: cardFlip 0.4s ease; }
.card.tapped.card-flipping { animation: none; } /* don't flip-animate while tapped */

/* Card animations */
@keyframes cardEnterBattlefield {
  from { opacity: 0; transform: scale(0.85) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cardEnterHand {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cardExit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-30px); }
}
@keyframes counterPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@keyframes lifeFlash {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}
@keyframes shuffleShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
/* Card enter glow — subtle purple edge highlight. Higher specificity to coexist with card-enter-bf */
.card.card-glow-enter {
  animation: cardEnterBattlefield 0.25s ease-out, cardGlowEnter 0.8s ease-out !important;
}

@keyframes cardGlowEnter {
  0%   { box-shadow: 0 0 0 0 rgba(124, 131, 255, 0); }
  25%  { box-shadow: 0 0 10px 3px rgba(124, 131, 255, 0.6), inset 0 0 6px 1px rgba(167, 139, 250, 0.25); }
  50%  { box-shadow: 0 0 14px 4px rgba(167, 139, 250, 0.4), inset 0 0 8px 2px rgba(167, 139, 250, 0.15); }
  100% { box-shadow: 0 0 0 0 rgba(124, 131, 255, 0); }
}

.card-enter-bf { animation: cardEnterBattlefield 0.25s ease-out; }
.card-enter-hand { animation: cardEnterHand 0.35s ease-out; }
.card-exit { animation: cardExit 0.25s ease-out forwards; pointer-events: none; transition: none !important; }
.counter-pulse { animation: counterPulse 0.2s ease; }
.life-flash-up { animation: lifeFlash 0.3s ease; color: var(--success) !important; }
.life-flash-down { animation: lifeFlash 0.3s ease; color: var(--danger) !important; }
.shuffle-shake { animation: shuffleShake 0.4s ease; }

/* Player hand */
.player-hand { display: flex; justify-content: center; padding: 24px 8px 4px; overflow-x: auto; min-height: 170px; align-items: flex-end; position: relative; z-index: 5; -webkit-overflow-scrolling: touch; scrollbar-width: thin; margin: 0 -4px; touch-action: pan-x; }
.player-hand > div, .player-hand .card-back { transition: opacity 0.25s ease-in-out; }
.player-hand .card { width: 110px; height: 154px; margin-left: -10px; transition: transform 0.2s ease, margin 0.25s ease; }
.player-hand .card:first-child { margin-left: 0; }
.player-hand .card:hover { transform: translateY(-16px) scale(1.05); z-index: 10; margin-left: 6px; margin-right: 6px; }
.hand-enter-wrapper { width: 0; overflow: hidden; flex-shrink: 0; animation: handSlotOpen 0.3s ease-in-out forwards; }
.hand-enter-wrapper .card { margin-left: 0; }
@keyframes handSlotOpen { from { width: 0; } to { width: 100px; } }

/* Action bar */
.action-bar { display: flex; gap: 6px; justify-content: center; padding: 6px 0; flex-wrap: wrap; }
.action-btn { font-size: 12px; padding: 8px 18px; border-radius: 8px; border: 1px solid var(--btn-secondary-border); background: var(--btn-secondary-bg); color: var(--text-primary); cursor: pointer; font-weight: 500; transition: background 0.15s; }
.action-btn:hover { background: var(--btn-secondary-hover); }
.action-btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--text-on-primary-btn); }
.action-btn.primary:hover { background: var(--btn-primary-hover); }

/* Hover preview panel — positioned near hovered card */
.card-preview { position: fixed; width: 240px; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 50; }
.card-preview.visible { opacity: 1; }
.card-preview img { width: 100%; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.preview-counters { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin-top: 4px; padding: 0 4px; }
.preview-counter-pill { font-size: 11px; font-weight: 600; color: #fff; padding: 2px 8px; border-radius: 8px; white-space: nowrap; }

/* Context menu */
.context-menu { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: overlayFadeIn 0.2s ease-out; }
.context-menu.closing { animation: overlayFadeOut 0.15s ease-in forwards; }
.context-inner { background: var(--panel-bg); border-radius: 14px; padding: 16px; min-width: 220px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); display: flex; flex-direction: column; gap: 4px; animation: panelScaleIn 0.2s ease-out; }
.context-menu.closing .context-inner { animation: panelScaleOut 0.15s ease-in forwards; }
.context-title { font-size: 15px; font-weight: 600; color: var(--text-primary); text-align: center; padding-bottom: 8px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.context-btn { padding: 10px 12px; border: none; border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); font-size: 14px; cursor: pointer; text-align: left; transition: background 0.15s; }
.context-btn:hover { background: var(--bg-hover); }
.ctx-icon { display: inline-block; width: 28px; text-align: center; font-size: 16px; vertical-align: middle; }
.context-btn.cancel { color: var(--text-muted); text-align: center; margin-top: 4px; background: transparent; }

/* Zone overlay */
.zone-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; animation: overlayFadeIn 0.2s ease-out; }
.zone-overlay.closing { animation: overlayFadeOut 0.15s ease-in forwards; }
.zone-overlay-inner { background: var(--panel-bg); border-radius: 14px; padding: 16px; max-width: 420px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.3); position: relative; animation: panelScaleIn 0.2s ease-out; }
.zone-overlay.closing .zone-overlay-inner { animation: panelScaleOut 0.15s ease-in forwards; }
.overlay-close { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 18px; color: var(--text-ghost); cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.15s, color 0.15s; z-index: 1; }
.overlay-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.zone-overlay-title { font-size: 15px; font-weight: 600; color: var(--text-primary); text-align: center; padding-bottom: 8px; border-bottom: 1px solid var(--divider); margin-bottom: 10px; }
.zone-overlay-cards { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.zone-overlay-card { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.zone-card-name { font-size: 10px; color: var(--text-muted); text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-empty { font-size: 13px; color: var(--text-muted); font-style: italic; padding: 20px; text-align: center; }

/* Library search */
.library-search { width: 100%; padding: 10px 12px; border: 1px solid var(--border-input); border-radius: 8px; background: var(--bg-input); color: var(--text-primary); font-size: 14px; outline: none; margin-bottom: 6px; }
.library-search:focus { border-color: var(--border-focus); }
/* Library selection */
.lib-action-bar { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--divider); margin-bottom: 8px; }
.lib-action-bar.visible { display: flex; }
.lib-count-text { font-size: 12px; color: var(--text-dim); flex: 1; }
.lib-count-text b { color: var(--success); }
.lib-pill-btn { padding: 8px 16px; border-radius: 999px; border: none; font-size: 12px; font-weight: 600; cursor: pointer; background: var(--bg-surface); color: var(--text-primary); transition: background 0.15s; white-space: nowrap; }
.lib-pill-btn:hover { background: var(--bg-hover); }
.lib-pill-primary { background: var(--btn-primary-bg); color: var(--text-on-primary-btn); }
.lib-pill-primary:hover { background: var(--btn-primary-hover); }
.zone-overlay-card { position: relative; }
.zone-overlay-card.selected .card { border-color: var(--success); }
.sel-check { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; background: var(--success); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; z-index: 25; box-shadow: 0 1px 3px rgba(0,0,0,0.2); pointer-events: none; }

/* Revealed cards banner */
.revealed-banner { display: flex; gap: 10px; justify-content: center; padding: 8px; background: var(--banner-warn-bg); border: 1px solid var(--banner-warn-border); border-radius: 10px; animation: revealFade 0.3s ease-in; }
.revealed-card { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.revealed-label { font-size: 10px; font-weight: 600; color: var(--banner-warn-text); }
.revealed-img { width: 120px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.revealed-name { font-size: 11px; font-weight: 600; color: var(--text-primary); }
@keyframes revealFade { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Overlay/panel entrance and exit animations */
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes panelScaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes panelScaleOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

/* Zone overlay card stagger */
.zone-overlay-card {
  animation: cardStaggerIn 0.2s ease-out backwards;
}

@keyframes cardStaggerIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Token modal */
.token-recent-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 10px 0 6px; }
.token-recent-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.token-preview { display: none; position: fixed; right: calc(50% + 230px); top: 50%; transform: translateY(-50%); z-index: 10002; pointer-events: none; }
.token-preview.visible { display: block; }
.token-preview img { width: 250px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
@media (max-width: 1024px) { .token-preview { display: none !important; } }

/* Toast notification */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-text); padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 200; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.visible { opacity: 1; }

/* === Game Log === */

/* Log sidebar (desktop) */
.log-sidebar { width: 240px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 10px; align-self: flex-start; max-height: calc(100vh - 20px); }
.log-sidebar-title { font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--divider); }
.log-sidebar-entries { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0; max-height: 250px; }

/* Log entries (shared) */
.log-entry { display: flex; align-items: flex-start; gap: 6px; padding: 5px 0; font-size: 11px; color: var(--text-dim); line-height: 1.4; border-bottom: 1px solid var(--divider); }
.log-time { font-size: 9px; color: var(--text-ghost); flex-shrink: 0; min-width: 32px; padding-top: 1px; }
.log-player { font-weight: 600; }
.log-action { color: var(--text-muted); }
.log-card { font-weight: 500; color: var(--text-primary); }
.log-detail { color: var(--text-muted); }
.log-reveal-img { width: 60px; border-radius: 4px; margin-top: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.log-empty { font-size: 11px; color: var(--text-ghost); font-style: italic; padding: 10px 0; }

/* Log strip (mobile) — hidden on desktop */
.log-strip { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: none; }
.log-strip-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; }
.log-strip-header:hover { background: var(--bg-hover); }
.log-strip-title { font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }
.log-strip-latest { font-size: 11px; color: var(--text-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-strip-expand { font-size: 10px; color: var(--accent); font-weight: 600; flex-shrink: 0; transition: transform 0.25s ease; }
.log-strip-expand.rotated { transform: rotate(180deg); }
.log-expanded { max-height: 0; overflow: hidden; transition: max-height 0.25s ease, padding 0.25s ease; padding: 0 12px; border-top: 1px solid var(--divider); }
.log-expanded.open { max-height: 200px; overflow-y: auto; padding: 0 12px 8px; }

/* === Number Input === */
.number-input {
  width: 80px;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  font-size: 18px;
  text-align: center;
  margin: 8px auto;
  display: block;
}
.number-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* === Peek Modal === */
.peek-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--overlay-bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.peek-inner {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.peek-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.peek-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.peek-done {
  padding: 6px 16px;
  border: 1px solid var(--border-interactive);
  border-radius: 6px;
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
}
.peek-done:hover {
  background: var(--btn-secondary-hover);
}
.peek-cards {
  display: flex;
  flex-direction: row;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 6px 12px 6px;
}
.peek-card {
  flex-shrink: 0;
  width: 180px;
  position: relative;
  cursor: pointer;
  border-radius: 10px;
  transition: opacity 0.2s;
}
.peek-card.peek-selected {
  outline: 3px solid #4af;
  outline-offset: 2px;
  border-radius: 10px;
}
.peek-card.peek-routed {
  opacity: 0.25;
  pointer-events: none;
}
.peek-card-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  z-index: 1;
}
.peek-card-img {
  width: 100%;
  border-radius: 8px;
  display: block;
}
.peek-card-placeholder {
  height: 250px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px;
  text-align: center;
}
.peek-routed-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: #4f4;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.peek-zones {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 12px;
}
.peek-zone {
  flex: 1;
  padding: 10px 8px;
  border: 2px dashed var(--border-interactive);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.peek-zone:hover, .peek-zone.peek-zone-hover {
  border-color: var(--border-focus);
  background: var(--accent-bg);
}
.peek-pills {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 4px;
  z-index: 2;
}
.peek-pill {
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-interactive);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.peek-pill:hover {
  background: var(--accent-bg);
  border-color: var(--border-focus);
}

/* ==========================================================================
   Player column (desktop left column; mobile drawer)
   ========================================================================== */

.player-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 240px;
  flex-shrink: 0;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 20px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.player-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-card.me {
  border: 2px solid var(--accent);
}

.player-card.opponent.viewing {
  border-color: var(--ring-viewing-border);
  box-shadow: 0 0 0 1px var(--ring-viewing-border);
}

.player-card.opponent.eliminated {
  opacity: 0.5;
  border-color: var(--border-subtle);
}

.pc-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pc-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
}

.pc-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
}

.pc-eliminated {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pc-life-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pc-life-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.pc-life-btn:hover {
  background: var(--btn-secondary-hover);
}

.pc-life {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-primary);
  min-width: 28px;
  text-align: center;
}

.pc-counter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pc-zones {
  display: flex;
  gap: 4px;
}

.pc-zslot {
  flex: 1;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 4px;
  text-align: center;
  cursor: pointer;
  min-height: 44px;
}

.pc-zslot:hover {
  background: var(--btn-secondary-hover);
}

.pc-zslot.pc-hand-slot {
  cursor: default;
}

.pc-zslot.pc-hand-slot:hover {
  background: var(--panel-bg);
}

.pc-zcount {
  display: block;
  font-size: 14px;
  font-weight: bold;
  color: var(--text-primary);
}

.pc-zlabel {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

.pc-commander-section {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pc-commander-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.pc-commander-thumb {
  width: 44px;
  height: 62px;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--panel-bg);
}

.pc-commander-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc-commander-thumb.empty {
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding: 2px;
}

.pc-commander-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pc-commander-name {
  font-size: 11px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-tax-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.pc-tax-btn {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
  cursor: pointer;
}

.pc-tax-btn:hover {
  background: var(--btn-secondary-hover);
}

.pc-tax-value {
  font-weight: bold;
  color: var(--text-primary);
  min-width: 16px;
  text-align: center;
}

.pc-commander-damage {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pc-damage-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.pc-damage-row.lethal .pc-damage-value,
.pc-damage-row.lethal .pc-damage-label {
  color: var(--danger);
}

.pc-damage-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-damage-btn {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
  cursor: pointer;
  font-size: 11px;
}

.pc-damage-btn:hover {
  background: var(--btn-secondary-hover);
}

.pc-damage-value {
  font-weight: bold;
  min-width: 18px;
  text-align: center;
}

.player-divider {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* === Responsive === */

/* Tablet (480-1024px) */
@media (max-width: 1024px) {
  .board-layout { flex-direction: column; }
  .card { width: 100px; height: 140px; }
  .card.tapped { margin: 4px 22px; }
  .player-hand .card { width: 110px; height: 154px; margin-left: -16px; }
  .player-hand { align-items: flex-end; padding: 8px 4px; }
  .card-preview { display: none; }
  .log-sidebar { display: none; }
  .log-strip { display: block; }
  .player-column { display: none; }
  .settings-gear { display: none; }
}

/* Phone (< 480px) */
@media (max-width: 480px) {
  .board { padding: 4px 8px; gap: 4px; }
  .card { width: 70px; height: 98px; }
  .card-stack-layer:not(.card-stack-host) { margin-bottom: -80px; }
  .card.tapped { margin: 2px 18px; }
  .card-pt { font-size: 8px; padding: 1px 4px; }
  .card-counters { font-size: 8px; padding: 0 4px; min-width: 18px; height: 18px; }
  .player-hand .card { width: 80px; height: 112px; margin-left: -18px; }
  .player-hand .card:hover { transform: translateY(-10px) scale(1.05); margin-left: 3px; margin-right: 3px; }
  .player-hand { min-height: 116px; align-items: flex-end; padding: 8px 4px; }
  .bf-zone { padding: 18px 6px 6px; gap: 4px; min-height: 50px; }
  .bf-zone.opp-creatures, .bf-zone.my-creatures { min-height: 80px; }
  .bf-label { font-size: 9px; }
  .card-back { width: 24px; height: 34px; }
  .action-btn { padding: 10px 14px; font-size: 13px; min-height: 44px; flex: 1; }
  .context-btn { padding: 14px; font-size: 15px; min-height: 48px; }
  .lobby-input, .lobby-textarea { font-size: 16px; }
  .lobby-btn { padding: 16px; font-size: 18px; min-height: 48px; }
  .card-preview { display: none; }
  .card-name-text { font-size: 7px; }
  .log-sidebar { display: none; }
  .log-strip { display: block; }
  .cmd-dmg-btn { width: 32px; height: 32px; font-size: 16px; min-height: 44px; }
  .cmd-dmg-toggle { width: 32px; height: 32px; min-height: 44px; }
  .cmd-zone-cards .card { width: 56px; height: 78px; }
}

/* Commander mode — mobile command zone uses .cmd-zone-cards */
.cmd-zone-cards { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.cmd-zone-cards .card { width: 100px; height: 140px; }

/* Commander mode — damage toggle + expandable section */
.cmd-dmg-toggle { padding: 2px 6px; border-radius: 4px; border: 1px solid var(--cmd-border); background: var(--cmd-bg); font-size: 9px; font-weight: 700; color: var(--cmd-text); cursor: pointer; letter-spacing: 0.03em; transition: background 0.15s; flex-shrink: 0; line-height: 1.2; }
.cmd-dmg-toggle:hover { background: var(--bg-hover); }
.cmd-dmg-section { width: 100%; padding-top: 6px; border-top: 1px solid var(--divider); margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.cmd-dmg-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; }
.cmd-dmg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cmd-dmg-name { flex: 1; color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-dmg-btn { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border-interactive); background: var(--bg-elevated); color: var(--text-primary); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cmd-dmg-btn:hover { background: var(--bg-hover); }
.cmd-dmg-value { font-size: 13px; font-weight: 700; min-width: 18px; text-align: center; color: var(--text-primary); }
.cmd-dmg-danger { color: var(--danger); }
.cmd-dmg-empty { font-size: 11px; color: var(--text-ghost); font-style: italic; }

/* Tap all button — inside land zone */
.tap-all-btn { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elevated); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10; transition: background 0.15s; color: var(--text-muted); padding: 0; line-height: 1; }
.tap-all-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Settings gear */
.settings-gear { position: fixed; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-elevated); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 40; transition: background 0.15s; color: var(--text-muted); }
.settings-gear:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Settings slide-out panel */
.settings-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0); z-index: 95; transition: background 0.25s; }
.settings-backdrop.visible { background: var(--overlay-bg); }
.settings-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 220px; background: var(--panel-bg); border-left: 1px solid var(--panel-border); box-shadow: -4px 0 20px rgba(0,0,0,0.2); z-index: 100; display: flex; flex-direction: column; padding: 16px; transform: translateX(100%); transition: transform 0.25s ease; }
.settings-panel.visible { transform: translateX(0); }
.settings-header { font-size: 14px; font-weight: 700; color: var(--text-primary); padding-bottom: 12px; border-bottom: 1px solid var(--divider); margin-bottom: 8px; }
.settings-label { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; padding: 4px 8px 10px; }
.settings-option { padding: 10px 8px; border: none; border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: 13px; cursor: pointer; text-align: left; font-weight: 500; transition: background 0.15s; display: flex; align-items: center; gap: 10px; }
.settings-option:hover { background: var(--bg-hover); }
.settings-icon { width: 18px; text-align: center; font-size: 14px; color: var(--text-dim); }
.settings-spacer { flex: 1; }
.settings-version { font-size: 10px; color: var(--text-ghost); text-align: center; }

/* Reset banner */
.reset-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--banner-warn-bg); border-bottom: 1px solid var(--banner-warn-border); padding: 10px 16px; display: flex; align-items: center; gap: 10px; z-index: 90; animation: slideIn 0.3s ease-out; }
.reset-banner-text { flex: 1; font-size: 13px; color: var(--text-primary); }
.reset-banner-btn { padding: 6px 14px; border: none; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; }
.reset-banner-btn.confirm { background: var(--success); color: #fff; }
.reset-banner-btn.confirm:hover { background: #3aaa3a; }
.reset-banner-btn.dismiss { background: var(--bg-surface); color: var(--text-muted); }
.reset-banner-btn.dismiss:hover { background: var(--bg-hover); }
.reset-pending { background: var(--banner-info-bg); border-bottom-color: var(--banner-info-border); }
.reset-pending .btn-spinner { width: 12px; height: 12px; border-color: rgba(58,110,165,0.3); border-top-color: var(--banner-info-text); margin-right: 6px; }
.reset-declined { background: rgba(192,50,26,0.1); border-bottom-color: rgba(192,50,26,0.3); }

/* === Draft UI === */
.draft-layout { max-width: 800px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.draft-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.draft-title { font-size: 20px; font-weight: 700; text-align: center; color: var(--text-primary); }
.draft-leave-btn { background: transparent; border: 1px solid var(--text-muted); color: var(--text-muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.draft-leave-btn:hover { border-color: var(--danger); color: var(--danger); }
.draft-leave-confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.draft-leave-confirm:hover { background: var(--danger); border-color: var(--danger); color: #fff; opacity: 0.9; }

/* Pack wrappers */
.packs-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 8px 0; }
/* Pack wrappers — styled booster packs */
.pack-wrapper {
  width: 90px;
  height: 130px;
  border-radius: 8px;
  background: linear-gradient(170deg, #1a1a1a 0%, #111 50%, #1a1a1a 100%);
  border: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}

/* Inner border detail */
.pack-wrapper::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  pointer-events: none;
}

/* Subtle sheen sweep */
.pack-wrapper::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.03) 45%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 55%, transparent 60%);
  pointer-events: none;
  transition: transform 0.5s;
}

.pack-wrapper:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}

.pack-wrapper:hover::after {
  transform: translateX(30%) translateY(30%);
}

.pack-wrapper.opened {
  background: transparent;
  border: 2px dashed var(--border-interactive);
  opacity: 0.3;
  cursor: default;
}

.pack-wrapper.opened::before,
.pack-wrapper.opened::after {
  display: none;
}

.pack-wrapper.opened:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-interactive);
}

.pack-set-icon {
  width: 36px;
  height: 36px;
  filter: brightness(0) invert(1);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.pack-wrapper:hover .pack-set-icon {
  opacity: 1;
}

.pack-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  max-width: 100%;
  padding: 0 6px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.pack-label.opened-label {
  color: var(--text-ghost);
}

/* Deck stats bar */
.deck-stats-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text-dim); }
.stat-item { white-space: nowrap; }
.stat-item b { color: var(--text-primary); font-weight: 700; }

/* Mana curve */
.mana-curve { display: inline-flex; align-items: flex-end; gap: 2px; margin-left: auto; }
.curve-col { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.curve-bar { width: 12px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; transition: height 0.2s; }
.curve-label { font-size: 8px; color: var(--text-muted); }

/* Sort controls */
.sort-controls { display: flex; gap: 6px; justify-content: center; }
.sort-btn { padding: 8px 14px; border: 1px solid var(--border-interactive); border-radius: 8px; background: var(--bg-elevated); color: var(--text-dim); font-size: 12px; font-weight: 500; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.sort-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-btn.active { background: var(--btn-primary-bg); border-color: var(--btn-primary-bg); color: var(--text-on-primary-btn); }

/* Draft sections */
.draft-section { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.draft-section-header { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--divider); }

/* Sort groups */
.sort-group { margin-bottom: 10px; }
.sort-group:last-child { margin-bottom: 0; }
.sort-group-header { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.sort-group-cards { display: flex; flex-wrap: wrap; gap: 6px; }

/* Draft cards */
.draft-card { cursor: pointer; transition: transform 0.15s, opacity 0.15s; position: relative; }
.draft-card:hover { transform: translateY(-4px); z-index: 10; }
.draft-card .card:hover { z-index: auto; }
.draft-stack-badge { position: absolute; top: -4px; right: -4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 8px; z-index: 15; pointer-events: none; line-height: 1.3; }
.draft-card-reveal { animation: draftCardReveal 0.3s ease-out both; }
@keyframes draftCardReveal {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Basic lands panel */
.lands-panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.lands-panel-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--divider); }
.lands-grid { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.land-tile { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 80px; }
.land-pip { width: 30px; height: 30px; }
.land-tile-name { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.land-tile-controls { display: flex; align-items: center; gap: 6px; }
.land-tile-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-interactive); background: var(--bg-surface); color: var(--text-primary); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.land-tile-btn:hover { background: var(--bg-hover); }
.land-tile-count { font-size: 18px; font-weight: 700; color: var(--text-primary); min-width: 20px; text-align: center; }

/* Draft actions */
.draft-actions { display: flex; justify-content: center; padding: 8px 0; }
.draft-ready-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 400px; }
.draft-ready-header { display: flex; justify-content: space-between; align-items: center; }
.draft-ready-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.draft-ready-count { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.draft-ready-stats { font-size: 12px; color: var(--text-dim); }
.draft-deck-name-input { padding: 10px 12px; border: 1px solid var(--border-input); border-radius: 8px; font-size: 14px; font-weight: 500; outline: none; width: 100%; box-sizing: border-box; transition: border-color 0.2s; background: var(--bg-input); color: var(--text-primary); }
.draft-deck-name-input:focus { border-color: var(--border-focus); }
.input-error { border-color: var(--danger) !important; background: rgba(192,50,26,0.05); }
.input-error::placeholder { color: var(--danger); }
.draft-waiting { font-size: 14px; color: var(--text-muted); font-style: italic; padding: 12px; }

/* Draft players */
.draft-players { display: flex; flex-direction: column; gap: 6px; }
.draft-player { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; }
.draft-player.ready { border-color: var(--success); background: rgba(42,138,42,0.1); }
.draft-player-name { font-weight: 500; font-size: 13px; }
.draft-player-deck { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.draft-player-status { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.draft-player.ready .draft-player-status { color: var(--success); font-weight: 600; }

/* Draft responsive — phone */
@media (max-width: 480px) {
  .pack-wrapper { width: 70px; height: 100px; }
  .pack-set-icon { width: 28px; height: 28px; }
  .pack-label { font-size: 8px; }
  .land-tile-btn { width: 36px; height: 36px; min-height: 44px; font-size: 18px; }
  .land-tile { min-width: 70px; padding: 8px; }
  .land-pip { width: 24px; height: 24px; }
  .sort-btn { padding: 10px 12px; font-size: 13px; min-height: 44px; }
  .draft-actions .lobby-btn { min-height: 48px; }
}

/* Drag-and-drop */
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: 0.8; transform: rotate(2deg) scale(1.05); }
.drag-source { opacity: 0.3; }
.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; transition: outline-color 0.15s, background 0.15s; }
.drop-target-hover { outline-color: #6a5acd; background: var(--accent-bg) !important; }

/* Deck tabs */
.deck-tabs { display: flex; gap: 4px; background: var(--deck-tab-track, rgba(255,255,255,0.04)); border-radius: 8px; padding: 3px; border: 1px solid var(--border); }
.deck-tab { flex: 1; padding: 8px; border: none; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.2s, color 0.2s; text-align: center; }
.deck-tab:hover { color: var(--text-dim); background: var(--deck-tab-hover, rgba(255,255,255,0.03)); }
.deck-tab.active { background: var(--bg-elevated); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.saved-deck-list { max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.saved-deck-item { padding: 10px 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.saved-deck-item:hover { background: var(--bg-hover); }
.saved-deck-item.selected { border-color: var(--accent); background: var(--accent-bg); }
.saved-deck-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.saved-deck-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.saved-deck-empty { font-size: 13px; color: var(--text-muted); font-style: italic; padding: 20px; text-align: center; }
.deck-tag { font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 600; text-transform: uppercase; }
.deck-tag.draft { background: var(--accent-bg); color: var(--accent); }

/* Info banners */
/* Game card (join existing) */
.game-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.game-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.game-card-mode { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.game-card-status { font-size: 11px; padding: 3px 10px; border-radius: 99px; background: var(--bg-surface); color: var(--text-dim); font-weight: 600; }
.game-card-detail { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.game-card-avatars { display: flex; gap: 8px; margin-bottom: 10px; }
.game-card-waiting { font-size: 12px; color: var(--text-muted); }
.lobby-anon-count { font-size: 11px; color: var(--text-ghost); text-align: center; margin-top: 6px; font-style: italic; }

.info-banner { padding: 10px 14px; border-radius: 10px; text-align: center; font-size: 12px; font-weight: 600; }
.join-banner { background: var(--banner-info-bg); border: 1px solid var(--banner-info-border); color: var(--banner-info-text); }
.warn-banner { background: var(--banner-warn-bg); border: 1px solid var(--banner-warn-border); color: var(--banner-warn-text); }

/* === Touch Preview (inline zoom + quick actions) === */
.touch-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(0, 0, 0, 0.3);
  animation: overlayFadeIn 0.15s ease-out;
}

.touch-preview-backdrop.closing {
  animation: overlayFadeOut 0.1s ease-in forwards;
}

.touch-preview-container {
  position: fixed;
  z-index: 251;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: panelScaleIn 0.15s ease-out;
}

.touch-preview-container.closing {
  animation: panelScaleOut 0.1s ease-in forwards;
}

.touch-preview-card {
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--accent);
  box-shadow: 0 8px 32px rgba(139, 119, 221, 0.4);
}

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

.touch-preview-toolbar {
  display: flex;
  background: var(--bg-surface);
  border-radius: 10px;
  overflow: hidden;
  min-height: 44px;
}

.touch-preview-action {
  padding: 8px 16px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.touch-preview-action + .touch-preview-action {
  border-left: 1px solid var(--border);
}

.touch-preview-action:active {
  background: var(--bg-hover);
}

/* Dim siblings of the previewed card */
.touch-preview-dimmed {
  opacity: 0.3 !important;
  pointer-events: none !important;
}

@media (pointer: coarse) {
  /* Action bar */
  .action-btn { min-height: 48px; }
  /* Context menu buttons */
  .context-btn { min-height: 48px; }
  /* Commander damage +/- buttons */
  .cmd-dmg-btn { width: 44px; height: 44px; font-size: 16px; }
  /* Commander damage toggle */
  .cmd-dmg-toggle { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  /* Zone overlay close button */
  .overlay-close { width: 44px; height: 44px; font-size: 22px; }
  /* Settings gear */
  .settings-gear { width: 44px; height: 44px; }
  /* Sort buttons in draft */
  .sort-btn { min-height: 44px; }
  .number-input { font-size: 16px; }
  .peek-card { width: 150px; }
  .peek-inner { padding: 12px; }
  /* Land tile +/- buttons in draft */
  .land-tile-btn { width: 44px; height: 44px; font-size: 20px; }
  /* Pack count +/- buttons in lobby */
  .pack-count-btn { width: 44px; height: 44px; font-size: 20px; }
  /* Disable hover effects that cause bounce/stuck states on touch */
  .player-hand .card:hover { transform: none; margin-left: -18px; margin-right: 0; }
  .player-hand .card:first-child:hover { margin-left: 0; }
  .card:hover { border-color: var(--card-border); }
  .card-stack .card:hover { transform: none; }
}

/* Auth */
.auth-header { text-align: center; margin-bottom: 8px; }
.auth-title { font-size: 38px; font-weight: 800; letter-spacing: -1.5px; color: var(--text-primary); margin: 0; }
.auth-divider { width: 36px; height: 1px; background: var(--border); margin: 12px auto; }
.auth-subtitle { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin: 0 0 16px; }
.auth-switch { font-size: 12px; color: var(--text-dim); text-align: center; margin-top: 4px; }
.auth-link { color: var(--text-muted); text-decoration: underline; cursor: pointer; }
.auth-link:hover { color: var(--text-primary); }
.auth-error {
  color: #e55; font-size: 13px; text-align: center; padding: 8px;
  background: rgba(238, 85, 85, 0.1); border-radius: 6px; margin-top: 4px;
}

/* Logout icon */
.logout-icon {
  position: fixed; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); cursor: pointer; transition: color 0.15s;
  z-index: 10;
}
.logout-icon:hover { color: var(--text-secondary); }

.admin-link {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
  text-decoration: none;
  z-index: 10;
}
.admin-link:hover { color: var(--text-secondary); }

/* Settings menu additions */
.settings-divider { height: 1px; background: var(--border); margin: 4px 8px; }
.settings-danger { color: var(--danger) !important; }
.settings-confirm-buttons { display: flex; gap: 8px; padding: 8px; }
.settings-confirm-buttons .settings-option { flex: 1; text-align: center; }

/* Room list */
.room-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.room-card {
  padding: 12px 14px; background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px; cursor: pointer; transition: background 0.15s;
}
.room-card:hover { background: var(--bg-hover); }
.room-card.full { opacity: 0.5; cursor: default; }
.room-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.room-card-name { font-weight: 600; font-size: 14px; }
.room-card-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.room-card-players {
  font-size: 12px; font-weight: 600; padding: 3px 8px; color: var(--text-muted);
  background: var(--bg-surface); border-radius: 5px; flex-shrink: 0;
}
.room-card.full .room-card-players { color: #e55; }
.room-empty { text-align: center; color: var(--text-secondary); padding: 24px; font-size: 14px; }

/* Create room form */
.create-room-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ── Coin/Dice Animation Overlay ── */
/* Backdrop sits BELOW the three.js canvas (#three-overlay is z-index 9999) so the
   3D dice/coin render on top of the dim, not underneath it. Text layer sits above. */
.anim-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.5);
  pointer-events: none;
  transition: opacity 0.4s;
}
.anim-backdrop.fading { opacity: 0; }
.anim-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.4s;
}
.anim-overlay.fading { opacity: 0; }

.anim-result {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}
.anim-result.visible { opacity: 1; transform: translateY(0); }
.anim-who {
  font-size: 13px;
  margin-top: 4px;
  opacity: 0.7;
}

/* ── Details Modal ── */
.details-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.details-modal {
  background: var(--bg-zone);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
}
.details-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
}
.details-layout {
  display: flex;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
  max-height: 80vh;
}
.details-image img {
  width: 220px;
  border-radius: 8px;
  flex-shrink: 0;
}
.details-content { flex: 1; min-width: 0; }
.details-name { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.details-mana { margin: 4px 0 6px; }
.details-type { font-size: 14px; color: var(--text-muted); font-style: italic; }
.details-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.details-oracle { font-size: 14px; color: var(--text-primary); line-height: 1.5; }
.details-oracle p { margin: 4px 0; }
.details-header { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.details-list { max-height: 300px; overflow-y: auto; }
.ruling-entry { margin-bottom: 10px; font-size: 13px; }
.ruling-date { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.ruling-text { color: var(--text-primary); line-height: 1.4; }
.ruling-empty { font-size: 13px; color: var(--text-muted); font-style: italic; }
.details-face-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.details-face-tab {
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}
.details-face-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Mana pips */
.mana-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  margin: 0 1px;
}

/* Mobile details */
@media (max-width: 768px) {
  .details-layout { flex-direction: column; }
  .details-image { text-align: center; }
  .details-image img { width: 180px; }
}

/* ── Cube Draft ── */
.draft-type-toggle { display: flex; gap: 4px; margin-bottom: 12px; }
.draft-type-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.draft-type-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cube-validation { font-size: 12px; margin-top: 8px; padding: 6px 10px; border-radius: 6px; }
.cube-validation.ok { color: #6bdf6b; background: rgba(107,223,107,0.1); }
.cube-validation.error { color: #e87070; background: rgba(232,112,112,0.1); }

/* ── Chaos Draft Tier Picker ── */
.chaos-tier-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.chaos-tier-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.chaos-tier-option:hover { border-color: var(--accent); }
.chaos-tier-option input[type="radio"] { margin-top: 3px; accent-color: var(--accent); }
.chaos-tier-option:has(input:checked) { border-color: var(--accent); background: rgba(255, 150, 80, 0.08); }
.chaos-tier-body { flex: 1; }
.chaos-tier-title { font-weight: 600; font-size: 13px; color: var(--text); }
.chaos-tier-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }

/* ── Turn Notification ── */
.turn-flash {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  border: 4px solid transparent;
  opacity: 0;
  transition: opacity 0.3s;
}
.turn-flash.active {
  opacity: 1;
  animation: turn-flash-pulse 0.8s ease-out;
}
.turn-flash.fading { opacity: 0; }
@keyframes turn-flash-pulse {
  0% { border-width: 4px; opacity: 0; }
  30% { border-width: 6px; opacity: 1; }
  60% { border-width: 4px; opacity: 0.7; }
  100% { border-width: 3px; opacity: 0; }
}

.turn-badge {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 9997;
  pointer-events: none;
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.turn-badge.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1024px) {
  .turn-badge { bottom: 160px; }
}

/* Three.js overlay canvas */
#three-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Pack opening — shake, glow, pop */
.pack-shaking {
  animation: packShake 0.8s ease-in forwards;
  box-shadow: 0 0 0 rgba(124, 131, 255, 0);
}

@keyframes packShake {
  0%   { transform: translateX(0);    box-shadow: 0 0 5px rgba(124, 131, 255, 0.1); }
  10%  { transform: translateX(-2px); box-shadow: 0 0 8px rgba(124, 131, 255, 0.15); }
  20%  { transform: translateX(2px);  box-shadow: 0 0 10px rgba(124, 131, 255, 0.2); }
  30%  { transform: translateX(-3px); box-shadow: 0 0 14px rgba(124, 131, 255, 0.3); }
  40%  { transform: translateX(3px);  box-shadow: 0 0 18px rgba(124, 131, 255, 0.4); }
  50%  { transform: translateX(-4px); box-shadow: 0 0 22px rgba(124, 131, 255, 0.5); }
  60%  { transform: translateX(5px);  box-shadow: 0 0 28px rgba(167, 139, 250, 0.6); }
  70%  { transform: translateX(-5px); box-shadow: 0 0 34px rgba(167, 139, 250, 0.7); }
  80%  { transform: translateX(6px);  box-shadow: 0 0 40px rgba(167, 139, 250, 0.8); }
  90%  { transform: translateX(-6px); box-shadow: 0 0 45px rgba(167, 139, 250, 0.9); }
  100% { transform: translateX(0);    box-shadow: 0 0 50px rgba(167, 139, 250, 1.0); }
}

.pack-popping {
  animation: packPop 0.5s ease-out forwards;
}

@keyframes packPop {
  0%   { transform: scale(1);    opacity: 1; box-shadow: 0 0 50px rgba(167, 139, 250, 1.0); }
  40%  { transform: scale(1.15); opacity: 0.8; box-shadow: 0 0 60px rgba(167, 139, 250, 0.8); }
  100% { transform: scale(0.8);  opacity: 0; box-shadow: 0 0 0 rgba(167, 139, 250, 0); }
}

/* ── Combat states ── */
.combat-attacking {
  border-color: rgba(231, 76, 60, 0.6) !important;
  box-shadow: 0 0 12px rgba(231, 76, 60, 0.3) !important;
}
.combat-blocking {
  border-color: rgba(52, 152, 219, 0.6) !important;
  box-shadow: 0 0 12px rgba(52, 152, 219, 0.3) !important;
}
.combat-dimmed {
  opacity: 0.5;
}

/* ── Combat buttons ── */
.combat-buttons {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 2;
  display: flex;
  gap: 6px;
  align-items: center;
}
.combat-btn {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.combat-btn-attack {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
  border-color: rgba(231, 76, 60, 0.3);
}
.combat-btn-block {
  background: rgba(52, 152, 219, 0.15);
  color: #3498db;
  border-color: rgba(52, 152, 219, 0.3);
}
.combat-btn-clear {
  background: rgba(39, 174, 96, 0.15);
  color: #27ae60;
  border-color: rgba(39, 174, 96, 0.3);
}
.combat-btn-cancel {
  background: transparent;
  color: #888;
  border-color: #555;
}
.combat-btn.active {
  color: #fff;
  box-shadow: 0 0 10px currentColor;
}
.combat-btn-attack.active {
  background: rgba(231, 76, 60, 0.3);
  border-color: #e74c3c;
}
.combat-btn-block.active {
  background: rgba(52, 152, 219, 0.3);
  border-color: #3498db;
}
.combat-btn.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

/* Mobile combat buttons */
@media (pointer: coarse) {
  .combat-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 6px 10px;
    font-size: 13px;
  }
}
@media (max-width: 480px) {
  .combat-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* Light theme combat overrides */
.light-theme .combat-btn-attack {
  background: rgba(231, 76, 60, 0.1);
}
.light-theme .combat-btn-block {
  background: rgba(52, 152, 219, 0.1);
}
.light-theme .combat-btn-clear {
  background: rgba(39, 174, 96, 0.1);
}
.light-theme .combat-btn-cancel {
  color: #666;
  border-color: #ccc;
}

/* === Mobile sticky header + player drawer === */

/* Hidden by default (desktop) — only shown inside the mobile media query. */
.game-header { display: none; }
.player-drawer,
.player-drawer-backdrop { display: none; }

/* Mobile breakpoint matches _isMobile() in board.js (<= 1024). */
@media (max-width: 1024px) {
  /* Sticky header at the top with hamburger + turn indicator + settings. */
  .game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    padding: 0 10px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    z-index: 50;
  }

  .gh-menu-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .gh-turn-wrap {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .gh-turn.mine {
    color: var(--accent);
    font-weight: 600;
  }
  .gh-spacer { flex: 0 0 0; }
  .gh-gear {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
  }

  /* Drawer itself — slides in from the left below the sticky header. */
  .player-drawer {
    display: block;
    position: fixed;
    top: 44px;
    bottom: 0;
    left: 0;
    width: min(320px, 85vw);
    background: var(--panel-bg);
    border-right: 1px solid var(--border);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .player-drawer.open { transform: translateX(0); }

  .player-drawer-backdrop {
    display: block;
    position: fixed;
    top: 44px;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }
  .player-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* Drawer hosts the same .player-column used on desktop. The earlier
     rule (line ~1200) hides the board-layout copy on mobile; re-show the
     drawer copy and give it mobile-appropriate sizing. Drop the desktop
     panel border/radius — the drawer itself is already the rounded panel. */
  .player-drawer .player-column {
    display: flex;
    width: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    padding: 10px;
    box-sizing: border-box;
  }

  /* Push board content down so the sticky header doesn't overlap it. */
  .board-layout { padding-top: 44px; }
}

/* ── Details modal: Prices section ───────────────────────────── */
.details-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.ds-title { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.ds-loading { font-size: 12px; color: var(--text-muted); font-style: italic; }
.ds-error { font-size: 12px; color: var(--text-muted); }
.price-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.price-row:last-child { border-bottom: none; }
.price-site { font-size: 13px; color: var(--text-primary); flex: 1; }
.price-region { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.price-value { font-size: 13px; color: var(--accent); font-weight: bold; }
.price-link { color: var(--accent); font-size: 12px; text-decoration: none; }
.price-link:hover { text-decoration: underline; }
