/* ==========================================================================
   ManaForge: MTG Deck Architect - Minimalist Developer Tools / Flat Theme
   Theme: Matte Slate / Dark Charcoal (#0f131a / #161c26) & Clean Gold Accent (#d4af37)
   Fully Optimized for Desktop, Tablet (1024px/768px), and Mobile (375px-480px)
   ========================================================================== */

:root {
  /* Obsidian & Charcoal Palette (Deep MTG Dark Theme) */
  --bg-main: #0c1017;
  --bg-surface: #131924;
  --bg-surface-elevated: #1a2232;
  --bg-card: #141b27;
  --bg-card-hover: #1c2637;
  --border-subtle: #242f44;
  --border-active: #38bdf8;
  --border-gold: #d4af37;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0b0f19;

  /* Magic Mana Colors & Radiant Halos */
  --mana-w: #fef08a;
  --mana-w-glow: rgba(254, 240, 138, 0.4);
  --mana-u: #38bdf8;
  --mana-u-glow: rgba(56, 189, 248, 0.4);
  --mana-b: #c084fc;
  --mana-b-glow: rgba(192, 132, 252, 0.4);
  --mana-r: #f87171;
  --mana-r-glow: rgba(248, 113, 113, 0.4);
  --mana-g: #4ade80;
  --mana-g-glow: rgba(74, 222, 128, 0.4);
  --mana-c: #cbd5e1;
  --mana-c-glow: rgba(203, 213, 225, 0.35);

  /* Gold & Accent Colors */
  --accent-gold: #eab308;
  --accent-gold-hover: #facc15;
  --accent-gold-glow: rgba(234, 179, 8, 0.35);
  --accent-blue: #0284c7;
  --accent-blue-hover: #38bdf8;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);

  /* Radius & Shadows */
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.7);
  --shadow-glow-gold: 0 0 20px rgba(234, 179, 8, 0.25);

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-brand: 'Cinzel', 'Outfit', Georgia, serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: relative;
}

/* Ambient Subtle Background */
.ambient-pw-background {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: -2;
  overflow: hidden;
  background-color: #0f131a;
}

.ambient-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center 25%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ambient-layer.visible {
  opacity: 0.04;
}

.ambient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 19, 26, 0.7) 0%, rgba(15, 19, 26, 0.95) 100%);
  pointer-events: none;
  z-index: -1;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-active);
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .container {
    padding: 0 0.85rem;
  }
}

/* ==========================================================================
   Site Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 0;
  width: 100%;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
}

.mana-wheel-container {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mana-wheel-svg {
  width: 100%;
  height: 100%;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.mtg-brand-title {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  line-height: 1;
}

.mtg-brand-sub {
  font-size: 0.62rem;
  color: var(--accent-gold);
  letter-spacing: 0.12em;
  font-weight: 700;
  margin-top: 2px;
}

/* Segmented Control Main Tabs */
.main-tabs-nav {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.main-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.main-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.main-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.tab-pill {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-gold);
  color: #0f131a;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Header: Moje balíčky Button (Prominent, High-Contrast & Eye-Catching) */
.btn-vault-header {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.16) 0%, rgba(234, 179, 8, 0.05) 100%);
  border: 1px solid rgba(234, 179, 8, 0.5);
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 10px rgba(234, 179, 8, 0.1);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.btn-vault-header:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.28) 0%, rgba(234, 179, 8, 0.12) 100%);
  border-color: var(--accent-gold);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.3);
  transform: translateY(-1px);
}

.btn-vault-header:active {
  transform: translateY(0);
}

.btn-vault-header .vault-icon {
  color: var(--accent-gold);
  filter: drop-shadow(0 0 5px rgba(234, 179, 8, 0.5));
  transition: transform 0.2s ease;
}

.btn-vault-header:hover .vault-icon {
  transform: scale(1.1);
}

.vault-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 9999px;
  background: var(--accent-gold);
  color: #0b0f19;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Flat Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-gold);
  color: #0f131a;
  border-color: var(--accent-gold);
}

.btn-primary:hover {
  background: var(--accent-gold-hover);
  border-color: var(--accent-gold-hover);
}

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

.btn-secondary:hover {
  background: #283144;
  border-color: #3e4c66;
}

