:root {
  --bg-color: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #10b981;
  --accent-hover: #059669;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent !important; /* Removes blue tap highlight overlay on mobile devices */
}

button,
a,
input,
select,
textarea,
div,
span,
.btn,
.top-login-btn,
.user-profile-menu,
.top-dropdown-item,
.warning-badge-btn,
.mushroom-card {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none;
}

button:focus,
button:focus-visible,
button:active,
a:focus,
a:focus-visible,
a:active,
input:focus,
select:focus {
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 0 4rem 0;
  overflow-x: hidden;
  /* Moved background to pseudo-element for compositor-friendly scroll */
  position: relative;
}

/* Fixed background via pseudo-element – composited by GPU, never causes repaint on scroll */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.95)),
    url('amanita_bg.png');
  background-size: cover;
  background-position: center;
  will-change: transform; /* keeps it on its own GPU layer */
}

#main-literature-container {
  width: 100%;
}

/* Top Main Bar (Inside Glass Panel & Literature Pages) */
.top-main-bar,
.top-navbar {
  position: sticky !important;
  top: 0.75rem !important;
  z-index: 9999 !important;
  width: 100% !important;
  background: rgba(15, 23, 42, 0.82) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 1.2rem !important;
  padding: 0.45rem 1.25rem !important;
  margin-bottom: 2rem !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  min-height: 68px !important;
  box-sizing: border-box !important;
}

/* Brand Logo */
.top-navbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.top-navbar-brand:hover {
  transform: scale(1.03);
}

.brand-logo-img {
  height: 54px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

/* Center Empty Space */
.top-navbar-center {
  flex: 1;
}

/* Right Section Container */
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Login Button (when user is NOT logged in) */
.top-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 0.75rem; /* Matches 12px border radius of search input & controls */
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.top-login-btn:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

/* User Profile Menu (Admin Panel Style with Dropdown) */
.user-profile-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem; /* Identical 12px border-radius to #search-input and controls below */
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.user-profile-menu:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
}

.user-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #10b981;
  object-fit: cover;
}

.user-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  border: 1.5px solid #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.user-profile-name {
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

.dropdown-arrow {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.user-profile-menu:hover .dropdown-arrow {
  color: #10b981;
}

/* Top User Dropdown Menu */
.top-user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 200px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 0;
  display: none;
  z-index: 10000;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  animation: fadeInDown 0.15s ease-out;
}

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

.top-user-dropdown.show {
  display: block;
}

.top-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: #e2e8f0;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.top-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item-admin:hover {
  color: #34d399;
}

.nav-item-logout {
  color: #fca5a5;
}

.nav-item-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

/* Glassmorphism Panel */
.glass-panel {
  background: rgba(15, 23, 42, 0.30);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 1.5rem;
  padding: 2.5rem;
  margin: 2rem auto 0;
  box-shadow: var(--shadow-lg);
  max-width: 1160px;
  width: 92%;
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #34d399, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.05em;
}

p.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.875rem 2rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: white;
  background-color: var(--accent-color);
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}

.btn:hover {
  background-color: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.5);
}

.btn-danger {
  background-color: var(--danger-color);
  box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background-color: var(--danger-hover);
  box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.5);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
  box-shadow: none;
}

.btn-outline:hover {
  background-color: var(--accent-color);
  color: white;
}

/* Bottom action navigation buttons on detail and literature pages */
.lit-page > div[style*="text-align: center"],
.lit-page div:not(header):not(.top-main-bar):not(.top-nav-right):has(> .btn:not(.top-login-btn)),
.lit-bottom-actions,
.bottom-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.5rem !important;
  margin-bottom: 2rem !important;
}

.lit-page > div[style*="text-align: center"] .btn,
.lit-page > div[style*="text-align: center"] .btn-outline,
.lit-page > div[style*="text-align: center"] .btn-lit,
.lit-page div:not(header):not(.top-main-bar):not(.top-nav-right):has(> .btn:not(.top-login-btn)) .btn,
.lit-bottom-actions .btn,
.bottom-actions .btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  margin: 0 !important;
}

