/* Sidebar Layout - Modern Left Navigation */

/* Remove top navigation since we're using sidebar */
.ah-nav {
  display: none !important;
}

/* Main layout container */
body {
  margin: 0;
  padding: 0;
  display: flex;
  min-height: 100vh;
  overflow: hidden; /* prevent page/body scroll; main-content will scroll */
  background: transparent;
}

/* Background is underlay, content above background */
.sidebar, .main-content { position: relative; z-index: 2; }

/* Hide mobile header/backdrop on desktop only */
@media (min-width: 933px) {
  .mobile-header { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}

/* Left Sidebar */
.sidebar {
  width: 240px;
  background: rgb(17, 26, 34);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  z-index: 1000;
  overflow-y: auto;
}

/* Hide sidebar completely on mobile by default */
@media (max-width: 768px) {
  .sidebar:not(.open) {
    left: -100% !important;
    pointer-events: none;
  }
  .sidebar.open {
    pointer-events: auto;
  }
}

.sidebar-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
}

/* Logo */
.sidebar-logo {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo img {
  height: 48px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}

/* Navigation */
.sidebar-nav {
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-item.active {
  background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.nav-item.active:hover {
  background: linear-gradient(135deg, #5AC8FA 0%, #007AFF 100%);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* User Section */
.sidebar-user {
  padding: 20px 12px 12px 20px;
  border-top: none;
  border-bottom: none;
  margin-bottom: 12px;
}

/* Email (user name) area gets its own divider below it */
.sidebar-user #sidebarUser {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}

/* Hide auth UI and protected links by default to prevent flicker; nav-global.js will reveal when authed */
.sidebar-user #sidebarUser { display: none; }
.sidebar-user #sidebarLogout { display: none; }
.sidebar a[href="mydecks.html"],
.sidebar a[href="campaigns.html"],
.sidebar a[href="deck-dashboard.html"] { display: none; }

.user-action {
  display: block;
  width: calc(100% - 20px); /* keep a small gap on the right */
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #ffffff;
  text-decoration: none;
  text-align: center;
  font-weight: 700; /* bold for consistency */
  font-size: 13px;
  transition: all 0.2s ease;
  cursor: pointer;
  margin-bottom: 8px;
}

.user-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Main Content */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 20px;
  padding-top: 20px !important; /* Ensure consistent top spacing from viewport */
  position: relative;
  overflow-x: hidden;
  height: 100vh;               /* make it a viewport-height scroll container */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Consistent top spacing from viewport top - matching expansions page */
/* The expansions page has: main-content padding-top (20px) + container padding-top (20px) + h1 margin-top (24px) = 64px total from viewport top */
/* For visual consistency, ALL pages should have 64px total spacing from the top of the viewport */
/* This ensures all content starts at the same vertical position across all pages */

/* Pages WITH containers: ensure container has padding-top: 20px and consistent width/alignment */
.main-content > .expansions-container,
.main-content > .campaigns-container,
.main-content > .investigators-container,
.main-content > .campaign-log-container,
.main-content > .setup-container,
.main-content > .admin-container,
.main-content > .rules-container {
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 20px !important;
  padding-top: 20px !important;
  margin-top: 0 !important;
  box-sizing: border-box !important;
}

/* Ensure first h1 in containers has margin-top: 24px (matching expansions page) - override inline styles */
.main-content > .expansions-container > h1.page-title:first-child,
.main-content > .campaigns-container > h1.page-title:first-child,
.main-content > .investigators-container > h1:first-child,
.main-content > .campaign-log-container > *:first-child > h1.page-title:first-child,
.main-content > .setup-container > h1:first-child,
.main-content > .admin-container > h1:first-child,
.main-content > .rules-container > h1:first-child {
  margin-top: 24px !important;
}

/* Pages WITHOUT containers: add 44px margin-top and ensure consistent left alignment */
/* Exclude cards page (.classBar and .filtersBar should not have max-width on cards page) */
/* Exclude login/register and settings pages (they should have narrower width) */
.main-content > .wrap:first-child:not(.expansions-container):not(.campaigns-container):not(.investigators-container):not(.campaign-log-container):not(.setup-container):not(.admin-container):not(.rules-container):not(:has(.panel)),
.main-content > .container:first-child:not(.expansions-container):not(.campaigns-container):not(.investigators-container):not(.campaign-log-container):not(.setup-container):not(.admin-container):not(.rules-container):not(:has(.panel)) {
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: 44px !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Narrower width for login/register and settings pages */
.main-content > .wrap:first-child:has(.panel),
.main-content > #bg + .wrap:has(.panel),
.main-content > .wrap:has(.panel) {
  max-width: 520px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 10px !important;
  box-sizing: border-box !important;
}

/* For pages where background element (#bg) is first, target the next content element */
/* Exclude login/register and settings pages (they should have narrower width) */
.main-content > #bg + .wrap:not(.expansions-container):not(.campaigns-container):not(.investigators-container):not(.campaign-log-container):not(.setup-container):not(.admin-container):not(.rules-container):not(:has(.panel)),
.main-content > #bg + .container:not(.expansions-container):not(.campaigns-container):not(.investigators-container):not(.campaign-log-container):not(.setup-container):not(.admin-container):not(.rules-container):not(:has(.panel)) {
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: 44px !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Handle any other first-child elements that aren't containers or background elements */
.main-content > *:first-child:not(.wallpaper-background):not(#bg):not(.expansions-container):not(.campaigns-container):not(.investigators-container):not(.campaign-log-container):not(.setup-container):not(.admin-container):not(.rules-container):not(.classBar):not(.filtersBar):not(.wrap):not(.container) {
  margin-left: auto !important;
  margin-right: auto !important;
  margin-top: 44px !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Note: classBar and filtersBar alignment is handled above in "Pages WITHOUT containers" section */

/* Faction Bar */
.classBar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(17, 26, 34, 0.6);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.classBar .reset-btn{
  margin-left: auto;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.2) 0%, rgba(255, 59, 48, 0.15) 100%);
  color: #ff6b6b;
  border: 1px solid rgba(255, 59, 48, 0.4);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.classBar .chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.9);
}

.classBar .chip:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.classBar .chip.active {
  background: rgba(106, 183, 255, 0.2);
  color: #6ab7ff;
  border-color: #6ab7ff;
}

.classBar .chip img {
  height: 16px;
  width: 16px;
  margin-right: 6px;
}

/* Horizontal Compact Filters Layout */
.filtersBar {
  display: flex;
  flex-wrap: wrap;
  background: rgba(17, 26, 34, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 16px;
  gap: 6px 10px;
  max-width: 100%;
  align-items: center;
  justify-content: flex-start; /* left align all content */
  position: sticky;
  top: 80px;
  z-index: 100;
  will-change: transform;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
}

/* Tiny divider between groups for clearer grouping */
.filtersBar > * + * {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  padding-left: 10px;
  margin-left: 8px;
}

.filterRow {
  display: contents;
}

.filterInputs {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 0; /* do not push to the right */
  flex-wrap: wrap;
  justify-content: flex-start;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
}

.filter-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-section label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  min-width: 50px;
}

/* Horizontal inline filter groups */
.filterGroup {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.filterLabel {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
  margin-right: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Horizontal inline Input Groups */
.inputGroup {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  min-width: 0;
}

.filterInputs .inputGroup:first-child {
  flex: 1 1 auto;
  min-width: 200px;
  max-width: 100%;
}

.inputGroup label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
  white-space: nowrap;
}

.inputGroup input[type="text"] {
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #eaf2f8;
  border-radius: 2px;
  font-size: 10px;
  outline: none;
  width: 80px;
  height: 18px;
  flex-shrink: 0;
}

.inputGroup input[type="text"]:focus {
  border-color: #6ab7ff;
  box-shadow: 0 0 0 1px rgba(106, 183, 255, 0.3);
}

/* Slider Containers */
.slider-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* Range Sliders */
.range-slider {
  width: 160px;
  height: 4px; /* thinner track */
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.range-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;  /* smaller thumb */
  height: 12px;
  background: linear-gradient(135deg, #6ab7ff 0%, #007AFF 100%);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(106, 183, 255, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.range-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #6ab7ff 0%, #007AFF 100%);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.range-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(106, 183, 255, 0.5);
}

.range-slider::-webkit-slider-track {
  background: linear-gradient(to right, #6ab7ff 0%, #6ab7ff 50%, rgba(255, 255, 255, 0.1) 50%);
  height: 3px;
  border-radius: 2px;
}

.range-slider::-moz-range-track {
  background: rgba(255, 255, 255, 0.1);
  height: 4px;
  border-radius: 2px;
  border: none;
}

/* Slider Value Display */
.slider-value {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Icon Chips */
.icon-chips {
  display: flex;
  gap: 4px;
}

.icon-chip {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.icon-chip.active {
  background: rgba(106, 183, 255, 0.2);
  border-color: #6ab7ff;
  box-shadow: 0 0 0 1px rgba(106, 183, 255, 0.3);
}

.icon-chip i {
  font-size: 16px;
}

/* Search Input */
.compact-input {
  width: 200px;
  padding: 6px 12px;
  background: rgba(8, 12, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #ffffff;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.compact-input:focus {
  border-color: #6ab7ff;
  box-shadow: 0 0 0 2px rgba(106, 183, 255, 0.2);
}

.compact-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Quick Chips */
.quick-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-chips > div {
  display: flex;
  gap: 4px;
}

.quick-chip {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.quick-chip:hover {
  background: rgba(255, 255, 255, 0.12);
}

.quick-chip.active {
  background: rgba(106, 183, 255, 0.2);
  color: #6ab7ff;
  border-color: #6ab7ff;
}

/* Consistent compact chips */
.filtersBar .chip {
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  height: 18px;
  min-height: 18px;
  max-height: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.filtersBar .chip:hover {
  background: rgba(255, 255, 255, 0.12);
}

.filtersBar .chip.active {
  background: rgba(106, 183, 255, 0.2);
  color: #6ab7ff;
  border-color: #6ab7ff;
}

/* Search input in horizontal layout */
.filtersBar input {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #eaf2f8;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  width: 170px;
  min-width: 150px;
  max-width: 100%;
  flex: 1 1 auto;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filtersBar input:focus {
  border-color: #6ab7ff;
  box-shadow: 0 0 0 3px rgba(106, 183, 255, 0.2), 0 2px 8px rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.6);
}

.filtersBar input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

/* Ultra-compact icon sizing */
.filtersBar .chip .arkham-icon {
  font-size: 10px;
  width: 12px;
  height: 12px;
  display: inline-block;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: 0;
}

/* Consistent icon chips */
.filtersBar #iconChips .chip {
  width: auto;
  min-width: 0;
  max-width: none;
  height: 18px;
  padding: 2px 6px;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  gap: 4px;
  flex-shrink: 0;
}

.filtersBar #slotChips .chip {
  height: 18px;
  padding: 2px 6px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  line-height: 1;
}

/* Ultra-compact chip images */
.filtersBar .chip img {
  width: 12px;
  height: 12px;
  object-fit: contain;
  object-position: center;
  margin-right: 0;
  vertical-align: middle;
}

/* Slot chip specific images */
.filtersBar #slotChips .chip img {
  width: 12px;
  height: 12px;
  object-fit: contain;
  margin-right: 0;
}

/* Icon-only chips (no text) */
.filtersBar .chip i.arkham-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  text-align: center;
  line-height: 16px;
  font-size: 12px;
}

/* Type Chips */
.type-chips {
  display: flex;
  gap: 6px;
}

.type-chip {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.type-chip:hover {
  background: rgba(255, 255, 255, 0.12);
}

.type-chip.active {
  background: rgba(106, 183, 255, 0.2);
  color: #6ab7ff;
  border-color: #6ab7ff;
}

/* Modern Reset Button */
.filtersBar .reset-btn { display:none; }

.filtersBar .reset-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.filtersBar .reset-btn:hover {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.3) 0%, rgba(255, 59, 48, 0.2) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
  border-color: rgba(255, 59, 48, 0.6);
}

.filtersBar .reset-btn:hover::before {
  left: 100%;
}

.filtersBar .reset-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.4);
}

/* Compact Card Count */
.filtersBar #total { display:none; }

/* Legacy styles for compatibility */
.reset-btn {
  padding: 6px 12px;
  background: rgba(255, 59, 48, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(255, 59, 48, 0.3);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.reset-btn:hover {
  background: rgba(255, 59, 48, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.card-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

/* Card Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  justify-content: center;
  gap: 14px;
  margin-top: 20px;
  min-height: 200px; /* Ensure grid has space */
}

/* Card styling to match existing design */
.card {
  width: 300px;
  background: rgba(10, 15, 20, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transform-origin: center center;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), 
              box-shadow 0.22s cubic-bezier(0.22, 1, 0.36, 1), 
              filter 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.card:hover {
  transform: scale(1.05);
  z-index: 30;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  filter: brightness(1.08);
}

.card img {
  width: 100%;
  display: block;
  background: #0b1116;
  border-radius: 19px;
}

.card .meta {
  padding: 10px 12px;
}

.card .name {
  font-weight: 800;
  font-size: 16px;
  color: #eaf2f8;
}

.card .sub {
  color: #b9c7d4;
  font-size: 12.5px;
}

.card .stats {
  margin-top: 6px;
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  color: #b9c7d4;
}

/* Loading spinner */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  
  .main-content {
    margin-left: 200px;
  }
  
  .compact-input {
    width: 150px;
  }
}

/* Updated to cover iPhone 15 Pro Max (430px) and all phones/tablets */
@media (max-width: 932px), (pointer: coarse) {
  html, body { overflow-x: hidden; }
  /* Stop desktop flex layout on phones to avoid reserved gutter */
  body { display: block; overflow: auto; } /* restore normal page scrolling on mobile */

  /* Make sidebar an off-canvas overlay; do NOT reserve width */
  .sidebar {
    position: fixed !important;
    left: -100% !important; /* Completely off-screen when closed */
    top: 0 !important;
    width: 240px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    display: block !important;
    transform: none !important;
    transition: left 0.3s ease !important;
    z-index: 12000 !important; /* Higher than backdrop */
    box-shadow: none !important;
    border-right: 1px solid rgba(255,255,255,0.1) !important;
    pointer-events: auto !important; /* Ensure sidebar is clickable */
  }
  
  .sidebar.open {
    left: 0 !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    height: auto;               /* allow content to size naturally on mobile */
    overflow-y: visible;        /* use page scroll on mobile */
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Mobile header with hamburger */
  .mobile-header { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    position: sticky; 
    top: 0; 
    z-index: 1100; 
    background: rgba(17, 26, 34, 0.95);
    border-bottom: 1px solid rgba(255,255,255,0.1); 
    padding: 10px 12px; 
  }
  .mobile-header .menu-btn {
    font-size: 20px; 
    line-height: 1; 
    padding: 6px 10px; 
    background: rgba(255,255,255,0.08); 
    border: 1px solid rgba(255,255,255,0.2); 
    color: #fff; 
    border-radius: 6px; 
  }
  .mobile-header .brand {
    display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; text-decoration: none;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 60vw;
  }
  .mobile-header .brand img { height: 24px; }
  .mobile-header .brand span { 
    display: inline !important; 
    font-size: 16px;
    margin-left: 8px;
  }
  .mobile-header .filters-btn { 
    display: flex !important; 
    align-items: center;
    justify-content: center;
  }

  /* Backdrop when menu open - Lighter and no blur, BEHIND sidebar */
  .sidebar-backdrop { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.3) !important; 
    z-index: 11000 !important; /* Lower than sidebar (12000) */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: auto !important; /* Allow clicking backdrop to close */
  }
  .sidebar.open ~ .sidebar-backdrop { 
    display: block; 
  }
  
  /* Ensure sidebar content is clickable */
  .sidebar * {
    pointer-events: auto !important;
  }
  
  /* Filters backdrop - Lighter and no blur, BEHIND filters panel */
  .filters-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3) !important;
    z-index: 12500 !important; /* Below filters panel (13000) but above sidebar (12000) */
    top: 56px; /* Below mobile header */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: auto !important;
  }
  body.filters-open .filters-backdrop {
    display: block !important;
    visibility: visible !important;
  }
  
  /* Full-screen filters sheet on mobile for readability */
  #mobileFiltersPanel{ 
    position:fixed !important; 
    top:56px !important; 
    left:0 !important; 
    right:0 !important; 
    bottom:0 !important; 
    z-index:13000 !important; /* Above sidebar (12000) */
    display:none !important; 
    overflow-y:auto !important; 
    overflow-x:hidden !important;
    -webkit-overflow-scrolling: touch !important;
    background: rgba(17,26,34,0.98) !important; 
    padding:12px 10px 80px 10px !important; 
    pointer-events: auto !important;
  }
  body.filters-open #mobileFiltersPanel{ 
    display:block !important; 
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Mobile filters panel header */
  #mobileFiltersPanel .mFiltersBar::before {
    content: 'Filters';
    display: block;
    width: 100%;
    padding: 8px 0;
    margin-bottom: 12px;
    text-align: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  
  /* Compact filter sections */
  #mobileFiltersPanel .filterGroup {
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(44, 44, 46, 0.3);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  #mobileFiltersPanel .filterGroup:last-child {
    margin-bottom: 0;
  }
  
  /* Make filter chips wrap better */
  #mobileFiltersPanel .filterGroup > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  /* Icon chips - smaller icons */
  #mobileFiltersPanel .chip .arkham-icon {
    font-size: 12px !important;
    width: 14px !important;
    height: 14px !important;
  }
  
  /* Icon chips with text - make more compact */
  #mobileFiltersPanel #iconChips .chip {
    font-size: 10px !important;
    padding: 5px 8px !important;
  }
  
  /* Slot chips - more compact */
  #mobileFiltersPanel #slotChips .chip {
    font-size: 10px !important;
    padding: 5px 8px !important;
  }
  #mobileFiltersPanel .filtersBar{ 
    position: static !important; 
    max-height: none !important; 
    opacity: 1 !important; 
    pointer-events: auto !important; 
    background: transparent !important; 
    border: 0 !important; 
    box-shadow: none !important; 
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  
  /* Show classBar in mobile filters panel */
  #mobileFiltersPanel .classBar {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    margin-bottom: 16px !important;
    padding: 12px !important;
    background: rgba(44, 44, 46, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    gap: 8px !important;
  }
  
  #mobileFiltersPanel .classBar .chip {
    margin: 0 !important;
    flex: 0 0 auto !important;
  }
  
  /* Filters bar in mobile panel */
  #mobileFiltersPanel .filtersBar {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    align-items: stretch !important;
  }
  
  /* Compact filter groups on mobile */
  #mobileFiltersPanel .filtersBar .filterGroup {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    width: 100% !important;
    margin-bottom: 0 !important;
    padding: 12px !important;
    background: rgba(44, 44, 46, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
  }
  
  /* Chips container within filter group */
  #mobileFiltersPanel .filterGroup > div {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }
  
  /* Smaller chips on mobile */
  #mobileFiltersPanel .filtersBar .chip {
    font-size: 12px !important;
    padding: 8px 12px !important;
    min-height: 36px !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Compact input groups */
  #mobileFiltersPanel .filtersBar .filterInputs {
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 12px !important;
    background: rgba(44, 44, 46, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
  }
  
  #mobileFiltersPanel .filtersBar input {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 14px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }
  
  /* Input group styling */
  #mobileFiltersPanel .filtersBar .inputGroup {
    width: 100% !important;
    margin: 0 !important;
  }
  
  /* Class bar chip images */
  #mobileFiltersPanel .classBar .chip img {
    height: 14px !important;
    width: 14px !important;
  }

  /* Phone spacing for containers */
  .main-content { 
    padding: 8px 8px 60px !important; 
    max-width: 100vw; 
    box-sizing: border-box; 
    padding-top: 0 !important;
  }
  .grid { 
    gap: 12px; 
    margin-top: 12px; 
    padding: 0 8px;
  }
  
  /* Ensure filter containers fit viewport on Safari and wrap dynamically */
  #classBar, .filtersBar { width: 100%; max-width: 100vw; box-sizing: border-box; -webkit-overflow-scrolling: touch; overflow-x: hidden; }
  .filtersBar .filterGroup, .filtersBar .filterInputs { width: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
  .filtersBar #typeChips,
  .filtersBar #kwModeChips,
  .filtersBar #slotChips,
  .filtersBar #iconChips,
  .filtersBar #mechChips,
  .filtersBar #sortChips,
  .filtersBar #dirChips { display:flex; flex-wrap: wrap; gap: 6px; width: 100%; }
  .filtersBar .chip{ white-space: nowrap; flex: 0 0 auto; }
  
  /* Make controls readable on phones */
  .filtersBar .chip{ font-size:12px; padding:6px 10px; }
  .filtersBar input{ width:100%; max-width:100%; }

  /* Investigators grid responsiveness */
  .investigators-grid { grid-template-columns: 1fr !important; gap: 12px !important; padding-bottom: 60px; }
  .investigators-container { padding: 8px; }

  /* Rules page container responsiveness */
  .rules-container { padding: 8px; }
  .rules-content { padding: 12px; }
  
  .filterRow {
    gap: 8px;
  }
  
  .filterInputs {
    min-width: 100%;
  }
  
  /* Icon chips with text on mobile */
  .filtersBar #iconChips .chip,
  .filtersBar #iconSortChips .chip {
    max-width: 90px;
    min-width: 60px;
    width: auto;
    height: 20px;
    padding: 2px 6px;
    gap: 4px;
  }
  
  .filtersBar #slotChips .chip {
    max-width: 70px;
    min-width: 35px;
    height: 20px;
    padding: 2px 6px;
    font-size: 10px;
  }
  
  .filtersBar .chip .arkham-icon {
    font-size: 10px;
    width: 12px;
    height: 12px;
  }
  
  /* Mobile chip images */
  .filtersBar .chip img {
    width: 12px;
    height: 12px;
    margin-right: 0;
  }
}




