:root {
  --bg: #07090d;
  --panel: rgba(12, 16, 22, 0.86);
  --panel-strong: rgba(8, 11, 16, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f6f1e8;
  --muted: #b6afa3;
  --green: #55d17e;
  --green-dark: #21864f;
  --gold: #d7b35b;
  --danger: #e06464;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

.screen.active {
  display: flex;
}

.home-screen,
.final-screen {
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

.home-bg,
.final-bg {
  position: absolute;
  inset: 0;
  background: #111 center / cover no-repeat;
  transform: scale(1.02);
  transition: opacity 300ms ease;
}

.home-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4, 6, 9, 0.84), rgba(4, 6, 9, 0.46) 48%, rgba(4, 6, 9, 0.76)),
    linear-gradient(0deg, rgba(4, 6, 9, 0.88), rgba(4, 6, 9, 0.08) 42%, rgba(4, 6, 9, 0.72));
}

.home-top {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 2;
  display: flex;
  gap: 10px;
}

.home-content,
.final-content {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100vw - 36px));
  padding: 92px 0 56px;
}

.home-content h1 {
  margin: 0;
  font-size: clamp(3.8rem, 10vw, 8.8rem);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0;
}

.final-content h2 {
  margin: 6px 0 12px;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--green);
  text-transform: uppercase;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.tagline,
.final-content p {
  max-width: 520px;
  margin: 18px 0 28px;
  color: var(--text);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.35;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 26px;
}

.expedition-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.expedition-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.expedition-filters select {
  min-width: 180px;
  min-height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(4, 6, 9, 0.78);
  font: inherit;
}

.primary-button,
.secondary-button,
.ghost-button,
.hint-button,
.icon-button,
.mode-pill {
  min-height: 44px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-button {
  padding: 14px 22px;
  border-color: rgba(85, 209, 126, 0.7);
  background: linear-gradient(180deg, #66df8a, #2a9b5d);
  color: #06100a;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(55, 190, 105, 0.22);
}

.secondary-button,
.ghost-button,
.hint-button,
.icon-button,
.mode-pill {
  padding: 12px 16px;
  font-weight: 750;
}

.ghost-button {
  background: rgba(3, 5, 8, 0.48);
  backdrop-filter: blur(10px);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.hint-button:hover,
.icon-button:hover,
.mode-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.32);
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.hint-button:active,
.icon-button:active,
.mode-pill:active {
  transform: translateY(1px) scale(0.99);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.hint-button:focus-visible,
.icon-button:focus-visible,
.mode-pill:focus-visible {
  outline: 3px solid rgba(85, 209, 126, 0.48);
  outline-offset: 3px;
}

.primary-button:disabled,
.hint-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.mode-pill {
  min-height: 38px;
  padding: 8px 13px;
  color: var(--muted);
}

.mode-pill.selected {
  color: #06100a;
  border-color: transparent;
  background: var(--gold);
}

.play-screen {
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 0%, rgba(34, 54, 72, 0.54), transparent 34%),
    linear-gradient(180deg, #06080c, #0a0d12 58%, #05070a);
}

.hud {
  height: 70px;
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  z-index: 3;
}

.hud div {
  display: flex;
  gap: 16px;
  align-items: center;
}

.hud .hud-score {
  display: flex;
  align-items: center;
  gap: 14px;
}

.timer-label {
  min-width: 58px;
  padding: 7px 10px;
  border: 1px solid rgba(85, 209, 126, 0.55);
  color: var(--green);
  text-align: center;
}

.timer-label.urgent {
  border-color: rgba(224, 100, 100, 0.7);
  color: #ff8989;
  animation: timer-pulse 700ms ease infinite alternate;
}

@keyframes timer-pulse {
  to { transform: scale(1.05); }
}

#modeLabel {
  color: var(--muted);
}

#scoreLabel {
  color: var(--gold);
  font-size: 1.1rem;
}

.viewer-wrap {
  position: relative;
  width: min(1480px, calc(100vw - 32px));
  height: min(76vh, calc(100vh - 166px));
  min-height: 430px;
  margin: 0 auto;
}

.image-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #111820;
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.image-stage.expanded {
  position: fixed;
  inset: 16px;
  z-index: 20;
  height: auto;
}

.image-stage.dragging {
  cursor: grabbing;
}

.image-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  transition: opacity 260ms ease, filter 300ms ease;
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

.image-stage.concealed img {
  filter: blur(3px) saturate(0.88);
}

.stage-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.24), transparent 16%, transparent 84%, rgba(0, 0, 0, 0.24)),
    radial-gradient(circle at center, transparent 52%, rgba(0, 0, 0, 0.38));
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: linear-gradient(110deg, #10151d, #19222e, #10151d);
  background-size: 260% 100%;
  animation: shimmer 1.4s ease infinite;
  font-weight: 800;
}

