:root {
  --lao-red: #ce1126;
  --lao-blue: #0032a0;
  --gold: #e0a326;
  --gold-light: #ffd873;
  --bg: #0e1b2b;
  --card-bg: #16283f;
  --card-glass: rgba(22, 40, 63, 0.72);
  --text: #eef3fa;
  --muted: #9fb3c8;
  --glow-gold: rgba(224, 163, 38, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% -10%, rgba(0, 50, 160, 0.25), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(224, 163, 38, 0.12), transparent 40%),
    var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* accounts for mobile browsers' collapsing address bar; 100vh alone left the footer pushed below the fold */
}

/* ---------- HUD ---------- */

#hud {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 10px 0;
  padding: 12px 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02) 45%, transparent 46%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.10), transparent 40%),
    var(--card-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  flex-wrap: wrap;
  gap: 10px;
  overflow: hidden;
}

#hud::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--lao-red), var(--gold), var(--lao-blue));
  opacity: 0.85;
}

.hud-title {
  font-size: 1.4em;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud-stats {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-bar {
  display: flex;
  gap: 2px;
}

.pip {
  font-size: 1.1em;
  color: #3a4a5c;
  transition: color .2s, text-shadow .2s;
}

.pip.filled {
  color: var(--lao-red);
  text-shadow: 0 0 6px rgba(214, 69, 69, 0.65);
}

.stat-text {
  font-size: 0.9em;
  color: var(--muted);
}

.regen-text {
  font-size: 0.8em;
  color: var(--muted);
  margin-left: 6px;
}

.progress-text {
  font-size: 0.9em;
  color: var(--muted);
}

.account-area {
  display: flex;
  align-items: center;
}

.gps-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.gps-btn:disabled:hover {
  background: transparent;
  color: var(--gold);
}

/* ---------- GPS banner ---------- */

.gps-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px;
  background: rgba(28, 51, 80, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 0.85em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gps-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s, transform .12s;
}

.gps-btn:hover {
  background: var(--gold);
  color: #0e1b2b;
  box-shadow: 0 0 14px var(--glow-gold);
  transform: translateY(-1px);
}

/* ---------- Map ---------- */

#map-wrap {
  flex: 1;
  min-height: 0; /* lets this shrink below its content size inside the column flex layout instead of overflowing the viewport */
  overflow: hidden;
  padding: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #0e1b2b;
}

.leaflet-container {
  background: #0e1b2b;
  font-family: inherit;
}

.place-divicon, .player-divicon {
  background: transparent;
  border: none;
}

.place-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* Icons sit inside a glowing gradient badge instead of floating bare
   emoji — the badge (not filter: drop-shadow on the glyph) is what
   carries depth/glow now, so it reads as a designed game icon rather
   than a raw emoji pasted on the map. */
.place-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 32% 28%, #1f3a5c, #0e1b2b 75%);
  border: 2px solid rgba(224, 163, 38, 0.3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: box-shadow .2s, transform .2s, border-color .2s;
}

.place-icon {
  font-size: 1.35em;
  line-height: 1;
}

.place-marker:hover .place-icon-badge {
  transform: scale(1.12);
  border-color: var(--gold-light);
}

.place-label {
  font-size: 0.65em;
  color: var(--muted);
  background: rgba(0,0,0,0.6);
  padding: 1px 6px;
  border-radius: 6px;
  margin-top: 4px;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-marker.visited .place-label {
  color: var(--text);
}

.place-marker.visited .place-icon-badge {
  border-color: rgba(255, 255, 255, 0.45);
}

.place-marker.in-range .place-icon-badge {
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 20px var(--glow-gold);
  transform: scale(1.08);
}

.badge {
  position: absolute;
  top: -10px;
  right: -4px;
  font-size: 1em;
  animation: bounce 1s infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.khoumsub-badge {
  filter: drop-shadow(0 0 6px var(--lvl-color, var(--gold)));
}

.energy-badge {
  filter: drop-shadow(0 0 6px #ffe066);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ---------- Player avatar ("you are here" glow dot) ---------- */

.player-marker-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.player-marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-gold), rgba(224, 163, 38, 0) 70%);
  animation: player-pulse 2.4s ease-out infinite;
}

.player-marker-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(224, 163, 38, 0.16);
}

.player-marker-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  border: 3px solid #fff;
  box-shadow: 0 0 12px rgba(224, 163, 38, 0.9), 0 2px 6px rgba(0, 0, 0, 0.45);
}

