:root {
  --bg: #f5f1dc;
  --card: #fffdf3;
  --ink: #163a44;
  --accent: #027c95;
  --accent-2: #00a7c8;
  --muted: #5d7680;
  --done: #1d8b5d;
  --locked: #8aaab4;
  --shadow: 0 10px 30px rgba(20, 58, 68, 0.16);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #fff8d6 0%, transparent 35%),
    radial-gradient(circle at 90% 8%, #d4f6ff 0%, transparent 30%),
    var(--bg);
}
body.night-mode {
  background:
    radial-gradient(circle at 15% 12%, #1f3144 0%, transparent 38%),
    radial-gradient(circle at 85% 10%, #2f4f62 0%, transparent 34%),
    #10202c;
  color: #e6f2f8;
}


.page {
  width: min(1200px, 94vw);
  margin: 24px auto 36px;
  display: grid;
  gap: 16px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, #0b9bb8, #0b7f97);
  color: #eaffff;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 4px 0;
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  line-height: 1;
}

.eyebrow {
  margin: 0;
  font-weight: 800;
  opacity: 0.9;
}

.subtitle { margin: 0; opacity: 0.9; }

.badge {
  white-space: nowrap;
  font-weight: 800;
  color: #0f4f5d;
  background: #d8fbff;
  padding: 10px 14px;
  border-radius: 999px;
}

.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel {
  background: var(--card);
  border: 2px solid #d6edf2;
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel h2,
.panel h3 {
  margin: 0 0 8px;
  font-family: "Baloo 2", sans-serif;
}

.hint { color: var(--muted); margin: 8px 0 0; }
.hidden { display: none !important; }

.progress-panel {
  display: grid;
  gap: 10px;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #d9edf1;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #04bf85, #10a8bf);
  transition: width 0.35s ease;
}

.map-tools {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto auto;
  align-items: center;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.route-mode-label {
  font-weight: 700;
  display: grid;
  gap: 6px;
}

.route-mode-label select {
  border: 1px solid #b7d5de;
  border-radius: 10px;
  padding: 8px 10px;
}

#routePath {
  pointer-events: none;
  transition: stroke 0.3s ease, stroke-width 0.3s ease;
}

/* SVG id-X elements clickable state */
#routeMap g[id^="id-"] {
  transition: opacity 0.3s ease, filter 0.3s ease;
}

#routeMap g[id^="id-"].is-active {
  opacity: 0.7;
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(2, 124, 149, 0.6));
}

.map-wrap {
  background: #d5eef5;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #87d2e5;
  box-shadow: var(--shadow);
}

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

.side-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 12px;
}

.side-panel fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.side-panel fieldset:disabled {
  opacity: 0.7;
}

#routeMap {
  width: 100%;
  display: block;
  height: auto;
}

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

label {
  display: grid;
  gap: 4px;
  font-weight: 700;
}

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

input, textarea {
  border: 1px solid #b7d5de;
  border-radius: 10px;
  padding: 10px;
  background: #fbfeff;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  color: var(--accent);
  background: #eefbfe;
  border: 1px solid #9edbe8;
}

.ghost-btn.is-active {
  background: #d7f7ff;
  border-color: #59bdd2;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.story-panel {
  border: 1px solid #cbe9f1;
  background: #f7fdff;
  border-radius: 12px;
  padding: 10px;
}

.story-card {
  position: relative;
  min-height: 92px;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.story-card.is-flipped {
  transform: rotateY(180deg);
}

.story-face {
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid #d3e8ef;
  backface-visibility: hidden;
  min-height: 92px;
}

.story-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.fact-list {
  margin: 8px 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.stop-video {
  width: 100%;
  height: 170px;
  border: 1px solid #c8e7ef;
  border-radius: 10px;
  background: #e8f5fa;
}

.photo-preview {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #bfe3eb;
  border-radius: 12px;
  background: #f4fdff;
}

.photo-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
}

.photo-stamp {
  position: absolute;
  right: 14px;
  top: 14px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px dashed #0f7f94;
  background: rgba(229, 252, 255, 0.9);
  font-weight: 800;
  font-size: 12px;
  color: #0f6f81;
}

#uploadStatus {
  margin-top: 10px;
  font-weight: 700;
}

.status-ok { color: #12754b; }
.status-warn { color: #9a6f00; }

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

.badge-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: #e4fbff;
  border: 1px solid #9fd8e6;
  font-weight: 700;
}

.leaderboard {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.gallery-list {
  display: grid;
  gap: 8px;
}

.gallery-card {
  padding: 10px;
  border-radius: 10px;
  background: #f4fbef;
  border: 1px solid #c8e4b7;
  font-weight: 700;
}

.story-template {
  padding: 10px;
  border: 1px dashed #70b8c8;
  border-radius: 10px;
  background: #f2fcff;
}

.building {
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(36, 38, 40, 0.22));
}

.toast-root {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
  z-index: 9999;
}

.toast {
  color: #103943;
  background: #e4fbff;
  border: 1px solid #8fd5e4;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.ok {
  background: #e8fff1;
  border-color: #9bdcb8;
}

.toast.warn {
  background: #fff8df;
  border-color: #e8cc7c;
}

.stop-dot { cursor: pointer; }
.stop-label {
  fill: white;
  font-size: 22px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.stop-title {
  fill: #0f4f5d;
  font-size: 16px;
  font-family: "Baloo 2", sans-serif;
  pointer-events: none;
}

.stop-dot.is-hidden { display: none; }
.native-stop.is-hidden { display: none !important; }
.stop-locked circle { fill: var(--locked); }
.stop-next circle {
  fill: #12b8d4;
  animation: pulse 1.7s ease-in-out infinite;
}
.stop-done circle { fill: var(--done); }

.native-stop-locked {
  opacity: 0.45;
}

.native-stop-next {
  filter: drop-shadow(0 0 10px rgba(18, 184, 212, 0.85));
  animation: pulse 1.7s ease-in-out infinite;
}

.native-stop-done {
  filter: saturate(1.15) brightness(1.05);
}

@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(18, 184, 212, 0.1)); }
  50% { filter: drop-shadow(0 0 10px rgba(18, 184, 212, 0.9)); }
}

.onboarding {
  position: fixed;
  inset: 0;
  background: rgba(9, 42, 49, 0.55);
  display: grid;
  place-items: center;
  z-index: 12000;
}

.onboarding-card {
  width: min(540px, 96vw);
  background: #fffef8;
  border: 2px solid #cbe7ee;
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.onboarding-card h2 {
  margin: 4px 0 8px;
  font-family: "Baloo 2", sans-serif;
}

.onboarding-steps {
  display: grid;
  gap: 6px;
  margin: 10px 0 12px;
}

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

  .side-panel {
    position: static;
  }

  .map-tools {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
