* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  background: #0a0a0a;
  color: #ffffff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  border-bottom: 2px solid #333;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 200px;
}

.topbar-right {
  justify-content: flex-end;
}

.topbar-center h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease-in-out infinite;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

@keyframes gradientShift {
  0%, 100% { background-position: 0 50%; }
  50% { background-position: 100% 50%; }
}

#coords {
  background: rgba(0,0,0,0.4);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #333;
  min-width: 180px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

#coords:hover {
  background: rgba(0,0,0,0.6);
  border-color: #4ecdc4;
  transform: scale(1.05);
}

#userCount {
  background: rgba(0,150,0,0.2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,255,0,0.3);
  font-size: 13px;
  font-weight: 500;
  min-width: 80px;
  text-align: center;
}

#happyHourIndicator {
  background: linear-gradient(45deg, #ffaa44, #ff6b6b);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: happyHourPulse 2s infinite;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(255, 170, 68, 0.3);
}

#adminIndicator {
  background: linear-gradient(45deg, #4ecdc4, #45b7d1);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
}

@keyframes happyHourPulse {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(255, 170, 68, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 4px 20px rgba(255, 170, 68, 0.6);
    transform: scale(1.05);
  }
}

#adminInstructions {
  color: #4ecdc4;
  font-weight: 500;
}

#cooldown {
  background: rgba(0,150,0,0.2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid rgba(0,255,0,0.3);
  font-size: 13px;
  font-weight: 500;
  min-width: 100px;
  text-align: center;
  transition: all 0.3s ease;
}

#container {
  display: flex;
  margin-top: 60px;
  height: calc(100vh - 60px);
  width: 100vw;
  position: relative;
}

#canvas {
  flex: 1;
  background: #000000;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
  width: 100vw;
  height: calc(100vh - 60px);
}

.palette-trigger {
  position: fixed;
  right: 0;
  top: 60px;
  width: 20px;
  height: calc(100vh - 60px);
  background: transparent;
  z-index: 800;
  cursor: pointer;
}

.palette-trigger::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60px;
  background: linear-gradient(90deg, transparent, rgba(78, 205, 196, 0.3));
  border-radius: 2px 0 0 2px;
  transition: all 0.3s ease;
}

.palette-trigger:hover::before {
  background: linear-gradient(90deg, transparent, rgba(78, 205, 196, 0.8));
  width: 8px;
  height: 100px;
}

#sidebar {
  position: fixed;
  right: -280px;
  top: 60px;
  width: 280px;
  height: calc(100vh - 60px);
  background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
  border-left: 2px solid #333;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  overflow-y: auto;
  z-index: 900;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.show {
  right: 0;
}

#sidebar.peek {
  right: -240px;
}

.palette-header {
  padding: 20px 16px 10px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.palette-header h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.palette-hint {
  font-size: 12px;
  color: #888;
  font-style: italic;
}

#palette {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.color {
  width: 28px;
  height: 28px;
  border: 2px solid #444;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.color:hover {
  transform: scale(1.2) translateY(-2px);
  border-color: #888;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.color.selected {
  outline: 2px solid #fff;
  outline-offset: 1px;
  border-color: #fff;
  transform: scale(1.3) translateY(-3px);
  z-index: 20;
  box-shadow: 0 0 15px rgba(255,255,255,0.5), 0 4px 16px rgba(0,0,0,0.4);
  animation: selectedPulse 2s infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(255,255,255,0.5), 0 4px 16px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 25px rgba(255,255,255,0.8), 0 4px 16px rgba(0,0,0,0.4); }
}

.selected-color-indicator {
  position: fixed;
  top: 70px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 3px solid #fff;
  border-radius: 50%;
  z-index: 700;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 15px rgba(255,255,255,0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.selected-color-indicator:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(0,0,0,0.7), 0 0 20px rgba(255,255,255,0.5);
}

#instructions {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(10px);
  border: 1px solid #333;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.instruction-group {
  text-align: center;
  line-height: 1.4;
}

