/* ==========================================================================
   DESIGN SYSTEM - OP TCG DECK BUILDER
   ========================================================================== */

:root {
  /* Color Palette - Cosmic Dark Theme */
  --bg-darkest: #080a0f;
  --bg-primary: #0b0e14;
  --bg-secondary: #121721;
  --bg-surface: #18202d;
  
  /* Glassmorphism settings */
  --glass-bg: rgba(18, 23, 33, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  
  /* Typography Colors */
  --text-primary: #f0f2f5;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  
  /* State Colors */
  --color-active: #3b82f6;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  
  /* One Piece Card Game Colors */
  --color-red: #ff4747;
  --color-green: #00e676;
  --color-blue: #2979ff;
  --color-purple: #d500f9;
  --color-black: #b0bec5;
  --color-yellow: #ffea00;
  
  /* Glow Effects */
  --glow-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
  
  /* Layout Constants */
  --header-height: 70px;
  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;

  /* Playtest HUD/Theme Styling Variables (easily swapped for pixel art) */
  --pt-font: inherit;
  --pt-border-radius: var(--border-radius-md);
  --pt-border-style: solid;
  --pt-box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  --pt-image-rendering: auto;
  --pt-badge-bg: rgba(255,255,255,0.04);
  --pt-badge-border: 1px solid var(--glass-border);
  --pt-border-color: rgba(255,255,255,0.1);

  --card-width-pt: 80px;
  --card-height-pt: calc(var(--card-width-pt) * 1.4);
  --hand-card-width-pt: 65px;
  
  /* Font Family */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: var(--border-radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Helper Class: Hidden */
.hidden {
  display: none !important;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-layout {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  height: 100vh;
  width: 100vw;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(213, 0, 249, 0.05) 0%, transparent 40%);
}

.app-layout:has(.app-header.hidden) {
  grid-template-rows: 1fr;
}


.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  box-shadow: 0 4px 20px var(--glass-shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-container {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--glow-shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fff 30%, var(--color-active) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  display: block;
  margin-top: -2px;
}

.app-nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.nav-btn i {
  font-size: 1rem;
}

.nav-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  color: var(--text-primary);
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
}

/* ==========================================================================
   MAIN COMPONENT PANELS
   ========================================================================== */

.app-main {
  position: relative;
  overflow: hidden;
  height: 100%;
}

.panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  display: none;
}

.panel.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
  animation: panel-fade-in var(--transition-normal) forwards;
}

@keyframes panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

/* Glass Panels general styling */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px var(--glass-shadow);
}

/* ==========================================================================
   BUTTONS AND CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background-color: var(--color-active);
  color: #fff;
  box-shadow: var(--glow-shadow);
}

.btn-primary:hover {
  background-color: #2563eb;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--glass-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: #232d3f;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--color-danger);
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.3);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--border-radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Form Controls */
.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-active);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.select-box select {
  width: 100%;
  padding: 12px 16px;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

.select-box select:focus {
  border-color: var(--color-active);
}

/* Toggle Switch */
.checkbox-box {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .slider {
  background-color: rgba(59, 130, 246, 0.2);
  border-color: var(--color-active);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--color-active);
  box-shadow: 0 0 8px var(--color-active);
}

/* ==========================================================================
   SIDEBAR FILTERS
   ========================================================================== */

.sidebar-filters {
  border-right: 1px solid var(--glass-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  height: 100%;
}

.filter-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 12px;
  font-weight: 700;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

#filter-cost.btn-grid {
  grid-template-columns: repeat(4, 1fr);
}

.filter-chip {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chip:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.filter-chip.active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: var(--color-active);
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

/* Color Chips overrides */
.filter-chip.color-red.active {
  background-color: rgba(255, 71, 71, 0.15);
  border-color: var(--color-red);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 71, 71, 0.2);
}
.filter-chip.color-green.active {
  background-color: rgba(0, 230, 118, 0.15);
  border-color: var(--color-green);
  color: #fff;
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.2);
}
.filter-chip.color-blue.active {
  background-color: rgba(41, 121, 255, 0.15);
  border-color: var(--color-blue);
  color: #fff;
  box-shadow: 0 0 8px rgba(41, 121, 255, 0.2);
}
.filter-chip.color-purple.active {
  background-color: rgba(213, 0, 249, 0.15);
  border-color: var(--color-purple);
  color: #fff;
  box-shadow: 0 0 8px rgba(213, 0, 249, 0.2);
}
.filter-chip.color-black.active {
  background-color: rgba(176, 190, 197, 0.15);
  border-color: var(--color-black);
  color: #fff;
  box-shadow: 0 0 8px rgba(176, 190, 197, 0.2);
}
.filter-chip.color-yellow.active {
  background-color: rgba(255, 234, 0, 0.15);
  border-color: var(--color-yellow);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 234, 0, 0.2);
}

/* ==========================================================================
   CARD DISPLAY AREA
   ========================================================================== */

.card-display-area {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  height: 100%;
}

.display-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 16px;
}

.results-count {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
}

.results-count span {
  font-weight: 700;
  color: var(--text-primary);
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.sort-box select {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 6px 12px;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

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

/* Compact grid inside builder panel */
.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

/* ==========================================================================
   CARD ITEMS (GRID CARD)
   ========================================================================== */

.card-item {
  position: relative;
  aspect-ratio: 1 / 1.4;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  cursor: pointer;
  background-color: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: all var(--transition-fast);
  user-select: none;
}

.card-item:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 10;
}

/* Card visual overlay styling based on colors */
.card-item.glow-Red:hover { box-shadow: 0 0 15px rgba(255, 71, 71, 0.4); border-color: var(--color-red); }
.card-item.glow-Green:hover { box-shadow: 0 0 15px rgba(0, 230, 118, 0.4); border-color: var(--color-green); }
.card-item.glow-Blue:hover { box-shadow: 0 0 15px rgba(41, 121, 255, 0.4); border-color: var(--color-blue); }
.card-item.glow-Purple:hover { box-shadow: 0 0 15px rgba(213, 0, 249, 0.4); border-color: var(--color-purple); }
.card-item.glow-Black:hover { box-shadow: 0 0 15px rgba(176, 190, 197, 0.4); border-color: var(--color-black); }
.card-item.glow-Yellow:hover { box-shadow: 0 0 15px rgba(255, 234, 0, 0.4); border-color: var(--color-yellow); }

/* Double color leader border */
.card-item.double-color-border {
  border-width: 2px;
}

.card-image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.3s;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

/* Text fallback card when image fails */
.card-text-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-primary) 100%);
  border-radius: var(--border-radius-md);
  font-size: 0.75rem;
  z-index: 1;
}

