:root {
  --bg-color: #0b0c10;
  --panel-bg: rgba(22, 24, 30, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary: #6c5ce7;
  --primary-hover: #8172ff;
  --secondary: #2d3436;
  --text-main: #f8f9fa;
  --text-muted: #a0a5ab;
  --accent: #00d2d3;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden; /* Prevent native scrolling, handled by app.js */
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* Map Container */
#map-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  z-index: 1;
  background-color: #0b0c10;
}

/* Fix Leaflet pane layering so UI stays on top without catching clicks */
.leaflet-pane {
  z-index: auto !important;
}
.leaflet-top, .leaflet-bottom {
  z-index: 9 !important; /* Keep below UI layer */
}

/* Ensure top-right controls are below the status badge */
.leaflet-top.leaflet-right {
  margin-top: 90px;
  margin-right: 20px;
}

/* Force pixelated sharp rendering on Zoom */
.leaflet-container,
.leaflet-image-layer,
.leaflet-zoom-animated,
.leaflet-pane canvas,
.leaflet-pane img,
canvas {
  image-rendering: -moz-crisp-edges !important;
  image-rendering: -webkit-optimize-contrast !important;
  image-rendering: crisp-edges !important;
  image-rendering: pixelated !important;
}

/* Ensure borders layer is totally transparent to clicks */
.borders-layer {
  pointer-events: none !important;
}

/* UI Layer */
#ui-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to canvas container */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

footer, .modal-backdrop {
  pointer-events: auto;
}

/* Allow clicks to pass through the glass panel and top bar background */
.top-bar, .glass-panel {
  pointer-events: none;
}

/* Re-enable clicks strictly for interactive items */
.btn, input, a, #leaderboard-list {
  pointer-events: auto;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Header */
.top-bar {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #a0a5ab);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo span {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
}

.status {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 210, 211, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 210, 211, 0.2);
}
.status::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Leaderboard */
#leaderboard {
  position: absolute;
  top: 70px;
  left: 20px;
  width: 200px;
  padding: 12px 16px;
}

#leaderboard h2 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#leaderboard-list {
  list-style: none;
}

#leaderboard-list li {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.75rem;
}
#leaderboard-list li:last-child {
  border-bottom: none;
}

.rank {
  font-weight: 700;
  color: var(--primary);
  width: 24px;
}
.name {
  flex-grow: 1;
  color: var(--text-main);
}
.score {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Floating Actions */
#action-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-radius: 50px;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
}
.color-picker-wrap label {
  display: none;
}

.color-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.3);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

#color-hex {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-main);
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

.btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.primary-btn {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}
.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}

.secondary-btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(255,255,255,0.2);
}
.secondary-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.4);
}

/* Footer */
footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}
footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
footer a:hover {
  text-decoration: underline;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  width: 90%;
  max-width: 400px;
  padding: 30px;
  text-align: center;
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.hidden .modal {
  transform: scale(0.9);
}

.modal h3 {
  font-size: 1.4rem;
  margin-bottom: 12px;
  color: var(--text-main);
}

.modal p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.ad-progress {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin-bottom: 12px;
  overflow: hidden;
}

.ad-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus {
  border-color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
  #action-controls {
    flex-wrap: wrap;
    justify-content: center;
    bottom: 20px;
    width: 95%;
    gap: 8px;
    border-radius: 24px;
  }
  .btn-group {
    flex-wrap: wrap;
    justify-content: center;
  }
  .btn-group .btn {
    flex: 1 1 auto;
  }
  #leaderboard {
    display: none; /* Hide on mobile to save space */
  }
}

#zoom-warning {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 15px 30px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 1px;
  pointer-events: none;
  animation: glow 2s infinite alternate;
  z-index: 50;
  transition: opacity 0.3s ease;
}

#zoom-warning.hidden {
  opacity: 0;
  visibility: hidden;
}

@keyframes glow {
  from { box-shadow: 0 0 10px rgba(118, 75, 175, 0.5); }
  to { box-shadow: 0 0 20px rgba(118, 75, 175, 0.8); }
}

#image-upload {
  display: none !important;
  visibility: hidden;
  opacity: 0;
  width: 0;
  height: 0;
}
