:root {
  --bg-light: #f4fff0;
  --bg-dark: #0b1409;
  --panel-light: #e3f5dc;
  --panel-dark: #10240c;
  --ink-light: #0d1a0a;
  --ink-dark: #e7f6e0;
  --accent: #37ff00;
  --accent-dark: #1d8600;
  --danger: #e04646;
  --muted-light: #5f7a5a;
  --muted-dark: #a7c4a0;
  --shadow: 0 10px 30px rgba(10, 20, 10, 0.2);
  --radius: 14px;
  --pad: 12px;
  --gap: 10px;
  --header-h: 52px;
  --bottom-h: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  background: var(--bg-light);
  color: var(--ink-light);
  letter-spacing: 0.2px;
}

body.theme-dark {
  background: var(--bg-dark);
  color: var(--ink-dark);
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr); /* column fills viewport (avoids content-width collapse) */
  overflow: hidden;
}

.header {
  min-height: var(--header-h);
  padding: calc(var(--pad) + 8px + env(safe-area-inset-top)) var(--pad) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

.title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 24px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.icon-btn, .btn {
  display: inline-block;
  text-align: center;
  border: 0;
  border-radius: 12px;
  background: var(--accent-dark);
  color: #ffffff;
  padding: 10px 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: var(--shadow);
}

.icon-btn.secondary, .btn.secondary {
  background: var(--panel-light);
  color: var(--ink-light);
  box-shadow: none;
}

body.theme-dark .icon-btn.secondary,
body.theme-dark .btn.secondary {
  background: var(--panel-dark);
  color: var(--ink-dark);
}

.btn.full {
  width: 100%;
}

.btn.ghost {
  background: transparent;
  border: 2px solid var(--accent-dark);
  color: var(--accent-dark);
  box-shadow: none;
}

body.theme-dark .btn.ghost {
  color: var(--accent);
  border-color: var(--accent);
}

.main {
  padding: var(--pad) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  overflow: hidden auto; /* never scroll sideways */
}

body[data-page="home"] .main {
  overflow: hidden;
  padding-bottom: 0;
}

.map-shell {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: var(--pad) 0 calc(var(--pad) + env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.panel {
  background: var(--panel-light);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

body.theme-dark .panel {
  background: var(--panel-dark);
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow-y: auto;
  padding-bottom: var(--pad);
}

.card {
  background: var(--panel-light);
  color: inherit;
  border-radius: var(--radius);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
  text-align: left;
}

button.card {
  cursor: pointer;
}

body.theme-dark .card {
  background: var(--panel-dark);
}

.card-title {
  font-weight: 700;
  font-size: 18px;
}

.card-meta {
  font-size: 13px;
  color: var(--muted-light);
}

.card img {
  border-radius: 10px;
}

body.theme-dark .card-meta {
  color: var(--muted-dark);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: transparent;
  border: 2px solid var(--accent-dark);
  color: inherit;
  border-radius: 10px;
  padding: 10px;
}

body.theme-dark .field input,
body.theme-dark .field textarea,
body.theme-dark .field select {
  border-color: var(--accent);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

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

.tag {
  border: 2px solid var(--accent-dark);
  border-radius: 999px;
  padding: 6px 12px;
  background: transparent;
  color: inherit;
  font-weight: 700;
}

.tag.active {
  background: var(--accent-dark);
  color: #ffffff;
}

body.theme-dark .tag {
  border-color: var(--accent);
}

body.theme-dark .tag.active {
  background: var(--accent);
  color: #0b1409;
}

.row {
  display: flex;
  gap: var(--gap);
  align-items: center;
}

.row.stretch {
  align-items: stretch;
}

.row.wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.center {
  text-align: center;
}

.small {
  font-size: 12px;
  color: var(--muted-light);
}

body.theme-dark .small {
  color: var(--muted-dark);
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-light);
  font-weight: 700;
}

body.theme-dark .chip {
  background: var(--panel-dark);
}

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

.grid-links a {
  background: var(--panel-light);
  padding: 16px;
  border-radius: var(--radius);
  font-weight: 700;
}

body.theme-dark .grid-links a {
  background: var(--panel-dark);
}

.hr {
  height: 2px;
  background: var(--accent-dark);
  border-radius: 999px;
  margin: calc(var(--gap) * 2) 0;
}

body.theme-dark .hr {
  background: var(--accent);
}

.notice {
  border-left: 4px solid var(--accent-dark);
  padding-left: 10px;
}

body.theme-dark .notice {
  border-left-color: var(--accent);
}

.qr {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--pad);
  background: #ffffff;
  border-radius: var(--radius);
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

.badge {
  background: var(--accent-dark);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

body.theme-dark .badge {
  background: var(--accent);
  color: #0b1409;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent-dark);
}

body.theme-dark .slider-row input[type="range"] {
  accent-color: var(--accent);
}

.section-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

[data-profile] {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.profile-hero {
  background: var(--panel-light);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

body.theme-dark .profile-hero {
  background: var(--panel-dark);
}

.profile-hero .hero-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 40px;
  letter-spacing: 1px;
  line-height: 1;
}

.lvl-badge {
  background-color: var(--accent-dark);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.18));
  color: #ffffff;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.theme-dark .lvl-badge {
  background: var(--accent);
  color: #0b1409;
}

.xp-bar-wrap {
  width: 100%;
  max-width: 200px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

body.theme-dark .xp-bar-wrap {
  background: rgba(255, 255, 255, 0.12);
}

.xp-bar {
  height: 100%;
  background: var(--accent-dark);
  border-radius: 999px;
  transition: width 0.4s ease;
}

body.theme-dark .xp-bar {
  background: var(--accent);
}

.btn.active {
  background: var(--accent-dark);
  color: #ffffff;
}

body.theme-dark .btn.active {
  background: var(--accent);
  color: #0b1409;
}

button.chip {
  border: 0;
  color: inherit;
  cursor: pointer;
}

a.lvl-badge {
  text-decoration: none;
  display: inline-block;
}

.spot-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 28px;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.1;
}

[data-admin-section] {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.levels-list {
  display: flex;
  flex-direction: column;
}

.level-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
}

.level-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
}

.level-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--muted-light);
  background: transparent;
  flex-shrink: 0;
  transition: all 0.2s;
}

body.theme-dark .level-dot {
  border-color: var(--muted-dark);
}

.level-dot.done {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.level-dot.here {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  width: 18px;
  height: 18px;
  box-shadow: 0 0 0 4px rgba(29, 134, 0, 0.2);
}

body.theme-dark .level-dot.done,
body.theme-dark .level-dot.here {
  background: var(--accent);
  border-color: var(--accent);
}

body.theme-dark .level-dot.here {
  box-shadow: 0 0 0 4px rgba(55, 255, 0, 0.2);
}

.level-line {
  flex: 1;
  width: 2px;
  background: var(--muted-light);
  opacity: 0.25;
  margin-top: 3px;
  min-height: 12px;
}

body.theme-dark .level-line {
  background: var(--muted-dark);
}

.level-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 10px; /* uniform so every LVL badge lines up */
}

.level-row.current .level-body {
  background: var(--panel-light);
  border-radius: var(--radius);
}

body.theme-dark .level-row.current .level-body {
  background: var(--panel-dark);
}

.level-row.future .level-body {
  opacity: 0.5;
}

/* spacing for plain wrapper pages */
[data-levels-wrap],
[data-help] {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* interactive star rating widget */
.stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.stars .star {
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
  padding: 0;
  color: var(--muted-light);
  transition: color 0.15s, transform 0.1s;
}

body.theme-dark .stars .star {
  color: var(--muted-dark);
}

.stars .star.filled,
body.theme-dark .stars .star.filled {
  color: #f5b50a;
}

body.theme-dark .stars .star.filled {
  color: #ffcb2e;
}

.stars .star:active {
  transform: scale(1.2);
}

.stars.compact {
  justify-content: flex-start;
}

.stars.compact .star {
  font-size: 22px;
}

.lb-rank {
  font-family: "Bebas Neue", sans-serif;
  font-size: 20px;
  color: var(--muted-light);
  min-width: 30px;
}

body.theme-dark .lb-rank {
  color: var(--muted-dark);
}

/* stat blocks (My Stats summary) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  width: 100%;
}

.stat-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: var(--panel-light);
  border-radius: var(--radius);
}

body.theme-dark .stat-block {
  background: var(--panel-dark);
}

.stat-label {
  font-size: 12px;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.theme-dark .stat-label {
  color: var(--muted-dark);
}

.stat-num {
  font-family: "Bebas Neue", sans-serif;
  font-size: 34px;
  line-height: 1;
}

/* help page sections */
.help-section {
  scroll-margin-top: 12px;
}

.help-section .card-title {
  margin-bottom: 4px;
}

.link-user {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
}

body.theme-dark .link-user {
  color: var(--accent);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-box {
  background: var(--bg-light);
  color: var(--ink-light);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
}

body.theme-dark .modal-box {
  background: var(--panel-dark);
  color: var(--ink-dark);
}

.modal-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 24px;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.badge-dot {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: middle;
  margin-left: 6px;
}

.disabled-link {
  opacity: 0.45;
}

.author-badge {
  background: var(--ink-light);
  color: var(--bg-light);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  flex-shrink: 0;
}

body.theme-dark .author-badge {
  background: var(--ink-dark);
  color: var(--bg-dark);
}

.like-btn {
  align-self: flex-start;
  cursor: pointer;
}

.like-btn.liked {
  background-color: var(--accent-dark);
  color: #ffffff;
}

body.theme-dark .like-btn.liked {
  background-color: var(--accent);
  color: #0b1409;
}

.like-btn.disliked {
  background-color: var(--danger);
  color: #ffffff;
}

/* compact segmented buttons (spot Visitors/Comments/Favorites) */
.btn.seg {
  padding: 8px 6px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: none;
}

/* map preview title stays on one line */
[data-selected-title] {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* colored map pins */
.spot-pin {
  background: none;
  border: 0;
}

/* Apple-style user location pin (blue dot + optional heading cone) */
.user-pin { background: none; border: 0; }

.user-pin-rot {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 5px rgba(0, 0, 0, 0.4);
}

.user-cone {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid #1a73e8;
}

.spot-pin-dot {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.45), rgba(0, 0, 0, 0.2));
}

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

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.2));
}

.swatch.selected {
  border-color: var(--ink-light);
  box-shadow: 0 0 0 2px var(--accent);
}

body.theme-dark .swatch.selected {
  border-color: var(--ink-dark);
}

.swatch.locked {
  opacity: 0.25;
  cursor: default;
}

/* map pin labels */
.pin-label.leaflet-tooltip {
  background-color: var(--accent-dark);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.18));
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 2px 8px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 12px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pin-label.leaflet-tooltip::before {
  display: none;
}

@media (max-width: 480px) {
  .title {
    font-size: 22px;
  }

  .header {
    min-height: 48px;
  }

  .bottom-actions {
    grid-template-columns: 1fr 1fr;
  }
}