.fallback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--text-secondary);
}

.fallback-rarity {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  font-size: 0.6rem;
}

.fallback-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  margin: 10px 0;
}

.fallback-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  line-height: 1.2;
}

.fallback-type {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.fallback-stats {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Card Action Overlays */
.card-count-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: var(--color-active);
  color: #fff;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  z-index: 5;
}

.col-owned-badge {
  background-color: var(--color-success);
}

.card-quick-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 60%, transparent 100%);
  padding: 10px;
  display: flex;
  justify-content: space-around;
  gap: 6px;
  opacity: 0;
  transform: translateY(100%);
  transition: all var(--transition-fast);
  z-index: 5;
}

.card-item:hover .card-quick-actions {
  opacity: 1;
  transform: translateY(0);
}

.action-btn-sm {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.action-btn-sm:hover {
  background-color: var(--color-active);
  border-color: transparent;
}

.action-btn-sm.btn-sub:hover {
  background-color: var(--color-danger);
}

/* Loading state */
.loading-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--text-secondary);
  gap: 16px;
}

.loading-icon {
  font-size: 2.5rem;
  color: var(--color-active);
}

/* ==========================================================================
   COLLECTION MANAGER PANEL
   ========================================================================== */

.collection-summary {
  padding: 24px;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100%;
  overflow-y: auto;
}

.summary-metric {
  display: flex;
  flex-direction: column;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 16px;
  border-radius: var(--border-radius-md);
  text-align: center;
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 0%, var(--color-active) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
  font-weight: 600;
}

.collection-quick-add h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.quick-add-form {
  display: flex;
  gap: 8px;
}

.quick-add-form input {
  flex-grow: 1;
  padding: 10px 14px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  text-transform: uppercase;
}

.quick-add-form input:focus {
  outline: none;
  border-color: var(--color-active);
}

.quick-add-form button {
  padding: 0 16px;
}

