/* Shimon Guesser — explorer atlas aesthetic */

:root {
  --ink: #041618;
  --deep: #062a2f;
  --teal: #0d4a52;
  --mist: #c5d5d2;
  --paper: #f3efe6;
  --coral: #ff6b4a;
  --coral-soft: #ffb39a;
  --lime: #c8f542;
  --lime-deep: #8fbf1a;
  --glass: rgba(6, 42, 47, 0.72);
  --glass-border: rgba(243, 239, 230, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--paper);
  background: var(--ink);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ——— Atmosphere ——— */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 15% 10%, rgba(13, 74, 82, 0.9), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(255, 107, 74, 0.18), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(200, 245, 66, 0.05), transparent 60%),
    linear-gradient(165deg, #031012 0%, #062a2f 45%, #0a1f24 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(197, 213, 210, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(197, 213, 210, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
}

/* ——— Screens ——— */
.screen {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
}

/* ——— Title ——— */
.screen-title {
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.title-panel {
  width: min(560px, 100%);
  text-align: left;
  animation: rise-in 0.9s var(--ease) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.2rem, 10vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin: 0 0 0.35em;
  background: linear-gradient(120deg, var(--paper) 40%, var(--lime) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand span {
  display: block;
  color: var(--coral);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  font-size: 0.42em;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 0.35em;
}

.lede {
  margin: 0 0 1.75rem;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--mist);
  max-width: 34ch;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--mist);
  font-size: 0.95rem;
}

.opt-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--coral);
}

.opt-row select {
  margin-left: auto;
  background: var(--deep);
  color: var(--paper);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.95rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.25s var(--ease), background 0.25s, box-shadow 0.25s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--coral);
  color: #1a0a06;
  box-shadow: 0 12px 32px rgba(255, 107, 74, 0.35);
}

.btn-primary:hover {
  background: #ff8266;
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(243, 239, 230, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--paper);
}

.btn-secondary:hover {
  background: rgba(243, 239, 230, 0.14);
}

.btn-ghost {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--mist);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.25);
}

.btn-ghost:hover {
  color: var(--paper);
  border-color: rgba(200, 245, 66, 0.45);
  background: rgba(200, 245, 66, 0.1);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.title-meta {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: rgba(197, 213, 210, 0.55);
}

/* ——— Playing ——— */
.screen-playing {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  background: linear-gradient(180deg, rgba(4, 22, 24, 0.92), rgba(4, 22, 24, 0.55) 70%, transparent);
}

.game-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.game-brand.pulse {
  animation: brand-pulse 0.7s var(--ease);
}

@keyframes brand-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.04);
    filter: brightness(1.25);
  }
  100% {
    transform: scale(1);
  }
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.hud-item label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(197, 213, 210, 0.6);
}

.hud-item strong {
  font-size: 1rem;
  font-weight: 700;
}

#round-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(243, 239, 230, 0.2);
  transition: background 0.3s, transform 0.3s;
}

.dot.done {
  background: var(--lime);
}

.dot.current {
  background: var(--coral);
  transform: scale(1.25);
  box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.25);
}

#timer {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 107, 74, 0.12);
  border: 1px solid rgba(255, 107, 74, 0.35);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#timer.urgent {
  animation: blink 0.8s ease infinite;
  background: rgba(255, 107, 74, 0.28);
}

@keyframes blink {
  50% {
    opacity: 0.65;
  }
}

.stage {
  position: relative;
  min-height: 0;
}

.street-wrap {
  position: absolute;
  inset: 0;
  background: #000;
}

#street-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.sv-fallback {
  position: absolute;
  inset: auto 1rem 7rem;
  max-width: 360px;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  font-size: 0.9rem;
  color: var(--mist);
  z-index: 15;
}

.sv-fallback button {
  margin-top: 0.5rem;
  text-decoration: underline;
  color: var(--lime);
}

