:root {
  --ink: #10221d;
  --muted: #65756f;
  --paper: #f6f0df;
  --paper-strong: #fff8e7;
  --moss: #314f3f;
  --pine: #13251f;
  --ember: #ff8a45;
  --gold: #e8bb56;
  --aqua: #4cb7a5;
  --danger: #b95337;
  --line: rgba(19, 37, 31, 0.16);
  --shadow: 0 26px 70px rgba(16, 34, 29, 0.18);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 138, 69, 0.24), transparent 34rem),
    radial-gradient(circle at 92% 18%, rgba(76, 183, 165, 0.22), transparent 30rem),
    linear-gradient(145deg, #f4ead0 0%, #ecdfbd 48%, #e5d0a3 100%);
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
}

button,
select,
a {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  overflow: hidden;
}

.hero {
  position: relative;
  padding: 1rem;
}

.hero::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(19, 37, 31, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 37, 31, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.topbar,
.hero-grid,
.section {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  color: var(--paper-strong);
  background: var(--pine);
  border: 2px solid rgba(255, 248, 231, 0.6);
  border-radius: 1.1rem;
  box-shadow: var(--shadow);
  font-size: 1.25rem;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  max-width: 15rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.ghost-link,
.secondary-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: rgba(255, 248, 231, 0.54);
  text-decoration: none;
}

.nav-button {
  color: var(--ink);
  cursor: pointer;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: clamp(1rem, 4vw, 4rem);
  align-items: center;
  min-height: 72vh;
  padding: 4rem 0 5rem;
}

.eyebrow,
.muted-label {
  margin: 0 0 0.45rem;
  color: var(--moss);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 12ch;
  margin-bottom: 1.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.5rem, 12vw, 8.7rem);
  letter-spacing: -0.08em;
  line-height: 0.83;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
}

h3 {
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.lead {
  max-width: 42rem;
  color: #40514b;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
}

.lead.small {
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.primary-action {
  display: inline-flex;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.15rem;
  color: var(--paper-strong);
  background: var(--pine);
  box-shadow: 0 12px 28px rgba(19, 37, 31, 0.25);
  cursor: pointer;
  text-decoration: none;
}

.primary-action.full {
  width: 100%;
  margin-top: 1rem;
}

.device-card {
  min-height: 29rem;
  border: 1px solid rgba(255, 248, 231, 0.48);
  border-radius: 2.2rem;
  padding: 1.2rem;
  color: var(--paper-strong);
  background:
    linear-gradient(160deg, rgba(19, 37, 31, 0.92), rgba(49, 79, 63, 0.84)),
    radial-gradient(circle at 70% 12%, rgba(255, 138, 69, 0.8), transparent 11rem);
  box-shadow: var(--shadow);
  transform: rotate(1.5deg);
}

.device-status,
.panel-header,
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.device-status {
  margin-bottom: 7rem;
  color: rgba(255, 248, 231, 0.78);
}

.route-line {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.route-dot {
  display: block;
  width: 2.7rem;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 248, 231, 0.22);
}

.route-dot.active {
  background: var(--ember);
}

.device-card h2 {
  margin-bottom: 0.4rem;
  font-size: 2.7rem;
}

.intel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.4rem;
}

.intel-pills span,
.freshness,
.tag {
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 248, 231, 0.15);
  font-size: 0.78rem;
}

.section {
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.section-heading {
  max-width: 52rem;
  margin-bottom: 2rem;
}

.value-grid,
.prototype-grid,
.quest-board,
.architecture-flow {
  display: grid;
  gap: 1rem;
}

.value-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.value-card,
.panel,
.map-panel,
.architecture-flow article,
.quest-card {
  border: 1px solid rgba(19, 37, 31, 0.12);
  border-radius: 1.5rem;
  padding: 1.1rem;
  background: rgba(255, 248, 231, 0.68);
  box-shadow: 0 18px 45px rgba(16, 34, 29, 0.08);
}

.card-index {
  display: inline-block;
  margin-bottom: 2.5rem;
  color: var(--ember);
  font-weight: 900;
}

.prototype-grid {
  grid-template-columns: 18rem minmax(0, 1fr) 22rem;
  align-items: stretch;
}

.profile-panel {
  background: var(--pine);
  color: var(--paper-strong);
}

.profile-panel .muted-label,
.profile-panel .stat-row span {
  color: rgba(255, 248, 231, 0.66);
}

.profile-name,
.profile-hint {
  color: rgba(255, 248, 231, 0.72);
  line-height: 1.45;
}

.profile-hint {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.avatar {
  display: grid;
  width: 4.2rem;
  height: 4.2rem;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 1.35rem;
  color: var(--pine);
  background: var(--gold);
  font-weight: 900;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 248, 231, 0.16);
  padding: 0.85rem 0;
}

.map-panel {
  min-height: 38rem;
  padding: 0;
  overflow: hidden;
}

.map-toolbar {
  padding: 1rem;
}

select {
  max-width: 12rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  background: var(--paper-strong);
}

.map-canvas {
  position: relative;
  height: calc(100% - 5.5rem);
  min-height: 31rem;
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 138, 69, 0.28), transparent 7rem),
    radial-gradient(circle at 75% 74%, rgba(76, 183, 165, 0.34), transparent 9rem),
    linear-gradient(135deg, rgba(49, 79, 63, 0.16), rgba(255, 248, 231, 0.6)),
    repeating-linear-gradient(30deg, rgba(19, 37, 31, 0.06) 0 2px, transparent 2px 22px);
}

