:root {
  --navy: #070B18;
  --deep: #0B1228;
  --blue: #2F80FF;
  --magenta: #FF2E88;
  --purple: #7A3CFF;
  --turquoise: #2EE6D6;
  --text: #E8F1FF;
  --dim: #93A0C4;
  --hud: #10182E;
  --stroke: #243056;
  --white: #ffffff;
  --phone: 420px;
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--navy);
  color: var(--text);
  overflow-x: hidden;
  max-width: 100%;
}
body { min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--turquoise);
  outline-offset: 2px;
}
svg { display: block; }

.app {
  width: 100%;
  max-width: var(--phone);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--navy);
  position: relative;
  overflow-x: hidden;
}

section[data-screen] {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--navy);
}
section[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.heading, .header h1, .dlg-title, .district-name, .mission h2, .ach h2, .guide h2, .daily-title {
  font-weight: 500;
  letter-spacing: 0.06em;
}

.splash {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  background: var(--navy);
}

.home {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}
.skyline {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.skyline svg {
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
}
.home-fade {
  position: absolute;
  left: 0;
  right: 0;
  top: 32%;
  bottom: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 11, 24, 0) 0%, rgba(7, 11, 24, 0.6) 48%, rgba(7, 11, 24, 0.95) 100%);
}
.hero {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(8px + env(safe-area-inset-top)) 20px 4px;
}
.district-name {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.15;
}
.route-line { margin: 4px 0 0; color: var(--dim); font-size: 14px; }
.xp-line { margin: 2px 0 0; color: var(--dim); font-size: 13px; }

.orb {
  border-radius: 50%;
  color: var(--white);
  font-weight: 500;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 46%, #b9d2ff 0%, #2F80FF 24%, #c43ad0 58%, #FF2E88 84%);
  box-shadow: 0 10px 26px rgba(255, 46, 136, 0.4);
}
.orb-hero {
  width: 112px;
  height: 112px;
  margin-top: 18px;
  font-size: 18px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}
.orb-nav {
  position: absolute;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 72px;
  height: 72px;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  z-index: 3;
}
.quiet-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}
.quiet {
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.04em;
  background: transparent;
}
.quiet.block {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
}

.panel {
  background: var(--hud);
  border: 1px solid var(--stroke);
  border-radius: 22px;
}
.daily {
  position: relative;
  z-index: 2;
  margin: 0 20px 10px;
  padding: 14px 16px;
}
.daily-title {
  margin: 4px 0 0;
  font-size: 16px;
}
.daily-best {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 13px;
}
.daily-state {
  margin: 2px 0 0;
  color: var(--turquoise);
  font-size: 12px;
}
.daily-state[hidden] { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 10px;
  padding: 0 18px;
  border-radius: 20px;
  background: var(--turquoise);
  color: var(--navy);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.dock {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  height: calc(64px + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--hud);
  border-top: 1px solid var(--stroke);
}
.nav-btn {
  min-width: 0;
  min-height: 44px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.nav-btn:first-child { letter-spacing: 0.04em; }
.nav-btn svg { width: 22px; height: 22px; fill: currentColor; }

.sub {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}
.header {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: calc(4px + env(safe-area-inset-top)) 16px 4px 4px;
  flex: none;
}
.back {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--text);
  flex: none;
}
.back svg { width: 24px; height: 24px; fill: currentColor; }
.header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}
.intro {
  margin: 0;
  padding: 0 20px 8px;
  color: var(--dim);
  font-size: 14px;
  flex: none;
}
.cleared { padding: 0 20px; flex: none; }
.banner {
  margin: 0;
  min-height: 36px;
  padding: 8px 20px calc(12px + env(safe-area-inset-bottom));
  color: var(--turquoise);
  font-size: 13px;
  flex: none;
}

.timeline {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 12px 12px 0;
}
.district-node {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 56px;
  background: none;
  color: inherit;
  text-align: left;
}
.district-node .bubble {
  width: 56px;
  height: 56px;
  margin-left: calc(34% - 28px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 16px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}
.district-node.locked .bubble { background: var(--stroke); color: var(--dim); }
.district-node.open .bubble,
.district-node.cleared .bubble { color: var(--navy); }
.district-node.open .bubble { background: var(--blue); }
.district-node.cleared .bubble { background: var(--turquoise); }
.district-node.open .bubble,
.district-node.cleared .bubble {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.district-node .meta {
  margin-left: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.district-node .name { font-size: 14px; font-weight: 500; color: var(--text); }
.district-node.locked .name { color: var(--dim); }
.district-node .count { font-size: 12px; color: var(--dim); }
.district-node .stem {
  position: absolute;
  left: 34%;
  top: 50%;
  width: 3px;
  height: 100%;
  background: var(--stroke);
  transform: translateX(-50%);
  z-index: 0;
}
.district-node .stem.live { background: var(--turquoise); }

.track-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}
.track-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.level-node {
  position: absolute;
  z-index: 1;
  width: 64px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: none;
  color: inherit;
  min-height: 44px;
}
.level-node .bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid var(--blue);
  background: var(--hud);
  color: var(--text);
}
.level-node.locked .bubble {
  background: var(--stroke);
  border-color: transparent;
  color: var(--dim);
}
.level-node.done .bubble {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--text);
}
.level-node.current .bubble { border-color: var(--turquoise); }
.level-node .pips {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.level-node .pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stroke);
  display: block;
}
.level-node .pips i.on { background: var(--turquoise); }

