:root {
  --bg-deep: #081521;
  --bg-mid: #10263b;
  --panel: rgba(8, 20, 34, 0.72);
  --panel-strong: rgba(11, 27, 44, 0.9);
  --panel-border: rgba(240, 226, 192, 0.14);
  --ink: #f7f1df;
  --muted: #b6c6cf;
  --accent: #ff7f51;
  --accent-soft: rgba(255, 127, 81, 0.18);
  --mint: #4fd1b8;
  --gold: #f3c15b;
  --sea: #0d4464;
  --sea-bright: #1b6b8e;
  --land: #efd39b;
  --land-shadow: #c9954b;
  --route: rgba(242, 241, 222, 0.22);
  --shadow: 0 22px 64px rgba(3, 8, 18, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 127, 81, 0.16), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(79, 209, 184, 0.14), transparent 22%),
    linear-gradient(160deg, var(--bg-mid), var(--bg-deep) 62%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 38%, transparent 90%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

.hero h1,
.target-card h2,
.focus-card h2,
.results-card h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  line-height: 0.95;
}

.hero h1 {
  max-width: 10ch;
  font-size: clamp(2.8rem, 5vw, 5.4rem);
  letter-spacing: -0.04em;
}

.hero-copy {
  display: grid;
  gap: 12px;
}

.hero-text,
.pool-description,
.focus-hook,
.legend-card p,
.results-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

.eyebrow-small {
  margin-bottom: 10px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(243, 193, 91, 0.22);
  background: rgba(243, 193, 91, 0.08);
  color: #fde7a7;
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.panel,
.map-panel {
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 18%),
    var(--panel);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 22px;
}

.map-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.panel-title-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.tiny-note {
  color: rgba(247, 241, 223, 0.58);
  font-size: 0.74rem;
}

.control {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.control span,
.checkbox-row span {
  font-size: 0.88rem;
  color: #e7dfcb;
}

select,
.button {
  border: 0;
  border-radius: 16px;
  font: inherit;
}

select {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(15, 37, 57, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  outline: none;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 18px 0 8px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--mint);
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background: linear-gradient(135deg, #1f8f8b, var(--mint));
  color: #042229;
  box-shadow: 0 12px 28px rgba(79, 209, 184, 0.26);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.button-accent {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, #ffad53, var(--accent));
  color: #381306;
  box-shadow: 0 12px 28px rgba(255, 127, 81, 0.22);
}

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

.stat,
.legend-card,
.focus-card,
.history-card,
.cloud-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat {
  display: grid;
  gap: 6px;
}

.stat-label {
  font-size: 0.76rem;
  color: rgba(247, 241, 223, 0.62);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat strong {
  font-size: 1.8rem;
  line-height: 1;
}

.legend-card {
  margin-top: 18px;
}

.legend-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}

.legend-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #f3edd8;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.dot-answer {
  background: var(--mint);
}

.dot-guess {
  background: var(--accent);
}

.dot-mastered {
  background: var(--gold);
}

.target-card {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: end;
  padding: 10px 10px 6px;
}

.target-kicker {
  margin: 0 0 6px;
  color: #f6d27c;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
}

.target-card h2 {
  font-size: clamp(2.1rem, 4vw, 3.6rem);
}

.target-meta {
  max-width: 28ch;
  text-align: right;
}

.target-meta p {
  margin: 0;
}

#targetClue {
  color: var(--ink);
  font-weight: 500;
}

#targetMeta {
  margin-top: 6px;
  color: rgba(247, 241, 223, 0.64);
  font-size: 0.92rem;
}

.map-frame {
  position: relative;
  overflow: hidden;
  min-height: 640px;
  padding: 12px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 70% 12%, rgba(79, 209, 184, 0.18), transparent 18%),
    radial-gradient(circle at 20% 88%, rgba(255, 127, 81, 0.18), transparent 20%),
    linear-gradient(180deg, var(--sea-bright), var(--sea));
}

#map {
  display: block;
  width: 100%;
  height: 72vh;
  min-height: 640px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #dce8f0, #c9dae5);
}

.map-loading {
  position: absolute;
  inset: 12px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(10, 22, 37, 0.28), rgba(10, 22, 37, 0.48)),
    radial-gradient(circle at top, rgba(79, 209, 184, 0.18), transparent 30%);
  color: #fff4d8;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
  pointer-events: none;
}

.map-caption {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: rgba(247, 241, 223, 0.72);
  font-size: 0.78rem;
  pointer-events: none;
}

.leaflet-container {
  font-family: "Space Grotesk", sans-serif;
  background: #d9e6ef;
}

