/* ==========================================================
   UI UPGRADES: GLASSMORPHISM & ANIMATIONS
   ========================================================== */

/* Glassmorphism Header */
header#main-header {
  background: rgba(15, 23, 42, 0.95) !important; /* Slate 900 */
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 75px;
}

/* Glassmorphism Quiz Container */
.quiz-container {
  background-color: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px !important;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
}

/* Premium Buttons */
.btn {
  background-color: rgba(240, 244, 248, 0.9) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.btn:not([disabled]):hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  background-color: #ffffff !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

.btn:not([disabled]):active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Fade In Animation for Questions */
.fade-in-content {
  animation: smoothFadeIn 0.4s cubic-bezier(0.39, 0.57, 0.56, 1) forwards;
}

@keyframes smoothFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Ensure selected True/False buttons use primary color */
html body button.tf-btn.selected-tf,
html body button.tf-btn.selected-tf:hover,
html body button.tf-btn.selected-tf:active,
body.dark-mode button.tf-btn.selected-tf,
body.dark-mode button.tf-btn.selected-tf:hover,
body.dark-mode button.tf-btn.selected-tf:active {
  background-color: var(--primary-color) !important;
  color: #ffffff !important;
  border: 1px solid var(--primary-color) !important;
  box-shadow: none !important;
}

/* Correct and wrong states moved to the end of the file for specificity */

/* Tablet / Small Desktop Optimizations removed because side navbar takes over at 769px */

@media (max-width: 768px) {
  #main-header {
    border-bottom: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 60px;
  }
  
  /* Restored Burger Menu visibility */
  header#main-header {
    justify-content: center; /* Center the logo */
    position: relative;
    /* Remove backdrop-filter because it creates a containing block that breaks position: fixed for #navbar */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(30, 41, 59, 0.98);
    padding-top: max(env(safe-area-inset-top), 28px) !important; /* Prevent status bar overlap */
    padding-bottom: 5px;
  }

  #navigation-controls {
    bottom: var(--safe-area-bottom);
    padding-bottom: max(env(safe-area-inset-bottom), 15px);
  }

  body.dark-mode #navigation-controls {
    background-color: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  #menu-toggle { 
    display: flex !important; 
    position: absolute;
    left: 15px;
    top: calc(50% + 12px); /* Adjusted for padding-top */
    transform: translateY(-50%);
    z-index: 1012; /* Above other header elements */
  }

  #theme-toggle {
    position: absolute;
    right: 15px;
    top: calc(50% + 12px); /* Adjusted for padding-top */
    transform: translateY(-50%);
    margin-left: 0;
  }

  body { padding-bottom: 20px; }

  /* Dark mode sidebar */
  body.dark-mode #navbar {
    background: rgba(30, 41, 59, 0.98);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  body.dark-mode .nav-btn {
    color: var(--text-primary) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  body.dark-mode .nav-btn:hover {
    background: rgba(255, 255, 255, 0.05) !important;
  }

  /* Make map background much more distinct on mobile */
  body::before {
    opacity: 1 !important;
  }

  .quiz-container {
    width: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background-color: rgba(255, 255, 255, 0.65) !important; /* Frosted glass instead of transparent for readability */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: var(--spacing-md) !important;
  }

  body.dark-mode .quiz-container {
    background-color: rgba(15, 23, 42, 0.75) !important; /* Dark frosted glass */
  }
  
  .question-container, #results-container {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 20px 20px 130px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
  }

  #start-screen {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 20px 20px 40px 20px; /* Reduced bottom padding */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
  }

  body.dark-mode .question-container,
  body.dark-mode #start-screen,
  body.dark-mode #results-container {
    background: rgba(15, 23, 42, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
  }
}

/* ==========================================================
   DARK MODE (Aegean Teal & Slate)
   ========================================================== */
