.navbar {
  background: #83b1b1;
  border-bottom: 1px solid #000;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Dark mode styles for navbar - BLACK THEME */
body.dark-mode .navbar {
  background: #103149;
  border-bottom: 1px solid #fffbf5;
}

/* Adjust the navbar-container to accommodate the mode selector */
.navbar-container {
  margin: 0 auto;
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.logo-mode-group {
  display: flex;
  align-items: center;
  margin-right: auto; /* Push this group to the left */
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  margin-right: 2rem;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.45rem;
  border-radius: 100%;
  width: 2.5rem;
  height: 2.5rem;
  transition: background 0.2s ease;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark-mode .dark-mode-toggle {
  color: #e0e0e0;
}

.dark-mode-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
}

body.dark-mode .dark-mode-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

.navbar-logo a {
  font-size: 1.25rem;
  font-weight: 500;
  color: #000;
  text-decoration: none;
  transition: color 0.3s ease;
}

/* Add this to position the mode selector correctly */
.navbar-logo {
  display: flex;
  align-items: center;
  height: 100%;
  flex-shrink: 0;
}

.navbar-logo .logo-image {
  display: block;
  height: 4rem;
  padding: 0.4rem;
  padding-left: 4rem;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  transition: all 0.3s ease;
}

/* Icon Navigation Styles - For both desktop and mobile */
.navbar-menu {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-icon {
  text-decoration: none;
  color: #000;
  font-weight: 500;
  font-size: 1.3rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  position: relative;
}

body.dark-mode .nav-icon {
  color: #e0e0e0;
}

.nav-icon:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #111827;
}

body.dark-mode .nav-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Tooltip for desktop icons - hide on mobile */
.nav-icon::after {
  content: attr(data-title);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1001;
  pointer-events: none;
}

body.dark-mode .nav-icon::after {
  background: rgba(255, 255, 255, 0.9);
  color: #000;
}

.nav-icon:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Sign In Button with Icon */
.signin-btn.nav-icon {
  border: 1px solid #000;
  border-radius: 6px;
  width: auto;
  padding: 0.4rem 0.8rem;
  font-size: 1.1rem;
}

body.dark-mode .signin-btn.nav-icon {
  border-color: #e0e0e0;
}

.signin-btn.nav-icon:hover {
  background: rgba(0, 0, 0, 0.08);;
}

body.dark-mode .signin-btn.nav-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* User Avatar */
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #000;
  padding: 2px;
  transition: all 0.2s ease-in-out;
  color: #000;
}

body.dark-mode .user-img {
  border-color: #e0e0e0;
  color: #e0e0e0;
}

.nav-icon:hover .user-img {
  background: #000;
  color: #fff;
}

body.dark-mode .nav-icon:hover .user-img {
  background: #e0e0e0;
  color: #000;
}

/* Remove all mobile menu/dropdown styles */
.mobile-menu-toggle,
.mobile-menu {
  display: none !important;
}

/* Responsive Styles */
@media (max-width: 768px) {
  .navbar-menu {
    display: flex !important; /* Always show icons */
    gap: 0.5rem; /* Reduced gap for mobile */
  }

  .navbar-logo .logo-image {
    height: 2.5rem;
    margin-left: 1rem;
    padding: 0;
    max-width: 150px;
  }

  .dark-mode-toggle{
    padding: 0;
  }

  .navbar-controls {
    margin-right: 0.5rem;
    gap: 0;
  }
  
  .navbar {
    padding: 0.5rem;
    position: static;
    top: auto;
    z-index: auto;
  }

  /* Hide tooltips on mobile for better touch experience */
  .nav-icon::after {
    display: none;
  }

  /* Adjust sign in button for mobile */
  .signin-btn.nav-icon {
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .navbar-menu {
    gap: 0.1rem;
  }

  .navbar-logo .logo-image {
    height: 2rem;
    max-width: 120px;
  }
}

/* Mode Selector Button */
.mode-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.2rem 0.4rem;
  margin-left: 10px;
  background: #eaf8f8;
  border: 2px solid #eaf8f8;
  border-radius: 10px;
  color: #000;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-selector:hover {
  background: #eaf8f8;
}

.mode-selector i {
  transition: transform 0.2s ease;
}

.mode-selector.active i {
  transform: rotate(180deg);
}

body.dark-mode .mode-selector {
  background-color: #2d536f;
  color: #e0e0e0;
}

/* Mode Modal */
.mode-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mode-modal.hidden {
  display: none;
}

/* prevents body to scroll when modal is open */
body:has(.mode-modal:not(.hidden)) {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

.mode-modal-content {
  background: #f6f4ef;
  color: #000;
  border-radius: 15px;
  max-width: 500px;
  width: 100%;
  top: -20%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  position: relative;
}

body.dark-mode .mode-modal-content {
  background: #436f8f;
  border-color: #e0e0e0;
  color: #e0e0e0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}

.mode-modal-content h3 {
  margin: 0;
  text-align: center;
  padding: 0.5rem;
  background-color: #c7dcdc;
  color: #000;
  font-family: 'Kanit', sans-serif;
  font-size: 18px;
  font-weight: 600;
}

body.dark-mode .mode-modal-content h3 {
  color: #e0e0e0;
  background-color: #143751;
}

.mode-options {
  display: flex;
  flex-direction: row;
  justify-content: center;
  padding: 1.5rem;
  gap: 12px;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 0 solid #000;
  border-radius: 8px;
  color: #000;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-option:hover {
  background: rgba(0, 0, 0, 0.05);
}

.mode-option.active {
  background: #83b1b1;
  color: #000;
}

.mode-option i {
  font-size: 18px;
}

body.dark-mode .mode-option {
  color: #e0e0e0;
  border-color: #e0e0e0;
}

body.dark-mode .mode-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .mode-option.active {
  background: #e0e0e0;
  color: #103149;
}

/* Responsive */
@media (max-width: 768px) {
  .mode-modal-content {
    max-height: 70vh;
  }

  .mode-selector {
    margin-left: 10px;
    font-size: 14px;
  }
  
  .navbar-logo .logo-image {
    margin-left: 1rem;
  }
}

.mode-close-btn {
  position: absolute;
  top: 0.25rem;
  right: 16px;
  font-size: 28px;
  font-weight: bold;
  color: #000;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
  z-index: 1;
}

.mode-close-btn:hover {
  color: #666;
}

body.dark-mode .mode-close-btn {
  color: #e0e0e0;
}

body.dark-mode .mode-close-btn:hover {
  color: #ffffff;
}

/* New Game Plus Button for Unlimited Mode */
.new-game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0.1rem 0.1rem;
  background: #eaf8f8;
  border: 2px solid #eaf8f8;
  border-radius: 50%;
  color: #000;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 2rem;
  height: 2rem;
  position: relative;
}

.new-game-btn:hover {
  background: #eaf8f8;
}

body.dark-mode .new-game-btn {
  background-color: #2d536f;
  color: #e0e0e0;
}

/* Tooltip for plus button */
.new-game-btn::after {
  content: attr(data-title);
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1001;
  pointer-events: none;
}

body.dark-mode .new-game-btn::after {
  background: rgba(255, 255, 255, 0.9);
  color: #000;
}

.new-game-btn:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .new-game-btn {
    margin-left: 6px;
    padding: 0.15rem 0.4rem;
    font-size: 14px;
    width: 1.7rem;
    height: 1.7rem;
  }
  
  /* Hide tooltip on mobile */
  .new-game-btn::after {
    display: none;
  }

  #open-how-to-play-nav{
    display: none;
  }
}