.form-help {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.collection-explorer {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  height: 100%;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 4rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty-state h2 {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 10px;
  font-weight: 700;
}

.empty-state p {
  max-width: 420px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==========================================================================
   DECK BUILDER PANEL & WORKSPACE
   ========================================================================== */

.decks-dashboard {
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
  overflow-y: auto;
  height: 100%;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 16px;
}

.dashboard-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

/* Deck item inside dashboard */
.deck-card {
  position: relative;
  border-radius: var(--border-radius-md);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  aspect-ratio: 1.8 / 1;
  background: linear-gradient(135deg, rgba(24, 32, 45, 0.4) 0%, rgba(18, 23, 33, 0.7) 100%);
}

.deck-card:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.deck-card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.deck-card-info h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.deck-card-leader {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.deck-card-leader-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.deck-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.deck-card-count {
  background-color: rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.deck-card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

.deck-card-badge.valid {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.deck-card-badge.invalid {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.deck-card-img-preview {
  width: 50px;
  height: 70px;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Favorite star overlay on a deck tile - .deck-card already has position:relative */
.deck-fav-star {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  z-index: 2;
}

.deck-fav-star:hover {
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.7);
}

.deck-fav-star.active {
  color: #f1c40f;
}

#deck-inspect-fav-btn.active {
  color: #f1c40f;
  border-color: rgba(241, 196, 15, 0.4);
}

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

/* Workspace editor view layout */
.deck-workspace {
  display: grid;
  grid-template-columns: 1fr 480px;
  height: 100%;
}

.workspace-search {
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.workspace-search-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.workspace-search-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-search-bar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ws-color-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.ws-color-filter .filter-chip {
  padding: 6px 12px;
  font-size: 0.75rem;
}

#ws-card-grid {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Right side Workspace deck list */
.workspace-decklist {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: rgba(0,0,0,0.15);
}

.decklist-header {
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.deck-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deck-title-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
  max-width: 280px;
}

.deck-title-edit input {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  width: 100%;
  border-bottom: 1px dashed var(--text-muted);
  padding-bottom: 2px;
}

.deck-title-edit input:focus {
  outline: none;
  border-bottom-color: var(--color-active);
}

.deck-rules-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.deck-counter {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}

.deck-validation-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
}

.deck-validation-badge.valid {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.deck-validation-badge.invalid {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Coach category taxonomy badge - same pill shape/typography as
   .deck-validation-badge, neutral color instead of valid/invalid green/red since a
   category isn't a pass/fail signal. */
.coach-category-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--color-active);
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-right: 6px;
}

.coach-tip-followed-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-left: 6px;
}

.coach-tip-followed-badge.followed {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.coach-tip-followed-badge.different {
  background-color: rgba(241, 196, 15, 0.15);
  color: var(--color-yellow);
  border: 1px solid rgba(241, 196, 15, 0.3);
}

.coach-tip-followed-badge.na {
  background-color: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}

.deck-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* Leader Slot */
.leader-section-container {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.leader-section-container h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  font-weight: 700;
}

.leader-slot {
  border: 2px dashed var(--glass-border);
  border-radius: var(--border-radius-md);
  aspect-ratio: 4 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.leader-slot:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.leader-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  gap: 6px;
  font-size: 0.85rem;
}

.leader-placeholder i {
  font-size: 1.5rem;
}

/* Leader Slot Populated View */
.leader-active-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 16px;
  background-color: rgba(255, 255, 255, 0.02);
  position: relative;
  cursor: pointer;
}

.leader-active-img {
  height: 100%;
  aspect-ratio: 1 / 1.4;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}

.leader-active-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leader-active-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.leader-active-name {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.leader-active-colors {
  display: flex;
  gap: 4px;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}

.leader-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 8px;
  transition: color var(--transition-fast);
}

.leader-remove-btn:hover {
  color: var(--color-danger);
}

/* Decklist Scroll items */
.decklist-container {
  flex-grow: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.decklist-scroll {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.deck-group h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 4px;
}

.deck-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  margin-bottom: 6px;
  gap: 12px;
  transition: all var(--transition-fast);
}

.deck-item-row:hover {
  background-color: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
}

.deck-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
  min-width: 0;
  cursor: pointer;
}

.deck-item-cost {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.15);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.deck-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-item-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.deck-item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.deck-item-quantity {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
  width: 16px;
  text-align: center;
}

.btn-item-action {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
}

.btn-item-action:hover {
  color: #fff;
}

/* Collection Inventory warning inside decklist row */
.deck-item-row.warning-owned {
  border-color: rgba(245, 158, 11, 0.4);
  background-color: rgba(245, 158, 11, 0.05);
}

.deck-item-row.warning-owned .deck-item-name {
  color: var(--color-warning);
}

.warning-icon-owned {
  color: var(--color-warning);
  font-size: 0.8rem;
  margin-left: 6px;
}

/* Deck Analytics view */
.deck-analytics {
  padding: 20px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: 250px;
}

.deck-analytics h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  font-weight: 700;
}

/* Custom HTML Cost Chart (Mana Curve) */
.cost-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 80px;
  padding: 0 10px;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 4px;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.chart-bar {
  width: 100%;
  background-color: rgba(59, 130, 246, 0.3);
  border: 1px solid var(--color-active);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  position: relative;
}

.chart-bar:hover {
  background-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.chart-bar-value {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.deck-types-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.stats-list, .rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  padding-bottom: 4px;
}

.stats-list span {
  font-weight: 700;
  color: #fff;
}

.rules-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.valid-icon { color: var(--color-success); }
.invalid-icon { color: var(--color-danger); }
.warning-icon { color: var(--color-warning); }

/* ==========================================================================
   CAMERA SCANNER OVERLAY & MODAL
   ========================================================================== */

/* Ensure closed dialogs are completely hidden to prevent event blocking on mobile */
dialog:not([open]) {
  display: none !important;
}

.scanner-modal, .card-detail-modal, .import-export-modal, .confirm-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  padding: 0;
  z-index: 200;
  outline: none;
}

.scanner-modal::backdrop, .card-detail-modal::backdrop, .import-export-modal::backdrop, .confirm-modal::backdrop {
  background-color: rgba(4, 5, 8, 0.85);
  backdrop-filter: blur(8px);
}

/* Reworked gameplay action-sheet: floats on desktop/tablet, bottom-anchored on mobile.
   Supports a minimized/peek state to avoid blocking visual play. */
.action-sheet-modal {
  position: fixed;
  top: auto;
  bottom: 20px;
  left: auto;
  right: 20px;
  width: calc(100% - 40px);
  max-width: 420px;
  margin: 0;
  border: none;
  background: transparent;
  padding: 0;
  z-index: 200;
  outline: none;
  color: var(--text-primary);
  transition: all var(--transition-fast) ease-in-out;
}

@media (max-width: 768px) {
  .action-sheet-modal {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }
}

.action-sheet-modal::backdrop {
  background-color: rgba(4, 5, 8, 0.15); /* Lightened backdrop */
  backdrop-filter: blur(1px); /* Softened blur */
}

.action-sheet-container {
  width: 100%;
  max-height: 70vh;
  max-height: 70dvh;
  overflow-y: auto;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--glass-border);
}

@media (max-width: 768px) {
  .action-sheet-container {
    border-radius: 16px 16px 0 0;
  }
}

/* Minimized/Peek State */
.action-sheet-modal.minimized {
  bottom: 20px;
  right: 20px;
  left: auto;
  top: auto;
  width: auto;
  min-width: 280px;
  max-width: 340px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.action-sheet-modal.minimized .modal-body {
  display: none !important;
}

.action-sheet-modal.minimized .action-sheet-container {
  border-radius: 12px;
  max-height: none;
}

@media (max-width: 768px) {
  .action-sheet-modal.minimized {
    bottom: 70px; /* Float slightly above the bottom navigation bar */
    right: 16px;
    left: auto;
    width: calc(100% - 32px);
    max-width: 360px;
  }
}

/* Header action button controls (minimize/close) */
.header-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-minimize {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-minimize:hover {
  color: var(--text-primary);
  transform: scale(1.15);
}


.action-sheet-option {
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.action-sheet-option:hover {
  background-color: #232d3f;
  border-color: rgba(255, 255, 255, 0.2);
}

.action-sheet-option:last-child {
  margin-bottom: 0;
}

.scanner-container {
  width: 90vw;
  max-width: 500px;
  background-color: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
}

.scanner-header, .modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scanner-header h2, .modal-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: #fff;
}

.scanner-view-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background-color: #000;
  overflow: hidden;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-guide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  /* Bottom-right, not centered - that's where the card ID is actually printed, so the
     guide box (and the crop sent to Vision, which follows this box's on-screen position
     - see computeCropRegion in app.js) should point there instead of the card's middle. */
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 28px 40px 0;
  background-color: rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.scanner-crop-box {
  width: 240px;
  height: 50px;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid var(--color-active);
}

.guide-corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.guide-corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.guide-corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.guide-corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.crop-indicator-text {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scanner-status {
  padding: 16px;
  background-color: rgba(0,0,0,0.4);
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

.scanner-actions {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background-color: var(--bg-secondary);
}

.scanner-actions .select-box {
  flex-grow: 1;
}

/* Scanner results toast feedback */
.scanner-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background-color: rgba(16, 185, 129, 0.95);
  backdrop-filter: blur(4px);
  color: #fff;
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 90vw;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.scanner-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.toast-message {
  flex: 1;
}

.toast-plus-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.toast-plus-btn:hover {
  background: rgba(255,255,255,0.4);
}

/* ==========================================================================
   CARD DETAIL POPUP
   ========================================================================== */

.detail-container {
  width: 90vw;
  max-width: 780px;
  background-color: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 45px rgba(0,0,0,0.8);
}

.detail-layout {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
}

.detail-image-box {
  padding: 24px;
  background-color: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-img {
  width: 100%;
  max-width: 280px;
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

.detail-info-box {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 480px;
  overflow-y: auto;
}

.detail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.detail-id {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: rgba(255,255,255,0.04);
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
}

.detail-info-box h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

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

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
}

.badge-color { background-color: var(--bg-surface); }
.badge-category { background-color: rgba(59, 130, 246, 0.15); color: var(--color-active); border-color: rgba(59, 130, 246, 0.3); }
.badge-rarity { background-color: rgba(255, 255, 255, 0.08); color: var(--text-primary); }

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background-color: rgba(0,0,0,0.15);
  border: 1px solid var(--glass-border);
  padding: 12px;
  border-radius: var(--border-radius-md);
  text-align: center;
}

.detail-stat {
  display: flex;
  flex-direction: column;
}

.detail-stat-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.detail-stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-effect-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 16px;
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
}

.detail-effect-box h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.detail-effect-box p {
  color: var(--text-primary);
  white-space: pre-line;
}

.detail-inventory-label {
  color: var(--text-primary);
  font-size: 0.85rem;
}

.detail-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
}

.detail-qty-control {
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  padding: 4px 8px;
  border-radius: var(--border-radius-md);
}

.qty-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  width: 24px;
  text-align: center;
}

/* ==========================================================================
   IMPORT / EXPORT DIALOG
   ========================================================================== */

.import-export-container {
  width: 90vw;
  max-width: 480px;
  background-color: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

#ie-textarea {
  width: 100%;
  background-color: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 14px;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
}

#ie-textarea:focus {
  border-color: var(--color-active);
}

.modal-actions {
  padding: 20px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-secondary);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================================================== */

@media (max-width: 1024px) {
  /* Deck Workspace Stacked Layout */
  .deck-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    overflow-y: auto;
  }
  
  .workspace-search {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
  }
}

@media (max-width: 768px) {
  /* Panel Layout Stacked */
  .panel-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  
  .sidebar-filters {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    max-height: 280px;
  }
  
  .collection-summary {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    height: auto;
  }
  
  /* App Nav Labels Hidden */
  .nav-btn span {
    display: none;
  }
  
  .nav-btn {
    padding: 12px;
  }
  
  /* Header adjustments */
  .app-header {
    padding: 0 16px;
  }
  
  .brand-text {
    display: none;
  }
  
  /* Card Detail Modal Layout */
  .detail-layout {
    grid-template-columns: 1fr;
  }
  
  .detail-image-box {
    padding: 12px;
  }
  
  .detail-img {
    max-width: 170px; /* Smaller card thumbnail for mobile viewports */
  }
  
  .detail-info-box {
    padding: 16px;
    max-height: 380px;
  }
  
  /* Cost chart scale on mobile */
  .cost-chart {
    gap: 6px;
  }
}



@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
  }
  
  .compact-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
  }
  
  .btn span {
    display: none;
  }
  
  .btn i {
    font-size: 1.1rem;
  }
  
  .header-actions .btn {
    padding: 12px;
  }
  
  .decks-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Buy Badge (fades in on hover, links out to TCGPlayer) */