body.dark-mode {
  --primary-color: #5b92a4; /* Lighter Aegean Blue for dark mode */
  --primary-light: #7bafc1;
  --secondary-color: #fbbf24; /* Amber 400 */
  --secondary-hover: #f59e0b;
  --bg-color: #1F232B; /* Clean Dark Anthracite */
  --card-bg: #252A34; /* Lighter Anthracite for cards */
  --text-primary: #f8fafc; /* Crisp Silver/White */
  --text-secondary: #cbd5e1; /* Lighter Slate for secondary text */
  --border-color: #44403c; /* Warm Stone 700 */
  --success-color: #849354; /* Lighter Sage Green for dark mode */
  --success-bg: rgba(132, 147, 84, 0.15);
  --error-color: #d14155; /* Dark Rose for dark mode */
  --error-bg: rgba(209, 65, 85, 0.15);
  --header-gradient: #262422; /* Match bg color for a clean look */
  --btn-gradient: linear-gradient(to right, #5b92a4, #48788a);
}

/* Specific component fixes for dark mode readability */
body.dark-mode select,
body.dark-mode option {
  background-color: var(--primary-light) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .statement-row,
body.dark-mode .matching-column,
body.dark-mode .image-selection-item,
body.dark-mode #reading-text-container {
  background: rgba(15, 23, 42, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .tf-btn {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .matching-item-row {
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .image-label,
body.dark-mode #reading-title,
body.dark-mode #reading-content {
  color: var(--text-primary) !important;
}

body.dark-mode .quiz-container {
  background-color: var(--card-bg) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .question-container,
body.dark-mode #results-container {
  background: var(--card-bg) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .btn {
  background-color: rgba(30, 41, 59, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .btn:not([disabled]):hover {
  background-color: rgba(51, 65, 85, 0.9) !important;
  border-color: var(--primary-light) !important;
}

body.dark-mode #prev-btn {
  background-color: rgba(30, 41, 59, 0.9) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-secondary) !important;
}

body.dark-mode #next-btn {
  background: var(--primary-color) !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 800 !important;
}

body.dark-mode header#main-header {
  background: rgba(15, 23, 42, 0.95);
}

body.dark-mode #question-text,
body.dark-mode #category-title {
  color: var(--text-primary) !important;
}

/* Theme Toggle Button */
#theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s ease;
  margin-left: auto; /* Push it to the right */
}

#theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* ==========================================================
   WRONG QUESTIONS BANK STYLES (Restored)
   ========================================================== */

/* ========================================================== */
/* SIDEBAR 3D & GLASSMORPHISM UPDATES                         */
/* ========================================================== */
@media (min-width: 769px) {
  /* 1. Glassmorphism for Sidebar */
  #navbar {
    background: rgba(253, 251, 247, 0.65) !important; /* Warm Ivory transparent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05) !important;
  }
  
  body.dark-mode #navbar {
    background: rgba(31, 35, 43, 0.65) !important; /* Anthracite transparent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3) !important;
  }

  /* 2. Remove Dividers & Setup 3D Buttons */
  .nav-btn {
    border-bottom: none !important;
    margin-bottom: 8px !important;
    border-radius: 12px !important; /* Make them look like pill/buttons */
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
  }

  /* 3. 3D Pressed/Selected State (Neumorphic Pop-out) */
  .nav-btn.selected {
    background: #ffffff !important;
    border-left: none !important;
    box-shadow: 
      -4px -4px 10px rgba(255, 255, 255, 1),
      4px 4px 10px rgba(0, 0, 0, 0.05) !important;
    transform: scale(0.98);
    color: var(--primary-color) !important;
    font-weight: 800 !important;
  }

  body.dark-mode .nav-btn.selected {
    background: #252A34 !important; /* Match card bg */
    border-left: none !important;
    box-shadow: 
      -2px -2px 6px rgba(255, 255, 255, 0.03),
      4px 4px 10px rgba(0, 0, 0, 0.4) !important;
    color: #f8fafc !important;
  }
  
  /* 4. Staggered Cascade Animation */
  @keyframes slideInLeftCascade {
    0% { opacity: 0; transform: translateX(-30px); }
    100% { opacity: 1; transform: translateX(0); }
  }
  
  #navbar .nav-btn {
    opacity: 0; /* Initially hidden */
    animation: slideInLeftCascade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  }
  
  #navbar .nav-btn:nth-child(1) { animation-delay: 0.05s; }
  #navbar .nav-btn:nth-child(2) { animation-delay: 0.10s; }
  #navbar .nav-btn:nth-child(3) { animation-delay: 0.15s; }
  #navbar .nav-btn:nth-child(4) { animation-delay: 0.20s; }
  #navbar .nav-btn:nth-child(5) { animation-delay: 0.25s; }
  #navbar .nav-btn:nth-child(6) { animation-delay: 0.30s; }
  #navbar .nav-btn:nth-child(7) { animation-delay: 0.35s; }
  #navbar .nav-btn:nth-child(8) { animation-delay: 0.40s; }
  #navbar .nav-btn:nth-child(9) { animation-delay: 0.45s; }
  #navbar .nav-btn:nth-child(10) { animation-delay: 0.50s; }
  #navbar .nav-btn:nth-child(11) { animation-delay: 0.55s; }
  #navbar .nav-btn:nth-child(12) { animation-delay: 0.60s; }
}

