* {
  box-sizing: border-box;
}

:root {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: dark;
  color: rgba(255, 255, 255, 0.87);
  /* Theme Specifics - Dark Default */
  --app-bg: linear-gradient(135deg, #1a1f35 0%, #0f1419 100%);
  --hero-gradient: linear-gradient(to right, #646cff, #c084fc, #9089fc);
  --card-hover-bg: linear-gradient(145deg, rgba(100, 108, 255, 0.1) 0%, rgba(255, 255, 255, 0.01) 100%);
  --card-hover-border: rgba(100, 108, 255, 0.5);
  --text-primary: rgba(255, 255, 255, 0.87);
  --text: var(--text-primary);
  /* Alias for backward compatibility */
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --daily-card-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(147, 51, 234, 0.05) 100%);

  /* Scrollbar Theme - Dark Default */
  --scrollbar-track: #0f1419;
  --scrollbar-thumb: #334155;
  --scrollbar-thumb-hover: #475569;
  --scrollbar-border: #0f1419;

  /* Progress colors */
  --progress-complete: #10b981;
  --progress-active: #646cff;
  --progress-locked: #6b7280;
  --primary: #646cff;
  --secondary: #535bf2;
  --text-muted: rgba(255, 255, 255, 0.75);
  --surface: #1a1a1a;

  /* Status colors */
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;

  /* Glass effect - Dark mode */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --border-color: rgba(255, 255, 255, 0.1);

  /* Background applied via variable */
  /* Remove background from :root, apply to body */
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}

a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  /* Changed from place-items: center */
  min-width: 320px;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

.app-container {
  width: 100%;
  max-width: 1400px;
  /* Limit max width for large screens */
  margin: 0 auto;
  /* Center horizontally */
  display: flex;
  flex-direction: column;
  flex: 1;
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}

button:hover {
  border-color: #646cff;
}

button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

/* Main Header Default (Dark Mode) */
.main-header {
  border-bottom: 1px solid var(--surface);
  background: transparent;
}

/* New Styles */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

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

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--secondary);
}

