*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  background: #1a1a2e;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Top bar ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a1a2e;
  color: #fff;
  z-index: 1000;
  flex-shrink: 0;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #e94560;
  white-space: nowrap;
  user-select: none;
}

/* ── Color palette ── */
#palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  max-width: calc(100vw - 120px);
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
  flex-shrink: 0;
}

.swatch:hover {
  transform: scale(1.25);
  z-index: 1;
}

.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 1px #fff;
  transform: scale(1.2);
}

/* ── Map ── */
#map {
  flex: 1;
  cursor: crosshair;
}

/* ── Pixel-art position pin ── */
.pixel-pin-wrapper {
  background: none !important;
  border: none !important;
}

.pixel-pin {
  position: relative;
  width: 20px;
  height: 20px;
}

.pixel-pin-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: #e94560;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
}

.pixel-pin-dot::before,
.pixel-pin-dot::after {
  content: '';
  position: absolute;
  background: #e94560;
}

.pixel-pin-dot::before {
  width: 4px;
  height: 4px;
  top: -4px;
  left: 2px;
}

.pixel-pin-dot::after {
  width: 4px;
  height: 4px;
  bottom: -4px;
  left: 2px;
}

.pixel-pin-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border: 2px solid #e94560;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.6;
  }
  75%, 100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* ── Locate button ── */
#locate-btn {
  position: absolute;
  right: 12px;
  bottom: 120px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  background: #1a1a2e;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

#locate-btn:hover {
  border-color: #e94560;
  background: #22223a;
}

#locate-btn.locating {
  pointer-events: none;
  opacity: 0.5;
}

.locate-icon {
  width: 16px;
  height: 16px;
  position: relative;
}

.locate-icon::before,
.locate-icon::after {
  content: '';
  position: absolute;
  background: #fff;
}

.locate-icon::before {
  width: 2px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

.locate-icon::after {
  width: 100%;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.locate-icon-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: #e94560;
  transform: translate(-50%, -50%);
}

/* ── Loading overlay ── */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  z-index: 3000;
  transition: opacity 0.4s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Welcome screen ── */
#welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 20rem;
  padding: 0 1.5rem;
}

#welcome.hidden {
  display: none;
}

#welcome-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.4rem;
  color: #e94560;
  margin-bottom: 1.5rem;
}

#welcome-text {
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  line-height: 1.6;
  letter-spacing: 0.3px;
  margin-bottom: 2rem;
}

#welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

#btn-enable-geo {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.2s ease;
}

#btn-enable-geo:hover {
  background: #d63851;
}

#btn-skip-geo {
  background: transparent;
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

#btn-skip-geo:hover {
  border-color: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.7);
}

/* ── Spinner screen ── */
#loading-spinner-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#loading-spinner-screen.hidden {
  display: none;
}

#loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  margin-top: 16px;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  letter-spacing: 1px;
}

#loading-slow-hint {
  margin-top: 10px;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  letter-spacing: 0.3px;
  transition: opacity 0.3s ease;
}

/* ── Location banner ── */
#location-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(233, 69, 96, 0.15);
  border-top: 1px solid rgba(233, 69, 96, 0.3);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  letter-spacing: 0.3px;
  line-height: 1.4;
  z-index: 1500;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

#location-banner.visible {
  transform: translateY(0);
}

.banner-text {
  flex: 1;
  padding-right: 12px;
}

.banner-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.banner-close:hover {
  color: #fff;
}

/* ── Toast notification ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,50,0.92);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2000;
  white-space: nowrap;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
  #topbar {
    padding: 6px 10px;
  }
  #logo {
    font-size: 15px;
    letter-spacing: 2px;
  }
  .swatch {
    width: 22px;
    height: 22px;
  }
  #locate-btn {
    bottom: 100px;
    width: 32px;
    height: 32px;
  }
  #location-banner {
    font-size: 11px;
    padding: 8px 10px;
  }
}
