:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: #17211b;
  background: #f5f7f5;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.missions-topbar {
  position: relative;
  z-index: 1000;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #dfe5e0;
}

.missions-brand {
  color: #143d26;
  font-size: 1.25rem;
  font-weight: 800;
  text-decoration: none;
}

.missions-topbar nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.missions-topbar nav a {
  color: #35433a;
  font-size: 0.95rem;
  text-decoration: none;
}

.missions-topbar nav a.active {
  color: #116530;
  font-weight: 800;
}

.missions-layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  height: calc(100vh - 64px);
  overflow: hidden;
}

.missions-panel {
  position: relative;
  z-index: 500;
  overflow-y: auto;
  padding: 24px;
  background: #f8faf8;
  border-right: 1px solid #dfe5e0;
}

.missions-panel__header {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #487358;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.mission-description {
  margin-bottom: 0;
  color: #55635a;
  line-height: 1.5;
}

.missions-panel > label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.86rem;
  font-weight: 750;
}

.missions-panel select {
  width: 100%;
  min-height: 44px;
  margin-bottom: 16px;
  padding: 9px 12px;
  color: #17211b;
  background: #fff;
  border: 1px solid #cdd7cf;
  border-radius: 10px;
}

.mission-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}

.meta-pill {
  padding: 5px 9px;
  color: #365340;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e7f2e9;
  border-radius: 999px;
}

.mission-card {
  margin-bottom: 14px;
  padding: 16px;
  background: #fff;
  border: 1px solid #dfe5e0;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgb(21 49 31 / 5%);
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 999px;
}

.status-badge--idle {
  color: #5b625e;
  background: #eef1ef;
}

.status-badge--active {
  color: #0a5524;
  background: #dff5e5;
}

.status-badge--warning {
  color: #7a4b00;
  background: #fff0cf;
}

.status-badge--complete {
  color: #fff;
  background: #116530;
}

.mission-status {
  margin-bottom: 0;
  color: #465249;
  line-height: 1.45;
}

.live-data {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.live-data > div {
  padding: 10px;
  background: #f5f8f5;
  border-radius: 10px;
}

.live-data span,
.live-data strong {
  display: block;
}

.live-data span {
  margin-bottom: 3px;
  color: #667169;
  font-size: 0.72rem;
}

.live-data strong {
  font-size: 0.88rem;
}

.checkpoint-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: checkpoint;
}

.checkpoint-item {
  counter-increment: checkpoint;
  display: grid;
  grid-template-columns: 29px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  background: #f7f9f7;
  border-radius: 10px;
}

.checkpoint-item::before {
  content: counter(checkpoint);
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  color: #42604c;
  font-size: 0.78rem;
  font-weight: 800;
  background: #e4ebe5;
  border-radius: 50%;
}

.checkpoint-item--complete::before {
  content: "✓";
  color: #fff;
  background: #188443;
}

.checkpoint-item--current {
  outline: 2px solid #74bd89;
  background: #f1faf3;
}

.checkpoint-name {
  font-size: 0.88rem;
  font-weight: 750;
}

.checkpoint-state {
  color: #68726b;
  font-size: 0.72rem;
  white-space: nowrap;
}

.reward-panel {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  color: #164026;
  background: linear-gradient(135deg, #e1f7e7, #f7fbda);
  border: 1px solid #b7dfc1;
  border-radius: 14px;
}

.reward-panel p {
  margin: 4px 0 0;
  line-height: 1.4;
}

.reward-icon {
  font-size: 2rem;
}

.mission-actions {
  display: grid;
  grid-template-columns: 1fr 0.55fr;
  gap: 9px;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: 10px;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  font-weight: 800;
  background: #116530;
  border: 1px solid #116530;
}

.secondary-button {
  color: #1f3e2a;
  font-weight: 750;
  background: #fff;
  border: 1px solid #b9c7bc;
}

.text-button {
  grid-column: 1 / -1;
  min-height: 34px;
  color: #5a655d;
  background: transparent;
  border: 0;
}

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

.prototype-tools {
  margin-top: 14px;
  padding: 12px 14px;
  color: #566159;
  font-size: 0.82rem;
  background: #eef2ef;
  border-radius: 12px;
}

.prototype-tools summary {
  color: #31493a;
  font-weight: 800;
  cursor: pointer;
}

.prototype-tools p {
  margin: 9px 0 0;
  line-height: 1.4;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
}

#debug-tools {
  margin-top: 12px;
}

.safety-note {
  margin: 14px 0 0;
  color: #6b5b32;
  font-size: 0.78rem;
  line-height: 1.4;
}

.missions-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  background: #dfe8df;
}

.mission-checkpoint-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  background: #5f6f64;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgb(0 0 0 / 28%);
}

.mission-checkpoint-icon.current {
  background: #e88d16;
}

.mission-checkpoint-icon.complete {
  background: #188443;
}

.user-location-icon {
  width: 18px;
  height: 18px;
  background: #1f6fff;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgb(31 111 255 / 55%);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .missions-topbar {
    height: auto;
    min-height: 58px;
    padding: 12px 16px;
  }

  .missions-topbar nav {
    gap: 10px;
  }

  .missions-topbar nav a {
    font-size: 0.78rem;
  }

  .missions-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 58px);
    overflow: visible;
  }

  .missions-panel {
    order: 2;
    overflow: visible;
    padding: 18px 16px 28px;
    border-top: 1px solid #dfe5e0;
    border-right: 0;
  }

  .missions-map {
    order: 1;
    min-height: 46vh;
  }

}
/* Evita que altres estils deformin les rajoles de Leaflet */
#missions-map.leaflet-container {
  position: relative;
  overflow: hidden;
}

#missions-map .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

#missions-map img {
  max-width: none;
}