@font-face {
  font-family: 'Quicksilver';
  src: url('/fonts/Quicksilver.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Quicksilver';
  src: url('/fonts/Quicksilver Italic.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Kdam Thmor';
  src: url('/fonts/KdamThmorPro.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Nunito';
  src: url('/fonts/Nunito-VariableFont_wght.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Nunito';
  src: url('/fonts/Nunito-VariableFont_wght.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Nunito', Tahoma, Geneva, Verdana, serif;
  color: #ffffff;
  background: rgb(50, 50, 50);
  overflow: hidden;
}

#menu {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

#menu .title {
  font-family: 'Nunito';
  font-size: 10rem;
  font-weight: bolder;
  margin-bottom: 1rem;
  color: #ffffff;
  letter-spacing: 5px;
  text-shadow:
    -2px -2px 0 #000000,
    2px -2px 0 #000000,
    -2px 2px 0 #000000,
    2px 2px 0 #000000,
    -3px 0px 0 #000000,
    3px 0px 0 #000000,
    0px -3px 0 #000000,
    0px 3px 0 #000000;
}

.room-name-display {
  background: #ff5f5f;
  color: #fafafa;
  text-align: center;
  margin-bottom: 1rem;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 20px;
  padding-right: 20px;
  line-height: 200%;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Nunito', serif;';
}

.room-name-display-room {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: 'Nunito', serif;';
}

.car-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0;
  width: 100%;
}

.single-car-card {
  background: #ffffff;
  color: #ff5f5f;
  padding: 2rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-width: 350px;
}

.car-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.car-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
}

.car-name {
  font-size: 1.5rem;
  color: #ff5f5f;
  font-family: 'Nunito', serif;
  font-weight: bold;
}

.car-ability {
  font-size: 0.9rem;
  color: #818181;
  font-family: 'Nunito', serif;
  font-weight: normal;
  margin-left: 1px;
}

.car-visual {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #ffffff;
}

.car-shape {
  transform-origin: center;
  position: relative;
  animation: rotate 8s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.car-visual svg {
  shape-rendering: geometricPrecision;
}

.car-visual polygon {
  shape-rendering: geometricPrecision;
}

.car-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-size: 1rem;
  color: #ff4757;
  font-weight: bold;
  margin-bottom: 0.3rem;
  font-family: "Nunito", serif;
}

.stat-bar {
  width: 100%;
  height: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.stat-fill.health { background: #ff4757; }
.stat-fill.speed { background: #3742fa; }
.stat-fill.regen { background: #2ed573; }

.stat-value {
  font-size: 0.9rem;
  color: #333;
  font-weight: 600;
}

/* Name input on the start screen */
#nameInput {
  padding: 0.8rem;
  margin: 1.5rem 0;
  border: 3px solid #ff5f5f;
  border-radius: 4px;
  width: 350px;
  font-size: 1.5rem;
  font-weight: bolder;
  font-family: 'Nunito', serif;
  background: #ffffff;
  color: #333;
  transition: all 0.3s ease;
  box-sizing: border-box;
  text-align: center;
}

#nameInput:focus {
  outline: none;
  border-color: #8a4fd3;
  transform: translateY(-2px);
}

#carSelection label {
  display: flex;
  align-items: center;
  margin: 0.5rem 0;
  cursor: pointer;
}

.carLabel {
  margin-left: 0.5rem;
}

.nav-button {
  padding: 0.5rem 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  border: none;
  background: #ff5f5f;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 80px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-button:hover {
  transform: translateY(-2px);
  background: #993939;
}

/* Spectator Canvas - Background Layer */
.spectator-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.7;
  display: block !important;
}

/* Game Canvas - Active Game Layer */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 2;
}

#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#stats span {
  margin-right: 1rem;
}

#upgrades {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

#upgrades button {
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: 2px;
  background-color: rgba(30, 30, 30, 0.8);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.8rem;
}

#upgrades button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* ABILITY HUD STYLES */
.ability-hud {
  position: fixed;
  bottom: 190px;
  right: 20px;
  background: rgba(20, 20, 20, 0.9);
  padding: 14px 12px;
  z-index: 50;
  width: 148px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.ability-progress-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ff5f5f;
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.1s ease-out;
}

.ability-progress-bg.on-cooldown {
  background: #993939;
}

.ability-name {
  position: relative;
  z-index: 1;
  color: #ffffff;
  font-size: 1em;
  font-weight: 600;
  font-family: 'Nunito', serif;
  text-align: center;
  display: block;
}

.ability-hint {
  position: relative;
  z-index: 1;
  color: #ffffff;
  font-size: 0.8em;
}

.hidden {
  display: none !important;
  pointer-events: none !important;
}

/* Kill Feed */
.kill-feed {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 99; /* Lower than performance overlay */
  max-width: 320px;
  max-height: 300px;
  overflow: hidden;
  pointer-events: none;
  transition: top 0.3s ease-out;
}

.kill-feed-message {
  background: rgba(20, 20, 20, 0.95);
  padding: 8px 12px;
  margin-bottom: 6px;
  font-family: 'Tahoma', serif;
  font-size: 0.85em;
  font-weight: bold;
  border-left: 3px solid;
  animation: killFeedSlideIn 0.3s ease-out forwards;
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.3s ease-out;
}

.kill-feed-message.fade-out {
  opacity: 0;
  transform: translateX(-20px);
}

.kill-feed-message.crash {
  border-left-color: #ef4444;
  color: #fecaca;
}

.kill-feed-message.win {
  border-left-color: #fbbf24;
  color: #fef3c7;
}

.kill-feed-message.info {
  border-left-color: #3b82f6;
  color: #dbeafe;
}

@keyframes killFeedSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Lap Counter */
.lap-counter {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: rgba(20, 20, 20, 0.9);
  padding: 10px 16px;
  font-family: 'Nunito', monospace;
  backdrop-filter: blur(10px);
  z-index: 50;
  min-width: 140px;
}

.lap-counter span {
  color: #ff5f5f;
  font-size: 0.9em;
  font-weight: 600;
  text-align: center;
  display: block;
}

#message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  padding: 1rem 2rem;
  border-radius: 8px;
  z-index: 9;
  font-size: 1.5rem;
  text-align: center;
}

.note {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 1rem;
}

/* Overlay base styles */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-family: 'Nunito', serif;
  color: white;
}

/* Loading Screen Styles */
.loading-overlay {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  z-index: 1000;
}

.loading-content {
  text-align: center;
}

.game-title {
  font-size: 2em;
  margin-bottom: 20px;
  font-weight: bold;
  font-family: 'Nunito', serif;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top: 4px solid #ff5f5f;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.2em;
  margin-bottom: 10px;
}

.loading-subtext {
  font-size: 0.9em;
  color: #aaa;
}

/* Disconnection Overlay Styles */
.disconnect-overlay {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 2000;
  font-family: 'Nunito', serif;

}