/* Warning card */
.warning-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: rgba(234, 179, 8, 0.07);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.warning-card-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.warning-card-text strong {
  display: block;
  color: #fde68a;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.warning-card-text p {
  color: #d4b77a;
  font-size: 0.8rem;
  line-height: 1.6;
  margin: 0;
}

.warning-card-text em {
  color: #fde68a;
  font-style: italic;
}

.warning-card-text strong + p strong {
  color: #fca5a5;
}

/* Category Sections */
.category-section {
  width: 100%;
  margin-bottom: 2rem;
  text-align: left;
}

.category-section:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #34d399;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

/* Game Grid / List */
.mushroom-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

/* Card — vertical layout */
.mushroom-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1.25rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 340px;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  text-decoration: none;
  color: inherit;
  /* Compositor layer per card: prevents scroll from causing full repaint */
  will-change: transform;
  transform: translateZ(0);
  /* Paint containment: browser can skip repainting cards outside viewport */
  contain: layout style paint;
}

.mushroom-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(16, 185, 129, 0.5);
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(0,0,0,0.5);
}

/* Edibility Badge */
.mushroom-card {
  position: relative;
}

.edibility-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  z-index: 10;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.2);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

.edibility-badge:hover {
  transform: scale(1.15);
}

.edibility-badge svg,
.edibility-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Beginner Badge */
.beginner-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 1.5rem;
  z-index: 10;
  cursor: help;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
  transition: transform 0.2s ease;
}

.beginner-badge:hover {
  transform: scale(1.15);
}

/* Deep Search Badge */
.deep-search-badge {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  font-size: 1.5rem;
  z-index: 10;
  cursor: help;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
  transition: transform 0.2s ease;
}

.deep-search-badge:hover {
  transform: scale(1.15);
}

/* Card image & Loader */
.mushroom-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  flex-shrink: 0;
  background: #0f172a linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  animation: cardImgShimmer 1.8s infinite linear;
  /* Keep shimmer on its own layer */
  isolation: isolate;
}

.mushroom-card-img::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: cardImgSpinner 0.8s infinite linear;
  z-index: 1;
  pointer-events: none;
}

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

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

.mushroom-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 2;
  transition: transform 0.4s ease, opacity 0.3s ease;
  /* Hint to browser to rasterise each image once on its own layer */
  will-change: transform;
  transform: translateZ(0);
}

.mushroom-card:hover .mushroom-card-img img {
  transform: scale(1.07);
}

.mushroom-card-img-placeholder {
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

/* Card body */
.mushroom-card-body {
  padding: 0.9rem 1rem 0.5rem;
  flex: 1;
  text-align: left;
}

.mushroom-card-body h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.mushroom-card-body h2 span {
  font-size: 1.05rem;
  color: #94a3b8;
  font-weight: 400;
  display: block;
  margin-top: 0.2rem;
}

.mushroom-card-body p {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Card Traits / Characteristics */
.mushroom-card-traits {
  margin-top: 1rem;
  text-align: left;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mushroom-card-traits strong {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mushroom-card-traits table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;
}

.mushroom-card-traits td {
  padding: 0.2rem 0;
  font-size: 0.8rem;
  color: #cbd5e1;
  vertical-align: top;
  line-height: 1.3;
}

.mushroom-card-traits td:first-child {
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  padding-right: 0.5rem;
}

.mushroom-card-traits td:first-child::before {
  content: "›";
  color: #34d399;
  font-weight: bold;
  margin-right: 0.4rem;
}

/* Card actions — buttons row */
.mushroom-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  flex-wrap: wrap;
}

.mushroom-card-actions .btn,
.mushroom-card-actions .btn-lit {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  padding: 0.45rem 0.6rem;
  text-align: center;
  white-space: nowrap;
}

.mushroom-card-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Gameplay specific */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 800px;
}

.image-frame {
  width: 100%;
  height: 400px;
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--panel-border);
  position: relative;
  background-color: #000;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.5s ease;
}