.btn-success {
  background: var(--success);
  color: #0b0f19;
  border-color: var(--success);
  font-weight: 700;
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.ui-icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  stroke: currentColor;
}

.btn-sm {
  padding: 0.38rem 0.7rem;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 0.28rem 0.55rem;
  font-size: 0.74rem;
}

.mobile-filter-toggle {
  display: none;
}

@media (max-width: 1080px) {
  .mobile-filter-toggle {
    display: inline-flex;
  }
  .header-hide-mobile {
    display: none !important;
  }
}

/* Settings Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

@media (max-width: 540px) {
  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-active);
}

/* ==========================================================================
   Main App Layout & Panels
   ========================================================================== */
.app-tab-panel {
  width: 100%;
}

.app-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.75rem 0 3.5rem 0;
  width: 100%;
}

@media (max-width: 1080px) {
  .app-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem 0 2.5rem 0;
  }
}

/* Left Sidebar Controls */
.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (max-width: 1080px) {
  .controls-panel {
    position: static;
    max-height: none;
  }
  .controls-panel.collapsed {
    display: none;
  }
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.section-title .badge {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* Mana Orbs Selector (Basic Land Symbols & MTG Colors) */
.mana-orbs-container {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
  width: 100%;
}

.mana-orb {
  height: 58px;
  border-radius: var(--radius-md);
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  padding: 4px 2px;
  gap: 4px;
  color: var(--text-muted);
}

.mana-orb .mana-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  display: block;
}

.mana-orb .label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  width: 100%;
  transition: color 0.15s ease;
}

.mana-orb:not(.active) .mana-icon {
  opacity: 0.7;
  filter: grayscale(25%);
}

.mana-orb:hover {
  background: var(--bg-surface-elevated);
  border-color: #3e4c66;
  color: var(--text-primary);
}

.mana-orb:hover .mana-icon {
  transform: scale(1.16);
  opacity: 1;
  filter: grayscale(0%) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.mana-orb.active {
  background: var(--bg-surface-elevated);
}

.mana-orb.active .mana-icon {
  opacity: 1;
  filter: grayscale(0%);
  transform: scale(1.06);
}

.mana-orb.active[data-color="W"] {
  border-color: var(--mana-w);
  color: var(--mana-w);
  background: radial-gradient(circle at center, rgba(254, 240, 138, 0.22) 0%, rgba(254, 240, 138, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-w-glow), inset 0 0 8px rgba(254, 240, 138, 0.15);
}
.mana-orb.active[data-color="W"] .label { color: var(--mana-w); }

.mana-orb.active[data-color="U"] {
  border-color: var(--mana-u);
  color: var(--mana-u);
  background: radial-gradient(circle at center, rgba(56, 189, 248, 0.22) 0%, rgba(56, 189, 248, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-u-glow), inset 0 0 8px rgba(56, 189, 248, 0.15);
}
.mana-orb.active[data-color="U"] .label { color: var(--mana-u); }

.mana-orb.active[data-color="B"] {
  border-color: var(--mana-b);
  color: var(--mana-b);
  background: radial-gradient(circle at center, rgba(192, 132, 252, 0.22) 0%, rgba(192, 132, 252, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-b-glow), inset 0 0 8px rgba(192, 132, 252, 0.15);
}
.mana-orb.active[data-color="B"] .label { color: var(--mana-b); }

.mana-orb.active[data-color="R"] {
  border-color: var(--mana-r);
  color: var(--mana-r);
  background: radial-gradient(circle at center, rgba(248, 113, 113, 0.22) 0%, rgba(248, 113, 113, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-r-glow), inset 0 0 8px rgba(248, 113, 113, 0.15);
}
.mana-orb.active[data-color="R"] .label { color: var(--mana-r); }

.mana-orb.active[data-color="G"] {
  border-color: var(--mana-g);
  color: var(--mana-g);
  background: radial-gradient(circle at center, rgba(74, 222, 128, 0.22) 0%, rgba(74, 222, 128, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-g-glow), inset 0 0 8px rgba(74, 222, 128, 0.15);
}
.mana-orb.active[data-color="G"] .label { color: var(--mana-g); }

.mana-orb.active[data-color="C"] {
  border-color: var(--mana-c);
  color: var(--mana-c);
  background: radial-gradient(circle at center, rgba(203, 213, 225, 0.22) 0%, rgba(203, 213, 225, 0.05) 100%);
  box-shadow: 0 0 16px var(--mana-c-glow), inset 0 0 8px rgba(203, 213, 225, 0.15);
}
.mana-orb.active[data-color="C"] .label { color: var(--mana-c); }

/* Archetypes Grid */
.archetypes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: none;
  overflow: visible;
  padding-right: 0;
  transition: all 0.25s ease;
}

.btn-toggle-archetypes {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-toggle-archetypes:hover {
  background: rgba(234, 179, 8, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.archetypes-collapsed-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.25rem;
}

.archetypes-collapsed-summary:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-gold);
}

.archetypes-collapsed-summary .active-arch-label {
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.archetypes-collapsed-summary .active-arch-label strong {
  color: var(--accent-gold);
  font-weight: 700;
}

.archetypes-collapsed-summary .toggle-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.archetype-card {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  position: relative;
}

.archetype-card:hover {
  background: var(--bg-surface-elevated);
  border-color: rgba(234, 179, 8, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.archetype-card.active {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.14) 0%, rgba(234, 179, 8, 0.03) 100%);
  border-color: var(--accent-gold);
  box-shadow: 0 0 14px rgba(234, 179, 8, 0.22), inset 0 0 8px rgba(234, 179, 8, 0.06);
}

.arch-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.arch-icon {
  font-size: 0.92rem;
  flex-shrink: 0;
  line-height: 1;
}

.arch-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archetype-card.active .arch-title {
  color: var(--accent-gold);
}

.arch-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  margin-top: 1px;
}

.arch-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.archetype-card.active .arch-tag {
  background: rgba(234, 179, 8, 0.18);
  color: var(--accent-gold);
}

.arch-speed {
  font-size: 0.64rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Master Generate CTA */
.btn-generate {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.25);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.btn-generate:hover {
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.4);
  transform: translateY(-1px);
}

/* ==========================================================================
   Right Workspace (Deck View, Hero, Analytics)
   ========================================================================== */
.deck-view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

/* Deck Header Hero */
.deck-hero {
  background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(19, 25, 36, 0.95) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.deck-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent-gold) 50%, transparent 100%);
  opacity: 0.85;
}

.deck-hero-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  width: 100%;
}

.deck-title-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.deck-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.deck-meta-tags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Subtle Deck Filter Tags ("jemná grafika") */
.deck-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 3px 9.5px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
}

.deck-tag:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.deck-tag.tag-gold {
  color: #facc15;
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.3);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.15);
}