.card-buy-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: #e67e22;
  color: #fff;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  border: 1px solid #d35400;
  z-index: 5;
  opacity: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-item:hover .card-buy-badge {
  opacity: 1;
}

/* ==========================================================================
   PREMIUM UI/UX POLISH - ANTIGRAVITY ENHANCEMENTS
   ========================================================================== */

/* Skeleton Loading Styling */
.skeleton-card {
  position: relative;
  aspect-ratio: 1 / 1.4;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background: linear-gradient(90deg, var(--bg-surface) 25%, #222c3c 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: pulse-skeleton 1.5s infinite linear;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

@keyframes pulse-skeleton {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 3D Flip Card Effect in Details */
.flip-card {
  background-color: transparent;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1.4;
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

/* Flip on hover or touch/click class */
.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.flip-card-front {
  background-color: var(--bg-surface);
}

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

.flip-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.65rem;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.2s;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
}

.flip-card:hover .flip-hint {
  opacity: 0;
}

.flip-card-back {
  background: radial-gradient(circle at center, #1b263b 0%, #0d1b2a 100%);
  color: white;
  transform: rotateY(180deg);
  border: 2px solid #e67e22; /* Gold/Bronze border like OP card back */
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8), 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.card-back-design {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(230, 126, 34, 0.4);
  border-radius: 8px;
  padding: 10px;
}

.card-back-logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 2px solid #e67e22;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(230, 126, 34, 0.4);
  animation: logo-glow 3s infinite alternate;
}

.card-back-logo img {
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.card-back-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #f1c40f, #e67e22);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.card-back-subtext {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 4px;
  color: #a0aec0;
  margin-top: -5px;
}

@keyframes logo-glow {
  0% {
    box-shadow: 0 0 15px rgba(230, 126, 34, 0.3);
  }
  100% {
    box-shadow: 0 0 30px rgba(230, 126, 34, 0.7);
  }
}

/* Dialog Opening Transitions */
.card-detail-modal[open], .scanner-modal[open], .import-export-modal[open], .confirm-modal[open] {
  animation: modal-fade-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.card-detail-modal::backdrop, .scanner-modal::backdrop, .import-export-modal::backdrop, .confirm-modal::backdrop {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-detail-modal[open]::backdrop, .scanner-modal[open]::backdrop, .import-export-modal[open]::backdrop, .confirm-modal[open]::backdrop {
  opacity: 1;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Deck Workspace Transition */
.deck-workspace:not(.hidden) {
  animation: workspace-fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes workspace-fade-in {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==========================================================================
   TRAINING ROOM / PLAYTEST PANEL
   ========================================================================== */

.playtest-setup {
  max-width: 900px;
  margin: 40px auto;
  padding: 40px;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 45px rgba(0,0,0,0.6);
  text-align: center;
}

.playtest-setup h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #fff;
}

.setup-intro {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 32px;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  align-items: center;
  gap: 24px;
}

.setup-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.setup-vs {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  margin: 0 auto;
}

.deck-preview-box {
  min-height: 180px;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.15);
  overflow: hidden;
}

.empty-preview {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Playtest Board */
.playtest-board {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--glass-border);
  position: relative;
}

.board-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

#pt-turn-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--pt-font);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 18px;
  background: rgba(11, 14, 20, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--pt-border-radius);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
  color: var(--color-active);
  font-size: 0.9rem;
  z-index: 10;
  white-space: nowrap;
}

#pt-turn-indicator.opponent-turn {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
  color: var(--color-red);
}

.vs-badge {
  background: var(--color-active);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  text-transform: uppercase;
}

.board-grid-layout {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.player-board {
  display: flex;
  flex-direction: column;
  padding: 6px 16px;
  overflow: hidden;
  justify-content: space-between;
  position: relative; /* Scope absolute children like side-badge icons */
}

.opponent-board {
  background-color: rgba(255, 71, 71, 0.08);
  border-left: 3px solid rgba(255, 71, 71, 0.4);
}

.user-board {
  background-color: rgba(41, 121, 255, 0.08);
  border-left: 3px solid rgba(41, 121, 255, 0.4);
}

/* Small badge icon marking which side of the board is you vs. the opponent/AI -
   deliberately an icon, not literal "You"/"Opponent" text (see product decision). */
.board-side-icon {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 10;
  font-size: 0.85rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  pointer-events: none; /* Let clicks pass through */
}

.opponent-board .board-side-icon {
  color: #ff4747;
  background: rgba(255, 71, 71, 0.15);
  border: 1px solid rgba(255, 71, 71, 0.3);
}

.user-board .board-side-icon {
  color: #2979ff;
  background: rgba(41, 121, 255, 0.15);
  border: 1px solid rgba(41, 121, 255, 0.3);
}

.board-divider {
  position: relative;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--glass-border) 50%, transparent);
  margin: 12px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.turn-hud-badge {
  background: rgba(41, 121, 255, 0.95);
  border: 1px solid rgba(41, 121, 255, 0.3);
  box-shadow: 0 0 15px rgba(41, 121, 255, 0.5);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: var(--pt-font);
  transition: all 0.3s ease;
}

.turn-hud-badge.opponent-turn {
  background: rgba(255, 71, 71, 0.95);
  border-color: rgba(255, 71, 71, 0.3);
  box-shadow: 0 0 15px rgba(255, 71, 71, 0.5);
}

/* Board Zones */
.board-zones {
  display: grid;
  grid-template-columns: 140px 1fr 200px;
  gap: 20px;
  align-items: center;
  flex-grow: 1;
  margin: 4px 0;
}

.opponent-board .board-zones {
  grid-template-columns: 200px 1fr 140px;
}

.leader-stage-zone {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.leader-slot-pt, .stage-slot-pt {
  width: var(--card-width-pt);
  aspect-ratio: 1 / 1.4;
  border-radius: var(--pt-border-radius);
  border: 2px dashed var(--pt-border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  overflow: hidden;
  box-shadow: var(--pt-box-shadow);
}

.leader-slot-pt img, .stage-slot-pt img, .hand-card img {
  image-rendering: var(--pt-image-rendering);
}

.leader-slot-pt:hover, .stage-slot-pt:hover {
  border-color: var(--color-active);
  background: rgba(0,0,0,0.4);
}

.leader-slot-pt.active-card, .stage-slot-pt.active-card {
  border-style: var(--pt-border-style);
  border-color: rgba(255,255,255,0.2);
}

.rested-allowed.rested {
  transform: rotate(90deg) scale(0.95);
  box-shadow: var(--pt-box-shadow);
  z-index: 5;
}

.don-power-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 6;
  pointer-events: none;
}

.character-zone-pt {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 1px dashed rgba(255,255,255,0.03);
  background: rgba(0,0,0,0.1);
  border-radius: var(--pt-border-radius);
  padding: 10px;
  overflow-x: auto;
}

.side-panel-pt {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-badge-pt {
  background: var(--pt-badge-bg);
  border: var(--pt-badge-border);
  padding: 8px 16px;
  border-radius: var(--pt-border-radius);
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--pt-box-shadow);
  transition: all var(--transition-fast);
}

.metric-badge-pt:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--color-active);
  transform: translateY(-2px);
}

.life-badge { border-color: rgba(241, 196, 15, 0.4); color: var(--color-yellow); }
.don-badge { border-color: rgba(155, 89, 182, 0.4); color: var(--color-purple); }

/* Hand Row */
.hand-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px;
  min-height: 100px;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
  border-radius: var(--pt-border-radius);
  min-width: 0;
}

.compact-hand {
  min-height: 60px;
  transform: scale(0.9);
}

.hand-card {
  width: var(--hand-card-width-pt);
  aspect-ratio: 1 / 1.4;
  border-radius: var(--pt-border-radius);
  background-color: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--pt-box-shadow);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.hand-card:hover {
  transform: translateY(-10px) scale(1.1);
  border-color: var(--color-active);
  z-index: 20;
}

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

/* Quick Actions row */
.pt-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-pt-sm {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  padding: 6px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-pt-sm:hover {
  background: var(--color-active);
  color: #fff;
  border-color: var(--color-active);
}

/* File Upload drag details */
.file-upload-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  text-align: center;
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.file-upload-zone:hover, .file-upload-zone.dragging {
  border-color: var(--color-active);
  background: rgba(59, 130, 246, 0.04);
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.file-upload-zone:hover .upload-icon {
  color: var(--color-active);
}

.upload-link {
  color: var(--color-active);
  text-decoration: underline;
  font-weight: 700;
}

.upload-status {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}

.divider-text {
  text-align: center;
  position: relative;
  margin: 16px 0;
}

.divider-text::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-border);
  z-index: 1;
}

.divider-text span {
  background: var(--bg-surface, #18202d);
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  position: relative;
  z-index: 2;
}

/* Upgrade Modal & Tier Cards */
.upgrade-modal {
  width: 90%;
  max-width: 750px;
  background: transparent;
  border: none;
  padding: 0;
  outline: none;
}

.upgrade-container {
  padding: 30px;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--glass-border);
  background: rgba(21, 26, 38, 0.98);
  backdrop-filter: blur(15px);
  color: #fff;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  max-height: 85vh;
  overflow-y: auto;
}

.upgrade-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.tier-cards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.tier-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  transition: all var(--transition-medium);
  position: relative;
  overflow: hidden;
}

.tier-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
}