.controls {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  width: 100%;
}

.controls .btn {
  flex: 1;
  max-width: 200px;
}

/* Modal Overlay & Card - Hardware Accelerated Smooth Animations */
.modal-overlay,
#filter-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 1.5rem !important;
  background: rgba(15, 23, 42, 0.82) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 999999 !important; /* Always on top of everything */
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s ease !important;
  will-change: opacity;
  box-sizing: border-box !important;
}

.modal-overlay.active,
#filter-modal.active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-content,
#filter-modal .modal-content {
  position: relative !important;
  margin: auto !important;
  background: rgba(30, 41, 59, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 1.5rem !important;
  width: 100% !important;
  max-width: 500px !important;
  max-height: 85vh !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 1.75rem 2rem !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85) !important;
  transform: scale(0.93) translateY(12px) translateZ(0) !important;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2) !important;
  will-change: transform;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.modal-overlay.active .modal-content,
#filter-modal.active .modal-content {
  transform: scale(1) translateY(0) translateZ(0) !important;
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.success-text {
  color: var(--accent-color);
}

.error-text {
  color: var(--danger-color);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

/* ==============================
   WARNING POPUP MODAL
   ============================== */
#warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  /* Block ALL pointer events on overlay — only the modal itself is clickable */
  pointer-events: all;
}

#warning-overlay.wm-visible {
  opacity: 1;
}

#warning-overlay.wm-closing {
  opacity: 0;
}

#warning-modal {
  background: rgba(20, 30, 50, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-radius: 1.5rem;
  padding: 2.25rem 2rem 1.75rem;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(234,179,8,0.1);
  transform: scale(0.93) translateY(12px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2);
  text-align: center;
}

#warning-overlay.wm-visible #warning-modal {
  transform: scale(1) translateY(0);
}

.wm-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.wm-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fde68a;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
  background: none;
  -webkit-text-fill-color: #fde68a;
}

.wm-body {
  text-align: left;
  margin-bottom: 1.5rem;
}

.wm-body p {
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

.wm-body p:last-child {
  margin-bottom: 0;
}

.wm-body strong {
  color: #f1f5f9;
}

.wm-body em {
  color: #94a3b8;
  font-style: italic;
}

.wm-danger {
  color: #f87171;
  font-weight: 700;
}

.wm-btn {
  display: inline-block;
  padding: 0.75rem 2.5rem;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #1c1008;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.35);
  letter-spacing: 0.01em;
}

.wm-btn:hover {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.5);
}

.wm-btn:active {
  transform: scale(0.98);
}

/* Warning Badge Button (matches shape and border-radius of search-input below) */
.warning-badge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 0.75rem; /* Identical 12px border-radius to #search-input and #sort-select */
  padding: 0.8rem 1.6rem;
  color: #fde68a;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  line-height: 1;
  text-align: center;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.warning-badge-btn .wbb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  color: #f59e0b;
}

.warning-badge-btn .wbb-text {
  display: inline-block;
  line-height: 1;
}

.warning-badge-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.65);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

.warning-badge-btn:active {
  transform: translateY(0);
}

/* Utility */

.hidden {
  display: none !important;
}