.deck-tag.tag-mana {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.deck-tag.tag-mana-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(11, 16, 25, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
}

.deck-tag.tag-budget {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
  font-weight: 600;
}

.deck-tag.tag-format {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
  font-weight: 600;
}

.deck-tag.tag-custom {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.25);
}

.deck-tag.tag-version {
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.25);
}

.deck-tag.tag-version-orig {
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

.deck-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

/* Core Primary Actions Group (Prominent Deck Controls) */
.deck-primary-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* 1. Vylepšit (Vibrant Gold Hero CTA) */
.btn-action-optimize {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%) !important;
  color: #0b0f19 !important;
  border: 1px solid #f59e0b !important;
  font-weight: 800 !important;
  font-size: 0.86rem !important;
  padding: 0.52rem 1.15rem !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.38) !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  letter-spacing: 0.02em;
}

.btn-action-optimize:hover {
  background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%) !important;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.55) !important;
  transform: translateY(-1px);
}

.btn-action-optimize .ui-icon {
  stroke: #0b0f19 !important;
}

/* 2. Test ruky (Vibrant Cyan/Blue Hero Button) */
.btn-action-testhand {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22) 0%, rgba(2, 132, 199, 0.12) 100%) !important;
  border: 1.5px solid rgba(56, 189, 248, 0.7) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.86rem !important;
  padding: 0.52rem 1.15rem !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 3px 14px rgba(14, 165, 233, 0.28) !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  letter-spacing: 0.01em;
}

.btn-action-testhand:hover {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.38) 0%, rgba(2, 132, 199, 0.22) 100%) !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.48) !important;
  transform: translateY(-1px);
}

.btn-action-testhand .ui-icon {
  color: #38bdf8 !important;
  stroke: #38bdf8 !important;
  filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.65));
}

