:root {
  color-scheme: light;
  --canvas: #f3f0e8;
  --surface: #fffcf5;
  --surface-raised: #ffffff;
  --ink: #17221f;
  --muted: #66706b;
  --faint: #929993;
  --jade: #2f6b5c;
  --jade-soft: #dceae3;
  --gold: #b98535;
  --gold-soft: #f5e8c8;
  --cinnabar: #a8493f;
  --night: #101a28;
  --night-raised: #17263c;
  --line: rgba(23, 34, 31, 0.14);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(90deg, rgba(23, 34, 31, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(23, 34, 31, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.onboarding {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.onboarding-panel {
  width: min(100%, 460px);
  min-height: min(760px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 252, 245, 0.88);
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.progress-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(23, 34, 31, 0.18);
}

.progress-dots .active {
  width: 24px;
  background: var(--jade);
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: ui-serif, "Songti SC", "STSong", Georgia, serif;
  line-height: 1.16;
}

.onboarding h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 7vw, 3rem);
}

.lead {
  color: var(--muted);
  line-height: 1.75;
}

.onboarding-visual {
  flex: 1;
  min-height: 220px;
  display: grid;
  place-items: center;
}

.steps-visual {
  grid-template-columns: 68px 1fr 68px 1fr 68px;
  gap: 10px;
}

.steps-visual span,
.steps-visual strong {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid var(--line);
  font-family: ui-serif, "Songti SC", Georgia, serif;
  font-size: 1.6rem;
}

.steps-visual i {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.watch-visual div {
  width: 180px;
  height: 230px;
  display: grid;
  place-items: center;
  border: 10px solid var(--ink);
  border-radius: 46px;
  background: var(--night);
  color: var(--surface);
  position: relative;
}

.watch-visual div::before,
.watch-visual div::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 76px;
  height: 44px;
  transform: translateX(-50%);
  background: var(--ink);
}

.watch-visual div::before {
  top: -54px;
  border-radius: 22px 22px 10px 10px;
}

.watch-visual div::after {
  bottom: -54px;
  border-radius: 10px 10px 22px 22px;
}

.watch-visual strong {
  color: var(--gold);
  font-size: 2.4rem;
}

.watch-visual span {
  position: absolute;
  top: 24px;
  font-size: 0.78rem;
  color: rgba(255, 252, 245, 0.72);
}

.notice-card,
.demo-banner,
.inline-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid rgba(47, 107, 92, 0.22);
  border-radius: 16px;
  background: var(--jade-soft);
  color: var(--ink);
  line-height: 1.45;
}

.notice-card span,
.demo-banner span {
  color: var(--muted);
}

.inline-alert {
  display: block;
  background: #fff5df;
  border-color: rgba(185, 133, 53, 0.32);
  margin: 0;
}

.inline-alert.success {
  background: var(--jade-soft);
}

.onboarding-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  font-weight: 800;
}

.primary-button {
  flex: 1;
  background: var(--ink);
  color: var(--surface);
}

.primary-button.on-dark {
  border: 1px solid var(--gold);
  background: var(--night);
  color: var(--gold-soft);
}

.primary-button:disabled {
  background: rgba(23, 34, 31, 0.08);
  color: var(--faint);
}

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(168, 73, 63, 0.28);
  background: rgba(168, 73, 63, 0.08);
  color: var(--cinnabar);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  padding-bottom: 82px;
}

.content-panel {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.side-nav {
  display: none;
}

.brand-mark,
.topbar,
.card-title-row,
.progress-label,
.settings-row,
.boundary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--ink);
  color: var(--surface);
  font-family: ui-serif, "Songti SC", Georgia, serif;
}

.brand-mark small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.topbar {
  min-height: 56px;
  margin-bottom: 12px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 1.8rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 252, 245, 0.7);
}

.demo-banner {
  margin-bottom: 14px;
}

.screen-grid {
  display: grid;
  gap: 14px;
}

.home-grid {
  align-items: start;
}

.hero-card,
.card,
.scroll-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 252, 245, 0.88);
  padding: 18px;
}

