html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
}

/* Map */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* --- SKY + ATMOSPHERE (no visible band) --- */
#sky-overlay,
#haze-overlay {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 5;
  /* above map (0), below HUD (10) and intro (50) */
  transform: translateZ(0);
}

/* Sky: keep it near the top so there's no mid-screen “edge” */
#sky-overlay {
  top: 0;
  height: 32vh;
  /* smaller = no halfway line */
  background: linear-gradient(rgba(126, 200, 255, 0.95) 0%,
      rgba(164, 220, 255, 0.55) 55%,
      rgba(255, 255, 255, 0.00) 100%);
  opacity: 0;
  transition: opacity 220ms ease;
}

/* Atmosphere: use a vignette (radial) instead of a big vertical gradient */
#haze-overlay {
  top: 0;
  bottom: 0;
  height: auto;

  /* This creates subtle “air” without a horizontal band */
  background:
    radial-gradient(1200px 700px at 50% 18%,
      rgba(255, 255, 255, 0.26) 0%,
      rgba(255, 255, 255, 0.10) 45%,
      rgba(255, 255, 255, 0.00) 70%),
    radial-gradient(1200px 900px at 50% 120%,
      rgba(0, 0, 0, 0.10) 0%,
      rgba(0, 0, 0, 0.00) 55%);

  opacity: 0;
  transition: opacity 220ms ease;
}

body.is-3d #sky-overlay {
  opacity: 1;
}

body.is-3d #haze-overlay {
  opacity: 1;
}

/* --- Fonts & Vars --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&display=swap');

:root {
  --font-main: 'Outfit', system-ui, sans-serif;
  --color-primary: #0b1020;
  --color-accent: #ffd700;
  --color-glass: rgba(20, 25, 40, 0.65);
  --color-glass-border: rgba(255, 255, 255, 0.12);
  --blur: 12px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

body {
  font-family: var(--font-main);
  color: #fff;
}

/* --- UI Layer Layout --- */
#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Let clicks pass through to map */
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

#ui-layer>* {
  pointer-events: auto;
  /* Re-enable clicks for UI elements */
}

/* --- Glass Components --- */
.glass-panel {
  background: var(--color-glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--color-glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* --- Player Card (Top Left) --- */
.player-card {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 50px;
  margin-top: 10px;
}

.player-avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-accent);
  background: #fff;
}

.player-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-name {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.xp-bar-container {
  width: 100px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--color-accent);
  box-shadow: 0 0 10px var(--color-accent);
}

.player-stats {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  gap: 8px;
}

/* --- Control Dock (Bottom Center) --- */
.control-dock {
  align-self: center;
  display: flex;
  gap: 16px;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.icon-btn span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-btn:hover,
.icon-btn.active {
  color: #fff;
  transform: translateY(-2px);
}

.icon-btn.active svg {
  color: var(--color-accent);
  filter: drop-shadow(0 0 8px var(--color-accent));
}

/* --- Action Buttons (Bottom Right) --- */
.action-buttons {
  position: absolute;
  bottom: 32px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.circle-btn {
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.circle-btn:active {
  transform: scale(0.9);
}

.circle-btn.small {
  width: 48px;
  height: 48px;
  color: #fff;
}

.circle-btn.large {
  width: 64px;
  height: 64px;
  color: #0b1020;
}

.primary-gradient {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  border: 2px solid #fff;
}

/* --- Misc Buttons --- */
.pill-btn {
  padding: 8px 16px;
  border-radius: 99px;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}


/* Intro Screen */
.intro {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: radial-gradient(1200px 800px at 50% 30%,
      rgba(126, 200, 255, 0.65),
      rgba(10, 15, 25, 0.65));
  backdrop-filter: blur(10px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.intro-card {
  width: min(520px, 100%);
  border-radius: 22px;
  padding: 18px 18px 16px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.intro-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.intro-subtitle {
  margin-top: 6px;
  font-size: 14px;
  opacity: 0.92;
}

.intro-bullets {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.95;
}

.intro-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.intro-actions button {
  flex: 1;
  padding: 11px 12px;
  border-radius: 14px;
  font-weight: 900;
}

.intro-actions .primary {
  background: rgba(255, 255, 255, 0.92);
  color: #0b1020;
}

.intro-actions .primary:hover {
  background: rgba(255, 255, 255, 1);
}

.intro-actions .ghost {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.intro-actions .ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.intro-footnote {
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.85;
}

/* Hide intro when closed */
body:not(.intro-open) .intro {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

/* While intro is open, dim HUD slightly */
body.intro-open .hud {
  opacity: 0.65;
}

/* Player marker (simple dot + radius ring look) */
.player-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid rgba(0, 0, 0, 0.85);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  position: relative;
}

.player-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08) inset;
}

/* Discovery markers */
.discovery {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.85);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
  position: relative;
}

.discovery::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 2px;
  height: 14px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 2px;
}

.discovery.can {
  transform: scale(1.25);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.32);
}

.discovery.discovered {
  opacity: 0.35;
}

/* Popup rounding */
.mapboxgl-popup-content {
  border-radius: 14px;
}

/* --- Player Avatar (Go-like) --- */
.player {
  width: 0;
  height: 0;
  position: relative;
  transform: translateZ(0);
  pointer-events: none;
}

.player-shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 14px;
  transform: translate(-50%, -10%);
  background: rgba(0, 0, 0, 0.22);
  filter: blur(1px);
  border-radius: 999px;
}

.player-bob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  animation: playerBob 1.4s ease-in-out infinite;
}