.disconnect-content {
  text-align: center;
  background: #ff5f5f;
  padding: 40px;
  font-family: 'Nunito', serif;
  max-width: 500px; /* Limit width for better readability */
  width: 90%; /* Responsive width */
}

.disconnect-title {
  font-size: 1.8em;
  margin-bottom: 20px;
  color: white;
  font-family: 'Nunito', serif;
}

.disconnect-message {
  font-size: 1.2em;
  margin-bottom: 15px;
  color: white;
}

.disconnect-details {
  font-size: 0.9em;
  color: white;
  margin-bottom: 25px;
  line-height: 1.4;
}

.disconnect-refresh-btn {
  background: #ff4444;
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  font-family: 'Nunito', serif;
}

.disconnect-refresh-btn:hover {
  background-color: #993939;
}

/* Menu Disconnection Warning Styles */
.menu-warning {
  background: #ffffff;
  border: 2px solid #ff5f5f;
  border-radius: 10px;
  padding: 30px;
  text-align: center;
  color: white;
  font-family: 'Nunito', serif;
  margin: 20px 0;
  max-width: 350px;
}

.warning-title {
  font-size: 1.5em;
  margin-bottom: 15px;
  color: #ff5f5f;
  font-family: 'Nunito', serif;
}

.warning-message {
  font-size: 1em;
  margin-bottom: 15px;
  color: #000000;
}

.warning-details {
  font-size: 0.9em;
  color: #000000;
  margin-bottom: 20px;
  line-height: 1.4;
}

.menu-refresh-btn {
  background: #ff5f5f;
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 1em;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-family: 'Nunito', serif;
}

.menu-refresh-btn:hover {
  background-color: #000000;
}

/* Modern Upgrade Cards */
.upgrade-cards-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 20px;
  z-index: 100;
  transition: all 0.3s ease;
}

/* Upgrade Points Counter beside cards */
.upgrade-points-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-right: 10px;
  margin-bottom: 8px;
}

.upgrade-points-label {
  font-size: 12px;
  font-weight: bold;
  color: #ff5f5f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.upgrade-points-count {
  font-size: 24px;
  font-weight: bold;
  color: #ffffff;
  background: rgba(20, 20, 20, 0.7);
  border-top: 4px solid #ff5f5f;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upgrade-card-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upgrade-cards-container.hidden {
  bottom: -120px;
  opacity: 0;
}

.upgrade-cards-container.compact {
  bottom: -20px;
  transform: translateX(-50%) scale(0.7);
}

.upgrade-cards-container.compact .upgrade-card {
  height: 50px;
  transform: translateY(15px);
}

.upgrade-cards-container.compact .upgrade-progress-blocks {
  margin-bottom: 1px;
}

.upgrade-cards-container.compact .upgrade-progress-block {
  height: 10px;
  width: 12px;
}

.upgrade-cards-container.compact .upgrade-points-display {
  transform: scale(0.7);
  margin-bottom: 0;
}

.upgrade-card {
  position: relative;
  width: 80px;
  height: 80px;
  background: rgba(20, 20, 20, 0.7);
  border-top: 4px solid #ff5f5f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upgrade-card:hover {
  transform: translateY(-5px) scale(1.05);
  background: rgba(30, 30, 30, 0.98);
}

.upgrade-card:active {
  transform: translateY(-3px) scale(1.02);
}

.upgrade-key-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: #ff5f5f;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  font-weight: bold;
  font-family: 'Nunito', serif;
}

.upgrade-name {
  font-size: 1em;
  color: #ffffff;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1px;
  font-family: 'Nunito', serif;
}

/* Animation for cards appearing */
@keyframes upgradeCardSlideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.upgrade-cards-container:not(.hidden) .upgrade-card {
  animation: upgradeCardSlideUp 0.4s ease forwards;
}

.upgrade-cards-container:not(.hidden) .upgrade-card:nth-child(1) {
  animation-delay: 0.1s;
}

.upgrade-cards-container:not(.hidden) .upgrade-card:nth-child(2) {
  animation-delay: 0.15s;
}

.upgrade-cards-container:not(.hidden) .upgrade-card:nth-child(3) {
  animation-delay: 0.2s;
}

/* Maxed upgrade cards */
.upgrade-card.maxed {
  border-color: #666;
  background: rgba(60, 60, 60, 0.95);
  cursor: not-allowed;
  animation: none !important;
}

.upgrade-card.maxed:hover {
  transform: none;
  border-color: #666;
  background: rgba(60, 60, 60, 0.95);
}

.upgrade-card.maxed .upgrade-key-indicator {
  background: #666;
}

.upgrade-card.maxed .upgrade-name {
  color: #999;
}

/* Upgrade Progress Blocks */
.upgrade-progress-blocks {
  display: flex;
  gap: 4px;
  margin-bottom: 2px;
}

.upgrade-progress-block {
  width: 14px;
  height: 10px;
  border-radius: 1px;
  opacity: 0.3;
  transition: all 0.3s ease;
}

.upgrade-progress-block.filled {
  opacity: 1;
}

/* LAP TIMER STYLES */
.lap-timer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(20, 20, 20, 0.9);
  padding: 12px 16px;
  font-family: 'Nunito', monospace;
  backdrop-filter: blur(10px);
  z-index: 50;
  min-width: 140px;
}

.lap-timer-current,
.lap-timer-best {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0;
}

.lap-timer-label {
  color: #ff5f5f;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lap-timer-time {
  color: #ffffff;
  font-size: 0.85em;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-align: right;
}

.lap-timer-best .lap-timer-time {
  color: #993939;
}

/* BOOST DISPLAY STYLES */
.boost-display {
  position: fixed;
  bottom: 120px;
  right: 20px;
  background: rgba(20, 20, 20, 0.9);
  padding: 10px 16px;
  font-family: 'Nunito', monospace;
  backdrop-filter: blur(10px);
  z-index: 50;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.boost-label {
  color: #ff5f5f;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.boost-bar-container {
  width: 120px;
  height: 8px;
  background: rgba(50, 50, 50, 0.8);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 165, 2, 0.3);
}

.boost-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b 0%, #ffa502 50%, #2ed573 100%);
  border-radius: 3px;
  transition: width 0.2s ease;
  width: 100%;
}

