:root {
  --bg-color: #050a0f;
  --accent-color: #00ff9d;
  --accent-glow: 0 0 10px rgba(0, 255, 157, 0.5);
  --text-main: #e0e6ed;
  --text-dim: #8b9bb4;
  --panel-bg: rgba(10, 20, 30, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#leaflet-map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  background: #020406;
  /* Deep space black */
}

/* UI Overlay */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  padding: 20px;
}

.top-bar {
  display: flex;
  gap: 20px;
  max-width: calc(100% - 360px);
}

.stat-pill {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: auto;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.green {
  background: #00ff9d;
  box-shadow: 0 0 5px #00ff9d;
}

.orange {
  background: #ff9d00;
  box-shadow: 0 0 5px #ff9d00;
}

.right-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 60px;
  width: 320px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  pointer-events: auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

body.panel-collapsed .right-panel {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

body.panel-collapsed #panel-toggle {
  border-color: rgba(0, 255, 157, 0.5);
  box-shadow: 0 0 12px rgba(0, 255, 157, 0.15);
}

.bottom-bar {
  position: absolute;
  left: 20px;
  right: 360px;
  bottom: 20px;
  pointer-events: none;
}

.bottom-bar span {
  display: inline-block;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
}

.panel-header {
  text-align: left;
}

.panel-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.panel-subtitle {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 4px;
}

.status-box {
  background: rgba(0, 255, 157, 0.1);
  border: 1px solid rgba(0, 255, 157, 0.2);
  padding: 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-color);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.user-stats {
  background: rgba(255, 255, 255, 0.03);
  padding: 15px;
  border-radius: 8px;
}

.stat-header {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 700;
}

.karma-display {
  text-align: center;
}

.karma-points {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.karma-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.posts-count {
  font-size: 12px;
  color: #fff;
  font-weight: 600;
  text-align: right;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 10px;
}

/* Progress bars for continents */
.continent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}

.progress-track {
  width: 100px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 2px;
  transition: width 0.5s;
}

/* City List */
.city-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.city-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
}

.city-info {
  display: flex;
  flex-direction: column;
}

.city-name {
  font-weight: 700;
  color: #fff;
}

.city-region {
  font-size: 10px;
  color: var(--text-dim);
}

.city-timer {
  font-family: 'Courier New', monospace;
  color: var(--accent-color);
  font-weight: 700;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: #151f2b;
  width: 400px;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  align-items: center;
}

.country-name {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
}

#post-input {
  width: 100%;
  height: 100px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  padding: 12px;
  font-family: 'Inter', sans-serif;
  resize: none;
}

#post-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.post-btn {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--accent-color);
  border: none;
  border-radius: 8px;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  transition: opacity 0.2s;
}

.post-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Banner */
.banner-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-banner {
  background: rgba(255, 50, 50, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  animation: slideDown 0.3s ease-out;
  pointer-events: auto;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0% {
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.4);
  }

  70% {
    opacity: 1;
    box-shadow: 0 0 0 6px rgba(0, 255, 157, 0);
  }

  100% {
    opacity: 0.6;
  }
}

/* Leaflet Customization */
.leaflet-container {
  background: #020406 !important;
}

/* ENHANCED VISIBILITY FIX for LABELS */
.city-marker-icon {
  font-family: 'Inter', sans-serif;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible !important;
}

.city-marker-icon div:nth-child(2) {
  font-size: 14px;
  /* Big font */
  font-weight: 800;
  color: #ffffff;

  /* Strong text shadow for contrast against ANY background */
  text-shadow:
    0 0 3px #000,
    0 0 5px #000,
    0 2px 4px rgba(0, 0, 0, 1);

  /* Transparent background, text only */
  background: transparent;
  padding: 0;
  border-radius: 0;

  /* No Glassmorphism */
  backdrop-filter: none;
  border: none;

  margin-left: 8px;
  transform: translateY(-1px);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* --- NEW UI ELEMENTS --- */

.clickable {
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.clickable:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.1);
}

.profile-pill {
  cursor: pointer;
}

.blue {
  background: #00a8ff;
  box-shadow: 0 0 5px #00a8ff;
}

/* Language Grid */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.lang-option {
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  transition: all 0.2s;
}

.lang-option:hover,
.lang-option.active {
  background: var(--accent-color);
  color: #000;
  font-weight: bold;
}

/* Profile Modal */
.small-modal {
  width: 320px;
}

.profile-input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  margin-bottom: 15px;
  font-family: 'Inter', sans-serif;
}

.profile-note {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
}

/* Achievements */
.achievement-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  opacity: 0.5;
  /* Locked state */
  filter: grayscale(1);
  transition: all 0.3s;
}

.achievement-item.unlocked {
  opacity: 1;
  filter: grayscale(0);
  border-color: var(--accent-color);
  background: rgba(0, 255, 157, 0.05);
  box-shadow: 0 0 10px rgba(0, 255, 157, 0.1);
}

.ach-icon {
  font-size: 20px;
}

.ach-info {
  display: flex;
  flex-direction: column;
}

.ach-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.ach-desc {
  font-size: 10px;
  color: var(--text-dim);
}

/* Notification Banner for Achievement */
.achievement-banner {
  background: linear-gradient(90deg, #ff9d00, #ff5e00);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 5px 20px rgba(255, 94, 0, 0.4);
  animation: slideDown 0.5s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- RIPPLE ANIMATION --- */
.map-ripple {
  width: 20px;
  height: 20px;
  background: rgba(0, 255, 157, 0.4);
  border-radius: 50%;
  border: 2px solid #00ff9d;
  box-shadow: 0 0 10px #00ff9d;
  animation: rippleExpand 1.5s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleExpand {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(10);
    opacity: 0;
  }
}

/* --- LIVE FEED --- */
.live-feed-container {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
  padding-right: 5px;
}

.feed-item {
  font-size: 11px;
  padding: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 2px solid var(--accent-color);
  color: #ccc;
  animation: slideInLeft 0.3s ease-out;
}

.feed-highlight {
  color: #fff;
  font-weight: 700;
}

.feed-time {
  font-size: 9px;
  color: var(--text-dim);
  float: right;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- POST MARKER --- */
.post-marker-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  /* Let clicks pass through to region */
}

.post-marker-icon.leaflet-div-icon {
  background: transparent;
  border: none;
}

.post-marker-dot {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 5px white;
}

.leaflet-tooltip.post-tooltip {
  background: rgba(7, 12, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.leaflet-tooltip-top.post-tooltip:before {
  border-top-color: rgba(7, 12, 18, 0.92);
}

@media (max-width: 980px) {
  .ui-overlay {
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .top-bar {
    max-width: calc(100% - 10px);
    gap: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .stat-pill {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 12px;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #panel-toggle {
    position: fixed;
    right: 10px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 1200;
    width: auto;
    min-width: 0;
    overflow: visible;
  }

  .right-panel {
    left: 10px;
    right: 10px;
    top: calc(68px + env(safe-area-inset-top));
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    border-radius: 14px;
    padding: 14px;
  }

  body.panel-collapsed .right-panel {
    transform: translateY(calc(100% + 18px));
  }

  .bottom-bar {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .bottom-bar span {
    font-size: 12px;
    line-height: 1.25;
    padding: 8px 10px;
  }

  .banner-container {
    top: calc(58px + env(safe-area-inset-top));
    width: calc(100vw - 20px);
  }
}
