* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── SCREENS ── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.screen.active {
  visibility: visible;
  pointer-events: all;
  opacity: 1;
}

/* ── PERMISSION ── */
#perm-screen {
  gap: 2rem;
  text-align: center;
  padding: 2rem;
}
#perm-screen h1 {
  font-size: clamp(2.2rem, 11vw, 3.5rem);
  font-weight: 100;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.2;
}
#perm-screen p {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.9;
  max-width: 260px;
}
.note {
  font-size: 0.62rem !important;
  color: rgba(255, 255, 255, 0.18) !important;
}

/* ── BUTTON ── */
.btn {
  padding: 0.9rem 2.6rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-appearance: none;
  border-radius: 0;
}
.btn:active  { background: rgba(255, 255, 255, 0.1); }
.btn:disabled { opacity: 0.35; }

/* ── ERROR BANNER ── */
#error-banner {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px), 0.8rem);
  left: 0.8rem;
  right: 0.8rem;
  background: rgba(180, 30, 30, 0.2);
  border: 1px solid rgba(255, 60, 60, 0.4);
  color: #ff7070;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  line-height: 1.75;
  padding: 0.75rem 1rem;
  text-align: center;
  z-index: 999;
  transition: opacity 0.4s;
  opacity: 0;
  pointer-events: none;
}
#error-banner.show { opacity: 1; }

/* ── GAME SCREEN ── */
#game-screen {
  justify-content: flex-start;
  padding-top: max(env(safe-area-inset-top, 0px), 3.5rem);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 1.5rem);
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

#timer {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 1rem);
  right: 1.2rem;
  font-size: 2rem;
  font-weight: 100;
  line-height: 1;
  transition: color 0.3s;
  z-index: 10;
}
#timer.urgent { color: #ff3333; }

#dbg {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 1rem);
  left: 1rem;
  font-size: 0.55rem;
  letter-spacing: 0.07em;
  color: rgba(255, 255, 255, 0.16);
  line-height: 1.9;
  z-index: 10;
}

#city-name {
  font-size: clamp(2rem, 10.5vw, 4rem);
  font-weight: 100;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.1;
  padding: 0 1rem;
  flex-shrink: 0;
  margin-bottom: 1.8rem;
}

#ring-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

#ring {
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
  flex-shrink: 0;
}

.cardinal {
  position: absolute;
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
}
#c-n { top: 4%;  left: 50%; }
#c-s { top: 96%; left: 50%; }
#c-e { top: 50%; left: 96%; }
#c-w { top: 50%; left: 4%;  }

#ring-canvas {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
}

#mode-label {
  flex-shrink: 0;
  font-size: 0.56rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  text-align: center;
  margin-top: 1rem;
  transition: color 0.3s;
  height: 1.2em;
}
#mode-label.warn { color: rgba(255, 200, 60, 0.8); }

#tap-hint {
  flex-shrink: 0;
  font-size: 0.6rem;
  letter-spacing: 0.26em;
  color: rgba(255, 255, 255, 0.26);
  text-transform: uppercase;
  text-align: center;
  margin-top: 0.6rem;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.26; }
  50%       { opacity: 0.7;  }
}

/* ── RESULT SCREEN ── */
#result-screen {
  justify-content: flex-start;
  padding-top: max(env(safe-area-inset-top, 0px), 3rem);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 1.5rem);
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

#res-city {
  font-size: clamp(1rem, 6vw, 1.8rem);
  font-weight: 100;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

#result-ring-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}
#result-ring {
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  flex-shrink: 0;
}
#result-canvas {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
}

#res-score-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
#res-delta {
  font-size: clamp(3.5rem, 16vw, 6.5rem);
  font-weight: 100;
  letter-spacing: -0.02em;
  line-height: 1;
}
#res-unit {
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 0.15rem;
}

#res-legend {
  flex-shrink: 0;
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 1rem;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4em;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

#res-rating {
  flex-shrink: 0;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-align: center;
  margin-top: 0.6rem;
}

/* ── GLOBE SCREEN ── */
#globe-screen {
  justify-content: flex-start;
  padding-top: max(env(safe-area-inset-top, 0px), 2rem);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 1.5rem);
  gap: 0;
}

#globe-header {
  flex-shrink: 0;
  text-align: center;
  margin-bottom: 0.8rem;
}
#globe-city-label {
  font-size: clamp(1rem, 6vw, 1.8rem);
  font-weight: 100;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}
#globe-sub {
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  margin-top: 0.3rem;
}

#globe-wrapper {
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Mapbox attribution compact override */
.mapboxgl-ctrl-attrib {
  font-size: 0.5rem !important;
  opacity: 0.4;
}

/* Custom markers */
.map-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}
.map-dot.city {
  width: 13px;
  height: 13px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

#globe-hint {
  flex-shrink: 0;
  font-size: 0.6rem;
  letter-spacing: 0.26em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
  text-align: center;
  margin-top: 1rem;
  animation: pulse 2.4s ease-in-out infinite;
}

/* ── SCORE COLORS ── */
.score-perfect { color: #00ff88; }
.score-good    { color: #aaff44; }
.score-ok      { color: #ffcc00; }
.score-bad     { color: #ff8800; }
.score-miss    { color: #ff3333; }