/* Light Mode - Cyan/Teal Theme */
/* Using html.light-mode for higher specificity and clarity */
html.light-mode {
  color-scheme: light;

  --app-bg: #ecfeff;
  /* Light Cyan/Teal wrapper */
  --glass-bg: rgba(255, 255, 255, 0.6);
  /* More opaque for contrast */
  --glass-border: rgba(7, 180, 186, 0.2);
  /* Tinted border */
  --glass-shadow: 0 4px 6px -1px rgba(3, 94, 174, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

  --primary: #035EAE;
  /* User Requested Blue */
  --secondary: #024b8f;
  /* Darker Blue */
  --text-muted: #6b7280;
  --surface: #ffffff;

  --success: #035EAE;

  /* Scrollbar Theme - Light Mode */
  --scrollbar-track: #e0f2fe;
  /* Slightly darker than surface for better visibility */
  --scrollbar-thumb: #035EAE;
  --scrollbar-thumb-hover: #024b8f;
  --scrollbar-border: #e0f2fe;

  --hero-gradient: linear-gradient(to right, #035EAE, #3b82f6, #035EAE);
  --card-hover-bg: linear-gradient(145deg, #eff6ff 0%, #ffffff 100%);
  --card-hover-border: #035EAE;
  --text-primary: #155e75;
  /* Dark Cyan/Blue Text for contrast */
  --text: var(--text-primary);
  --text-secondary: #164e63;
  /* Cyan 900 for better contrast */
  --text-tertiary: #0e7490;
  /* Cyan 700 */
  --daily-card-bg: linear-gradient(135deg, #cffafe 0%, #ecfeff 100%);
  --border-color: #e5e7eb;
}

/* Force Light Mode Overrides with high specificity */
html.light-mode body {
  color: #1f2937;
  background: var(--app-bg);
}

/* Light Mode Overrides for Specific Elements */
html.light-mode .glass-card {
  background: white;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

html.light-mode button {
  background-color: white;
  color: #1f2937;
  border: 1px solid #e5e7eb;
}

html.light-mode button:hover {
  background-color: #ecfeff;
  border-color: #035EAE;
}

html.light-mode .btn-primary {
  background-color: #035EAE;
  color: white;
  border: none;
}

html.light-mode .btn-primary:hover {
  background-color: #024b8f;
}

html.light-mode a {
  color: #035EAE;
}

html.light-mode a:hover {
  color: #024b8f;
}

html.light-mode .main-header {
  background: transparent;
  border-bottom: none !important;
  /* User requested removal strictly */
}

html.light-mode .logo {
  color: #035EAE !important;
}

/* Responsive Styles */
.table-cell-responsive {
  padding: 1.5rem;
}

.options-grid {
  display: grid;
  gap: 1.5rem;
}

.option-btn {
  padding: 1.25rem 1.5rem;
  /* Slightly reduced vertical padding for better look */
  font-size: 1.1rem;
  width: 100%;
}

/* Quiz Ready View Styles */
.quiz-ready-view {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.quiz-ready-card {
  padding: 3rem;
  border-radius: 1.5rem;
  text-align: center;
  max-width: 600px;
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  margin: auto;
  /* Safe centering */
  flex-shrink: 0;
  /* Prevent crushing */
}

.quiz-stats-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 3rem;
  background: var(--surface);
  /* Theme aware background */
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  /* Added border for definition */
}

.quiz-action-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quiz-mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

  .app-container {
    padding: 0;
  }

  .learning-view-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
    overflow-y: auto !important;
  }

  .sidebar {
    max-height: 300px;
    margin-bottom: 1rem;
  }

  .content-area {
    height: auto !important;
    min-height: 500px;
  }

  h1 {
    font-size: 2rem;
  }

  .game-header-responsive {
    flex-wrap: wrap;
    justify-content: center !important;
    gap: 1rem !important;
  }

  .game-header-responsive .stat-box {
    min-width: 80px;
  }

  .leaderboard-container-responsive {
    overflow-x: auto !important;
  }

  .mobile-hidden {
    display: none !important;
  }

  .table-cell-responsive {
    padding: 0.5rem !important;
    font-size: 0.9rem;
  }

  .question-card {
    padding: 1rem !important;
    /* Reduced padding from 1.5rem */
  }

  .question-card h3 {
    font-size: 1.2rem !important;
    margin-bottom: 1.5rem !important;
    /* Use important to override inline styles if present */
  }

  .options-grid {
    gap: 0.5rem !important;
  }

  .option-btn {
    padding: 0.75rem 1rem !important;
    font-size: 1rem !important;
    min-height: 3.5rem;
    /* Ensure minimum touch target size */
    display: flex;
    align-items: center;
  }

  /* Quiz Ready View Mobile Overrides */
  .quiz-ready-card {
    padding: 1.5rem;
    /* Reduced from 3rem */
  }

  .quiz-stats-box {
    margin-bottom: 2rem;
    padding: 1rem;
  }

  .quiz-mode-buttons {
    grid-template-columns: 1fr;
    /* Stack buttons on mobile */
  }
}

/* Scrollbar Styling - Applied to all elements */
/* Scrollbar Styling - Forced Dark Theme */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 0;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 7px;
  border: 3px solid var(--scrollbar-border);
}

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

/* Apply to all elements specifically to override defaults */
*::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

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

*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 7px;
  border: 3px solid var(--scrollbar-border);
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

/* Firefox */
* {
  scrollbar-width: auto;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.content-card {
  scrollbar-gutter: stable;
}

/* Materials Dialog/Sidebar */
.materials-dialog {
  background: var(--glass-bg);
}

html.light-mode .materials-dialog {
  background: rgba(255, 255, 255, 0.95);
  /* Increased opacity as requested (90-95%) */
  border: 1px solid rgba(0, 0, 0, 0.1);
  /* Slight border definition for the solid look */
}

/* Question Card & Badges */
.question-card {
  padding: 2.5rem;
  background: var(--surface);
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

html.light-mode .question-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.difficulty-badge,
.category-badge {
  font-size: 0.8rem;
  padding: 0.35rem 1rem;
  border-radius: 2rem;
  text-transform: capitalize;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Default Dark Mode Badge */
.difficulty-badge,
.category-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

/* Light Mode Badge */
html.light-mode .difficulty-badge,
html.light-mode .category-badge {
  background: rgba(3, 94, 174, 0.1);
  color: var(--primary);
  border: 1px solid rgba(3, 94, 174, 0.2);
}

/* Daily Challenge Banner */
.daily-challenge-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  /* Increased from 1.5rem */
  text-align: center;
  font-weight: 600;
}

html.light-mode .daily-challenge-banner {
  background: var(--daily-card-bg);
  color: var(--primary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 4px rgba(3, 94, 174, 0.1);
}

/* Results View Styling */
.results-card {
  background: var(--surface);
  padding: 3rem;
  border-radius: 1rem;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

html.light-mode .results-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--glass-shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0.75rem;
}

html.light-mode .stats-grid {
  background: rgba(3, 94, 174, 0.05) !important;
  border: 1px solid rgba(3, 94, 174, 0.1);
}

.final-score .score-value {
  display: block;
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.final-score .score-label {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.stat-item .label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-item .value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Final Logo Refinement */
.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-icon {
  height: 4.5rem;
  /* Slightly larger to allow the text to be legible at correct proportions */
  object-fit: contain;
  transition: transform 0.2s ease;
}

.logo-container:hover .logo-icon {
  transform: scale(1.05);
}

.logo-text-wrapper {
  display: flex;
  flex-direction: column;
  line-height: 0.85;
  /* Tight spacing like the original */
  font-family: 'Inter', sans-serif;
  padding-top: 0.2rem;
}

.logo-main-text {
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: #228fa6;
  /* Exact color from icon analysis */
}

.logo-sub-text__part {
  /* display: flex;
  align-items: center;
  width: 100%; */
  /* justify-content: space-around; */
}

.logo-sub-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #228fa6;
  margin-top: 0.2rem;
}

.logo-aws-tag {
  color: var(--text);
  font-weight: 900;
  border-bottom: 4px solid #FF9900;
  margin-left: 0.2rem;
  padding-bottom: 0px;
  line-height: 1;
}

html.light-mode .logo-aws-tag {
  color: #1a1f35;
}