/* btn-lit — Literatura dugme */
.btn-lit {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-lit:hover {
  background: rgba(99, 102, 241, 0.35);
  border-color: #818cf8;
  color: #e0e7ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-lit-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-lit-disabled:hover {
  transform: none;
  box-shadow: none;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

/* ==============================
   LITERATURA PAGE
   ============================== */
.lit-page {
  max-width: 860px;
  width: 95%;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  overflow: visible !important;
}

/* Back nav */
.lit-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  margin-bottom: 2rem;
  transition: color 0.2s;
}

.lit-back:hover {
  color: var(--accent-color);
}

/* Hero */
.lit-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 1.5rem;
  padding: 2.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.lit-hero-text h1 {
  font-size: 2rem;
  background: linear-gradient(to right, #34d399, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.lit-hero-text .latin-name {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 1rem;
  -webkit-text-fill-color: var(--text-secondary);
}

.lit-hero-text p {
  color: var(--text-secondary);
  line-height: 1.7;
}

.lit-hero-img {
  border-radius: 1rem;
  overflow: hidden;
  aspect-ratio: 4/3;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.lit-hero-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sections */
.lit-section {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 1.25rem;
  padding: 2rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.5s ease-out both;
}

.lit-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  -webkit-text-fill-color: var(--text-primary);
  color: var(--text-primary);
}

.lit-section p {
  color: #cbd5e1;
  line-height: 1.75;
  margin-bottom: 0.9rem;
}

.lit-section p:last-child {
  margin-bottom: 0;
}

.lit-section ul, .lit-section ol {
  color: #cbd5e1;
  padding-left: 1.5rem;
  line-height: 1.8;
}

.lit-section li {
  margin-bottom: 0.35rem;
}

.lit-section strong {
  color: #f1f5f9;
}

/* Nutrient table */
.nutrient-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nutrient-table th {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 0.65rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
}

.nutrient-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #cbd5e1;
}

.nutrient-table tr:last-child td {
  border-bottom: none;
}

.nutrient-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* Property cards (prepoznavanje) */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.prop-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.25s ease;
}

.prop-card:hover {
  border-color: rgba(52, 211, 153, 0.5);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.prop-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.prop-card-label {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
}

.prop-card-label span {
  display: block;
  color: #f1f5f9;
  font-size: 0.92rem;
}

/* Lookalike (dvojnik) cards */
.lookalike {
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(239, 68, 68, 0.04);
  transition: border-color 0.2s;
}

.lookalike:last-child {
  margin-bottom: 0;
}

.lookalike:hover {
  border-color: rgba(239, 68, 68, 0.5);
}

.lookalike h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f87171;
  margin-bottom: 0.25rem;
}

.lookalike h3 .la-latin {
  font-weight: 400;
  font-style: italic;
  font-size: 0.9em;
  color: #fca5a5;
}

.lookalike .danger-badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 9999px;
  font-size: 0.75rem;
  padding: 0.15rem 0.65rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.lookalike p {
  color: #cbd5e1;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.lookalike ul {
  color: #cbd5e1;
  padding-left: 1.5rem;
  line-height: 1.8;
  margin-bottom: 1rem;
}

.la-img-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  /* Firefox Scrollbar Customization */
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 185, 129, 0.3) rgba(15, 23, 42, 0.3);
}

/* Chrome, Edge, Safari Scrollbar Customization */
.la-img-row::-webkit-scrollbar {
  height: 6px;
}

.la-img-row::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.35);
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.la-img-row::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.1);
  transition: background 0.2s ease;
}

.la-img-row::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.5);
  border-color: rgba(16, 185, 129, 0.2);
}

.la-img-row img {
  height: 130px;
  border-radius: 0.75rem;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(239,68,68,0.2);
  transition: transform 0.2s;
}

.la-img-row img:hover {
  transform: scale(1.04);
}

/* Warning Lookalike (Not deadly, gastrointestinal or conditional) */
.warning-lookalike {
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
}
.warning-lookalike:hover {
  border-color: rgba(245, 158, 11, 0.6);
}
.warning-lookalike h3 {
  color: #fbbf24;
}
.warning-lookalike h3 .la-latin {
  color: #fcd34d;
}
.warning-lookalike img {
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
}

/* Summary box */
.lit-summary {
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(52,211,153,0.05));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 1.25rem;
  padding: 1.75rem 2rem;
  margin-top: 2rem;
  color: #a7f3d0;
  line-height: 1.8;
  font-size: 1.05rem;
  box-shadow: 0 0 40px rgba(16,185,129,0.05);
}

.lit-summary strong {
  color: #34d399;
}