.tier-card.active-tier::before {
  background: var(--color-active);
}

.tier-card.pro-tier::before {
  background: linear-gradient(90deg, #f1c40f, #e67e22);
}

.tier-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.tier-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tier-badge {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.tier-card.pro-tier .tier-badge {
  color: #f1c40f;
}

.tier-price {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
}

.tier-price span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tier-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.tier-features li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-features li i {
  color: var(--color-success);
  font-size: 0.9rem;
}

.upgrade-modal[open] {
  animation: modal-fade-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.upgrade-modal::backdrop {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.upgrade-modal[open]::backdrop {
  opacity: 1;
}

@media (max-width: 768px) {
  .tier-cards-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .upgrade-container {
    padding: 20px;
  }
}

/* Mobile Usability Pass v1 - Training Room (both the pre-match Setup screen and
   public/playtest.js's in-match board). Nothing here existed before this pass; none of
   these selectors had any responsive CSS. The board rules are shared verbatim with
   PvP's board markup (the #pvp-me- and #pvp-opp- prefixed selectors), so those fixes apply there too at no extra
   cost. Deliberately placed at the END of the file, not near the other breakpoints
   above - every selector below has its own unscoped base rule defined later in this
   file than the other breakpoints' original location, and CSS resolves equal-
   specificity ties by source order regardless of media-query nesting, so a scoped
   override placed *before* its own base rule loses the tie and silently never applies
   at any viewport width. Confirmed as a real bug this way (not device-specific) via a
   real device screenshot showing the override having no visible effect at all. */
@media (max-width: 600px) {
  /* .board-zones' fixed 200px+200px side columns (see rule above) alone exceed a
     375-430px phone viewport before the center character zone gets any space at all -
     the single biggest phone-layout break in the app. Collapse to one stacked column;
     `order` normalizes p1's and p2's mirrored DOM order (see index.html) to the same
     visual stack: leader/stage row, then characters, then life/DON/deck/trash badges. */
  .board-zones {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px;
    margin: 6px 0;
  }

  .leader-stage-zone {
    flex-direction: row;
    justify-content: center;
    order: 1;
  }

  .character-zone-pt {
    order: 2;
    min-height: 110px;
  }

  .side-panel-pt {
    flex-direction: row;
    flex-wrap: wrap;
    order: 3;
  }

  .side-panel-pt .metric-badge-pt {
    flex: 1 1 calc(50% - 4px);
  }

  /* Plain vh is resolved against mobile Safari/Chrome's *largest* viewport (address bar
     hidden), which can leave the board taller than what's actually visible once the bar
     is showing. dvh (where supported) tracks the real visible viewport instead - kept as
     a second declaration so browsers without dvh support silently keep the vh fallback
     above it. This is a partial fix, not a complete one: the outer shells (.app-layout,
     .app-main, .playtest-board) still use plain vh/100% - a fully robust fix needs a
     uniform dvh pass or a visualViewport-driven CSS variable across the whole shell,
     which is real, more invasive work correctly deferred to the later redesign. */
  .board-grid-layout {
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }


  /* Short viewports responsive scaling */
  @media (max-height: 820px), (max-width: 1024px) {
    :root {
      --card-width-pt: 70px;
      --hand-card-width-pt: 52px;
    }
    .player-board {
      padding: 8px 16px;
    }
    .board-zones {
      gap: 10px;
      margin: 4px 0;
    }
    .character-zone-pt {
      min-height: 110px;
      padding: 6px;
    }
    .hand-row {
      min-height: 80px;
    }
    .board-header {
      padding: 8px 16px;
    }
  }

  /* Tap targets below common ~44px touch guidance. .hand-card/.leader-slot-pt/
     .stage-slot-pt are deliberately left alone - they're this app's real physical-card-
     size convention, not stray undersized buttons. */
  .btn-pt-sm {
    padding: 10px 14px;
    font-size: 0.8rem;
    min-height: 44px;
  }

  .metric-badge-pt {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* .board-header (title + Export/etc. actions) overflows a 375px width even with
     Export hidden by default. */
  .board-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .board-title {
    flex-basis: 100%;
    order: -1;
    justify-content: center;
  }

  /* .setup-grid's rigid `grid-template-columns: 1fr 60px 1fr` (Training Room Setup, the
     pre-match deck-picker screen - a separate screen from the in-match board fixed
     above, missed by this pass originally) squeezes both player cards down to roughly
     100px wide on a real phone once the fixed 60px VS column and .playtest-setup's own
     40px side padding are subtracted - confirmed via a real device photo showing
     "Player 2 (Opponent Deck)"'s heading/dropdown/import button all text-clipped on the
     right edge. Stack to one column; the VS circle becomes its own centered row between
     the two deck cards instead of a middle grid column. */
  .playtest-setup {
    padding: 20px 16px;
    margin: 16px auto;
  }

  .playtest-setup h2 {
    font-size: 1.5rem;
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  /* Grid items (like flex items - see .hand-row's min-width:auto fix earlier in this
     same pass) have an implicit min-width:auto by default, meaning they refuse to
     shrink below their own content's natural minimum width even inside a 1fr column.
     Player 2's card (the "Import 3rd Party Deck" button especially) is wide enough on
     its own to overflow the narrow single column and spill off-screen rather than
     actually stacking. */
  .setup-card {
    min-width: 0;
  }

  .setup-vs {
    margin: 4px auto;
  }

  /* The three preset-game-count buttons (Simulate Matchup / Simulate vs the Field
     panels) are an inline-styled `display:flex; gap:8px` row in index.html with no
     wrap - same "3 items in a row, no responsive handling" issue as .setup-grid. */
  #sim-n-buttons,
  #field-sim-n-buttons {
    flex-wrap: wrap;
  }

  .sim-n-btn,
  .field-sim-n-btn {
    flex: 1 1 calc(33% - 6px);
    min-height: 44px;
  }
}

/* Mobile Usability Pass v1, follow-up (app-wide header/nav) - found via the
   Cards/Collection/Decks/PvP survey appendix, not part of the original Training Room
   scope. .app-header (.brand | .app-nav | .header-actions) has never had any wrap or
   overflow handling at any breakpoint - at a real ~390-412px phone width, the logo (40px)
   + 5 icon-only nav buttons (~40px each + gaps) + the two header-action buttons add up to
   roughly 390-400px on their own, before the header's own side padding, meaning a tab
   (worst case, PvP - the last one) could become genuinely unreachable with no way to
   scroll to it, since body/.app-layout both have overflow:hidden. Placed at the true end
   of the file (same reasoning as the block above - every selector here has its own base
   rule, and the existing 768px breakpoint's .app-header/.nav-btn/.brand-text rules,
   defined earlier in this file - all correctly overridden by placement order alone). */
@media (max-width: 600px) {
  .app-header {
    padding: 0 10px;
  }

  /* .brand and .header-actions keep their natural size (flex-shrink:0) - the logo and
     Sign In/Scan Card buttons are few enough and important enough to always stay fully
     visible. .app-nav is the one section allowed to shrink below its content's natural
     width (min-width:0 - the same flexbox min-width:auto trap already hit and fixed for
     .hand-row in the original pass) and become horizontally scrollable instead - this
     guarantees every tab stays reachable via a swipe even if not all fit on screen at
     once, rather than any tab silently overflowing off-screen with no way back to it. */
  .brand {
    flex-shrink: 0;
  }

  .header-actions {
    flex-shrink: 0;
  }

  .app-nav {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .nav-btn {
    flex-shrink: 0;
    padding: 10px 10px;
  }
}

/* Card Zoom Hover Preview */
#card-zoom-overlay {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  visibility: hidden;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  width: 260px;
  height: 362px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.2);
  background: rgba(20, 26, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#card-zoom-overlay.visible {
  visibility: visible;
  opacity: 1;
  transform: scale(1);
}

#card-zoom-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.deck-item-thumb {
  width: 24px;
  height: 33px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform var(--transition-fast);
}

.deck-item-info:hover .deck-item-thumb {
  transform: scale(1.15);
}

/* Mulligan Banner Styling (Absolute Overlay, Pixel art ready via variables) */
.mulligan-banner {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 8px 16px;
  border-radius: var(--pt-border-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), var(--pt-box-shadow);
  border: 1px solid var(--color-active);
  background: rgba(20, 26, 38, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--pt-font);
}

.opponent-board .mulligan-banner {
  bottom: auto;
  top: 80px;
  border-color: var(--color-red);
}

.user-board .mulligan-banner {
  bottom: auto;
  top: 20px;
}

.mulligan-banner span {
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
}

/* Height-based responsive adjustments (PWA screen heights) */
@media (max-height: 800px) {
  :root {
    --card-width-pt: 72px;
    --hand-card-width-pt: 56px;
  }
  .player-board {
    padding: 4px 12px;
  }
  .board-zones {
    margin: 2px 0;
  }
  .character-zone-pt {
    min-height: 110px;
  }
  #pt-p1-hand-row, #pt-p2-hand-row {
    min-height: 82px;
  }
  .mulligan-banner {
    padding: 6px 12px;
  }
  .opponent-board .mulligan-banner {
    top: 60px;
    bottom: auto;
  }
  .user-board .mulligan-banner {
    top: 12px;
    bottom: auto;
  }
}

@media (max-height: 680px) {
  :root {
    --card-width-pt: 64px;
    --hand-card-width-pt: 48px;
  }
  .board-header {
    padding: 8px 16px;
    margin-bottom: 6px;
  }
  .character-zone-pt {
    min-height: 98px;
  }
  #pt-p1-hand-row, #pt-p2-hand-row {
    min-height: 72px;
  }
}

/* Force Flex layout and height pass-through on the playtest panel wrapper ONLY during an active match */
#playtest-panel.active:has(#playtest-board-view:not(.hidden)),
#playtest-panel.active.match-active {
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
  height: 100%;
}

/* ==========================================================================
   TRAINING ROOM FUTURISTIC SCI-FI TABLETOP REDESIGN
   ========================================================================== */

#playtest-board-view {
  background-color: #020409 !important;
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.5) 0%, transparent 80%),
    radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 0, 60, 0.05) 0%, transparent 40%),
    radial-gradient(1.5px 1.5px at 40px 60px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 200px 100px, rgba(255,255,255,0.6), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 120px 240px, rgba(255,255,255,0.5), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 380px 420px, rgba(255,255,255,0.6), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 620px 150px, rgba(255,255,255,0.4), rgba(0,0,0,0)),
    radial-gradient(2.5px 2.5px at 850px 320px, rgba(255,255,255,0.5), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 1050px 180px, rgba(255,255,255,0.6), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 1300px 390px, rgba(255,255,255,0.5), rgba(0,0,0,0)) !important;
  background-size: cover;
  position: relative;
  overflow: hidden;
}