.map-pin {
  position: absolute;
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid var(--paper-strong);
  border-radius: 50% 50% 50% 0;
  color: var(--paper-strong);
  background: var(--moss);
  box-shadow: 0 8px 20px rgba(16, 34, 29, 0.26);
  transform: translate(-50%, -50%) rotate(-45deg);
  cursor: pointer;
}

.map-pin span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  transform: rotate(45deg);
  font-size: 0.78rem;
  font-weight: 900;
}

.map-pin.event {
  background: var(--ember);
}

.map-pin.safety {
  background: var(--danger);
}

.map-pin.service {
  background: var(--aqua);
}

.map-pin.active {
  outline: 4px solid rgba(232, 187, 86, 0.45);
}

.intel-panel {
  min-height: 38rem;
}

.freshness {
  color: var(--moss);
  background: rgba(76, 183, 165, 0.18);
  font-weight: 800;
}

.intel-list {
  display: grid;
  gap: 0.75rem;
}

.intel-card {
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.44);
}

.intel-card h4 {
  margin: 0 0 0.35rem;
}

.intel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.tag {
  background: rgba(19, 37, 31, 0.08);
}

.quest-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quest-progress {
  height: 0.7rem;
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(19, 37, 31, 0.1);
}

.quest-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ember), var(--gold));
}

.architecture-flow {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.account-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 1rem;
}

.account-card {
  background: rgba(19, 37, 31, 0.9);
  color: var(--paper-strong);
}

.account-card .muted-label {
  color: rgba(255, 248, 231, 0.68);
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.account-stats div {
  border: 1px solid rgba(255, 248, 231, 0.14);
  border-radius: 1rem;
  padding: 0.85rem;
  background: rgba(255, 248, 231, 0.08);
}

.account-stats span,
.account-stats strong {
  display: block;
}

.account-stats span {
  color: rgba(255, 248, 231, 0.66);
  font-size: 0.78rem;
}

.account-stats strong {
  margin-top: 0.25rem;
  font-size: 1.35rem;
}

.badge-list {
  display: grid;
  gap: 0.7rem;
}

.badge-item {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.32);
}

.badge-item strong,
.badge-item span {
  display: block;
}

.badge-item span {
  margin: 0.2rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.badge-item.unlocked {
  border-color: rgba(232, 187, 86, 0.6);
  background: rgba(232, 187, 86, 0.18);
}

.badge-item.unlocked span {
  color: var(--moss);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(19, 37, 31, 0.58);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.auth-modal {
  position: relative;
  width: min(38rem, 100%);
  max-height: min(92vh, 54rem);
  overflow: auto;
  border: 1px solid rgba(255, 248, 231, 0.42);
  border-radius: 1.7rem;
  padding: clamp(1.2rem, 4vw, 2rem);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 138, 69, 0.2), transparent 15rem),
    var(--paper-strong);
  box-shadow: var(--shadow);
}

.auth-modal h2 {
  margin-bottom: 1rem;
  font-size: clamp(2rem, 6vw, 3.2rem);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.auth-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.2rem;
}

.auth-form.compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--moss);
  font-size: 0.86rem;
  font-weight: 800;
}

.auth-form input,
.auth-form select {
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 0.9rem;
  background: rgba(255, 255, 255, 0.76);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.4rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.auth-divider::before,
.auth-divider::after {
  flex: 1;
  height: 1px;
  content: "";
  background: var(--line);
}

.full-button {
  display: inline-flex;
  justify-content: center;
  cursor: pointer;
}

.form-message {
  min-height: 1.4rem;
  margin: 0.8rem 0 0;
  color: var(--danger);
  font-weight: 800;
}

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

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .hero-grid,
  .prototype-grid,
  .value-grid,
  .quest-board,
  .architecture-flow,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .device-card {
    transform: none;
  }

  .prototype-grid {
    align-items: start;
  }

  .intel-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
  }

  .nav-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-actions .ghost-link {
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
  }

  .hero {
    padding: 0.75rem;
  }

  .topbar,
  .hero-grid,
  .section {
    width: min(100% - 1rem, 1180px);
  }

  .hero-grid {
    min-height: auto;
    padding: 2rem 0 3rem;
  }

  h1 {
    font-size: clamp(3.2rem, 19vw, 5rem);
  }

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

  select {
    width: 100%;
    max-width: none;
  }

  .auth-form.compact {
    grid-template-columns: 1fr;
  }
}