/* Responsive */
@media (max-width: 640px) {
  .lit-hero {
    grid-template-columns: 1fr;
  }
  .lit-hero-img {
    order: -1;
  }
  .prop-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  body {
    justify-content: flex-start;
  }
}

/* Sticky Controls Bar (Pretraga, Sortiranje, Filteri - Inside Glass Panel) */
.controls-container {
  position: sticky;
  top: 5.4rem;
  z-index: 9998;
  width: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.2rem;
  padding: 0.65rem 1.25rem;
  margin: 1.25rem 0 1.75rem 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  transition: all 0.25s ease;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.control-search {
  flex: 1;
  min-width: 260px;
}

.controls-subgroup {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

.control-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.25rem;
  margin-bottom: 0.2rem;
}

/* Unpinned state (when user toggles off sticky lock) */
.controls-container.unpinned {
  position: relative !important;
  top: auto !important;
  box-shadow: none !important;
}

#filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  box-sizing: border-box;
  padding: 0 1.1rem;
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 0.75rem;
  line-height: 1;
}

#pin-controls-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  width: 42px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 0.75rem;
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
  box-shadow: none !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

#pin-controls-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-color);
  box-shadow: none !important;
  transform: translateY(-1px);
}

#search-input {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 0 2.8rem 0 2.8rem;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: all 0.2s;
}

.clear-search {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.clear-search:hover {
  color: #f8fafc;
}

#search-input:focus {
  border-color: #34d399;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.2);
}

.sort-filter-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#sort-select {
  height: 42px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  padding: 0 2rem 0 0.85rem;
  border-radius: 0.75rem;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  cursor: pointer;
}

/* Mobile Responsiveness for Sticky Main Bar & Controls Bar */
@media (max-width: 768px) {
  .top-main-bar,
  .top-navbar {
    top: 0.35rem;
    min-height: 52px;
    padding: 0.3rem 0.75rem;
    border-radius: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .brand-logo-img {
    height: 40px;
    max-width: 165px;
  }

  .user-profile-menu {
    padding: 3px 9px 3px 4px;
    gap: 6px;
    border-radius: 0.6rem;
  }

  .user-avatar-img,
  .user-avatar-placeholder {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .user-profile-name {
    font-size: 12.5px;
  }

  .top-login-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 0.6rem;
  }

  .controls-container {
    top: calc(0.75rem + 68px + 6px); /* navbar-top + navbar-height + gap */
    padding: 0.55rem 0.75rem;
    margin: 0.75rem 0 1.25rem 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    border-radius: 0.9rem;
  }

  .control-label {
    display: none;
  }

  .control-search {
    width: 100%;
    min-width: 100%;
  }

  .controls-subgroup {
    display: flex;
    width: 100%;
    gap: 0.5rem;
  }

  .control-sort {
    flex: 1;
  }

  .control-filter {
    flex: 0 0 auto;
  }

  #sort-select {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.88rem;
    height: 42px;
    line-height: 1.2;
    border-radius: 0.6rem;
  }

  #search-input {
    padding: 0.5rem 2.2rem 0.5rem 2.2rem;
    font-size: 0.88rem;
    height: 42px;
    line-height: 1.2;
    border-radius: 0.6rem;
  }

  #filter-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    height: 42px;
    border-radius: 0.6rem;
  }

  #pin-controls-btn {
    height: 42px !important;
    width: 42px !important;
    border-radius: 0.6rem !important;
    box-sizing: border-box !important;
    padding: 0 !important;
  }

  .control-pin {
    flex: 0 0 auto;
  }

  .search-icon {
    left: 0.7rem;
    font-size: 0.9rem;
  }

  /* Mobile Adjustments for Filter Modal Overlay & Card */
  #filter-modal,
  .modal-overlay {
    padding: 0.5rem 0.5rem 0.5rem 0.5rem !important;
    align-items: flex-start !important; /* Lifts modal card up towards top on mobile */
  }

  #filter-modal .modal-content,
  .modal-content {
    width: 96% !important;
    max-width: 100% !important;
    max-height: 94vh !important; /* Increased height so full content & buttons fit easily */
    margin-top: 0.5rem !important; /* Balanced minimal top spacing */
    padding: 1.1rem 1rem !important;
    border-radius: 1.25rem !important;
  }

  .modal-header {
    margin-bottom: 0.75rem !important;
    padding-bottom: 0.6rem !important;
    gap: 0.65rem !important;
  }

  .modal-header h2 {
    font-size: 1.25rem !important;
  }

  .modal-icon {
    width: 38px !important;
    height: 38px !important;
  }

  .modal-actions {
    margin-top: 0.5rem !important;
    padding-top: 0.65rem !important;
    gap: 0.5rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .modal-actions .btn {
    padding: 0.55rem 1rem !important;
    font-size: 0.88rem !important;
  }
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 1.1rem;
}