#playtest-board-view::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  background-position: center;
  pointer-events: none;
  z-index: 0;
}

/* Mirrored Player Boards & Absolute Positions */
.player-board {
  background: transparent !important;
  border: none !important;
  position: relative;
  padding: 12px 32px !important;
}

.board-zones {
  grid-template-columns: 1fr 180px !important;
  padding: 0 40px !important;
}

.opponent-board .board-zones {
  grid-template-columns: 180px 1fr !important;
}

/* Position Metrics Sidebar in Corners */
.user-board .side-panel-pt {
  position: absolute;
  bottom: 12px;
  left: 24px;
  flex-direction: row !important;
  gap: 12px;
  z-index: 10;
}

.opponent-board .side-panel-pt {
  position: absolute;
  top: 12px;
  right: 24px;
  flex-direction: row !important;
  gap: 12px;
  z-index: 10;
}

/* Profile Badges */
.player-profile-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  position: absolute;
  z-index: 10;
  background: rgba(10, 16, 26, 0.7);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.opponent-profile {
  top: 12px;
  left: 24px;
  border-color: rgba(255, 0, 60, 0.25);
  box-shadow: 0 0 10px rgba(255, 0, 60, 0.15);
}

.user-profile {
  bottom: 12px;
  right: 24px;
  border-color: rgba(0, 240, 255, 0.25);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-size: 0.8rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.05em;
  font-family: var(--pt-font);
}