.hero-card {
  display: grid;
  gap: 16px;
  border-radius: 28px;
}

.artifact-heading {
  text-align: center;
}

.artifact-heading span {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.92rem;
}

.artifact-heading h2 {
  margin: 4px 0;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
}

.artifact-heading p,
.card p,
.result-card p,
.scroll-card p {
  color: var(--muted);
  line-height: 1.55;
}

.sword-stage {
  min-height: 260px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.aura-ring {
  width: 230px;
  height: 230px;
  border: 1px solid rgba(185, 133, 53, 0.35);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 34px rgba(185, 133, 53, 0.06),
    inset 0 0 0 74px rgba(23, 34, 31, 0.04);
  position: absolute;
}

.sword-visual {
  width: 80px;
  height: 220px;
  position: relative;
  transform: rotate(-14deg);
}

.blade {
  position: absolute;
  top: 0;
  left: 34px;
  width: 12px;
  height: 142px;
  background: linear-gradient(90deg, #d9f6f1, #ffffff 45%, #8fc9be);
  clip-path: polygon(50% 0, 100% 18%, 78% 100%, 22% 100%, 0 18%);
  box-shadow: 0 0 24px rgba(47, 107, 92, 0.22);
}

.guard {
  position: absolute;
  top: 136px;
  left: 12px;
  width: 56px;
  height: 10px;
  border-radius: 999px;
  background: var(--gold);
}

.grip {
  position: absolute;
  top: 144px;
  left: 31px;
  width: 18px;
  height: 52px;
  border-radius: 999px;
  background: repeating-linear-gradient(180deg, var(--ink), var(--ink) 8px, #31413c 8px, #31413c 15px);
}

.pommel {
  position: absolute;
  top: 194px;
  left: 26px;
  width: 28px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
}

.floaty .sword-visual {
  animation: hoverSword 4s ease-in-out infinite;
}

@keyframes hoverSword {
  0%,
  100% {
    transform: translateY(-4px) rotate(-14deg);
  }
  50% {
    transform: translateY(8px) rotate(-10deg);
  }
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-label strong {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(23, 34, 31, 0.1);
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--gold));
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.stat-row div {
  padding: 12px 10px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.stat-row div + div {
  border-left: 1px solid var(--line);
}

.stat-row span,
.quick-link span,
.settings-row span,
.boundary-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-row strong,
.quick-link strong {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.stack {
  display: grid;
  gap: 14px;
}

.status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--gold-soft);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.artifact-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.artifact-list button,
.mission-row,
.quick-link {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
}

.artifact-list button {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.artifact-list .selected,
.mission-row.selected {
  border-color: var(--gold);
  background: rgba(245, 232, 200, 0.72);
}

.artifact-list small {
  color: var(--muted);
}

.two-column-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-link {
  min-height: 88px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  text-align: left;
}

.wealth-card {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-soft);
}

.wealth-card h2 {
  margin-bottom: 4px;
  font-size: 3rem;
  font-variant-numeric: tabular-nums;
}

.pouch-visual {
  width: 110px;
  height: 110px;
  position: relative;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 50% 38%, #fff8dc 0 8px, transparent 9px), var(--jade);
  box-shadow: inset 0 -18px 0 rgba(23, 34, 31, 0.16);
}

.pouch-visual::before {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 20px;
  height: 18px;
  border-radius: 999px;
  background: var(--gold);
}

.destination-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spirit-screen {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: 28px;
  background: var(--night);
  color: var(--surface);
}

.spirit-copy p,
.disclaimer,
.empty-state {
  color: rgba(255, 252, 245, 0.76);
}

.spirit-copy h2 {
  margin-bottom: 6px;
  font-size: 2rem;
}

.formation {
  width: min(100%, 358px);
  aspect-ratio: 1;
  justify-self: center;
  position: relative;
  border-radius: 50%;
  border: 1px solid rgba(245, 232, 200, 0.2);
  box-shadow:
    inset 0 0 0 42px rgba(255, 255, 255, 0.03),
    inset 0 0 0 86px rgba(185, 133, 53, 0.08);
}

.formation::before,
.formation::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 1px dashed rgba(245, 232, 200, 0.24);
}

.formation::after {
  inset: 34%;
  border-style: solid;
}

.formation-core,
.node {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.formation-core {
  inset: calc(50% - 42px);
  width: 84px;
  height: 84px;
  background: var(--gold);
  color: var(--night);
  font-size: 1.8rem;
  font-weight: 900;
}

.node {
  width: 58px;
  height: 58px;
  background: var(--night-raised);
  color: var(--gold-soft);
  border: 1px solid rgba(245, 232, 200, 0.25);
  font-weight: 900;
}

.node.primary {
  background: var(--cinnabar);
  color: var(--surface);
}

.node-0 {
  top: 4%;
  left: calc(50% - 29px);
}

.node-1 {
  top: 32%;
  right: 4%;
}

.node-2 {
  bottom: 8%;
  right: 18%;
}

.node-3 {
  bottom: 8%;
  left: 18%;
}

.node-4 {
  top: 32%;
  left: 4%;
}

.result-card {
  background: var(--night-raised);
  border-color: rgba(245, 232, 200, 0.18);
}

.mission-layout {
  display: grid;
  place-items: start center;
}

.scroll-card {
  width: min(100%, 620px);
  position: relative;
  overflow: hidden;
}

.scroll-visual {
  height: 10px;
  margin: -4px -6px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), #f8df9d, var(--gold));
}

.mission-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.mission-row {
  min-height: 96px;
  display: grid;
  grid-template-columns: 44px 1fr 28px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  text-align: left;
}

.mission-row small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

.difficulty-badge {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-weight: 900;
}

.radio-dot {
  color: var(--gold);
  font-weight: 900;
}

.settings-layout {
  display: grid;
  gap: 14px;
}

.settings-section {
  display: grid;
  gap: 10px;
}

.settings-row {
  min-height: 58px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.settings-row:first-of-type {
  border-top: 0;
}

.settings-row small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  line-height: 1.35;
}

.settings-row input[type="number"],
.api-base-row input {
  width: min(100%, 240px);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  padding: 0 12px;
  color: var(--ink);
}

.settings-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--ink);
}

.disabled-row {
  color: var(--faint);
}

.api-base-row {
  display: grid;
  gap: 8px;
}

.api-base-row input {
  width: 100%;
}

.boundary-list {
  display: grid;
  gap: 12px;
}

.boundary-row {
  display: grid;
  justify-items: start;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.boundary-row p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 252, 245, 0.94);
  backdrop-filter: blur(14px);
}