/* 3. Uložit (Vibrant Emerald/Green Hero Button) */
.btn-action-save {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(5, 150, 105, 0.12) 100%) !important;
  border: 1.5px solid rgba(52, 211, 153, 0.7) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.86rem !important;
  padding: 0.52rem 1.15rem !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 3px 14px rgba(16, 185, 129, 0.28) !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  letter-spacing: 0.01em;
}

.btn-action-save:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.38) 0%, rgba(5, 150, 105, 0.22) 100%) !important;
  border-color: #34d399 !important;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.48) !important;
  transform: translateY(-1px);
}

.btn-action-save .ui-icon {
  color: #34d399 !important;
  stroke: #34d399 !important;
  filter: drop-shadow(0 0 5px rgba(52, 211, 153, 0.65));
}

/* Compact Export Action Group (Print, Copy TXT, Download .txt) */
.deck-export-group {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px 4px;
}

.deck-export-group .btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  min-height: auto;
  gap: 0.35rem;
}

.deck-export-group .btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.deck-export-group .btn svg {
  opacity: 0.75;
}

.deck-export-group .btn:hover svg {
  opacity: 1;
}

/* Stats Bar */
.deck-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 768px) {
  .deck-stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat-box {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-box:hover {
  border-color: rgba(234, 179, 8, 0.35);
  background: var(--bg-surface-elevated);
  transform: translateY(-1px);
}

.stat-top-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-icon {
  font-size: 0.82rem;
  line-height: 1;
}

.stat-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-value.highlight-gold {
  color: var(--accent-gold);
}

/* ==========================================================================
   MTG Mana Pip System (Crisp Circular Symbols & Pips)
   ========================================================================== */
.card-mana-pips {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  vertical-align: middle;
}

.mana-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.25);
  user-select: none;
  position: relative;
  overflow: hidden;
  line-height: 1;
}

.mana-pip-sm {
  width: 16px;
  height: 16px;
  font-size: 0.65rem;
}

.mana-pip-md {
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
}

.mana-pip-lg {
  width: 26px;
  height: 26px;
  font-size: 0.88rem;
}