.profile-title {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--pt-font);
}

.profile-avatar-hex {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  color: #fff;
  font-size: 0.8rem;
}

.opponent-profile .profile-avatar-hex {
  background: rgba(255, 0, 60, 0.15);
  box-shadow: inset 0 0 0 1.5px rgba(255, 0, 60, 0.5);
  color: #ff003c;
}

.user-profile .profile-avatar-hex {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: inset 0 0 0 1.5px rgba(0, 240, 255, 0.5);
  color: #00f0ff;
}

/* Hexagonal Metrics Badges */
.metric-badge-pt {
  clip-path: polygon(10px 0%, calc(100% - 10px) 0%, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0% 50%);
  background: rgba(10, 16, 26, 0.8) !important;
  border: none !important;
  padding: 6px 16px !important;
  text-align: center;
  min-width: 90px;
  justify-content: center !important;
  align-items: center;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em;
  box-shadow: none !important;
  transform: none !important;
}

.metric-badge-pt:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  transform: translateY(-1px) !important;
}

.life-badge {
  box-shadow: inset 0 0 0 1px rgba(241, 196, 15, 0.3) !important;
  color: #f1c40f !important;
  filter: drop-shadow(0 0 3px rgba(241, 196, 15, 0.2));
}
.life-badge:hover {
  box-shadow: inset 0 0 0 1px rgba(241, 196, 15, 0.6) !important;
}