#sort-select:focus {
  border-color: #34d399;
}

#sort-select option {
  background: #1e293b;
  color: #f8fafc;
}

#filter-btn {
  padding: 0.7rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.filter-group h4 {
  color: #f8fafc;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.2rem;
}

.filter-label {
  display: flex;
  color: #cbd5e1;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  align-items: center;
  gap: 0.5rem;
}

.filter-label input[type="checkbox"] {
  accent-color: #34d399;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.5rem;
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  overflow-y: auto !important;
  flex: 1 1 auto !important;
  padding-right: 0.4rem;
  margin-bottom: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

/* Custom Emerald Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
  width: 5px;
}

.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9999px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  border-radius: 9999px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #34d399;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  justify-content: flex-end;
}

/* ==============================
   LIGHTBOX / FULLSCREEN SLIDESHOW
   ============================== */

body.lightbox-active {
  overflow: hidden;
}

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 30, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  position: relative;
  width: 90%;
  max-width: 960px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10005;
}

.lightbox-index-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.lightbox-image-container {
  position: relative;
  flex: 1;
  width: 100%;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-caption {
  width: 100%;
  max-width: 760px;
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-primary);
  background: rgba(30, 41, 59, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.25rem;
  padding: 1.25rem 2rem;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.lightbox-caption strong {
  display: block;
  font-size: 1.15rem;
  color: #34d399;
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.lightbox-desc-text {
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.6;
}

.lightbox-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  width: 3.25rem;
  height: 3.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: #94a3b8;
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10020;
}

.lightbox-close:hover {
  background: var(--danger-color);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.08) rotate(90deg);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3.75rem;
  height: 3.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: #cbd5e1;
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  user-select: none;
  z-index: 10020;
}

.lightbox-prev {
  left: 2.5rem;
}

.lightbox-next {
  right: 2.5rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: var(--accent-color);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
}

.lightbox-prev:hover {
  transform: translateY(-50%) scale(1.08) translateX(-3px);
}

.lightbox-next:hover {
  transform: translateY(-50%) scale(1.08) translateX(3px);
}

.lightbox-prev:active,
.lightbox-next:active {
  transform: translateY(-50%) scale(0.96);
}

/* Lightbox Image Hover Feedback on Main Page */
.lit-page img {
  transition: filter 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.lit-page img:hover {
  filter: brightness(1.1);
}

/* Responsive adjustments for Lightbox */
@media (max-width: 1024px) {
  .lightbox-prev {
    left: 1.5rem;
  }
  .lightbox-next {
    right: 1.5rem;
  }
}

/* ============================================================
   SCROLL PERFORMANCE: MOBILE OPTIMIZATIONS
   ============================================================ */

/* On mobile strip all expensive compositing effects from cards
   These are the single biggest cause of scroll jank on low-end phones */
@media (max-width: 768px) {
  /* Remove backdrop-filter from cards — major GPU savings */
  .mushroom-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    /* content-visibility: auto tells browser to skip off-screen cards entirely */
    content-visibility: auto;
    /* contain-intrinsic-size prevents layout shifts when cards pop in */
    contain-intrinsic-size: auto 420px;
  }

  /* Remove backdrop-filter from the sticky nav bar too — causes full-page recomposite */
  .top-main-bar,
  .top-navbar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(15, 23, 42, 0.96) !important;
  }

  /* Remove backdrop-filter from glass panel */
  .glass-panel {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(15, 23, 42, 0.97) !important;
  }

  /* Pause shimmer animation when scrolling — class toggled by JS scroll handler */
  body.is-scrolling .mushroom-card-img {
    animation-play-state: paused !important;
  }

  /* Disable card hover transforms on touch (they cause repaints) */
  .mushroom-card:hover {
    transform: translateZ(0) !important;
  }

  /* Prevent the grid from causing layout reflows — use GPU layer */
  #mushrooms-grid {
    transform: translateZ(0);
    will-change: scroll-position;
  }

  /* Remove transition on card image hover for mobile (no hover on touch) */
  .mushroom-card-img img {
    transition: opacity 0.2s ease !important;
  }

  /* Overscroll bounce on iOS for smooth feel */
  body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* ---- Scroll perf for individual species / literature pages ---- */
  /* Each content section gets its own GPU layer — prevents full page repaint */
  .lit-section,
  .lit-hero,
  .highlight-box,
  .danger-box,
  .warning-box {
    transform: translateZ(0);
    contain: layout style paint;
  }

  /* Remove backdrop-filter from lit-page sections if any exist */
  .lit-section,
  .lit-hero {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Disable image zoom transition on touch (no hover on mobile) */
  .lit-page img {
    transition: none !important;
  }
}