.boost-bar.low {
  background: linear-gradient(90deg, #ff6b6b 0%, #ff7675 100%);
}

.boost-bar.medium {
  background: linear-gradient(90deg, #ff7675 0%, #ffa502 100%);
}

.boost-bar.high {
  background: linear-gradient(90deg, #ffa502 0%, #2ed573 100%);
}

.boost-text {
  color: #ffffff;
  font-size: 1.2em;
  font-weight: bold;
  font-family: 'Nunito', monospace;
  text-align: center;
}

/* DEBUG PANEL STYLES */
.debug-panel {
  position: fixed;
  top: 65px;
  right: 10px;
  width: 360px;
  background: rgba(20, 20, 20, 0.95);
  border: 2px solid #ff5f5f;
  border-radius: 8px;
  font-family: ''Nunito'', serif;
  font-size: 0.85em;
  backdrop-filter: blur(10px);
  z-index: 1000;
  transition: all 0.3s ease;
}

.debug-panel.hidden {
  transform: translateX(100%);
  opacity: 0;
}

.debug-header {
  background: rgba(68, 60, 226, 0.3);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ff5f5f;
}

.debug-title {
  color: #ff5f5f;
  font-weight: bold;
  font-size: 0.9em;
}

.debug-toggle {
  background: none;
  border: none;
  color: #ff5f5f;
  font-size: 1.2em;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 2px;
}

.debug-toggle:hover {
  background: rgba(4, 0, 79, 0.3);
}

.debug-content {
  max-height: 80vh;
  overflow-y: auto;
  padding: 12px;
  transition: all 0.3s ease;
}

.debug-content.collapsed {
  max-height: 0;
  padding: 0 12px;
  overflow: hidden;
}

.debug-section {
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(68, 60, 226, 0.5);
  padding-bottom: 12px;
}

.debug-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.debug-section h4 {
  color: #ff5f5f;
  margin: 0 0 8px 0;
  font-size: 0.9em;
  font-weight: bold;
}

.debug-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.debug-row:last-child {
  margin-bottom: 0;
}

.debug-row label {
  color: #cccccc;
  font-size: 0.8em;
  min-width: 80px;
  flex-shrink: 0;
}

.debug-btn {
  background: rgba(45, 106, 250, 0.8);
  border: none;
  border-radius: 4px;
  color: white;
  padding: 4px 8px;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.debug-btn:hover {
  background: rgba(45, 106, 250, 1);
  transform: translateY(-1px);
}

.debug-btn:active {
  transform: translateY(0);
}

.debug-btn.full-width {
  width: 100%;
  margin-top: 4px;
}

.debug-btn.danger {
  background: rgba(220, 38, 38, 0.8);
}

.debug-btn.danger:hover {
  background: rgba(220, 38, 38, 1);
}

.debug-btn[data-active="true"] {
  background: rgba(34, 197, 94, 0.8);
}

.debug-btn[data-active="true"]:hover {
  background: rgba(34, 197, 94, 1);
}

.debug-slider {
  flex: 1;
  margin: 0 4px;
  accent-color: #ff5f5f;
}

.debug-row span {
  color: #ffffff;
  font-size: 0.8em;
  min-width: 40px;
  text-align: right;
  font-family: monospace;
}

input[type="number"] {
  background: rgba(60, 60, 60, 0.8);
  border: 1px solid #666;
  border-radius: 3px;
  color: white;
  padding: 2px 4px;
  font-size: 0.8em;
  width: 60px;
}

input[type="number"]:focus {
  outline: none;
  border-color: #ff5f5f;
}

.debug-data {
  background: rgba(60, 60, 60, 0.5);
  border-radius: 4px;
  padding: 8px;
  font-size: 0.75em;
  color: #cccccc;
  max-height: 150px;
  overflow-y: auto;
}

.debug-player {
  margin-bottom: 8px;
  padding: 4px;
  background: rgba(80, 80, 80, 0.5);
  border-radius: 3px;
}

.debug-player:last-child {
  margin-bottom: 0;
}

/* Custom scrollbar for debug panel */
.debug-content::-webkit-scrollbar,
.debug-data::-webkit-scrollbar {
  width: 6px;
}

.debug-content::-webkit-scrollbar-track,
.debug-data::-webkit-scrollbar-track {
  background: rgba(60, 60, 60, 0.3);
  border-radius: 3px;
}

.debug-content::-webkit-scrollbar-thumb,
.debug-data::-webkit-scrollbar-thumb {
  background: rgba(60, 82, 229, 0.6);
  border-radius: 3px;
}

.debug-content::-webkit-scrollbar-thumb:hover,
.debug-data::-webkit-scrollbar-thumb:hover {
  background: rgba(60, 82, 229, 0.8);
}

/* SETTINGS SYSTEM STYLES */

/* Settings Button */
.settings-button {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  background: #ff5f5f(255, 255, 255, 0.9);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 15;
}

.settings-button:hover {
  transform: translateY(-2px) rotate(45deg);
  background: #993939;
  color: #ffffff;
}

/* Settings Modal */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.settings-modal:not(.hidden) {
  opacity: 1;
}

.settings-content {
  background: #ffffff;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.settings-modal:not(.hidden) .settings-content {
  transform: scale(1);
}

.settings-header {
  background: #ff5f5f;
  color: white;
  padding: 20px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-title {
  margin: 0;
  font-size: 2rem;
  font-family: 'Nunito', serif;
}

.settings-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.settings-body {
  padding: 25px;
  max-height: 60vh;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 25px;
  border-bottom: 2px solid #ff5f5f;
  padding-bottom: 20px;
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section-title {
  margin: 0 0 15px 0;
  font-size: 1.2rem;
  color: #ff5f5f;
  font-family: 'Nunito', serif;
  font-weight: 600;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.settings-row:last-child {
  margin-bottom: 0;
}

.settings-label {
  color: #555;
  font-size: 1rem;
  font-weight: 500;
  font-family: 'Nunito', serif;
}

.settings-placeholder {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
  text-align: center;
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 25px;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 25px;
  transition: all 0.3s ease;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 19px;
  width: 19px;
  left: 3px;
  top: 3px;
  background-color: white;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-input:checked + .toggle-slider {
  background-color: #ff5f5f;
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(25px);
}

/* Performance Overlay Styles */
.performance-overlay {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  transition: top 0.3s ease-out;
}

.performance-overlay.below-toolbar {
  top: 80px;
}

.fps-display,
.ping-display {
  background: rgba(20, 20, 20, 0.6);
  color: #ffffff;
  padding: 6px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  font-weight: bolder;
  text-align: center;
  min-width: 80px;
}

.fps-display {
  border-top: 2px solid #ff5f5f;
}

.ping-display {
  border-top: 2px solid #ff5f5f;
}

/* Custom scrollbar for settings modal */
.settings-body::-webkit-scrollbar {
  width: 6px;
}

.settings-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.settings-body::-webkit-scrollbar-thumb {
  background: rgba(183, 130, 240, 0.6);
  border-radius: 3px;
}

.settings-body::-webkit-scrollbar-thumb:hover {
  background: rgba(183, 130, 240, 0.8);
}

/* Room Browser Styles */
.room-browser-button {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Nunito', serif;
  cursor: pointer;
  margin-top: 1rem;
  transition: all 0.3s ease;
}

.room-browser-button:hover {
  background: #b6b6b6;
  transform: translateY(-2px);
}

.room-browser-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
 
.room-browser-content {
  background: #2f2f2f;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
}

.room-browser-header {
  background: #ff5f5f;
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-browser-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.room-browser-close-btn {
  background: white;
  border: none;
  color: #ff5f5f;
  font-size: 2rem;
  cursor: pointer;
  padding-bottom: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.room-browser-close-btn:hover {
  background: #ff5f5f;
  color: white;
}

.room-browser-body {
  padding: 20px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

.room-browser-section {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ffffff;
}

.room-browser-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.section-title {
  color: #ff5f5f;
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.refresh-button {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.refresh-button:hover {
  background: #993939;
  transform: translateY(-2px);
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

.room-card {
  background: #ff5f5f;
  border: none;
  padding: 15px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-card:hover {
  background: #993939;
  transform: translateY(-2px);
}

.room-card-content {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.room-preview-container {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  position: relative;
}

.room-map-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.room-map-placeholder {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.7rem;
  text-align: center;
}

.room-details {
  flex: 1;
  min-width: 0;
}

.room-name {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-info {
  color: #ffffff;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.room-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}

.room-players-list {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.75rem;
  line-height: 1.3;
}

.no-players {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  font-style: italic;
}

.room-join-button {
  width: 100%;
  padding: 10px;
  background: #ffffff;
  color: #ff5f5f;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.room-join-button:hover:not(:disabled) {
  background: #cccccc;
  transform: translateY(-1px);
}

.room-join-button:disabled {
  background: #666;
  cursor: not-allowed;
  opacity: 0.6;
}

.room-private-badge {
  background: #ef4444;
  color: white;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.room-full-badge {
  background: #f59e0b;
  color: white;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.loading-message, .error-message, .no-rooms-message {
  text-align: center;
  color: #cccccc;
  padding: 40px;
  font-size: 1.1rem;
}

.error-message {
  color: #ef4444;
}

.create-room-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
}

/* .form-input, .form-select {
  padding: 12px;
  background: #ffffff; 
  color: #3a3a3a;
  font-size: 1.2rem;
  font-family: 'Nunito', serif;
  font-weight: bold;
  text-align: center;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: #ff5f5f;
} */

.form-slider {
  width: 100%;
  height: 6px;
  background: #3a3a3a;
  outline: none;
  -webkit-appearance: none;
}

.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #ff5f5f;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.form-slider::-webkit-slider-thumb:hover {
  background: #993939;
  transform: scale(1.1);
}

.form-slider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-slider.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-slider:disabled::-webkit-slider-thumb,
.form-slider.disabled::-webkit-slider-thumb {
  cursor: not-allowed;
  background: #666666;
}

.form-slider:disabled::-webkit-slider-thumb:hover,
.form-slider.disabled::-webkit-slider-thumb:hover {
  background: #666666;
  transform: none;
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.form-checkbox {
  width: 20px;
  height: 20px;
  appearance: none;
  background: #3a3a3a;
  border: #993939;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
}

.form-checkbox:checked {
  background: #ff5f5f;
}

.form-checkbox:checked::after {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.form-checkbox-text {
  color: #ffffff;
  font-size: 1rem;
}

.create-room-button {
  padding: 16px;
  background: #ff5f5f;
  color: white;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.create-room-button:hover:not(:disabled) {
  background: #993939
  transform: translateY(-2px);
}

.create-room-button:disabled {
  background: #666;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

/* Create Room Modal */
.create-room-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001; /* Higher than room browser modal */
  backdrop-filter: blur(4px);
}

.create-room-content {
  background: #2f2f2f;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
}

.create-room-header {
  background: #ff5f5f;
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.create-room-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.create-room-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.create-room-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.create-room-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
}

.create-room-open-button {
  padding: 16px 32px;
  background: #ff5f5f;
  color: white;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.create-room-open-button:hover {
  background: #993939;
  transform: translateY(-2px);
}

/* Map Selection Styles */
.map-selection {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.selected-map-display {
  min-height: 44px;
  border: 2px solid #555;
  background: #1a1a1a;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.selected-map-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.selected-map-name {
  font-weight: 600;
  color: #ff5f5f;
}

.no-map-selected {
  color: #888;
  font-style: italic;
}

.browse-map-button {
  padding: 12px 20px;
  background: #ff5f5f;
  color: white;
  border: none;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.browse-map-button:hover {
  background: #993939;
  transform: translateY(-1px);
}

.clear-map-btn {
  background: #ff4444;
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.clear-map-btn:hover {
  background: #cc3333;
}

/* Host Options Modal */
.host-options-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.host-options-content {
  background: #2f2f2f;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
}

.host-options-header {
  background: #ff5f5f;
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.host-options-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.host-options-close-btn {
  background: white;
  border: none;
  color: #ff5f5f;
  font-size: 2rem;
  cursor: pointer;
  padding-bottom: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.host-options-close-btn:hover {
  background: #ff5f5f;
  color: white;
}

.host-options-body {
  padding: 20px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

.host-options-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #555;
}

.host-options-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.host-map-input-container {
  margin-top: 10px;
}

.host-map-input {
  min-height: 50px;
  border: 2px solid #555;
  background: #1a1a1a;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.host-map-input:hover {
  border-color: #ff5f5f;
  background: #252525;
}

.host-map-input-text {
  flex: 1;
  color: #888;
  font-style: italic;
  user-select: none;
}

.host-map-input-text.has-map {
  color: #ff5f5f;
  font-weight: 600;
  font-style: normal;
}

.host-map-clear-btn {
  background: #ff5f5f;
  border: none;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 10px;
}

.host-map-clear-btn:hover {
  background: #993939;
  transform: scale(1.1);
}

.apply-map-change-button {
  padding: 12px 24px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-bottom: 10px;
  background: #ff5f5f;
  color: white;
}

.apply-map-change-button {
  background: #ff5f5f;
  color: white;
}

.apply-map-change-button:hover {
  background: #993939;
  transform: translateY(-1px);
}

.host-warning {
  background: rgba(255, 95, 95, 0.1);
  border: 1px solid #ff5f5f;
  border-radius: 4px;
  padding: 12px;
  color: #ff9999;
  font-size: 0.9rem;
  margin-top: 10px;
}

.host-warning strong {
  color: #ff5f5f;
}

.host-options-body::-webkit-scrollbar {
  width: 8px;
}

.host-options-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.host-options-body::-webkit-scrollbar-thumb {
  background: rgba(255, 95, 95, 0.6);
  border-radius: 4px;
}

.host-options-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 95, 95, 0.8);
}

.room-browser-body::-webkit-scrollbar {
  width: 8px;
}

.room-browser-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.room-browser-body::-webkit-scrollbar-thumb {
  background: rgba(183, 130, 240, 0.6);
  border-radius: 4px;
}

.room-browser-body::-webkit-scrollbar-thumb:hover {
  background: rgba(183, 130, 240, 0.8);
}

@media (max-width: 768px) {
  .room-browser-content {
    width: 95%;
    max-height: 95vh;
  }
  
  .rooms-list {
    grid-template-columns: 1fr;
  }
  
  .room-card {
    padding: 12px;
    gap: 10px;
  }
  
  .room-card-content {
    gap: 10px;
  }
  
  .room-preview-container {
    width: 60px;
    height: 45px;
  }
  
  .room-name {
    font-size: 1rem;
  }
  
  .room-info {
    font-size: 0.8rem;
  }
  
  .room-players-list {
    font-size: 0.7rem;
  }
  
  .no-players {
    font-size: 0.7rem;
  }
  
  .create-room-form {
    gap: 15px;
  }
  
  .create-room-content {
    width: 95%;
    max-width: 95%;
  }
  
  .create-room-header {
    padding: 16px;
  }
  
  .create-room-title {
    font-size: 1.2rem;
  }
  
  .create-room-body {
    padding: 8px;
  }
}

/* ============ LEADERBOARD STYLES ============ */

/* Mini Leaderboard (Always Visible) */
.mini-leaderboard {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px;
  min-width: 200px;
  max-width: 300px;
  backdrop-filter: blur(10px);
  z-index: 100;
  font-family: 'Nunito', Tahoma, Geneva, Verdana, serif;
  font-size: 12px;
  color: #ffffff;
  transition: top 0.3s ease-out;
}

.mini-leaderboard.below-toolbar {
  top: 80px;
}

.mini-leaderboard-header {
  color: #ff5f5f;
  font-weight: bold;
  text-align: center;
  margin-bottom: 8px;
  font-size: 1rem;
  text-transform: uppercase;
  font-family: 'Nunito', Tahoma, Geneva, Verdana, serif;
  letter-spacing: 1px;
}

.mini-leaderboard-content {
  max-height: 300px;
  overflow-y: auto;
}

.mini-leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-leaderboard-entry:last-child {
  border-bottom: none;
}

.mini-leaderboard-player {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mini-leaderboard-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mini-leaderboard-name {
  font-size: 1rem;
  font-weight: bold;;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.mini-leaderboard-laps {
  font-size: 1rem;
  color: #ff5f5f;
  font-weight: bold;
  white-space: nowrap;
}

/* Detailed Leaderboard Modal */
.detailed-leaderboard-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(5px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Nunito', serif;
}

.detailed-leaderboard-content {
  padding: 30px;
  max-width: 900px;
  max-height: 80vh;
  width: 90%;
  overflow-y: auto;
}

.leaderboard-title {
  color: #ff5f5f;
  font-size: 28px;
  font-weight: bold;
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.leaderboard-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  margin: 0;
}

/* Leaderboard Table */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: rgb(40, 40, 40);
  overflow: hidden;
}

.leaderboard-table th {
  padding: 15px 12px;
  text-align: center;
  color: #ffffff;
  font-family: 'Nunito', serif;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 1px;
}

.leaderboard-table tbody tr:nth-child(even) {
  background: rgba(60, 60, 60, 0.3);
}

.leaderboard-table tbody tr:nth-child(odd) {
  background: rgba(40, 40, 40, 0.3);
}

.leaderboard-table tbody tr:hover {
  background: rgba(37, 150, 190, 0.2);
}

.leaderboard-table td {
  padding: 12px;
  text-align: center;
  color: #ffffff;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Rank column styling */
.leaderboard-table .rank-1 {
  color: #ffd700;
  font-weight: bold;
}

.leaderboard-table .rank-2 {
  color: #c0c0c0;
  font-weight: bold;
}

.leaderboard-table .rank-3 {
  color: #cd7f32;
  font-weight: bold;
}

/* Player column with color indicator */
.leaderboard-player-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.leaderboard-player-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.leaderboard-player-name {
  font-weight: 800;
  font-family: 'Tahoma', serif;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    -2px 0px 0 #000000,
    2px 0px 0 #000000,
    0px -2px 0 #000000,
    0px 2px 0 #000000;
}

/* Stats highlighting */
.leaderboard-table .stat-laps {
  color: #ff6b6b;
  font-family: 'Nunito', serif;
  font-weight: bold;
}

.leaderboard-table .stat-kills {
  color: #ff6b6b;
  font-family: 'Nunito', serif;
  font-weight: bold;
}

.leaderboard-table .stat-deaths {
  color: #ff6b6b;
  font-family: 'Nunito', serif;
  font-weight: bold;
}

.leaderboard-table .stat-kdr {
  color: #ff6b6b;
  font-family: 'Nunito', serif;
  font-weight: bold;
}

.leaderboard-table .stat-best-lap {
  color: #ff6b6b;
  font-family: 'Monospace', monospace;
  font-weight: bold;
}

/* Spectator entries */
.leaderboard-table .spectator-row:hover {
  background: rgba(60, 60, 80, 0.3);
}

.leaderboard-table .spectator-indicator {
  background: #666666 !important;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.leaderboard-table .spectator-status {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  text-align: center;
  padding-left: 20px;
}

/* Responsive design for leaderboard */
@media (max-width: 768px) {
  .mini-leaderboard {
    right: 10px;
    top: 10px;
    min-width: 150px;
    font-size: 11px;
  }
  
  .detailed-leaderboard-content {
    padding: 20px;
    width: 95%;
    max-height: 90vh;
  }
  
  .leaderboard-title {
    font-size: 22px;
  }
  
  .leaderboard-table th,
  .leaderboard-table td {
    padding: 8px 6px;
    font-size: 11px;
  }
  
  .leaderboard-player-cell {
    flex-direction: column;
    gap: 4px;
  }
  
  .leaderboard-player-color {
    width: 8px;
    height: 8px;
  }
}

/* Hide mini leaderboard scrollbar */
.mini-leaderboard-content::-webkit-scrollbar {
  width: 4px;
}

.mini-leaderboard-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.mini-leaderboard-content::-webkit-scrollbar-thumb {
  background: #ff5f5f;
  border-radius: 2px;
}

.mini-leaderboard-content::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 150, 190, 0.8);
}

/* Authentication Screen Styles */
.auth-screen {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #323232;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 15;
}

.auth-container {
  padding: 2rem;
  min-width: 400px;
  max-width: 500px;
}

.auth-title {
  font-family: 'Nunito', serif;
  font-size: 3.5rem;
  margin-bottom: 2rem;
  color: #ffffff;
  text-align: center;
  letter-spacing: 1px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  height: auto;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    -2px 0px 0 #000000,
    2px 0px 0 #000000,
    0px -2px 0 #000000,
    0px 2px 0 #000000;
}

.auth-selection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.auth-option {
  width: 100%;
}

.auth-option-btn {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-weight: 600;
  border: none;
  background: #ff5f5f;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Nunito', serif;
}

.auth-option-btn:hover {
  background: #993939;
  color: #ffffff;
  transform: translateY(-2px);
}

.auth-form {
  animation: fadeInUp 0.3s ease-out;
}

.auth-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.auth-form-title {
  color: #ff5f5f;
  font-size: 1.8rem;
  margin: 0;
  font-weight: 600;
}

.auth-back-btn {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.auth-back-btn:hover {
  background: #993939;
  color: #ffffff;
}

.auth-form-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-label {
  color: #ffffff;
  font-weight: 500;
  font-size: 0.9rem;
}

.auth-input {
  padding: 0.8rem 1rem;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  font-size: 1.3rem;
  font-family: 'Nunito', serif;
  font-weight: bold;
  transition: all 0.2s ease;
  text-align: center;
}

.auth-input:focus {
  outline: none;
  border: 1px solid #ff5f5f;
  background: #ffffff;
}

.auth-input::placeholder {
  color: #888;
}

.auth-submit-btn {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  background: #ff5f5f;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 0.5rem;
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  background-color: #993939;
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-error {
  color: #ff4757;
  font-size: 0.9rem;
  padding: 0.5rem;
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 4px;
  margin-top: 0.5rem;
}

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
}

.auth-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(37, 150, 190, 0.3);
  border-top: 4px solid #ff5f5f;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.auth-loading-text {
  color: #ff5f5f;
  font-size: 1.1rem;
  font-weight: 500;
}

.play-btn {
  background: #ff5f5f !important;
  font-size: 1.2rem !important;
  padding: 1.2rem 2rem !important;
  font-weight: 700 !important;
  letter-spacing: 1px;
  font-family: 'Nunito', serif;
}

.play-btn:hover {
  background: #993939 !important;
  transform: translateY(-2px);
}

.auth-options-footer {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.auth-link-btn {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  font-size: 1rem;
  font-weight: bold;
  font-family: 'Nunito', serif;
  cursor: pointer;
  padding: 0.5rem;
  transition: all 0.2s ease;
  width: 100%;
}

.auth-link-btn:hover {
  background: #993939;
  transform: none;
  transform: translateY(-2px);
}

.auth-separator {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 300;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Menu Header Styles */
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 2rem;
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 1rem;
  background: #ff5f5f(30, 30, 30, 0.8);
  backdrop-filter: blur(5px);
}

.player-name {
  color: #ff5f5f;
  font-weight: 600;
  font-size: 1.1rem;
}

.logout-btn {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #993939;
  color: #ffffff;
}

/* Top Toolbar Styles */
.toolbar-hover-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 80px;
  z-index: 2000;
  pointer-events: none;
}

.top-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: #ff5f5f;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 2001;
  transform: translateY(-100%);
  transition: transform 0.3s ease-out;
}

.top-toolbar.visible {
  transform: translateY(0);
}

.top-toolbar.always-visible {
  transform: translateY(0);
  pointer-events: auto;
}

.toolbar-left {
  display: flex;
  align-items: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 0 30px;
}

.toolbar-player-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.toolbar-player-name {
  color: #ffffff;
  font-weight: bold;
  font-size: 1.1rem;
}

.toolbar-level-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-progress-bar {
  width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.level-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

.toolbar-level-info {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  font-weight: 500;
}

.toolbar-back-btn,
.toolbar-kill-btn,
.toolbar-logout-btn,
.toolbar-settings-btn {
  background: #ffffff;
  border: none;
  color: #ff5f5f;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.toolbar-back-btn:hover,
.toolbar-kill-btn:hover,
.toolbar-logout-btn:hover,
.toolbar-settings-btn:hover {
  background: #ff5f5f;
  color: #ffffff;
  transform: translateY(-1px);
}

.toolbar-back-btn svg,
.toolbar-kill-btn svg,
.toolbar-logout-btn svg,
.toolbar-settings-btn svg {
  transition: transform 0.2s ease;
}

.toolbar-settings-btn:hover svg {
  transform: rotate(45deg);
}

.toolbar-logout-btn:hover svg {
  transform: rotate(180deg);
}

.toolbar-back-btn:hover svg {
  transform: rotate(180deg);
}

.toolbar-kill-btn:hover svg {
  transform: scale(1.1);
}

/* Remove old settings button styles */
.settings-button {
  display: none;
}

/* Responsive Design for Authentication */
@media (max-width: 768px) {
  .auth-container {
    min-width: 90%;
    max-width: 90%;
    margin: 1rem;
    padding: 1.5rem;
  }
  
  .auth-title {
    font-size: 2.5rem;
  }
  
  .top-toolbar {
    height: 50px;
    padding: 0 15px;
  }
  
  .toolbar-player-name {
    font-size: 1rem;
  }
  
  .level-progress-bar {
    width: 80px;
    height: 3px;
  }
  
  .toolbar-level-info {
    font-size: 0.7rem;
  }
  
  .toolbar-kill-btn,
  .toolbar-logout-btn,
  .toolbar-settings-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
  }
  
  .toolbar-right {
    gap: 10px;
  }
  
  .toolbar-hover-zone {
    height: 60px;
  }
  
  /* Mobile disconnect overlay adjustments */
  .disconnect-overlay {
    padding-top: 15vh; /* Less top padding on mobile */
  }
  
  .disconnect-content {
    padding: 25px; /* Reduced padding on mobile */
    width: 95%; /* More width on mobile */
  }
  
  .disconnect-title {
    font-size: 1.5em; /* Smaller title on mobile */
  }
}

/* Map Editor Styles */
.map-editor-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  z-index: 2000;
  background-color: #323232;
}

.map-editor-sidebar {
  margin-top: 6vh;
  width: 300px;
  background-color: #2a2a2a;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: #ffffff;
  font-family: 'Nunito', serif;
}

#mapSelect {
  background-color: #ffffff;
  color: #333;
  border: none;
  padding: 0.5rem;
  font-size: 1rem;
}

.map-editor-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.map-editor-buttons button {
  background-color: #ff5f5f;
  color: #ffffff;
  border: none;
  padding: 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.map-editor-buttons button:hover {
  background-color: #993939;
}

#mapDataInput {
  flex-grow: 1;
  background-color: #1e1e1e;
  color: #ffffff;
  border: 1px solid #444;
  padding: 0.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  resize: none;
}

.map-editor-canvas {
  flex-grow: 1;
  background-color: #323232;
  cursor: crosshair;
}

/* New Editor UI Styles */
.editor-section {
  border-bottom: 1px solid #444;
  padding-bottom: 1rem;
}

.editor-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #ff5f5f;
}

.tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
}

.tool-btn {
  background-color: #444;
  color: #ffffff;
  border: none;
  padding: 0.5rem 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tool-btn:hover {
  background-color: #666;
}

.tool-btn.active {
  background-color: #ff5f5f;
}

.editor-section label {
  display: block;
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.editor-section input[type="checkbox"] {
  margin-right: 0.5rem;
}

.editor-section select {
  background-color: #444;
  color: #ffffff;
  border: 1px solid #666;
  padding: 0.25rem;
  font-size: 0.9rem;
  width: 100%;
}

#propertiesPanel {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

#layersPanel {
  max-height: 150px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.property-input {
  background-color: #444;
  color: #ffffff;
  border: 1px solid #666;
  padding: 0.25rem;
  font-size: 0.8rem;
  width: 100%;
  margin: 0.25rem 0;
}

.property-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.25rem 0;
}

.property-label {
  font-size: 0.8rem;
  min-width: 80px;
}

.layer-item {
  background-color: #444;
  padding: 0.25rem 0.5rem;
  margin: 0.25rem 0;
  cursor: move;
  font-size: 0.8rem;
  transition: background-color 0.2s, opacity 0.2s;
}

.layer-item:hover {
  background-color: #666;
}

.layer-item.selected {
  background-color: #ff5f5f;
}

.layer-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.layer-item.drag-over {
  background-color: #5f5fff;
  border: 2px dashed #8f8fff;
}

/* Property Editor Styles */
.property-form {
  padding: 0;
}

.property-form h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: #ff5f5f;
  text-transform: capitalize;
}

.property-form h5 {
  margin: 0.5rem 0 0.25rem 0;
  font-size: 0.8rem;
  color: #ccc;
  font-weight: normal;
}

.property-group {
  margin: 0.5rem 0;
  padding: 0.25rem;
  border-left: 2px solid #666;
  padding-left: 0.5rem;
}

.color-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-input {
  width: 40px;
  height: 25px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.color-preview {
  font-size: 0.7rem;
  color: #aaa;
  min-width: 60px;
}

.property-slider {
  width: 100%;
  margin: 0.25rem 0;
}

.property-checkbox {
  margin-right: 0.5rem;
}

/* Improved property input styling */
.property-input {
  font-size: 0.8rem;
  width: 80px;
}

.property-input[type="text"] {
  width: 100%;
}

select.property-input {
  width: 100%;
  font-size: 0.8rem;
}

/* Chat System Styles */
.chat-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 350px;
  max-height: 250px;
  z-index: 15;
  font-family: 'Nunito', Tahoma, Geneva, Verdana, serif;
}

.chat-messages {
  padding: 8px 12px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.chat-message {
  color: #ffffff;
  font-size: 1rem;
  margin-bottom: 4px;
  line-height: 1.3;
  word-wrap: break-word;
}

.chat-message:last-child {
  margin-bottom: 0;
}

.chat-player-name {
  color: #ff5f5f;
  font-weight: 600;
  margin-right: 4px;
}

.chat-message-text {
  color: #ffffff;
}

.chat-input-area {
  background: rgba(0, 0, 0, 0.8);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.chat-input-area.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.chat-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  font-family: 'Nunito', serif;
}

.chat-input:focus {
  border-color: #ff5f5f;
  background: rgba(255, 255, 255, 0.15);
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.chat-hint {
  color: rgba(255, 255, 255, 0.6);
  font-size: 10px;
  margin-top: 5px;
  text-align: center;
}

/* Hide chat messages when no messages exist */
.chat-messages:empty {
  display: none;
}

/* Chat Prompt */
.chat-prompt {
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  cursor: pointer;
}

.chat-prompt:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 95, 95, 0.3);
  transform: translateY(-1px);
}

.chat-prompt-text {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
  user-select: none;
}

.chat-prompt.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1a1a1a;
  padding: 0;
  margin-top: 5vh;
  min-width: 400px;
  max-width: 500px;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 20px 25px 15px 25px;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #333;
  color: #fff;
}

.modal-body {
  padding: 25px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  color: #ccc;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.form-input, .form-select {
  width: 100%;
  padding: 12px 15px;
  background: #2a2a2a;
  border: 2px solid #444;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: #ff5f5f;
  background: #333;
}

.radio-group {
  display: flex;
  gap: 15px;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #ccc;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.radio-label:hover {
  color: #fff;
}

.radio-label input[type="radio"] {
  margin-right: 8px;
  accent-color: #ff5f5f;
}

.radio-text {
  user-select: none;
}

.modal-footer {
  padding: 20px 25px;
  border-top: 1px solid #333;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn {
  padding: 10px 20px;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.btn-secondary {
  background: #444;
  color: #ccc;
}

.btn-secondary:hover {
  background: #555;
  color: #fff;
}

.btn-primary {
  background: #ff5f5f;
  color: white;
}

.btn-primary:hover {
  background: #ff4444;
  transform: translateY(-1px);
}

#browseMapModal {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(2px);
  z-index: 10001;
}

.browse-modal {
  background: #2f2f2f;
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  overflow: hidden;
}

.map-browser-header {
  background: #ff5f5f;
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.browse-modal .modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
}

.browse-modal .close-button {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.browse-modal .close-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Map Browser Body */
.map-browser-body {
  padding: 20px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

/* Map Filters Section */
.map-filters-section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #444;
}

.map-search-container {
  margin-bottom: 15px;
}

.map-search-input {
  width: 100%;
  padding: 12px 15px;
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 0;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.map-search-input:focus {
  outline: none;
  border-color: #ff5f5f;
  background: #333;
}

.map-search-input::placeholder {
  color: #888;
}

.map-filter-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.filter-toggle-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.filter-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #ff5f5f;
}

.filter-text {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
}

.map-count-display {
  color: #ccc;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Maps Grid */
.maps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
  padding: 10px 0;
}

.map-entry {
  background: #2a2a2a;
  padding: 15px;
  border: 2px solid #444;
  transition: all 0.3s ease;
  cursor: pointer;
}

.map-entry:hover {
  border-color: #ff5f5f;
  transform: translateY(-2px);
}

.map-category {
  color: #ff5f5f;
}

.map-preview {
  width: 100%;
  height: 150px;
  background: #1a1a1a;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
  border: 1px solid #444;
  overflow: hidden;
  position: relative;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
}

.no-preview {
  color: #888;
  font-size: 14px;
  font-style: italic;
}

.map-info h4 {
  margin: 0 0 8px 0;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.map-info p {
  margin: 4px 0;
  color: #ccc;
  font-size: 14px;
}

/* Map Leaderboard Section */
.map-leaderboard-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #444;
}

.map-leaderboard-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.map-leaderboard-text {
  flex: 1;
}

.map-best-time {
  color: #ff5f5f;
  font-size: 14px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  margin-bottom: 4px;
}

.map-record-holder {
  color: #aaa;
  font-size: 12px;
  font-style: italic;
}

.no-records-text {
  color: #777;
  font-size: 13px;
  font-style: italic;
  text-align: center;
  padding: 4px 0;
}

.leaderboard-btn {
  background: #3a3a3a;
  border: 2px solid #555;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.leaderboard-btn:hover {
  background: #ff5f5f;
  border-color: #ff5f5f;
  transform: scale(1.05);
}

.leaderboard-btn svg {
  color: #ccc;
  transition: color 0.2s ease;
}

.leaderboard-btn:hover svg {
  color: white;
}

.no-maps-message {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 1.1rem;
  font-style: italic;
}

/* Map Editor Status Bar */
.editor-status-bar {
  position: absolute;
  bottom: 0;
  left: 300px; /* Account for sidebar width */
  right: 0;
  height: 32px;
  background: rgba(40, 40, 40, 0.95);
  border-top: 1px solid #555;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  font-family: 'Nunito', serif;
  font-size: 12px;
  color: #ddd;
  z-index: 100;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.status-right {
  display: flex;
  align-items: center;
}

#editorToolName {
  font-weight: bold;
  color: #4CAF50;
}

.editor-hint {
  color: #FFD700;
  font-style: italic;
}

.editor-coords {
  font-family: 'Courier New', monospace;
  color: #87CEEB;
}

/* Map Editor Property Help Text */
.property-help {
  font-size: 11px;
  color: #999;
  font-style: italic;
  margin: 5px 0 10px 0;
  line-height: 1.3;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 3px;
  border-left: 2px solid #4CAF50;
}

/* Vertex Context Menu */
.vertex-context-menu {
  position: fixed;
  z-index: 10000;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  min-width: 150px;
  font-size: 13px;
}

.context-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  color: #ddd;
  transition: background-color 0.2s;
}

.context-menu-item:hover {
  background: #3a3a3a;
  color: #fff;
}

.context-menu-item:first-child {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.context-menu-item:last-child {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.context-menu-item.disabled {
  color: #666;
  cursor: not-allowed;
}

.context-menu-item.disabled:hover {
  background: transparent;
  color: #666;
}

.context-menu-separator {
  height: 1px;
  background: #444;
  margin: 4px 0;
}

/* Shape Tool Hover Menu */
.shape-tool-hover-menu {
  position: fixed;
  z-index: 10000;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  min-width: 100px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

.hover-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  color: #ddd;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.hover-menu-item:hover {
  background: #3a3a3a;
  color: #fff;
}

.hover-menu-item:first-child {
  border-radius: 4px 4px 0 0;
}

.hover-menu-item:last-child {
  border-radius: 0 0 4px 4px;
}

/* Mobile Controls */
.mobile-controls {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 80;
}

.mobile-controls.hidden {
  display: none;
}

/* Virtual Joystick */
.mobile-joystick {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 150px;
  height: 150px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.joystick-outer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(20, 20, 20, 0.9);
  border: 4px solid #ff5f5f;
  border-radius: 50%;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  background: rgba(255, 95, 95, 0.8);
  border: 3px solid #ff5f5f;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s ease;
}

.joystick-knob.active {
  background: rgba(255, 95, 95, 1);
}

/* Mobile Boost Button */
.mobile-boost-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 100px;
  height: 100px;
  background: rgba(20, 20, 20, 0.9);
  border: 4px solid #ff5f5f;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transition: all 0.2s ease;
}

.mobile-boost-button:active {
  transform: scale(0.95);
  background: rgba(30, 30, 30, 0.98);
}

.boost-icon {
  font-size: 2em;
  color: #ff5f5f;
  margin-bottom: 4px;
  line-height: 1;
}

.boost-label {
  font-family: 'Nunito', serif;
  font-size: 0.75em;
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Mobile Ability Button */
.mobile-ability-button {
  position: fixed;
  bottom: 150px;
  right: 30px;
  width: 80px;
  height: 80px;
  background: rgba(20, 20, 20, 0.9);
  border: 4px solid #ff5f5f;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transition: all 0.2s ease;
}

.mobile-ability-button:active {
  transform: scale(0.95);
  background: rgba(30, 30, 30, 0.98);
}

.mobile-ability-button.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.ability-icon {
  font-size: 1.8em;
  color: #ff5f5f;
  margin-bottom: 2px;
  line-height: 1;
}

.ability-label {
  font-family: 'Nunito', serif;
  font-size: 0.65em;
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Hide mobile controls on desktop */
@media (min-width: 769px) and (hover: hover) {
  .mobile-controls {
    display: none !important;
  }
}

/* Menu Buttons Grid */
.menu-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  margin-top: 1rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.menu-grid-button {
  background: #ff5f5f;
  border: none;
  color: #ffffff;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Nunito', serif;
  cursor: pointer;
  transition: all 0.3s ease;
}

.menu-grid-button:hover:not(:disabled) {
  background: #ff7f7f;
  transform: translateY(-2px);
}

.menu-grid-button:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.5;
}

.global-leaderboard-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.global-leaderboard-header {
  background: #ff5f5f;
  color: white;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.global-leaderboard-content {
  background: #2f2f2f;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
}

/* maybe a search feature in future? */
.global-leaderboard-body {
  
}

.global-leaderboard-close-btn {
  background: white;
  border: none;
  color: #ff5f5f;
  font-size: 2rem;
  cursor: pointer;
  padding-bottom: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.global-leaderboard-close-btn:hover {
  background: #ff5f5f;
  color: white;
}

.current-user-leaderboard-row {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #ff5f5f;
}

.current-user-leaderboard-row .leaderboard-table tbody tr {
  background: rgba(255, 95, 95, 0.2);
  border: 2px solid #ff5f5f;
}

/* Time Trial Leaderboard Modal */
.time-trial-leaderboard-content {
  background: #2f2f2f;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  border-radius: 8px;
}

.time-trial-leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  background: #3a3a3a;
  border-bottom: 2px solid #ff5f5f;
}

.time-trial-leaderboard-header h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.5rem;
}

.time-trial-leaderboard-close-btn {
  background: white;
  border: none;
  color: #ff5f5f;
  font-size: 2rem;
  cursor: pointer;
  padding-bottom: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  border-radius: 4px;
}

.time-trial-leaderboard-close-btn:hover {
  background: #ff5f5f;
  color: white;
}

.time-trial-leaderboard-body {
  padding: 20px 30px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
}

.user-best-time {
  background: rgba(255, 95, 95, 0.1);
  border: 2px solid #ff5f5f;
  border-radius: 6px;
  padding: 15px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-rank-badge {
  background: #ff5f5f;
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 1.1rem;
}

.user-time {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ffffff;
  font-family: 'Courier New', monospace;
}

.no-record {
  text-align: center;
  color: #bbbbbb;
  font-size: 1rem;
  padding: 10px;
}

.current-user-row {
  background: rgba(255, 95, 95, 0.2) !important;
  border-left: 4px solid #ff5f5f !important;
}

.rank-cell {
  font-weight: bold;
  color: #ff5f5f;
}

.time-cell {
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

.date-cell {
  color: #aaaaaa;
  font-size: 0.9rem;
}