:root {
  /* Base colors for light mode */
  --bg1: #f8f9fc;
  --bg2: #e1ecf4;
  --text: #222;
  --muted-text: #555;
  --highlight: #ff6b6b;
  --card-bg: linear-gradient(145deg, #ffffff, #f2f2f2);
  --sub-bg: linear-gradient(145deg, #f5f5f5, #ebf1f5);
  --item-bg: rgba(255, 255, 255, 0.75);
  --item-hover: rgba(255, 255, 255, 0.9);
  --particle-color: rgba(0, 0, 0, 0.15);
}

body.night-mode {
  /* Dark‑mode overrides */
  --bg1: #0e1014;
  --bg2: #1a1d23;
  --text: #eee;
  --muted-text: #ccc;
  --highlight: #8ab4f8;
  --card-bg: rgba(30, 34, 44, 0.7);
  --sub-bg: rgba(30, 34, 44, 0.5);
  --item-bg: rgba(40, 44, 54, 0.6);
  --item-hover: rgba(60, 60, 70, 0.8);
  --particle-color: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', sans-serif;
}

body {
  background: linear-gradient(120deg, var(--bg1), var(--bg2));
  background-size: 200% 200%;
  animation: bgShift 18s ease-in-out infinite alternate;
  color: var(--text);
  padding: 20px;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.5s, color 0.5s;
  /* Enable GPU acceleration */
  transform: translateZ(0);
  will-change: background;
}

@keyframes bgShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* Toggle button */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--highlight);
  color: #fff;
  border: none;
  font-size: 22px;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  transition: background 0.3s;
  z-index: 100;
  /* GPU acceleration */
  will-change: transform, background;
}

.theme-toggle:hover {
  background: #e85a5a;
  transform: translateZ(0);
}

/* Translation Toggle (globe) */
.translation-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--highlight);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  transition: background 0.3s, transform 0.2s;
  z-index: 100;
  /* GPU acceleration */
  will-change: transform, background;
}

.translation-toggle:hover {
  background: #e85a5a;
  transform: scale(1.1) translateZ(0);
}

.translation-toggle:active {
  transform: scale(0.95) translateZ(0);
}

/* Particles behind - optimized for performance */
.bg-particles {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  /* GPU acceleration */
  will-change: auto;
  transform: translateZ(0);
}

/* Header */
.restaurant-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  margin-bottom: 30px;
}

.restaurant-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.restaurant-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--highlight);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  background: #fff;
  /* GPU acceleration */
  transform: translateZ(0);
  will-change: transform;
}

.restaurant-name {
  font-size: 30px;
  color: var(--highlight);
}

.restaurant-details {
  font-size: 14px;
  color: var(--muted-text);
}

/* Search */
#searchInput {
  padding: 12px 16px;
  width: 100%;
  max-width: 450px;
  border-radius: 10px;
  border: 2px solid var(--highlight);
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
}

#searchInput:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2);
}

/* Menu area */
.menu-container {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 5%;
  /* Optimized rendering */
  contain: layout style;
}

/* Loading indicator */
.loading-indicator {
  text-align: center;
  padding: 20px;
  font-size: 18px;
  color: var(--muted-text);
}

/* Category - optimized for performance */
.category {
  background: var(--card-bg);
  border-left: 6px solid var(--highlight);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  /* GPU acceleration */
  transform: translateZ(0);
  will-change: transform;
  /* Performance optimization */
  contain: layout style;
}

.category:hover {
  transform: translateY(-3px) scale(1.01) translateZ(0);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.15);
}

.category h2 {
  font-size: 24px;
  margin-bottom: 12px;
  cursor: pointer;
  padding-right: 24px;
  user-select: none;
}

.category h2::after {
  content: '▼';
  position: absolute;
  top: 22px;
  right: 22px;
  transition: transform 0.3s ease;
  will-change: transform;
}

.category.collapsed h2::after {
  transform: rotate(-90deg) translateZ(0);
}

/* Subcategory - optimized */
.subcategory {
  background: var(--sub-bg);
  border-left: 4px solid var(--highlight);
  border-radius: 12px;
  padding: 18px;
  margin-top: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  transition: max-height 0.4s ease, opacity 0.4s ease, transform 0.3s ease;
  max-height: 9999px;
  opacity: 1;
  transform: translateZ(0);
  /* Performance optimization */
  contain: layout style;
}

.subcategory h3 {
  font-size: 18px;
  margin-bottom: 10px;
  cursor: pointer;
  padding-right: 20px;
  user-select: none;
}

.subcategory h3::after {
  content: '▼';
  position: absolute;
  top: 18px;
  right: 18px;
  transition: transform 0.3s ease;
  will-change: transform;
}

.subcategory.collapsed h3::after {
  transform: rotate(-90deg) translateZ(0);
}

/* When collapsed - optimized transitions */
.category.collapsed .subcategory,
.subcategory.collapsed .item {
  max-height: 0;
  opacity: 0;
  transform: scaleY(0) translateZ(0);
  margin: 0;
  pointer-events: none;
  transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

/* Items - heavily optimized */
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--item-bg);
  border-radius: 12px;
  padding: 12px;
  backdrop-filter: blur(10px);
  margin-bottom: 10px;
  transition: transform 0.2s ease, background 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  /* GPU acceleration and performance */
  transform: translateZ(0);
  will-change: transform;
  contain: layout style paint;
}

.item:hover {
  transform: scale(1.02) translateZ(0);
  background: var(--item-hover);
}

.item img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  /* Optimize image rendering */
  image-rendering: optimizeSpeed;
  transform: translateZ(0);
}

.item-details strong {
  font-size: 16px;
  color: var(--text);
}

.item-details p {
  font-size: 13px;
  color: var(--muted-text);
  margin: 2px 0;
}

.item-price {
  font-weight: 600;
  color: var(--highlight);
}

/* Hidden items for search optimization */
.item.hidden {
  display: none;
}

.subcategory.hidden {
  display: none;
}

.category.hidden {
  display: none;
}

.restaurant-map a {
  color: black;
  text-decoration: underline;
  transition: color 0.3s;
}

.restaurant-map a:hover {
  color: var(--highlight);
  text-decoration: underline;
}

.site-footer {
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.site-footer a {
  color: var(--highlight);
  text-decoration: underline;
}

body.night-mode .restaurant-map a {
  color: white;
}

body.night-mode .restaurant-map a:hover {
  color: var(--highlight);
  text-decoration: underline;
}

/* Media queries for better mobile performance */
@media (max-width: 768px) {
  .category {
    padding: 16px;
  }
  
  .subcategory {
    padding: 14px;
  }
  
  .item {
    padding: 10px;
  }
  
  .item img {
    width: 50px;
    height: 50px;
  }
}

/* Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .bg-particles {
    display: none;
  }
}