.mana-pip svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.mana-pip-generic {
  background: radial-gradient(circle at 35% 35%, #e2dedc 0%, #a8a29e 100%);
  color: #0f172a;
  font-family: var(--font-mono);
  font-weight: 800;
  border: 1px solid #78716c;
  line-height: 1;
}

.mana-pip-hybrid {
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.hybrid-symbol-text {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

.mana-free-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

.mana-raw-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Analytics Row (Mana Curve & Type Ratio) */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  width: 100%;
}

@media (max-width: 840px) {
  .analytics-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.analytics-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.analytics-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mana Curve Histogram */
.curve-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.45rem;
  height: 120px;
  padding: 1rem 0.5rem 0.35rem;
  background: rgba(11, 16, 25, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.curve-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 4px;
  cursor: pointer;
  position: relative;
}

.curve-bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, #facc15 0%, #ca8a04 100%);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, filter 0.2s ease;
  box-shadow: 0 2px 8px rgba(202, 138, 4, 0.35);
}

.curve-bar-col:hover .curve-bar {
  background: linear-gradient(180deg, #fde047 0%, #eab308 100%);
  filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.65));
}

.curve-count {
  font-size: 0.74rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  transition: transform 0.15s ease, color 0.15s ease;
}

.curve-bar-col:hover .curve-count {
  transform: scale(1.2);
  color: var(--accent-gold);
}

.curve-label-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

/* Composite Type Composition Bar (Moxfield / Scryfall style) */
.type-composition-bar {
  grid-column: 1 / -1;
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #1a2232;
  margin-bottom: 0.5rem;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  gap: 1px;
}

.comp-segment {
  height: 100%;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.comp-creatures { background: #22c55e; }
.comp-instants { background: #38bdf8; }
.comp-sorceries { background: #818cf8; }
.comp-artifacts { background: #f59e0b; }
.comp-enchantments { background: #c084fc; }
.comp-planeswalkers { background: #fb7185; }
.comp-lands { background: #d4af37; }

/* Type Breakdown Pills Grid */
.type-pills-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

@media (max-width: 500px) {
  .type-pills-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

.type-pill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s ease;
}

.type-pill-item:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.type-pill-item .type-name-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.type-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.type-pill-item .type-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.type-pill-item .type-badge {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* Mana Pip Color Requirement Summary Row */
.mana-pip-ratio-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
}

.mana-pip-ratio-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   Deck Categories & Card Grids
   ========================================================================== */
.deck-categories {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.category-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.category-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.category-count {
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2.5px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-gold);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 1rem;
  width: 100%;
}

@media (max-width: 640px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }
}

/* Card Item Box */
.card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.card-item:hover {
  transform: translateY(-4px);
  border-color: rgba(234, 179, 8, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55), 0 0 16px rgba(234, 179, 8, 0.15);
}

.card-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  background: #090d14;
  overflow: hidden;
  cursor: pointer;
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.card-item:hover .card-image-wrap img {
  transform: scale(1.03);
}

/* Subtle holographic sheen sweep */
.card-image-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.06) 40%, rgba(255,255,255,0.18) 50%, rgba(255,255,255,0) 60%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
  pointer-events: none;
}

.card-item:hover .card-image-wrap::after {
  transform: translateX(100%);
}

.card-count-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(11, 16, 25, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  z-index: 3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.02em;
}

.card-rarity-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brand);
  font-size: 0.62rem;
  font-weight: 900;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.card-rarity-badge.rarity-mythic {
  background: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  color: #ffffff;
  border: 1.5px solid #fdba74;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

.card-rarity-badge.rarity-rare {
  background: linear-gradient(135deg, #eab308 0%, #b45309 100%);
  color: #ffffff;
  border: 1.5px solid #fef08a;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
}

.card-rarity-badge.rarity-uncommon {
  background: linear-gradient(135deg, #94a3b8 0%, #475569 100%);
  color: #ffffff;
  border: 1.5px solid #cbd5e1;
}

.card-rarity-badge.rarity-common {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #475569;
}

.card-pt-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.card-info {
  padding: 0.6rem 0.7rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.card-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.card-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-mana-pips-wrap {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.card-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  gap: 0.35rem;
  margin-top: auto;
}

.card-type-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-price-pill {
  flex-shrink: 0;
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  background: rgba(234, 179, 8, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.card-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-main);
  gap: 0.4rem;
}

.card-qty-control {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-qty {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-qty:hover {
  background: #283144;
  border-color: var(--border-active);
  color: #ffffff;
}

.btn-qty:active {
  transform: scale(0.92);
}

.card-btn-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Strategy Guide Block */
.strategy-guide-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

/* ==========================================================================
   Dedicated Deck Improver Styling
   ========================================================================== */
.improver-hero-banner {
  text-align: center;
  padding: 2.25rem 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.improver-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}

.improver-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.improver-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Search Card Box */
.improver-search-card-box {
  max-width: 960px;
  margin: 0 auto 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.improver-search-container {
  position: relative;
}

.improver-search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  gap: 0.75rem;
  transition: border-color 0.15s ease;
}

.improver-search-input-wrap:focus-within {
  border-color: var(--border-active);
}

.improver-search-icon {
  font-size: 1rem;
  color: var(--text-muted);
}

.improver-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  font-family: var(--font-body);
}

.improver-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.improver-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;
}

.autocomplete-item:hover {
  background: var(--bg-surface-elevated);
}

.autocomplete-art {
  width: 44px;
  height: 60px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.autocomplete-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.autocomplete-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-link-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0;
}

.btn-link-toggle:hover {
  color: var(--text-primary);
}

.improver-text-import-box {
  margin-top: 0.85rem;
  padding: 1rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.quick-presets-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.65rem;
}

.btn-sample-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.76rem;
  cursor: pointer;
}

.btn-sample-chip:hover {
  border-color: var(--border-active);
  color: var(--text-primary);
}

.improver-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  resize: vertical;
}

.improver-textarea-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}

/* Toolbar Bar */
.improver-toolbar-bar {
  max-width: 960px;
  margin: 0 auto 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.improver-toolbar-inputs {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-width: 300px;
  flex-wrap: wrap;
}

.btn-improver-run {
  padding: 0.85rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.25);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.btn-improver-run:hover {
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.4);
  transform: translateY(-1px);
}

/* Improver Deck Section & Meta Bar (Fix for text collision) */
.improver-deck-section {
  width: 100%;
  margin-bottom: 2.5rem;
}

.improver-deck-meta-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.25rem;
}

.improver-deck-name-wrap {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.deck-name-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 24px;
}

.improver-meta-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editing-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.65rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.editing-status-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.editing-status-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.btn-save-as-new-link {
  background: transparent;
  border: none;
  color: var(--accent-gold);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 0 0 0.5rem;
  border-left: 1px solid var(--border-subtle);
  text-decoration: underline;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.btn-save-as-new-link:hover {
  color: var(--accent-gold-hover);
}

.improver-name-input {
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}

.improver-name-input:focus {
  border-color: var(--border-active);
}

.improver-deck-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn-clear-all {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.btn-clear-all:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.improver-deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.improver-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.improver-deck-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.summary-chip {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-surface-elevated);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.summary-chip.highlight-gold {
  color: var(--accent-gold);
  border-color: rgba(212, 175, 55, 0.35);
}

.improver-large-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.improver-empty-deck-large {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.empty-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 1.25rem;
}

/* Improver Scorecards & Results */
.improver-results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.improver-scorecards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.improver-scorecard {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.scorecard-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.scorecard-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.scorecard-value.highlight-green {
  color: var(--success);
}

.scorecard-value.highlight-gold {
  color: var(--accent-gold);
}

/* Swaps List */
.improver-swaps-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.improver-swap-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

.swap-card-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
}

.swap-card-box.old-card {
  background: var(--bg-main);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.swap-card-box.new-card {
  background: var(--bg-main);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.swap-card-img {
  width: 58px;
  height: 82px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.swap-arrow-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold);
  font-size: 1.25rem;
  font-weight: 700;
}

.swap-details-box {
  grid-column: 1 / -1;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Mana Audit Box */
.improver-mana-audit-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mana-audit-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mana-pips-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mana-pip-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.mana-swaps-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.mana-swaps-checklist li {
  padding-left: 1.2rem;
  position: relative;
}

.mana-swaps-checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
}

/* Cuts List */
.improver-cuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.improver-cut-item {
  background: var(--bg-surface);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.improver-cut-item img {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 3px;
}

/* ==========================================================================
   Modals & Popups (Clean Flat Theme)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100%;
  max-height: 100vh;
  background: rgba(15, 19, 26, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

#previewModal {
  z-index: 1500;
}

.modal-window {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

#previewModal .modal-window {
  z-index: 1501;
  border-color: #3e4c66;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 5;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.15rem;
}

.modal-footer {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ==========================================================================
   Hand Simulator Modal (Realistic Card Fan / Mobile Optimized)
   ========================================================================== */
#handModal .modal-window {
  max-width: 920px;
  background: radial-gradient(circle at 50% 120%, #1e293b 0%, #0f172a 100%);
  border-color: rgba(234, 179, 8, 0.35);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8);
}

#handModal .modal-body {
  padding: 1rem 0.75rem 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
}

.hand-rating-banner {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  width: 100%;
  text-align: center;
  margin-bottom: 0.75rem;
}

.hand-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.hand-spread {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  width: 100%;
  min-height: 250px;
  padding: 35px 15px 15px 15px;
  perspective: 1200px;
  overflow: visible;
  user-select: none;
}

.hand-card {
  position: relative;
  width: 110px;
  max-width: 110px;
  margin-left: -32px;
  flex-shrink: 0;
  cursor: pointer;
  transform-origin: 50% 130%;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75));
  border-radius: 6px;
  touch-action: manipulation;
}

.hand-card:first-child {
  margin-left: 0;
}

.hand-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
  background: #0b0f19;
}

/* Hover & Active Lift Effect */
.hand-card:hover,
.hand-card:focus-visible,
.hand-card.active-touch {
  transform: translateY(-36px) scale(1.22) rotate(0deg) !important;
  z-index: 99 !important;
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.95));
}

.hand-card.card-just-drawn {
  animation: cardDrawIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardDrawIn {
  from {
    opacity: 0;
    transform: translateY(-60px) scale(0.6);
  }
  to {
    opacity: 1;
  }
}

/* Mobile & Tablet Optimizations for Hand Simulator */
@media (max-width: 768px) {
  #handModal .modal-window {
    width: 96%;
    max-width: 96%;
    margin: 0.5rem auto;
  }

  #handModal .modal-body {
    padding: 0.75rem 0.35rem 1rem 0.35rem;
  }

  .hand-spread {
    min-height: 190px;
    padding: 25px 5px 10px 5px;
  }

  .hand-card {
    width: clamp(52px, 12.5vw, 68px);
    max-width: 68px;
    margin-left: clamp(-30px, -6.2vw, -16px);
    border-radius: 5px;
  }

  .hand-card:first-child {
    margin-left: 0;
  }

  .hand-card:hover,
  .hand-card:focus-visible,
  .hand-card.active-touch {
    transform: translateY(-30px) scale(1.35) rotate(0deg) !important;
  }

  #handModal .modal-footer {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
  }

  #handModal .modal-footer .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.45rem 0.4rem;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .hand-spread {
    min-height: 175px;
    padding: 20px 2px 5px 2px;
  }

  .hand-card {
    width: clamp(46px, 12.8vw, 56px);
    max-width: 56px;
    margin-left: clamp(-32px, -6.8vw, -18px);
  }

  .hand-card:first-child {
    margin-left: 0;
  }

  .hand-card:hover,
  .hand-card.active-touch {
    transform: translateY(-26px) scale(1.4) rotate(0deg) !important;
  }
}