.don-badge {
  box-shadow: inset 0 0 0 1px rgba(155, 89, 182, 0.3) !important;
  color: #bb86fc !important;
  filter: drop-shadow(0 0 3px rgba(155, 89, 182, 0.2));
}
.don-badge:hover {
  box-shadow: inset 0 0 0 1px rgba(155, 89, 182, 0.6) !important;
}

.deck-badge {
  box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.3) !important;
  color: #3498db !important;
  filter: drop-shadow(0 0 3px rgba(52, 152, 219, 0.2));
}
.deck-badge:hover {
  box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.6) !important;
}

.trash-badge {
  box-shadow: inset 0 0 0 1px rgba(149, 165, 166, 0.3) !important;
  color: #95a5a6 !important;
  filter: drop-shadow(0 0 3px rgba(149, 165, 166, 0.2));
}
.trash-badge:hover {
  box-shadow: inset 0 0 0 1px rgba(149, 165, 166, 0.6) !important;
}

/* High-Tech Empty Card Slots */
.leader-slot-pt, .stage-slot-pt {
  background: rgba(10, 16, 26, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 4px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  font-size: 0.65rem !important;
  color: rgba(255,255,255,0.3) !important;
  letter-spacing: 0.1em;
}

#pt-p1-leader-slot, #pt-p1-stage-slot {
  border-color: rgba(0, 240, 255, 0.2) !important;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.08), inset 0 0 8px rgba(0, 240, 255, 0.04) !important;
}

#pt-p2-leader-slot, #pt-p2-stage-slot {
  border-color: rgba(255, 0, 60, 0.2) !important;
  box-shadow: 0 0 8px rgba(255, 0, 60, 0.08), inset 0 0 8px rgba(255, 0, 60, 0.04) !important;
}

/* Active Cards on Field (User vs Opponent Glows) */
#pt-p1-leader-slot.active-card, 
#pt-p1-stage-slot.active-card,
#pt-p1-character-zone .leader-slot-pt.active-card {
  border-color: rgba(0, 240, 255, 0.5) !important;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3) !important;
}

#pt-p2-leader-slot.active-card, 
#pt-p2-stage-slot.active-card,
#pt-p2-character-zone .leader-slot-pt.active-card {
  border-color: rgba(255, 0, 60, 0.5) !important;
  box-shadow: 0 0 12px rgba(255, 0, 60, 0.3) !important;
}

/* Trash Slot Styling inside the character area */
.trash-zone-pt {
  border: 1px dashed rgba(0, 240, 255, 0.25);
  box-shadow: inset 0 0 8px rgba(0, 240, 255, 0.05);
}

/* Fanned Hand Cards Layout */
.hand-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 90px !important;
  position: relative;
  margin: 6px 0 !important;
}

.hand-card {
  --angle-step: 3.5deg;
  --y-step: 2px;
  --mid-index: calc((var(--card-count) - 1) / 2);
  --relative-index: calc(var(--card-index) - var(--mid-index));
  
  transform: rotate(calc(var(--relative-index) * var(--angle-step))) 
             translateY(calc(var(--relative-index) * var(--relative-index) * var(--y-step) + 12px));
  transform-origin: center bottom;
  transition: transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s ease !important;
  margin: 0 -10px !important;
  z-index: calc(10 + var(--card-index));
  position: relative;
}

.hand-card:hover {
  transform: scale(1.2) rotate(0deg) translateY(-30px) !important;
  z-index: 100 !important;
  box-shadow: 0 10px 24px rgba(0,0,0,0.55) !important;
}

/* Laser Board Divider */
.board-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 20%, rgba(255,255,255,0.06) 80%, transparent 100%) !important;
  position: relative;
  margin: 8px 0 !important;
}

.board-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 240, 255, 0.3) 30%, rgba(0, 240, 255, 0.3) 50%, rgba(255, 0, 60, 0.3) 50%, rgba(255, 0, 60, 0.3) 70%, transparent 100%) !important;
}

/* Cyber Turn Banner */
.turn-hud-badge {
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.1) 0%, rgba(10, 16, 26, 0.95) 20%, rgba(10, 16, 26, 0.95) 80%, rgba(0, 240, 255, 0.1) 100%) !important;
  border: 1px solid rgba(0, 240, 255, 0.45) !important;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2), inset 0 0 12px rgba(0, 240, 255, 0.08) !important;
  color: #00f0ff !important;
  font-family: var(--pt-font);
  font-weight: 900;
  font-size: 0.85rem !important;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 6px 32px !important;
  clip-path: polygon(12px 0%, calc(100% - 12px) 0%, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0% 50%);
  text-shadow: 0 0 6px rgba(0, 240, 255, 0.4) !important;
}

.turn-hud-badge.opponent-turn {
  background: linear-gradient(90deg, rgba(255, 0, 60, 0.1) 0%, rgba(10, 16, 26, 0.95) 20%, rgba(10, 16, 26, 0.95) 80%, rgba(255, 0, 60, 0.1) 100%) !important;
  border-color: rgba(255, 0, 60, 0.45) !important;
  box-shadow: 0 0 12px rgba(255, 0, 60, 0.2), inset 0 0 12px rgba(255, 0, 60, 0.08) !important;
  color: #ff003c !important;
  text-shadow: 0 0 6px rgba(255, 0, 60, 0.4) !important;
}

/* Hide vertical scrollbar artifacts on the playtest board */
.player-board,
.board-zones,
.leader-stage-zone {
  overflow: hidden !important;
}

.character-zone-pt {
  overflow-y: hidden !important;
}