@keyframes playerBob {

  0%,
  100% {
    transform: translate(-50%, -52%);
  }

  50% {
    transform: translate(-50%, -48%);
  }
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 18px;
  position: relative;
  background: rgba(255, 255, 255, 0.90);
  border: 2px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.28);
}

/* Simple “trainer” silhouette (stylised) */
.player-hat {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 26px;
  height: 12px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(42, 140, 255, 0.95), rgba(18, 90, 210, 0.95));
  border-radius: 10px 10px 8px 8px;
}

.player-head {
  position: absolute;
  left: 50%;
  top: 14px;
  width: 16px;
  height: 16px;
  transform: translateX(-50%);
  background: rgba(255, 220, 190, 0.95);
  border-radius: 999px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.player-body {
  position: absolute;
  left: 50%;
  top: 30px;
  width: 20px;
  height: 12px;
  transform: translateX(-50%);
  background: rgba(40, 60, 90, 0.90);
  border-radius: 10px;
}

.player-badge {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 210, 80, 0.95);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Facing / direction cone */
.player-cone {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130px;
  height: 130px;
  transform: translate(-50%, -50%) rotate(0deg);
  transform-origin: 50% 50%;
  background: conic-gradient(from 270deg,
      rgba(42, 140, 255, 0.00) 0deg,
      rgba(42, 140, 255, 0.24) 18deg,
      rgba(42, 140, 255, 0.00) 36deg,
      rgba(42, 140, 255, 0.00) 360deg);
  border-radius: 999px;
  filter: blur(0.2px);
}

/* Subtle pulse */
.player-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 2px solid rgba(42, 140, 255, 0.35);
  animation: playerPulse 1.6s ease-out infinite;
}

@keyframes playerPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.7;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
  }
}

/* ================================
   COMPASS: Go-like (custom)
   ================================ */

/* Kill Mapbox's default compass so it never shows */
.mapboxgl-ctrl-compass,
.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass {
  display: none !important;
}

/* Optional: slightly tuck the zoom buttons so they don't fight our compass */
.mapboxgl-ctrl-top-right {
  margin-top: 10px;
  margin-right: 10px;
}

/* Our compass container */
/* Our compass container */
#game-compass {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  /* above HUD */
  width: 80px;
  height: 80px;
  border-radius: 50%;
  pointer-events: none;

  /* Vintage Compass Rose Background */
  background-image: url('./assets/compass_rose.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;

  /* Remove old styles */
  background-color: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;

  display: grid;
  place-items: center;

  /* Drop shadow for the whole compass */
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

/* Remove inner bezel */
#game-compass::before {
  display: none;
}

/* Remove "N" label (it's on the image) */
#game-compass::after {
  display: none;
}

/* Needle container */
#compass-arrow {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  display: grid;
  place-items: center;
}

/* Needle Image */
#compass-arrow::before {
  content: "";
  position: absolute;
  width: 20px;
  /* Adjust based on needle aspect ratio */
  height: 70px;
  background-image: url('./assets/compass_needle.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;

  /* Remove old needle styles */
  background-color: transparent;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Remove center cap */
#compass-arrow::after {
  display: none;
}

/* Hide compass when intro is open */
body.intro-open #game-compass {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}