@keyframes player-pulse {
  0% { transform: scale(0.35); opacity: 0.85; }
  70% { opacity: 0.15; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ---------- Footer ---------- */

#footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 10px 10px;
  padding: 10px 22px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 45%, transparent 46%),
    var(--card-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 0.85em;
  overflow: hidden;
}

#dev-skip-btn {
  background: transparent;
  border: 1px dashed #3a4a5c;
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.85em;
  cursor: pointer;
}

#dev-skip-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(22, 40, 63, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 0.9em;
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: opacity .25s, transform .25s;
  z-index: 1500; /* above Leaflet's panes/controls (up to ~1000) */
}

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

/* ---------- Modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 20, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000; /* above Leaflet's panes/controls (up to ~1000) */
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: linear-gradient(165deg, #1a3050, var(--card-bg) 65%);
  border: 1px solid rgba(224, 163, 38, 0.45);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(224, 163, 38, 0.08);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.level-badge {
  background: var(--lvl-color, var(--gold));
  color: #0e1b2b;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.85em;
  box-shadow: 0 0 12px color-mix(in srgb, var(--lvl-color, var(--gold)) 55%, transparent);
}

.prize {
  color: var(--gold);
  font-weight: 700;
}

.modal-place {
  font-size: 0.9em;
  color: var(--muted);
  margin-bottom: 10px;
}

.modal-question {
  font-size: 1.15em;
  font-weight: 600;
  margin-bottom: 18px;
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  background: #1c3350;
  color: var(--text);
  border: 1px solid #2c4a6e;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 1em;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s, box-shadow .15s;
}

.option-btn:hover {
  background: #24406a;
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.option-btn:active {
  transform: translateY(0);
}

.win-card {
  border-color: var(--lao-red);
}

.win-emoji {
  font-size: 2.6em;
  margin-bottom: 8px;
}

.win-text {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
}

.win-link {
  display: block;
  margin: 0 auto 14px;
  padding: 10px 14px;
  max-width: 220px;
  background: var(--gold);
  color: #0e1b2b;
  font-weight: 700;
  text-decoration: none;
  border-radius: 14px;
  transition: filter .15s;
}

.win-link:hover {
  filter: brightness(1.1);
}

.bank-notice {
  background: rgba(224, 163, 38, 0.12);
  border: 1px solid var(--gold);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.88em;
  line-height: 1.4;
  margin-bottom: 14px;
  text-align: left;
}

.claim-code-box {
  background: #0e1b2b;
  border: 1px dashed #3a4a5c;
  border-radius: 14px;
  padding: 12px;
  margin: 4px 0 10px;
}

.claim-code-label {
  font-size: 0.8em;
  color: var(--muted);
  margin-bottom: 4px;
}

.claim-code {
  font-family: 'Consolas', monospace;
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--gold);
  margin-bottom: 10px;
}

.copy-code-btn {
  max-width: 180px;
  margin: 0 auto;
  padding: 6px 12px;
  font-size: 0.85em;
}

.claim-code-hint {
  font-size: 0.8em;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.auth-field {
  margin-bottom: 12px;
  text-align: left;
}

.auth-field label {
  display: block;
  font-size: 0.82em;
  color: var(--muted);
  margin-bottom: 4px;
}

.auth-field input {
  width: 100%;
  background: #0e1b2b;
  border: 1px solid #2c4a6e;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95em;
  font-family: inherit;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--gold);
}

.win-link-btn {
  display: block;
  margin: 0 auto 10px;
  max-width: 220px;
  background: var(--gold);
  color: #0e1b2b;
  border-color: var(--gold);
  font-weight: 700;
}

.win-link-btn:hover {
  filter: brightness(1.1);
}

.win-ok-btn {
  max-width: 160px;
  margin: 0 auto;
  background: var(--lao-red);
  border-color: var(--lao-red);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  #hud {
    margin: 6px 6px 0;
    padding: 8px 14px;
    border-radius: 18px;
    gap: 4px 10px;
  }
  .hud-title { font-size: 1.1em; }
  .hud-stats { gap: 4px 14px; }
  .pip { font-size: 0.9em; }
  .stat-text, .progress-text { font-size: 0.8em; }
  .regen-text { font-size: 0.72em; margin-left: 3px; }
  .account-area .gps-btn { padding: 2px 10px; font-size: 0.78em; }

  .gps-banner {
    padding: 5px 14px;
    font-size: 0.78em;
  }
  .gps-banner .gps-btn { padding: 2px 10px; font-size: 0.85em; }

  #footer {
    flex-direction: column;
    align-items: flex-start;
    margin: 0 6px 6px;
    padding: 6px 14px;
    font-size: 0.76em;
  }

  .place-label { display: none; }
}