/* Individual wrong question card */
.wrong-bank-card {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-left: 4px solid #ef4444;
  border-radius: 10px;
  padding: 12px 15px;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

body.dark-mode .wrong-bank-card {
  background: var(--card-bg);
  border-color: var(--border-color);
  border-left-color: #ef4444; /* Keep the red left border as a subtle indicator */
}

.wrong-bank-card:hover {
  transform: translateX(4px);
  border-left-color: #dc2626;
  box-shadow: 0 3px 12px rgba(239, 68, 68, 0.2);
  background: #fff0f0;
}

body.dark-mode .wrong-bank-card:hover {
  background: rgba(51, 65, 85, 0.6);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

.wrong-bank-card:active {
  transform: translateX(2px);
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.15);
}

/* "Sadece bu soruyu ÃƒÂ§ÃƒÂ¶z" arrow hint */
.wrong-bank-card-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: #ef4444;
  opacity: 0;
  transition: opacity 0.2s, right 0.2s;
}

.wrong-bank-card:hover .wrong-bank-card-arrow {
  opacity: 1;
  right: 10px;
}

/* ==========================================================
   Restore Correct/Wrong Button States (High Specificity)
   ========================================================== */
.btn.correct,
.btn.correct:hover,
.btn.correct:active,
.tf-btn.correct,
.tf-btn.correct:hover,
button.tf-btn.selected-tf.correct,
button.tf-btn.selected-tf.correct:hover {
  background-color: #e6f9ec !important;
  color: #145c29 !important;
  border-color: transparent !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

body.dark-mode .btn.correct,
body.dark-mode .btn.correct:hover,
body.dark-mode .btn.correct:active,
body.dark-mode .tf-btn.correct,
body.dark-mode .tf-btn.correct:hover,
body.dark-mode button.tf-btn.selected-tf.correct,
body.dark-mode button.tf-btn.selected-tf.correct:hover {
  background-color: #252A34 !important;
  color: #6ee7b7 !important;
  border-color: #6ee7b7 !important;
  box-shadow: 0 0 10px rgba(110, 231, 183, 0.1) !important;
  opacity: 1 !important;
}

.btn.wrong,
.btn.wrong:hover,
.btn.wrong:active,
.tf-btn.wrong,
.tf-btn.wrong:hover,
button.tf-btn.selected-tf.wrong,
button.tf-btn.selected-tf.wrong:hover {
  background-color: #ffebe6 !important;
  color: #8b0000 !important;
  border-color: transparent !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

body.dark-mode .btn.wrong,
body.dark-mode .btn.wrong:hover,
body.dark-mode .btn.wrong:active,
body.dark-mode .tf-btn.wrong,
body.dark-mode .tf-btn.wrong:hover,
body.dark-mode button.tf-btn.selected-tf.wrong,
body.dark-mode button.tf-btn.selected-tf.wrong:hover {
  background-color: #252A34 !important;
  color: #fda4af !important;
  border-color: #fda4af !important;
  box-shadow: 0 0 10px rgba(253, 164, 175, 0.1) !important;
  opacity: 1 !important;
}

body.dark-mode .btn-reset {
  color: rgba(255, 255, 255, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  background-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .btn-reset:hover {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #fda4af !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* Image Selection correct/wrong states for dark mode */
body.dark-mode .image-selection-item.correct-image {
  background: rgba(34, 197, 94, 0.2) !important;
  border-color: var(--success-color) !important;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.3) !important;
}

body.dark-mode .image-selection-item.wrong-image {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: var(--error-color) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3) !important;
}

body.dark-mode .image-selection-item.selected-image {
  background: rgba(59, 130, 246, 0.15) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.3) !important;
}

/* ==========================================================
   NEW HOME GRID DESIGN
   ========================================================== */

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  max-width: 600px;
  margin: 0 auto 20px auto;
  padding: 0 10px;
}

.home-grid-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 10px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(145deg, #ffffff, #f1f5f9);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 
    inset 0 2px 2px rgba(255, 255, 255, 1), 
    inset 0 -2px 4px rgba(0, 0, 0, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.08),
    0 4px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 100px;
}

body.dark-mode .category-card {
  background: linear-gradient(145deg, #252A34, #1F232B) !important;
  border-left: 4px solid transparent !important;
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.05),
    0 8px 16px rgba(0, 0, 0, 0.4);
}

/* Category Card Custom Tints (Light Mode) */
.category-card.card-institutions { background: #f4f1ea !important; }
.category-card.card-history { background: #fcf6e3 !important; }
.category-card.card-geography { background: #e6f2f5 !important; }
.category-card.card-culture { background: #f9f0f5 !important; }
.category-card.card-language { background: #f0f5ea !important; }
.category-card.card-listening { background: #f2eff9 !important; }
.category-card.card-speaking { background: #fff4ed !important; }
.category-card.simulation-card { background: #f0f4ff !important; }
.category-card.bottom-card { background: #fff0f2 !important; }

/* Removed old explicit speaking styles */

/* Category Card Custom Accent Lines (Dark Mode) */
body.dark-mode .category-card.card-institutions { border-left-color: #d4af37 !important; }
body.dark-mode .category-card.card-history { border-left-color: #fbbf24 !important; }
body.dark-mode .category-card.card-geography { border-left-color: #38bdf8 !important; }
body.dark-mode .category-card.card-culture { border-left-color: #f472b6 !important; }
body.dark-mode .category-card.card-language { border-left-color: #a3e635 !important; }
body.dark-mode .category-card.card-listening { border-left-color: #a78bfa !important; }
body.dark-mode .category-card.card-speaking { border-left-color: #d97706 !important; }
body.dark-mode .category-card.simulation-card { border-left-color: #6366f1 !important; }
body.dark-mode .category-card.bottom-card { border-left-color: #ef4444 !important; }

.category-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 
    inset 0 2px 2px rgba(255, 255, 255, 1), 
    inset 0 -2px 4px rgba(0, 0, 0, 0.02),
    0 12px 24px rgba(0, 0, 0, 0.12),
    0 6px 12px rgba(0, 0, 0, 0.08);
}

body.dark-mode .category-card:hover {
  background: linear-gradient(145deg, rgba(71, 85, 105, 0.95), rgba(45, 62, 80, 0.95));
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2),
    0 15px 30px rgba(0, 0, 0, 0.4),
    0 6px 12px rgba(0, 0, 0, 0.3);
}

.category-card:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.5), 
    inset 0 4px 8px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .category-card:active {
  box-shadow: 
    inset 0 4px 8px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.05),
    inset 0 2px 4px rgba(255, 255, 255, 1);
  border: 1px solid rgba(255, 255, 255, 0.7);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode .card-icon {
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.category-card:hover .card-icon {
  transform: scale(1.05);
  box-shadow: 
    0 6px 15px rgba(0, 0, 0, 0.1),
    inset 0 2px 4px rgba(255, 255, 255, 1);
}

body.dark-mode .category-card:hover .card-icon {
  box-shadow: 
    0 6px 15px rgba(0, 0, 0, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.15);
}

.card-title {
  color: var(--text-primary, #333);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  text-align: center;
}

.bottom-card {
  min-height: 50px;
  padding: 12px;
}

/* Remove colored backgrounds to keep it clean */
/* Removed hardcoded dark colors */

@media (max-width: 480px) {
  .home-grid {
    gap: 10px;
  }
  .card-icon {
    font-size: 1.6rem;
    width: 46px;
    height: 46px;
    margin-bottom: 6px;
  }
  .card-title {
    font-size: 0.75rem;
  }
  .category-card {
    min-height: 85px;
    padding: 10px 8px;
    border-radius: 14px;
  }
}

/* ========================================================== */
/* X. DESKTOP LEFT SIDEBAR LAYOUT (Web App Mode)              */
/* ========================================================== */
@media (min-width: 769px) {
  body {
    padding-left: 280px; /* Push main content right */
  }

  header#main-header {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 32px 0; /* Push logo down from top edge */
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: none !important;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.98) !important; /* Force white background to override category colors */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
  }

  body.dark-mode header#main-header {
    background: rgba(15, 23, 42, 0.98) !important; /* Force dark background */
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }

  .logo-text {
    color: var(--text-primary) !important; /* Dark text for light mode */
  }

  body.dark-mode .logo-text {
    color: #ffffff !important; /* White text for dark mode */
  }

  .logo-container {
    padding: 0 var(--spacing-lg);
    margin-bottom: 35px;
    width: 100%;
    justify-content: center; /* Center align on larger screens */
    gap: 12px;
    flex-wrap: wrap;
    text-align: center; /* Ensure wrapped text is centered */
  }

  .header-logo-image {
    width: 46px !important;
    height: 46px !important;
  }

  .logo-text {
    font-size: clamp(1rem, 4vw, 1.25rem) !important;
    color: var(--text-primary) !important;
    white-space: normal !important;
    word-wrap: break-word;
    line-height: 1.2;
    text-align: center !important;
  }

  #navbar {
    flex-direction: column !important;
    width: 100%;
    max-width: 100% !important;
    flex: 1 !important; /* Allow navbar to fill remaining height so auto-margins work */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    gap: 0 !important;
    justify-content: flex-start !important;
  }

  .nav-btn {
    width: 100%;
    text-align: left;
    border: none !important;
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
    padding: 16px var(--spacing-lg) !important;
    border-radius: 0 !important;
    background: transparent;
    color: var(--text-primary);
    white-space: normal !important; /* Allow text to wrap if very long */
    display: flex;
    align-items: center;
    gap: 10px;
  }

  body.dark-mode .nav-btn {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
  }

  .nav-btn:hover {
    background: rgba(0, 0, 0, 0.03);
  }

  body.dark-mode .nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  .nav-btn.selected {
    border-left: 4px solid var(--primary-color) !important;
    background: rgba(14, 165, 233, 0.05) !important;
    border-radius: 0 !important;
    color: var(--primary-color) !important;
    box-shadow: none !important;
    padding-left: calc(var(--spacing-lg) - 4px) !important;
  }

  body.dark-mode .nav-btn.selected {
    background: rgba(56, 189, 248, 0.1) !important;
    color: var(--primary-color) !important;
    border-left: 4px solid var(--primary-color) !important;
  }

  body.dark-mode #navbar .nav-btn.selected {
    background: rgba(45, 212, 191, 0.1);
    color: var(--primary-color);
  }

  body.dark-mode .nav-icon-container {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  body.dark-mode #navbar .nav-btn:hover .nav-icon-container,
  body.dark-mode #navbar .nav-btn.selected .nav-icon-container {
    background: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  }
  
  body.dark-mode .quiz-container {
    background-color: var(--card-bg) !important;
  }
}

/* ==========================================================
   READING TEXT ACCORDION (SMART READING)
   ========================================================== */
#reading-text-container.reading-accordion {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  margin-bottom: var(--spacing-lg);
  overflow: hidden;
  max-height: none !important; /* Override legacy limit */
  flex-shrink: 0; /* Prevent the flex parent from shrinking this container! */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode #reading-text-container.reading-accordion {
  background: rgba(15, 23, 42, 0.75) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

#reading-collapsible-content {
  padding: 20px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

#reading-text-container.expanded #reading-collapsible-content {
  max-height: 3000px; /* Allow full expansion */
  opacity: 1;
}

#reading-toggle-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  margin: 12px;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.1);
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  border: 1px solid rgba(14, 165, 233, 0.2);
  transition: all 0.2s ease;
}

body.dark-mode #reading-toggle-header {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

#reading-toggle-header:hover {
  background: rgba(14, 165, 233, 0.15);
}

body.dark-mode #reading-toggle-header:hover {
  background: rgba(56, 189, 248, 0.15);
}

#reading-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--text-primary);
  border-bottom: 2px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 10px;
}

body.dark-mode #reading-title {
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
}

#reading-content {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap; /* Ensures \n line breaks in JS string are rendered correctly */
}

/* ========================================================== */
/* SIDEBAR 3D & GLASSMORPHISM UPDATES (MOBILE)                */
/* ========================================================== */
@media (max-width: 768px) {
  /* 1. Glassmorphism for Mobile Sidebar */
  #navbar {
    background: rgba(253, 251, 247, 0.75) !important; /* Warm Ivory transparent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05) !important;
  }
  
  body.dark-mode #navbar {
    background: rgba(31, 35, 43, 0.75) !important; /* Anthracite transparent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3) !important;
  }

  /* 2. Remove Dividers & Setup 3D Buttons */
  #navbar .nav-btn {
    border-bottom: none !important;
    margin-bottom: 8px !important;
    border-radius: 12px !important; /* Make them look like pill/buttons */
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
  }

  /* 3. 3D Pressed/Selected State (Neumorphic Pop-out) */
  #navbar .nav-btn.selected {
    background: #ffffff !important;
    border-left: none !important;
    box-shadow: 
      -4px -4px 10px rgba(255, 255, 255, 1),
      4px 4px 10px rgba(0, 0, 0, 0.05) !important;
    transform: scale(0.98);
    color: var(--primary-color) !important;
    font-weight: 800 !important;
  }

  body.dark-mode #navbar .nav-btn.selected {
    background: #252A34 !important; /* Match card bg */
    border-left: none !important;
    box-shadow: 
      -2px -2px 6px rgba(255, 255, 255, 0.03),
      4px 4px 10px rgba(0, 0, 0, 0.4) !important;
    color: #f8fafc !important;
  }
  
  /* 4. Staggered Cascade Animation */
  @keyframes slideInLeftCascadeMobile {
    0% { opacity: 0; transform: translateX(-30px); }
    100% { opacity: 1; transform: translateX(0); }
  }
  
  #navbar.open .nav-btn {
    opacity: 0; /* Initially hidden */
    animation: slideInLeftCascadeMobile 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  }
  
  #navbar.open .nav-btn:nth-child(1) { animation-delay: 0.05s; }
  #navbar.open .nav-btn:nth-child(2) { animation-delay: 0.10s; }
  #navbar.open .nav-btn:nth-child(3) { animation-delay: 0.15s; }
  #navbar.open .nav-btn:nth-child(4) { animation-delay: 0.20s; }
  #navbar.open .nav-btn:nth-child(5) { animation-delay: 0.25s; }
  #navbar.open .nav-btn:nth-child(6) { animation-delay: 0.30s; }
  #navbar.open .nav-btn:nth-child(7) { animation-delay: 0.35s; }
  #navbar.open .nav-btn:nth-child(8) { animation-delay: 0.40s; }
  #navbar.open .nav-btn:nth-child(9) { animation-delay: 0.45s; }
  #navbar.open .nav-btn:nth-child(10) { animation-delay: 0.50s; }
  #navbar.open .nav-btn:nth-child(11) { animation-delay: 0.55s; }
  #navbar.open .nav-btn:nth-child(12) { animation-delay: 0.60s; }
}

/* Move navigation controls directly under the quiz container on desktop */
@media (min-width: 769px) {
  #navigation-controls {
    position: static !important;
    background-color: transparent !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 20px auto 40px auto !important;
    max-width: 650px !important;
    border: none !important;
  }
  body.dark-mode #navigation-controls {
    background-color: transparent !important;
    border-top: none !important;
  }
}

/* ========================================================== */
/* Wrong Bank Grid Mode Theme                                 */
/* ========================================================== */

body.wrong-bank-active #main-header {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
}

body.dark-mode.wrong-bank-active #main-header {
  background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%) !important;
}

.category-card.wrong-theme {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #fca5a5;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.15);
}

.category-card.wrong-theme .card-icon {
  background: white;
  color: #ef4444;
}

.category-card.wrong-theme .card-title {
  color: #b91c1c;
}

body.dark-mode .category-card.wrong-theme {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
  border: 1px solid #991b1b;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.dark-mode .category-card.wrong-theme .card-icon {
  background: #2a0404;
  color: #fca5a5;
}

body.dark-mode .category-card.wrong-theme .card-title {
  color: #fecaca;
}