@media (max-width: 768px) {

  html {
    font-size: 17px !important;
  }
  body {
    padding: 0.5rem 0 !important;
    font-size: 1.05rem !important;
  }
  h1 {
    font-size: 2.1rem !important;
  }
  p.subtitle {
    font-size: 1.05rem !important;
    line-height: 1.65 !important;
  }
  .glass-panel {
    width: 98% !important;
    max-width: 100% !important;
    padding: 1.2rem 0.75rem !important;
    border-radius: 1rem !important;
  }
  .lit-page, html body .lit-page {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.75rem 0.3rem 3rem !important;
    font-size: 1.05rem !important;
  }
  .lit-hero, html body .lit-hero {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
    padding: 1.25rem 0.85rem !important;
    border-radius: 1rem !important;
  }
  .lit-section, html body .lit-section {
    padding: 1.2rem 0.85rem !important;
    margin-bottom: 1.25rem !important;
    border-radius: 1rem !important;
  }
  .lit-section h1 {
    font-size: 1.95rem !important;
  }
  .lit-section h2 {
    font-size: 1.4rem !important;
    margin-top: 2rem !important;
  }
  .lit-section h3 {
    font-size: 1.2rem !important;
  }
  .lit-section p, .lit-section li {
    font-size: 1.08rem !important;
    line-height: 1.7 !important;
  }
  .highlight-box, .danger-box, .warning-box {
    padding: 1.1rem 0.9rem !important;
    margin: 1.25rem 0 !important;
    font-size: 1.02rem !important;
  }
  .highlight-box p, .danger-box p, .warning-box p,
  .highlight-box li, .danger-box li, .warning-box li {
    font-size: 1.02rem !important;
  }
  .mushroom-card {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .mushroom-card-body h2 {
    font-size: 1.08rem !important;
  }
  .mushroom-card-body h2 span {
    font-size: 0.95rem !important;
  }
  .mushroom-card-body p {
    font-size: 0.92rem !important;
    line-height: 1.5 !important;
  }
  .mushroom-card-traits td {
    font-size: 0.9rem !important;
  }
  .mushroom-card-traits strong {
    font-size: 0.88rem !important;
  }
  .control-label {
    font-size: 0.95rem !important;
  }
  .search-box input {
    font-size: 1rem !important;
  }
  .btn, .btn-outline, .btn-lit {
    font-size: 1rem !important;
  }
  /* Mobile View: Bottom action buttons separated & equal length/width */
  /* ONLY target the specific wrapper divs at the bottom — NEVER navbar elements */
  .lit-page > div[style*="text-align: center"],
  .lit-bottom-actions,
  .bottom-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 440px !important;
    margin: 2.5rem auto 1.5rem !important;
    padding: 0 0.75rem !important;
    gap: 0.85rem !important;
    box-sizing: border-box !important;
  }
  .lit-page > div[style*="text-align: center"] .btn,
  .lit-page > div[style*="text-align: center"] .btn-outline,
  .lit-page > div[style*="text-align: center"] .btn-lit,
  .lit-bottom-actions .btn,
  .bottom-actions .btn {
    display: flex !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0.95rem 1.25rem !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    min-height: 48px !important;
    border-radius: 0.75rem !important;
  }
  /* Order: bottom nav buttons — use ONLY within the text-align:center wrapper */
  .lit-page > div[style*="text-align: center"] a[href*="literatura"],
  .lit-page > div[style*="text-align: center"] a.btn-lit {
    order: 1 !important;
  }
  .lit-page > div[style*="text-align: center"] a[href*="kviz"] {
    order: 2 !important;
  }
  .lit-page > div[style*="text-align: center"] a[href="index.html"],
  .lit-page > div[style*="text-align: center"] a[href="./index.html"] {
    order: 3 !important;
  }
  .lit-page > div[style*="text-align: center"] a[href="../../"],
  .lit-page > div[style*="text-align: center"] a[href="../../index.html"] {
    order: 10 !important;
  }
  /* === NAVBAR RESET: force correct layout regardless of other rules === */
  .lit-page header.top-main-bar,
  .top-main-bar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: nowrap !important;
  }
  /* Logo: always left */
  .top-main-bar .top-navbar-brand {
    order: 0 !important;
    width: auto !important;
    min-width: unset !important;
    max-width: unset !important;
    display: flex !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  /* User section: always right */
  .top-main-bar .top-nav-right {
    order: 1 !important;
    width: auto !important;
    min-width: unset !important;
    max-width: unset !important;
    display: flex !important;
    flex-direction: row !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
  }
  /* Login button inside navbar: normal size, never full-width */
  /* NOTE: do NOT set display here — JS controls visibility via inline style */
  .top-main-bar .top-login-btn,
  .top-nav-right .top-login-btn {
    width: auto !important;
    min-width: unset !important;
    max-width: unset !important;
    flex-direction: row !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
    min-height: unset !important;
    border-radius: 0.65rem !important;
    order: unset !important;
  }
  /* User profile menu inside navbar: always a row when visible */
  /* NOTE: do NOT set display here — JS controls visibility via inline style */
  .top-nav-right .user-profile-menu {
    order: unset !important;
    width: auto !important;
    flex-direction: row !important;
  }
  .lightbox-content {
    width: 95%;
    height: 80vh;
  }
  .lightbox-image-container {
    max-height: 50vh;
  }
  .lightbox-prev,
  .lightbox-next {
    width: 3rem;
    height: 3rem;
    font-size: 1.3rem;
  }
  .lightbox-prev {
    left: 0.5rem;
  }
  .lightbox-next {
    right: 0.5rem;
  }
  .lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.4rem;
  }
  .lightbox-caption {
    margin-top: 1rem;
    padding: 1rem;
  }
  .lightbox-caption strong {
    font-size: 1.05rem;
  }
  .lightbox-desc-text {
    font-size: 0.85rem;
  }
}

/* --- BACK TO TOP BUTTON --- */
.back-to-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(16, 185, 129, 0.4);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.8);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    background-color: rgba(5, 150, 105, 0.9);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
/* ==============================
   CUSTOM SCROLLBARS (Global)
   ============================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.4); 
  border-radius: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.4); 
  border-radius: 8px;
  border: 2px solid rgba(15, 23, 42, 0.4);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(16, 185, 129, 0.8); 
}

/* Specijalno tanki skrol za tabele ako su manje */
.lit-section table::-webkit-scrollbar {
  height: 8px;
}