/* Vault Deck Item Cards (Redesigned & Cleaned) */
.vault-deck-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.vault-deck-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  transition: border-color 0.15s ease;
}

.vault-deck-item:hover {
  border-color: var(--border-active);
}

.vault-deck-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.vault-deck-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.vault-deck-name {
  color: var(--text-primary);
  font-size: 1.02rem;
  font-weight: 700;
}

.vault-deck-meta-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.vault-meta-dot {
  color: var(--text-muted);
}

.vault-meta-price {
  color: var(--accent-gold);
  font-weight: 700;
  font-family: var(--font-mono);
}

.vault-deck-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.vault-deck-actions .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

.vault-deck-actions .btn-del {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.vault-deck-actions .btn-del:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* Preview Modal Internal Columns */
.card-preview-modal-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.preview-image-column {
  flex: 0 0 280px;
}

.preview-image-column img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.preview-details-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.preview-oracle-box {
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-line;
}

.preview-legalities-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.legality-badge {
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 600;
}

.legality-badge.legal {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.legality-badge.not-legal {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}

.toast.error {
  border-color: var(--danger);
  color: #fca5a5;
}

.toast.warning {
  border-color: var(--accent-gold);
  color: #fde047;
}

.toast.info {
  border-color: var(--border-active);
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  background: var(--bg-surface);
}

/* ==========================================================================
   Full Responsive Design Overrides & Touch Targets (Below 900px / 768px / 480px)
   ========================================================================== */
@media (max-width: 900px) {
  .improver-swap-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .swap-arrow-divider {
    transform: rotate(90deg);
    margin: -0.25rem 0;
  }
  .swap-details-box {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .swap-details-box > div:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    width: 100%;
  }
  .swap-details-box .btn {
    min-height: 38px;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 0.75rem;
  }

  .header-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }
  .logo-group {
    order: 1;
  }
  .header-actions {
    order: 2;
    display: flex;
    align-items: center;
    width: auto;
    gap: 0.35rem;
  }
  .header-actions .btn {
    min-height: 34px;
    font-size: 0.76rem;
    padding: 0.3rem 0.5rem;
    justify-content: center;
  }
  .header-actions .btn-vault-header {
    min-height: 34px;
    font-size: 0.78rem;
    padding: 0.32rem 0.6rem;
    font-weight: 700;
  }
  .main-tabs-nav {
    order: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .main-tab-btn {
    justify-content: center;
    padding: 0.5rem;
    min-height: 38px;
  }

  .deck-hero-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .deck-hero-actions,
  .improver-deck-actions-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
  }
  .deck-primary-actions-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }
  .deck-primary-actions-group .btn-action-optimize {
    grid-column: 1 / -1;
    min-height: 46px;
    font-size: 0.92rem !important;
    justify-content: center;
  }
  .deck-primary-actions-group .btn-action-testhand,
  .deck-primary-actions-group .btn-action-save {
    width: 100%;
    min-height: 42px;
    font-size: 0.84rem !important;
    justify-content: center;
  }
  .deck-primary-actions-group .btn-clear-all {
    grid-column: 1 / -1;
    min-height: 38px;
    justify-content: center;
  }
  .deck-hero-actions .deck-export-group,
  .improver-deck-actions-group .deck-export-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    gap: 0.3rem;
    padding: 3px;
    background: var(--bg-main);
  }
  .deck-hero-actions .deck-export-group .btn,
  .improver-deck-actions-group .deck-export-group .btn {
    width: 100%;
    min-height: 34px;
    padding: 0.3rem 0.2rem;
    font-size: 0.7rem;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
  }

  .improver-toolbar-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .improver-toolbar-inputs {
    flex-direction: column;
    min-width: 0;
    width: 100%;
  }
  .btn-improver-run {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }

  .improver-deck-meta-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .improver-large-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }
  .improver-scorecards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  /* Hand Modal Mobile Footer */
  #handModal .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 0.6rem;
  }
  .hand-deck-counter {
    text-align: center;
    width: 100%;
    font-size: 0.82rem;
  }
  .hand-actions-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }
  .hand-actions-wrap #btnMulligan {
    grid-column: 1 / -1;
  }
  .hand-actions-wrap .btn {
    min-height: 42px;
    font-size: 0.8rem;
    padding: 0.4rem 0.35rem;
    white-space: nowrap;
    justify-content: center;
  }

  /* Swap Modal Suggestions & Search Results */
  .swap-suggestions-grid,
  .swap-results-grid {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }

  .vault-deck-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .vault-deck-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.4rem;
    width: 100%;
  }
  .vault-deck-actions .btn {
    min-height: 42px;
    justify-content: center;
  }

  .card-preview-modal-body {
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
  }
  .preview-image-column {
    flex: 0 0 auto;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
  }
  .preview-details-column {
    width: 100%;
  }
  .preview-legalities-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .preview-actions-footer {
    flex-direction: column;
    width: 100%;
  }
  .preview-actions-footer .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .modal-window {
    width: 95vw !important;
    max-height: 90vh !important;
    margin: 0 auto !important;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.5rem;
  }
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }
  .card-actions-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.35rem 0.45rem;
  }
  .card-qty-control {
    width: auto;
    gap: 2px;
  }
  .card-qty-val {
    min-width: 14px !important;
    font-size: 0.78rem !important;
  }
  .btn-qty {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
  }
  .btn-swap {
    font-size: 0.72rem;
    padding: 0.25rem 0.45rem;
    white-space: nowrap;
    gap: 0.25rem;
  }
  .vault-deck-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .cards-grid,
  .improver-large-grid,
  .improver-scorecards-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   Improver Loading & Spinner Component
   ========================================================================== */