.leaflet-control-zoom a {
  background: rgba(8, 20, 34, 0.9);
  color: var(--ink);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.leaflet-control-attribution {
  background: rgba(8, 20, 34, 0.72) !important;
  color: rgba(247, 241, 223, 0.72);
}

.leaflet-control-attribution a {
  color: #ffe29a;
}

.town-label-icon {
  background: transparent;
  border: 0;
}

.map-town-label {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(7, 18, 31, 0.86);
  color: #fff5df;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 22px rgba(4, 9, 17, 0.25);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.feedback-bar {
  min-height: 58px;
  padding: 0 10px 8px;
}

.feedback-bar p {
  margin: 0;
  color: #fff2db;
  font-size: 1rem;
  line-height: 1.5;
}

.focus-card h2 {
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.focus-meta {
  margin: 8px 0 10px;
  color: #f0deb7;
}

.history-card,
.cloud-card {
  margin-top: 16px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.history-main {
  display: grid;
  gap: 2px;
}

.history-name {
  color: var(--ink);
  font-weight: 600;
}

.history-note {
  color: rgba(247, 241, 223, 0.62);
  font-size: 0.84rem;
}

.history-score {
  font-weight: 700;
  color: #ffe6b0;
}

.town-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.town-chip {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.town-chip:hover {
  transform: translateY(-1px);
}

.town-chip.is-selected {
  background: rgba(79, 209, 184, 0.2);
  border-color: rgba(79, 209, 184, 0.5);
}

.town-chip.is-mastered {
  border-color: rgba(243, 193, 91, 0.58);
  box-shadow: inset 0 0 0 1px rgba(243, 193, 91, 0.18);
}

.results-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 10, 19, 0.7);
  backdrop-filter: blur(10px);
  z-index: 5;
}

.results-card {
  width: min(480px, 100%);
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top right, rgba(255, 127, 81, 0.24), transparent 24%),
    linear-gradient(180deg, rgba(17, 43, 69, 0.96), rgba(8, 20, 34, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
}

.results-card h2 {
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 5vw, 4rem);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.map-sea-label,
.map-region-label,
.map-road-label {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-sea-label {
  fill: rgba(242, 246, 250, 0.45);
  font-size: 16px;
}

.map-region-label {
  fill: rgba(24, 41, 50, 0.58);
  font-size: 14px;
  font-weight: 700;
}

.map-road-label {
  fill: rgba(247, 241, 223, 0.6);
  font-size: 12px;
}

.route-ring,
.route-line {
  fill: none;
  stroke: var(--route);
  stroke-width: 2.5;
  stroke-dasharray: 8 10;
}

.landmass {
  fill: url(#landGradient);
  stroke: rgba(99, 52, 15, 0.45);
  stroke-width: 4;
}

.land-shadow {
  fill: rgba(64, 34, 7, 0.12);
}

.town-dot {
  stroke: rgba(4, 28, 39, 0.7);
  stroke-width: 2;
  opacity: 0.95;
}

.town-dot.is-mastered {
  stroke: rgba(243, 193, 91, 0.7);
  stroke-width: 2.6;
}

.town-dot.is-answer {
  fill: var(--mint);
  stroke: rgba(8, 44, 38, 0.92);
  stroke-width: 3;
}

.town-halo {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(247, 241, 223, 0.8);
  stroke-width: 2;
}

.answer-halo {
  fill: rgba(79, 209, 184, 0.18);
  stroke: rgba(79, 209, 184, 0.7);
  stroke-width: 3;
}

.guess-mark {
  fill: var(--accent);
  stroke: rgba(67, 16, 3, 0.9);
  stroke-width: 3;
}

.answer-mark {
  fill: var(--mint);
  stroke: rgba(4, 39, 35, 0.9);
  stroke-width: 3;
}

.answer-line {
  fill: none;
  stroke: rgba(247, 241, 223, 0.92);
  stroke-width: 3;
  stroke-dasharray: 12 10;
  animation: drift 8s linear infinite;
}

.town-label {
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  fill: #143142;
  paint-order: stroke fill;
  stroke: rgba(253, 246, 230, 0.92);
  stroke-width: 4px;
  pointer-events: none;
}

@keyframes drift {
  from {
    stroke-dashoffset: 0;
  }

  to {
    stroke-dashoffset: -44;
  }
}

@media (max-width: 1220px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .map-caption {
    flex-direction: column;
    align-items: flex-start;
  }

  .control-panel,
  .info-panel {
    order: 2;
  }

  .map-panel {
    order: 1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .hero h1 {
    max-width: 12ch;
  }

  .target-card {
    flex-direction: column;
    align-items: start;
  }

  .target-meta {
    text-align: left;
  }

  .button-row {
    flex-direction: column;
  }

  .map-frame {
    min-height: auto;
  }
}
