@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  color-scheme: light;
  --bg-deep: #071f37;
  --bg-mid: #0e365f;
  --bg-soft: #eff7ff;
  --panel: rgba(8, 31, 56, 0.7);
  --panel-strong: rgba(7, 23, 42, 0.88);
  --panel-light: rgba(255, 255, 255, 0.92);
  --line: rgba(121, 207, 231, 0.22);
  --line-strong: rgba(11, 69, 112, 0.12);
  --ink: #f5fbff;
  --ink-dark: #0e2742;
  --muted: #c0d3e6;
  --muted-dark: #5a7590;
  --accent: #49c6e5;
  --accent-deep: #1c7aa4;
  --accent-soft: rgba(73, 198, 229, 0.14);
  --signal: #d6f10c;
  --signal-soft: rgba(214, 241, 12, 0.12);
  --warning-soft: rgba(255, 144, 96, 0.14);
  --success-soft: rgba(43, 196, 154, 0.15);
  --shadow-xl: 0 28px 64px rgba(1, 10, 20, 0.34);
  --shadow-lg: 0 20px 40px rgba(3, 15, 30, 0.24);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 14%, rgba(73, 198, 229, 0.22), transparent 24%),
    radial-gradient(circle at 84% 20%, rgba(214, 241, 12, 0.12), transparent 18%),
    radial-gradient(circle at 50% 100%, rgba(73, 198, 229, 0.12), transparent 34%),
    linear-gradient(140deg, #06182c 0%, #0b3158 48%, #0f3d68 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-shell {
  width: min(1200px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 430px);
  gap: 24px;
  align-items: stretch;
}

.login-hero,
.login-card,
.brand-card,
.panel,
.map-header,
.auth-loading-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(18px);
}

.login-hero,
.brand-card,
.map-header,
.auth-loading-card {
  background:
    linear-gradient(160deg, rgba(11, 48, 84, 0.94), rgba(5, 22, 39, 0.88)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0));
}

.login-card,
.panel {
  background: var(--panel-light);
  color: var(--ink-dark);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}

.login-hero {
  min-height: 680px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(6px);
  opacity: 0.8;
}

.hero-orb-a {
  inset: 42px auto auto 30px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(73, 198, 229, 0.28), transparent 72%);
}

.hero-orb-b {
  inset: auto 20px 36px auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(214, 241, 12, 0.18), transparent 70%);
}

.login-card {
  padding: 30px 28px;
  align-self: center;
}

.brand-logo {
  width: 100%;
  max-width: 310px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
  object-fit: contain;
  box-shadow: 0 18px 34px rgba(4, 19, 33, 0.18);
}

.login-logo {
  margin-bottom: 22px;
}

.app-logo {
  max-width: 260px;
  margin-bottom: 18px;
}

.auth-loading-logo {
  max-width: 220px;
  margin-bottom: 18px;
}

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

.login-card .eyebrow,
.panel .eyebrow {
  color: var(--accent-deep);
}

h1,
h2 {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  letter-spacing: 0.01em;
}

.login-hero h1,
.brand-card h1 {
  margin: 10px 0 12px;
  font-size: clamp(3.3rem, 6vw, 5.4rem);
  line-height: 0.9;
}

.login-card h2,
.auth-loading-card h1,
.map-header h2 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.92;
}

.intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.login-card .intro,
.panel .intro,
.map-header p:last-child,
.field span,
.upload-field span,
.stat-label,
.hint,
.waypoint-meta {
  color: var(--muted-dark);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.hero-metric {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(121, 207, 231, 0.18);
}

.hero-metric strong {
  display: block;
  font-size: 1.25rem;
  color: var(--signal);
}

.hero-metric span {
  display: block;
  margin-top: 6px;
  color: rgba(245, 251, 255, 0.78);
  font-size: 0.92rem;
}

.login-form {
  display: grid;
  gap: 10px;
}

.field,
.upload-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.compact {
  margin-bottom: 0;
}

input,
select,
textarea,
button {
  border-radius: var(--radius-md);
  border: 1px solid rgba(16, 79, 124, 0.14);
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink-dark);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(73, 198, 229, 0.8);
  box-shadow: 0 0 0 4px rgba(73, 198, 229, 0.16);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

button {
  padding: 13px 16px;
  cursor: pointer;
  border-color: transparent;
  color: #07233f;
  font-weight: 700;
  background:
    linear-gradient(135deg, #d6f10c 0%, #8ef52d 100%);
  box-shadow: 0 14px 26px rgba(183, 212, 16, 0.24);
  transition: transform 150ms ease, opacity 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

button.ghost {
  background: rgba(73, 198, 229, 0.1);
  color: var(--accent-deep);
  border: 1px solid rgba(73, 198, 229, 0.2);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(73, 198, 229, 0.18);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.button-row.stacked,
.button-row.single {
  grid-template-columns: 1fr;
}

.login-actions {
  margin-top: 12px;
}

.challenge-panel {
  margin-bottom: 4px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(73, 198, 229, 0.12), rgba(73, 198, 229, 0.05));
  border: 1px solid rgba(73, 198, 229, 0.18);
}

.challenge-title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--ink-dark);
}

.auth-status {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(73, 198, 229, 0.1);
  color: #13466f;
  font-weight: 700;
}

.hint {
  margin: 12px 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.protected-page.auth-pending {
  overflow: hidden;
}

.protected-shell {
  visibility: hidden;
}

.protected-page.auth-ready .protected-shell {
  visibility: visible;
}

.auth-loading {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.protected-page.auth-pending .auth-loading {
  display: flex;
}

.auth-loading-card {
  width: min(100%, 560px);
  padding: 28px;
}

.auth-loading-card p:last-child {
  margin: 0;
  color: rgba(245, 251, 255, 0.78);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(340px, 430px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.map-area {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

.brand-card {
  padding: 24px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 1.8rem;
  line-height: 0.95;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  min-width: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(73, 198, 229, 0.08), rgba(73, 198, 229, 0.02));
  border: 1px solid rgba(73, 198, 229, 0.12);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  color: var(--ink-dark);
  font-size: 1.24rem;
}

.waypoints-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.waypoint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.waypoint-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(240, 248, 255, 0.9));
  border: 1px solid rgba(73, 198, 229, 0.12);
}

.waypoint-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-dark);
}

.remove-waypoint {
  min-width: 92px;
  padding: 10px 12px;
}

.map-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
}

.map-header-copy {
  max-width: 760px;
}

.save-indicator {
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--signal-soft);
  color: #344900;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(214, 241, 12, 0.18);
}

.map-warning {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 144, 96, 0.3);
  background: var(--warning-soft);
  color: #8f3f14;
  box-shadow: var(--shadow-lg);
}

#map {
  flex: 1 1 auto;
  min-height: 620px;
  border-radius: 30px;
  overflow: hidden;
  border: 1px solid rgba(121, 207, 231, 0.16);
  box-shadow: var(--shadow-xl);
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
}

.marker-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--signal);
  color: #062340;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 28px rgba(4, 19, 33, 0.26);
  font-size: 0.78rem;
  font-weight: 700;
}

.marker-chip.start {
  background: #49c6e5;
}

.marker-chip.finish {
  background: #0d3b66;
  color: #ffffff;
}

@media (max-width: 1100px) {
  .login-shell,
  .page-shell {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: auto;
  }

  .sidebar {
    overflow: visible;
  }

  #map {
    min-height: 500px;
  }
}

@media (max-width: 720px) {
  .login-page,
  .page-shell,
  .auth-loading {
    padding: 12px;
  }

  .login-shell {
    gap: 16px;
  }

  .login-hero,
  .login-card,
  .brand-card,
  .panel,
  .map-header,
  .auth-loading-card {
    padding: 18px;
    border-radius: 22px;
  }

  .hero-metrics,
  .stats-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

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

  #map {
    min-height: 420px;
    border-radius: 22px;
  }
}
