* {
  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: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.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; }

#version {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px), 0.8rem);
  left: 50%; transform: translateX(-50%);
  font-size: 0.6rem; letter-spacing: 0.12em;
  color: rgba(255,255,255,0.6);
  pointer-events: none; z-index: 5;
}
.hero-icon { font-size: clamp(3rem, 14vw, 5rem); line-height: 1; flex-shrink: 0; }
.game-label {
  font-size: 0.72rem; letter-spacing: 0.06em;
  color: rgba(255,255,255,0.6); text-align: center;
}

/* Pill buttons */
.btn-pill {
  width: 85%; max-width: 340px;
  padding: 1rem 2rem; border: none; border-radius: 50px;
  background: #fff; color: #000;
  font-family: inherit; font-size: 1.05rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
}
.btn-pill:active { opacity: 0.82; }
.btn-pill:disabled { opacity: 0.35; }
.btn-pill-outline {
  width: 85%; max-width: 340px;
  padding: 1rem 2rem;
  border: 1.5px solid rgba(255,255,255,0.3); border-radius: 50px;
  background: rgba(255,255,255,0.1); color: #fff;
  font-family: inherit; font-size: 1.05rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
}
.btn-pill-outline:active { background: rgba(255,255,255,0.18); }

#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.7rem; line-height: 1.75;
  padding: 0.75rem 1rem; text-align: center;
  z-index: 999; transition: opacity 0.4s; opacity: 0;
  pointer-events: none; border-radius: 10px;
}
#error-banner.show { opacity: 1; }

/* PERM SCREEN */
#perm-screen { gap: 1.5rem; text-align: center; padding: 3rem 2rem; }
#perm-screen h1 {
  font-size: clamp(2rem, 9vw, 3rem); font-weight: 700; letter-spacing: -0.03em;
}
#perm-screen p {
  font-size: 0.88rem; line-height: 1.6;
  color: rgba(255,255,255,0.7); max-width: 280px;
}

/* REVEAL SCREEN */
#reveal-screen { gap: 0.8rem; text-align: center; padding: 2rem; }
#reveal-city-name {
  font-size: clamp(2.5rem, 12vw, 4.5rem);
  font-weight: 700; letter-spacing: -0.02em; text-transform: uppercase;
}

/* GAME SCREEN */
#game-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);
  gap: 0; overflow: hidden;
}
#countdown-fill {
  position: absolute; bottom: 0; left: 0; right: 0; height: 0;
  background: linear-gradient(to top, rgba(200,50,20,0.22), rgba(255,100,40,0.04));
  pointer-events: none; z-index: 0;
  transition: height 0.85s ease-out;
}
#game-header {
  flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; gap: 0.15rem; padding: 0 1rem; z-index: 1;
}
#city-name {
  font-size: clamp(1.6rem, 8vw, 2.8rem);
  font-weight: 700; letter-spacing: -0.02em;
  text-transform: uppercase; text-align: center;
}
#compass-wrapper {
  flex: 1; width: 100%; min-height: 0;
  position: relative; z-index: 1;
}
#ring-canvas { display: block; width: 100%; height: 100%; }
#countdown-display {
  flex-shrink: 0; display: flex; align-items: baseline;
  justify-content: center; margin: 0.4rem 0 0.6rem; z-index: 1;
}
#timer {
  font-size: clamp(3rem, 15vw, 5rem); font-weight: 700;
  line-height: 1; transition: color 0.6s;
}
.timer-s {
  font-size: clamp(1.3rem, 7vw, 2rem); font-weight: 400;
  color: rgba(255,255,255,0.55); margin-left: 0.08em;
}
#dbg {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 0.5rem);
  left: 0.8rem; font-size: 0.52rem;
  color: rgba(255,255,255,0.25); font-family: monospace; z-index: 10;
}
#mode-label {
  flex-shrink: 0; font-size: 0.62rem; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.65); text-transform: uppercase;
  text-align: center; height: 1.4em; z-index: 1;
}
#mode-label.warn { color: #ffcc44; }
#guess-btn {
  margin-top: 0.3rem;
  margin-bottom: max(env(safe-area-inset-bottom, 0px), 1.2rem);
  z-index: 1;
}

/* RESULT SCREEN */
#result-screen {
  justify-content: flex-start; padding: 0; overflow: hidden;
}
#result-scroll {
  width: 100%; height: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
#result-top {
  min-height: 100dvh; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding-top: max(env(safe-area-inset-top, 0px), 2.5rem);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 1.5rem);
  padding-left: 1.5rem; padding-right: 1.5rem;
}
#res-verdict {
  font-size: clamp(2rem, 9vw, 3rem); font-weight: 700;
  letter-spacing: -0.03em; text-align: center; flex-shrink: 0;
}
#res-delta-label {
  font-size: 0.85rem; color: rgba(255,255,255,0.65);
  margin-top: 0.3rem; flex-shrink: 0;
}
#result-globe-wrapper {
  flex: 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 0.8rem 0;
}
#result-globe-canvas {
  border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 30px rgba(80,120,200,0.18), 0 0 60px rgba(80,120,200,0.08);
}
#res-bottom-row {
  flex-shrink: 0; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 0.8rem;
}
#res-score { font-size: 1.6rem; font-weight: 700; }
#res-score .pts {
  font-size: 0.9rem; font-weight: 400;
  color: rgba(255,255,255,0.6); margin-left: 0.2em;
}

/* WIKI SECTION */
#wiki-section {
  min-height: 100dvh; min-height: 100vh;
  padding: 1.5rem 1.5rem max(env(safe-area-inset-bottom, 0px), 2.5rem);
  background: #0c0c14;
  display: flex; flex-direction: column; gap: 1rem;
}
#wiki-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.2); margin: 0 auto 0.3rem; flex-shrink: 0;
}
#wiki-city-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
#wiki-tagline { font-size: 0.82rem; color: rgba(255,255,255,0.65); line-height: 1.5; }
#wiki-photos-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.4rem; border-radius: 14px; overflow: hidden;
}
#wiki-photos-grid img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  cursor: pointer; display: block; touch-action: manipulation;
}
#wiki-photos-grid img:first-child:last-child {
  grid-column: 1 / -1; aspect-ratio: 16/9;
}
#wiki-text { font-size: 0.85rem; line-height: 1.75; color: rgba(255,255,255,0.82); }
#wiki-link {
  display: inline-block; font-size: 0.7rem; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.5); text-decoration: none; padding: 0.4rem 0;
}

/* LIGHTBOX */
#lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
#lightbox.hidden { display: none; }
#lightbox-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.92); }
#lightbox-img {
  position: relative; z-index: 1;
  max-width: 95vw; max-height: 88vh;
  object-fit: contain; border-radius: 10px;
}

/* VERDICT COLORS */
.verdict-best  { color: #00e87a; }
.verdict-great { color: #aaee44; }
.verdict-ok    { color: #ffcc00; }
.verdict-bad   { color: #ff5533; }
