/* Geoguesser — dark theme, mobile-first.
   Palette: bg #0e1116, panel #161b23, text #e9ecf3, muted #8a93a6,
   accent (GG-ish green) #3ddc84, warn #ffb02e. */

:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel-2: #1d2430;
  --line: #262f3d;
  --text: #e9ecf3;
  --muted: #8a93a6;
  --accent: #3ddc84;
  --accent-dark: #22a35e;
  --warn: #ffb02e;
  --danger: #ff5c5c;
  --radius: 12px;
  --hud-h: 56px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ---------------- screens ---------------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ---------------- home ---------------- */

.home-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(24px, env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
}

.hero {
  text-align: center;
  padding: 34px 12px 10px;
  position: relative;
}
.hero-badge {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}
.hero-title {
  font-size: clamp(30px, 6.4vw, 52px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  background: linear-gradient(92deg, #7ef0b6, #3ddc84 45%, #ffd166);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: fall linear infinite;
}
@keyframes fall {
  0%   { transform: translateY(-20px) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(540deg); }
}

.home-head { text-align: center; margin: 26px 0 20px; }
.app-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.app-title::before { content: "🌍 "; }
.tagline {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .mode-grid { grid-template-columns: repeat(4, 1fr); }
}
.mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  font: inherit;
}
.mode:hover { transform: translateY(-2px); border-color: var(--accent-dark); background: var(--panel-2); }
.mode:active { transform: translateY(0); }
.mode-ico { font-size: 28px; line-height: 1.2; }
.mode-name { font-weight: 700; font-size: 15px; margin-top: 4px; }
.mode-desc { font-size: 11.5px; color: var(--muted); }

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
}
.switch em { color: var(--muted); font-style: normal; }
.switch input {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  flex: none;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked { background: var(--accent-dark); border-color: var(--accent-dark); }
.switch input:checked::after { transform: translateX(14px); background: #fff; }

.foot-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
}

/* ---------------- HUD (top bar) ---------------- */

.hud {
  height: var(--hud-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
  min-width: 0;
}
.hud-round { font-weight: 700; font-size: 15px; }
.hud-of { color: var(--muted); font-weight: 400; }
.hud-score { font-size: 12.5px; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); }

/* buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.1s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn.cta { background: var(--accent); color: #06210f; }
.btn.cta:hover { filter: brightness(1.08); }
.btn.cta:disabled { background: var(--panel-2); color: var(--muted); cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { padding: 8px 12px; }
.btn.big { padding: 13px 30px; font-size: 17px; border-radius: 12px; }

/* ---------------- viewer ---------------- */

.viewer {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 0;
}
#viewer, #map-container { position: absolute; inset: 0; }
.sv-embed, .map-embed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.sv-zoom {
  position: absolute;
  right: 14px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}
.sv-zoom button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.sv-zoom button:active { background: var(--panel-2); }

/* ---------------- overlays ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 18px 60px rgba(0,0,0,0.5);
}
.overlay-card h3 { font-size: 21px; margin-bottom: 8px; }
.overlay-card p { color: var(--muted); font-size: 14.5px; margin-bottom: 18px; }
.overlay-card .btn { margin-top: 4px; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.45s ease;
}
.splash.fading { opacity: 0; pointer-events: none; }
.splash-round {
  font-size: clamp(34px, 8vw, 58px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent);
  animation: splash-in 0.5s ease;
}
@keyframes splash-in {
  from { transform: scale(1.25); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------------- map ---------------- */

.map-container { flex: 1; position: relative; background: #0a0d12; min-height: 0; }

.mcq {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 22px 18px calc(26px + env(safe-area-inset-bottom));
  background: var(--bg);
  z-index: 30;
}
.mcq h3 { font-size: 19px; margin-bottom: 4px; }
.mcq h3 small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin: 6px 0 14px; }
.mcq-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) { .mcq-grid { grid-template-columns: repeat(3, 1fr); } }
.mcq-opt {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 10px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.1s ease;
}
.mcq-opt:hover { border-color: var(--accent-dark); transform: translateY(-2px); }
.mcq-opt.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

/* reveal card */
.reveal-card { padding: 30px 26px; }
.reveal-distance {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.reveal-points {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin: 4px 0 10px;
}
.reveal-actual {
  color: var(--muted);
  font-size: 14.5px;
  margin-bottom: 20px;
  min-height: 20px;
}

/* ---------------- result ---------------- */

.result-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: max(30px, env(safe-area-inset-top)) 20px calc(30px + env(safe-area-inset-bottom));
  text-align: center;
}
.result-hero h2 { font-size: 22px; color: var(--muted); font-weight: 600; }
.result-total {
  font-size: clamp(56px, 13vw, 84px);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(92deg, #7ef0b6, #3ddc84);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  margin: 6px 0 2px;
}
.result-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.result-rounds {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 26px;
  text-align: left;
}
.result-row {
  display: grid;
  grid-template-columns: 74px 1fr 74px;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.result-row .rr-name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .rr-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
}
.result-row .rr-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  width: 0;
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.result-row .rr-pts { font-weight: 700; font-size: 14px; text-align: right; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  animation: toast-in 0.2s ease;
  max-width: 86vw;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