.play {
  position: relative;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--navy);
}
#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: var(--navy);
}
.hud {
  position: relative;
  z-index: 2;
  padding: calc(8px + env(safe-area-inset-top)) 12px 0 16px;
  pointer-events: none;
}
.hud-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto 44px;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.hud-pill {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  background: var(--hud);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 6px 10px;
}
.hud-pill.lives { flex: 0 0 auto; }
.hud-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.hud-pill b {
  display: block;
  margin-top: 1px;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.1;
}
.life-pips {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.life-pips i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--turquoise);
  display: block;
}
.life-pips i.off { background: var(--stroke); }
.pause {
  pointer-events: auto;
  width: 44px;
  flex: 0 0 44px;
  min-height: 44px;
  align-self: stretch;
  border-radius: 12px;
  background: var(--hud);
  border: 1px solid var(--stroke);
  color: var(--text);
  display: grid;
  place-items: center;
  flex: none;
}
.pause svg { width: 20px; height: 20px; fill: currentColor; }
.progress {
  margin-top: 8px;
  height: 6px;
  border-radius: 4px;
  background: var(--stroke);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--turquoise);
}
.progress-label {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 12px;
}
.power-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.power-row[hidden] { display: none; }
.power-row span {
  background: var(--hud);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 12px;
}
.power-row span[hidden] { display: none; }

.list, .scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
}
.mission, .ach { padding: 16px; }
.mission h2, .ach h2 {
  margin: 0;
  font-size: 16px;
}
.mission h2.done { color: var(--turquoise); }
.ach.locked { opacity: 0.72; }
.ach.locked h2 { color: var(--dim); }
.mission .detail, .ach .detail {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.mission .count {
  margin: 10px 0 0;
  font-size: 14px;
}
.bar {
  margin-top: 6px;
  height: 6px;
  border-radius: 4px;
  background: var(--stroke);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--turquoise);
  border-radius: 4px;
}
.status {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.status.ok { color: var(--turquoise); }

.records-body, .settings-body {
  padding: 0 20px calc(24px + env(safe-area-inset-bottom));
}
.stats { padding: 18px; }
.stats .kicker { margin-top: 16px; }
.stats .kicker:first-child { margin-top: 0; }
.stat {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.1;
}
.routes-cleared {
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 14px;
}
.filled {
  border: 0;
  background: var(--turquoise);
  color: var(--navy);
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 20px;
}
.filled.block {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
}
.records-body .quiet.block { margin-top: 4px; }

.toggles { padding: 8px 16px; }
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  font-size: 16px;
}
.knob {
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: #2c3348;
  flex: none;
}
.knob .ios {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.knob::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  background: var(--white);
  transition: transform 0.18s ease;
  pointer-events: none;
}
.knob:has(.ios:checked) { background: var(--turquoise); }
.knob:has(.ios:checked)::after { transform: translateX(20px); }

.tune { margin-top: 12px; padding: 16px; }
.segment {
  display: flex;
  margin-top: 10px;
  padding: 3px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
}
.segment button {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 650;
  background: transparent;
}
.segment button.on { background: #3c4258; }
.sense-label { margin-top: 16px; }
.sense-value { margin: 4px 0 0; font-size: 16px; }
.response {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 4px 0 0;
  background: transparent;
}
.response::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background:
    radial-gradient(circle, #9eeae4 1.4px, transparent 1.6px) left center / 16px 8px repeat-x,
    linear-gradient(90deg, var(--turquoise) var(--fill, 33%), #2a3148 var(--fill, 33%));
}
.response::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 26px;
  margin-top: -9px;
  border-radius: 1px;
  background: #d5deef;
}
.response::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: #2a3148;
}
.response::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--turquoise);
}
.response::-moz-range-thumb {
  width: 3px;
  height: 26px;
  border: 0;
  border-radius: 1px;
  background: #d5deef;
}

.notes { margin-top: 12px; padding: 14px 16px; }
.guide { min-height: 176px; margin-top: 8px; touch-action: pan-y; }
.guide h2 { margin: 0; font-size: 16px; }
.guide p { margin: 6px 0 0; color: var(--dim); font-size: 14px; line-height: 1.35; }
.guide-index { margin: 4px 0 0; color: var(--dim); font-size: 12px; }
.reset { margin-top: 16px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.64);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal[hidden] { display: none !important; }
.sheet {
  width: min(var(--phone), 100%);
  max-height: min(86dvh, 740px);
  overflow: auto;
  background: var(--deep);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.sheet::before {
  content: "";
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--turquoise);
  align-self: center;
}
.sheet .kicker { margin-top: 14px; }
.dlg-title {
  margin: 14px 0 0;
  font-size: 22px;
}
.dlg-title.sm { font-size: 20px; }
.center { text-align: center; }
.dlg-body {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 15px;
}
.score-xl {
  margin: 8px 0 0;
  font-size: 32px;
  font-weight: 400;
  text-align: center;
}
.sheet .dim-line {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}
.sheet .best-line, .sheet .lives-line, .sheet .district-line {
  margin: 4px 0 0;
  font-size: 14px;
  text-align: center;
}
.sheet .new-best {
  margin: 0;
  color: var(--turquoise);
  font-size: 13px;
  text-align: center;
}
.sheet .xp-line {
  margin: 8px 0 0;
  color: var(--turquoise);
  font-size: 16px;
  text-align: center;
}
.star-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.star-row svg { width: 22px; height: 22px; }
.sheet .bar { margin-top: 6px; }
.sheet .filled, .sheet .quiet {
  width: 100%;
  border-radius: 20px;
}
.sheet .filled {
  min-height: 48px;
  margin-top: 8px;
}
.sheet .filled.first { margin-top: 18px; }
.sheet .quiet { min-height: 44px; margin-top: 4px; }
.sheet .extra { margin: 8px 0 0; font-size: 14px; }

@media (max-width: 420px) {
  .district-node .bubble { width: 52px; height: 52px; margin-left: calc(34% - 26px); }
}