.nav-stack button,
.bottom-nav button {
  min-height: 44px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.nav-stack button.active,
.bottom-nav button.active {
  background: var(--ink);
  color: var(--surface);
}

@media (max-width: 420px) {
  .stat-row {
    grid-template-columns: 1fr;
  }

  .stat-row div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .two-column-card,
  .destination-card,
  .wealth-card {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

@media (min-width: 860px) {
  .app-shell {
    grid-template-columns: 260px 1fr;
    padding-bottom: 0;
  }

  .side-nav {
    min-height: 100vh;
    display: block;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255, 252, 245, 0.58);
  }

  .nav-stack {
    display: grid;
    gap: 8px;
    margin-top: 28px;
  }

  .nav-stack button {
    text-align: left;
    padding: 0 14px;
  }

  .bottom-nav {
    display: none;
  }

  .content-panel {
    padding: 28px 28px 40px;
  }

  .home-grid {
    grid-template-columns: minmax(420px, 1fr) minmax(300px, 380px);
  }

  .screen-grid:not(.home-grid),
  .settings-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .spirit-screen {
    grid-template-columns: minmax(260px, 0.8fr) minmax(340px, 1fr);
    align-items: center;
  }

  .spirit-screen .result-card,
  .spirit-screen .primary-button,
  .spirit-screen .disclaimer,
  .spirit-screen .empty-state {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