.improver-loading {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
}

.improver-loading h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.improver-loading p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.clean-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(234, 179, 8, 0.15);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: cleanSpin 0.75s linear infinite;
  margin: 0 auto 1.25rem auto;
}

@keyframes cleanSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   User Authentication & Profile Styles
   ========================================================================== */
.header-auth-section {
  display: inline-flex;
  align-items: center;
}

.btn-auth-trigger {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-subtle);
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-auth-trigger:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(234, 179, 8, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: 9999px;
  padding: 2px 4px 2px 10px;
  gap: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-pill-info {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #f1f5f9;
  max-width: 170px;
}

.user-avatar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.2);
  color: var(--accent-gold);
  flex-shrink: 0;
}

.user-email-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-user-logout {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 3px 8px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-user-logout:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

/* Auth Modal Specifics */
.auth-modal-title-group h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin: 0;
}

.auth-modal-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.auth-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-subtle);
}

.auth-tab-btn {
  flex: 1;
  padding: 0.65rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.auth-tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background: rgba(234, 179, 8, 0.05);
}

.auth-alert {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.35;
}

.auth-alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.auth-alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

/* Vault Modal: Guest Banner */
.vault-guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.vault-guest-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  color: #cbd5e1;
  font-size: 0.82rem;
}

.vault-guest-banner-content svg {
  color: var(--accent-gold);
  flex-shrink: 0;
  margin-top: 2px;
}

.vault-guest-banner-content strong {
  display: block;
  color: #ffffff;
  margin-bottom: 2px;
  font-size: 0.86rem;
}

.vault-guest-banner-content p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.78rem;
}

.btn-vault-login {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .vault-guest-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .user-pill-info {
    max-width: 110px;
  }
}