/* Map panel */
#map-panel {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 25;
  width: min(340px, calc(100vw - 2rem));
  height: min(260px, 42vh);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
  background: var(--deep);
  transition:
    width 0.35s var(--ease),
    height 0.35s var(--ease),
    border-radius 0.35s var(--ease);
  display: flex;
  flex-direction: column;
}

#map-panel.expanded {
  width: min(560px, calc(100vw - 2rem));
  height: min(480px, 62vh);
}

#map-panel .map-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: rgba(4, 22, 24, 0.92);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

#map-panel .map-toolbar p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--mist);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#guess-map {
  flex: 1;
  min-height: 0;
}

.map-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  background: rgba(4, 22, 24, 0.92);
  border-top: 1px solid var(--glass-border);
}

.map-actions .btn {
  flex: 1;
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 10px;
}

.icon-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(243, 239, 230, 0.08);
  font-size: 0.85rem;
}

.icon-btn:hover {
  background: rgba(243, 239, 230, 0.16);
}

/* Leaflet tweaks */
.leaflet-container {
  background: #0a1c20;
  font-family: var(--font-body);
}

/* ——— Reveal ——— */
.screen-reveal {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.reveal-card {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 0;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: rgba(6, 42, 47, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise-in 0.55s var(--ease) both;
}

.reveal-copy {
  padding: 1.75rem 1.6rem;
}

.reveal-rating {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  background: rgba(243, 239, 230, 0.08);
}

.reveal-rating[data-tier="gold"] {
  background: rgba(200, 245, 66, 0.18);
  color: var(--lime);
}

.reveal-rating[data-tier="good"] {
  background: rgba(255, 179, 154, 0.18);
  color: var(--coral-soft);
}

.reveal-rating[data-tier="ok"] {
  color: var(--mist);
}

.reveal-rating[data-tier="miss"] {
  color: #ff8f7a;
}

.reveal-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.1;
  margin: 0 0 0.25rem;
  letter-spacing: -0.03em;
}

.reveal-country {
  margin: 0 0 1rem;
  color: var(--coral-soft);
  font-weight: 600;
}

.reveal-hint {
  margin: 0 0 1.25rem;
  color: var(--mist);
  font-size: 0.95rem;
}

.reveal-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
}

.metric span {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(197, 213, 210, 0.55);
  margin-bottom: 0.25rem;
}

.metric strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

#reveal-points {
  color: var(--lime);
}

.reveal-map-wrap {
  min-height: 280px;
  position: relative;
}

#result-map {
  position: absolute;
  inset: 0;
}

/* ——— Summary ——— */
.screen-summary {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
}

.summary-card {
  width: min(640px, 100%);
  padding: 2rem 1.6rem;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: rgba(6, 42, 47, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise-in 0.6s var(--ease) both;
}

.summary-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
}

#final-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0.4rem 0 0.5rem;
  background: linear-gradient(120deg, var(--paper), var(--lime));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#final-blurb {
  color: var(--mist);
  margin: 0 0 1.25rem;
  max-width: 40ch;
}

.score-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(243, 239, 230, 0.1);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

#score-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--lime));
  transition: width 1s var(--ease);
}

#score-pct {
  font-size: 0.8rem;
  color: rgba(197, 213, 210, 0.65);
  margin-bottom: 1.5rem;
}

#round-breakdown {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

#round-breakdown li {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.9rem;
}

.rb-round {
  font-weight: 700;
  color: var(--coral-soft);
}

.rb-place {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rb-dist {
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

.rb-pts {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--lime);
}

.summary-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ——— Responsive ——— */
@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .reveal-card {
    grid-template-columns: 1fr;
  }

  .reveal-map-wrap {
    min-height: 220px;
  }

  #map-panel {
    width: calc(100vw - 1.5rem);
    height: 38vh;
    right: 0.75rem;
    bottom: 0.75rem;
  }

  #map-panel.expanded {
    width: calc(100vw - 1.5rem);
    height: 55vh;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .hud-stats {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
