:root {
  --font-primary: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Light theme */
  --bg-primary-light: #ffffff;
  --bg-secondary-light: #f5f7fa;
  --text-primary-light: #121826;
  --text-secondary-light: #4b5563;
  --accent-light: #3b82f6;
  --border-light: #e5e7eb;
  --card-shadow-light: 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Dark theme */
  --bg-primary-dark: #121826;
  --bg-secondary-dark: #1f2937;
  --text-primary-dark: #f3f4f6;
  --text-secondary-dark: #9ca3af;
  --accent-dark: #60a5fa;
  --border-dark: #374151;
  --card-shadow-dark: 0 4px 6px rgba(0, 0, 0, 0.2);

  /* Platform colors */
  --leetcode: #00af9b;
  --codechef: #745d46;
  --gfg: #2f8d46;
  --codeforces: #318ce7;

  /* Applied theme (default light) */
  --bg-primary: var(--bg-primary-light);
  --bg-secondary: var(--bg-secondary-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --accent: var(--accent-light);
  --border: var(--border-light);
  --card-shadow: var(--card-shadow-light);

  /* Spacing */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
}

/* Dark theme class */
.dark-theme {
  --bg-primary: var(--bg-primary-dark);
  --bg-secondary: var(--bg-secondary-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --accent: var(--accent-dark);
  --border: var(--border-dark);
  --card-shadow: var(--card-shadow-dark);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Suppress ALL transitions during initial theme load to prevent FOUC */
.no-transition *,
.no-transition *::before,
.no-transition *::after {
  transition: none !important;
  animation: none !important;
}

.dark body {
  background-color: #020617;
  color: #f8fafc;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-2);
}

header {
  background-color: var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h2,
header a,
header span {
  margin-bottom: 0 !important;
  line-height: 1.25 !important;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--leetcode), var(--codeforces));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-3);
  font-weight: 700;
  color: var(--text-primary);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--text-primary);
}

p {
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
}

main {
  padding: var(--space-4) 0;
}

section {
  margin-bottom: var(--space-5);
}

.theme-toggle {
  display: flex;
  align-items: center;
}

#theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  border-radius: 50%;
  transition: background-color 0.3s;
}

#theme-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.dark-theme #theme-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.light-icon,
.dark-icon {
  transition: opacity 0.3s, transform 0.3s;
}

.light-theme .light-icon {
  display: none;
}

.light-theme .dark-icon {
  display: block;
}

.dark-theme .light-icon {
  display: block;
}

.dark-theme .dark-icon {
  display: none;
}

.loading {
  text-align: center;
  padding: var(--space-3);
  color: var(--text-secondary);
  font-style: italic;
}

footer {
  background-color: var(--bg-secondary);
  padding: var(--space-3) 0;
  margin-top: var(--space-4);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Responsive design */
@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  .container {
    padding: 0 var(--space-2);
  }

  main {
    padding: var(--space-3) 0;
  }

  section {
    margin-bottom: var(--space-4);
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.25rem;
  }

  .container {
    padding: 0 var(--space-1);
  }
}

/* Ensure Hero Sections always have white text regardless of theme,
   but exclude buttons/links which need dark text on white backgrounds.
   Only target text color properties to avoid stripping background gradients. */
#next-contest,
#next-event,
#next-contest *:not(a):not(button):not(a *):not(button *),
#next-event *:not(a):not(button):not(a *):not(button *) {
  color: white !important;
  -webkit-text-fill-color: white !important;
}

#next-contest p,
#next-event p {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Explicitly force Register Now button text to black */
#next-contest a,
#next-event a,
.event-url {
  color: black !important;
  -webkit-text-fill-color: black !important;
}

#next-contest .status-badge,
#next-event .status-badge {
  color: white !important;
}

/* Refined Navbar Lamp Glow */
.glass-nav {
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 0.75rem 0.5rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: space-around;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.dark .mobile-bottom-nav {
  background: rgba(2, 6, 23, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: #64748b;
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  transition: color 0.2s;
}

.dark .mobile-nav-item {
  color: #94a3b8;
}

.mobile-nav-item.active {
  color: var(--accent);
}

.mobile-nav-item .material-symbols-outlined {
  font-size: 1.5rem;
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none;
  }
}

/* Hide body scrollbar in some conditions or adjust padding */
body {
  padding-bottom: 4rem;
  /* Buffer for mobile nav */
}

@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
  }
}