.instruction-group strong {
  color: #4ecdc4;
  margin-right: 8px;
}

.instruction-group span {
  margin: 0 2px;
}

#loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  z-index: 2000;
  border: 2px solid #333;
}

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

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

#connectionStatus {
  position: fixed;
  top: 120px;
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 701;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #333;
  backdrop-filter: blur(5px);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4444;
  animation: statusBlink 1s infinite;
}

.connection-status.connected .status-indicator {
  background: #44ff44;
  animation: none;
}

@keyframes statusBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  #sidebar {
    width: 220px;
    right: -220px;
  }

  #sidebar.peek {
    right: -180px;
  }
  
  #palette {
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
  }
  
  .color {
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 768px) {
  #topbar {
    height: 50px;
    padding: 0 10px;
  }
  
  .topbar-center h1 {
    font-size: 18px;
  }
  
  .topbar-left, .topbar-right {
    gap: 10px;
    min-width: auto;
    flex-wrap: wrap;
  }

  #happyHourIndicator, #adminIndicator {
    font-size: 11px;
    padding: 6px 8px;
  }
  
  #container {
    margin-top: 50px;
    height: calc(100vh - 50px);
  }

  #canvas {
    height: calc(100vh - 50px);
  }

  .palette-trigger {
    top: 50px;
    height: calc(100vh - 50px);
    width: 30px;
  }

  #sidebar {
    top: 50px;
    width: 240px;
    right: -240px;
    height: calc(100vh - 50px);
  }

  #sidebar.peek {
    right: -200px;
  }
  
  #palette {
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    padding: 12px;
  }
  
  .color {
    width: 28px;
    height: 28px;
  }
  
  #instructions {
    bottom: 10px;
    font-size: 11px;
    padding: 8px 16px;
    max-width: 90%;
  }

  #coords {
    min-width: 120px;
    font-size: 11px;
  }

  .selected-color-indicator {
    top: 60px;
    width: 35px;
    height: 35px;
  }
}

@media (max-width: 480px) {
  .topbar-left, .topbar-right {
    flex-direction: column;
    gap: 2px;
  }
  
  #topbar {
    height: auto;
    padding: 8px;
    min-height: 50px;
  }
  
  #happyHourIndicator, #adminIndicator {
    font-size: 10px;
    padding: 4px 6px;
  }

  #happyHourIndicator i, #adminIndicator i {
    font-size: 12px;
  }

  #container {
    margin-top: 60px;
    height: calc(100vh - 60px);
  }

  #canvas {
    height: calc(100vh - 60px);
  }

  .palette-trigger {
    top: 60px;
    height: calc(100vh - 60px);
  }

  #sidebar {
    top: 60px;
    height: calc(100vh - 60px);
    width: 200px;
    right: -200px;
  }

  #sidebar.peek {
    right: -160px;
  }

  #palette {
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 8px;
  }

  .color {
    width: 24px;
    height: 24px;
  }

  .selected-color-indicator {
    top: 70px;
    width: 30px;
    height: 30px;
  }
}

#palette::-webkit-scrollbar, #sidebar::-webkit-scrollbar {
  width: 6px;
}

#palette::-webkit-scrollbar-track, #sidebar::-webkit-scrollbar-track {
  background: #1a1a1a;
}

#palette::-webkit-scrollbar-thumb, #sidebar::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

#palette::-webkit-scrollbar-thumb:hover, #sidebar::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.color:focus {
  outline: 2px solid #4ecdc4;
  outline-offset: 3px;
}

@media (prefers-contrast: high) {
  #topbar {
    background: #000;
    border-bottom: 3px solid #fff;
  }
  
  .color {
    border-width: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .color {
    transition: none;
  }
  
  .color:hover {
    transform: none;
  }
  
  .color.selected {
    animation: none;
    transform: none;
  }
  
  .loading-spinner {
    animation: none;
  }
  
  @keyframes gradientShift {
    0%, 100% { background-position: 0 50%; }
  }

  #sidebar {
    transition: none;
  }
}