.loading.hidden {
  display: none;
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.viewer-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.photo-dock {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-dock > span {
  min-width: 94px;
  padding: 11px 12px;
  color: var(--muted);
  background: rgba(3, 5, 8, 0.72);
  backdrop-filter: blur(12px);
  font-size: 0.78rem;
  font-weight: 800;
}

.reveal-button {
  background: rgba(3, 5, 8, 0.72);
  backdrop-filter: blur(12px);
}

.icon-button {
  min-width: 44px;
  background: rgba(3, 5, 8, 0.66);
  backdrop-filter: blur(12px);
}

.guess-bar {
  position: relative;
  min-height: 96px;
  padding: 18px 26px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.country-choices {
  position: absolute;
  left: 50%;
  bottom: 82px;
  z-index: 8;
  width: min(620px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 10, 15, 0.95);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.country-choices button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.country-choices button.correct {
  border-color: var(--green);
  background: rgba(85, 209, 126, 0.2);
}

.country-choices button.wrong {
  border-color: var(--danger);
  background: rgba(224, 100, 100, 0.2);
}

.hint-area {
  position: absolute;
  left: 26px;
  display: flex;
  gap: 8px;
}

.hint-button {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.guess-button {
  min-width: min(330px, 90vw);
  min-height: 56px;
}

.map-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(3, 5, 8, 0.78);
  backdrop-filter: blur(14px);
  padding: 22px;
}

.map-overlay.open {
  display: grid;
  place-items: center;
}

.map-shell {
  width: min(1180px, 100%);
  height: min(780px, calc(100vh - 44px));
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.map-head,
.map-action {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.map-action {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.map-head span,
.map-action span {
  color: var(--muted);
}

.map-head strong {
  display: block;
  margin-top: 2px;
  font-size: 1.25rem;
}

.map-surface,
.result-map {
  min-height: 300px;
  background: #121820;
}

.fallback-map {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    #101720;
  background-size: 10% 10%;
  cursor: crosshair;
}

.fallback-map::before {
  content: "";
  position: absolute;
  inset: 8% 4%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  clip-path: polygon(8% 28%, 20% 18%, 33% 25%, 45% 16%, 58% 24%, 75% 17%, 93% 31%, 86% 55%, 70% 50%, 60% 65%, 45% 56%, 29% 68%, 13% 56%);
  background: rgba(85, 209, 126, 0.08);
}

.fallback-pin {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -100%);
  border: 3px solid #fff;
  background: var(--green);
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.fallback-pin.guess {
  background: #f7f2e8;
}

.fallback-pin.actual {
  background: var(--green);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  rotate: 0deg;
}

.fallback-line {
  position: absolute;
  height: 2px;
  background: rgba(215, 179, 91, 0.9);
  transform-origin: 0 50%;
}

.leaflet-container {
  background: #111820;
  font: inherit;
}

.leaflet-control-attribution {
  background: rgba(8, 11, 16, 0.8) !important;
  color: #c7c0b6 !important;
}

.leaflet-control-attribution a {
  color: #cfe8d8 !important;
}

.custom-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #07100a;
  font-weight: 900;
  border: 3px solid #07100a;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.36);
}

.guess-marker {
  border-radius: 50% 50% 50% 0;
  background: #f7f2e8;
  transform: rotate(-45deg);
}

.guess-marker span {
  transform: rotate(45deg);
}

.actual-marker {
  background: var(--green);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.result-screen {
  min-height: 100vh;
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  background: #06080c;
}

.result-screen.active {
  display: grid;
}

.result-map {
  min-height: 100vh;
}

.result-panel {
  align-self: stretch;
  padding: 34px;
  background: rgba(7, 10, 15, 0.95);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-panel h2 {
  margin: 0 0 26px;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 0.98;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 26px;
}

.metric-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  font-weight: 850;
}

.metric-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--gold);
  font-size: 1.4rem;
}

.clue-list h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
}

.clue-list ul {
  margin: 0 0 26px;
  padding-left: 20px;
  line-height: 1.5;
}

.round-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 680px;
  margin-top: 22px;
}

.round-chip {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 850;
}

.journey-recap {
  display: grid;
  gap: 8px;
  width: min(720px, 100%);
  margin-top: 18px;
}

.recap-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 28px 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--line);
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(10px);
}

.recap-row img {
  width: 84px;
  height: 50px;
  object-fit: cover;
}

.recap-row div {
  min-width: 0;
}

.recap-row strong,
.recap-row span {
  display: block;
}

.recap-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.recap-row b {
  color: var(--gold);
}

.recap-rank {
  color: var(--muted) !important;
  text-align: center;
  font-weight: 900;
}

.info-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  color: var(--text);
  background: #0a0e14;
  box-shadow: var(--shadow);
  padding: 26px;
}

.info-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.close-dialog {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.credits-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.credit-item {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.credit-item a {
  color: #9fe5b5;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.stat-grid span {
  color: var(--muted);
  display: block;
}

.stat-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

@media (max-width: 820px) {
  .home-top {
    left: 14px;
    right: 14px;
    justify-content: flex-end;
  }

  .home-content,
  .final-content {
    padding-top: 118px;
  }

  .hud {
    height: auto;
    padding: 14px;
    gap: 10px;
    align-items: flex-start;
  }

  .hud div {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .viewer-wrap {
    width: 100vw;
    height: calc(100vh - 186px);
    min-height: 360px;
  }

  .photo-dock {
    right: 10px;
    left: 10px;
    bottom: 66px;
    flex-wrap: wrap;
  }

  .photo-dock > span {
    min-width: 82px;
  }

  .reveal-button {
    flex: 1;
  }

  .guess-bar {
    min-height: 128px;
    padding: 12px 14px 18px;
    flex-direction: column;
  }

  .country-choices {
    bottom: 116px;
  }

  .hint-area {
    position: static;
    width: 100%;
    justify-content: center;
  }

  .guess-button,
  .guess-bar .primary-button {
    width: 100%;
  }

  .map-overlay {
    padding: 0;
  }

  .map-shell {
    width: 100%;
    height: 100%;
    border: 0;
  }

  .map-action {
    align-items: stretch;
    flex-direction: column;
  }

  .map-action .primary-button {
    width: 100%;
  }

  .result-screen.active {
    display: flex;
    flex-direction: column;
  }

  .result-map {
    min-height: 48vh;
  }

  .result-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 24px 18px;
  }

  .metric-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .recap-row {
    grid-template-columns: 24px 64px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .recap-row img {
    width: 64px;
    height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
