:root {
  --ink: #17201b;
  --muted: #637067;
  --paper: #f6f2e8;
  --surface: #fffaf0;
  --line: #d8cfbd;
  --green: #1f7a5c;
  --green-dark: #13523e;
  --coral: #d95d43;
  --gold: #c9952f;
  --blue: #406f9f;
  --shadow: 0 18px 60px rgba(23, 32, 27, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

main {
  position: relative;
  height: 100svh;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition:
    opacity 240ms ease,
    transform 240ms ease;
}

.page.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

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

button,
input {
  font: inherit;
}

input {
  min-width: 0;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 54px);
  background: rgba(246, 242, 232, 0.78);
  border-bottom: 1px solid rgba(216, 207, 189, 0.8);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(31, 122, 92, 0.26);
}

.nav-links {
  display: flex;
  gap: clamp(14px, 3vw, 34px);
  color: var(--muted);
  font-size: 0.94rem;
}

.nav-links a:hover {
  color: var(--green-dark);
}

.nav-action {
  padding: 10px 16px;
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--green-dark);
  font-weight: 700;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.user-pill[hidden] {
  display: none;
}

.user-pill span {
  display: grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: var(--green);
  color: white;
  font-size: 0.78rem;
  font-weight: 860;
}

.user-pill strong {
  font-size: 0.9rem;
}

.auth-section {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 110px 20px 34px;
}

.auth-card {
  width: min(470px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 10px;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.98;
}

.auth-card p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.auth-form label,
.avatar-group legend {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 760;
}

.auth-form input[type="email"],
.auth-form input[type="text"],
.auth-form input[inputmode="numeric"] {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

.avatar-group {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.avatar-group legend {
  grid-column: 1 / -1;
}

.avatar-group input {
  position: absolute;
  opacity: 0;
}

.avatar-group span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 860;
}

.avatar-group input:checked + span {
  border-color: var(--green);
  background: #e7eee7;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px var(--green);
}

.hero {
  position: relative;
  display: grid;
  min-height: 100svh;
  align-items: center;
  overflow: hidden;
  padding: 118px clamp(20px, 6vw, 82px) 96px;
  isolation: isolate;
}

#heroCanvas {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  background: #f3eddf;
}

.hero::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(246, 242, 232, 0.98) 0%, rgba(246, 242, 232, 0.74) 46%, rgba(246, 242, 232, 0.24) 100%),
    linear-gradient(0deg, rgba(246, 242, 232, 0.96) 0%, rgba(246, 242, 232, 0) 34%);
}

.hero-content {
  max-width: 760px;
}

h1,
h2,
h3,
p {
  text-wrap: balance;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(3.05rem, 7.2vw, 6.8rem);
  line-height: 0.91;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 620px;
  margin: 28px 0 0;
  color: #405046;
  font-size: clamp(1.08rem, 2vw, 1.34rem);
  line-height: 1.56;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 20px;
  font-weight: 760;
}

.button.primary {
  background: var(--green);
  color: white;
  box-shadow: 0 14px 34px rgba(31, 122, 92, 0.24);
}

.page-jump {
  min-width: 220px;
}

.button.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.68);
}

.builder-section,
.plan-section {
  display: grid;
  min-height: 100svh;
  align-content: center;
  padding: 88px clamp(20px, 6vw, 82px) 26px;
  overflow: auto;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 18px;
}

h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3.1vw, 2.9rem);
  line-height: 1;
  letter-spacing: 0;
}

.builder {
  display: grid;
  grid-template-columns: minmax(280px, 0.76fr) minmax(320px, 1.24fr);
  gap: 22px;
  align-items: start;
}

.status-panel,
.map-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(23, 32, 27, 0.08);
}

.status-panel {
  width: min(980px, 100%);
}

.builder-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.builder-form label,
.builder-form legend {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 760;
}

.diagnosis {
  display: grid;
  gap: 9px;
}

.choice-group {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.choice-row label {
  display: block;
  min-width: 0;
}

.choice-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-row span {
  display: grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 760;
  text-align: center;
  cursor: pointer;
}

.choice-row input:checked + span {
  border-color: var(--green);
  background: #e7eee7;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px var(--green);
}

.choice-row input:focus-visible + span {
  outline: 3px solid rgba(31, 122, 92, 0.28);
  outline-offset: 2px;
}

.pace-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.pace-control legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.pace-control label {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.pace-control input {
  accent-color: var(--green);
}

.step-actions {
  display: grid;
  grid-template-columns: 0.42fr 0.58fr;
  gap: 10px;
  margin-top: 4px;
}

.step-button {
  width: 100%;
  border: 0;
  cursor: pointer;
}

.map-board {
  grid-column: 1 / -1;
  min-height: 0;
  overflow: hidden;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.map-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 760;
}

.map-header strong {
  text-align: right;
}

.state-summary {
  display: grid;
  gap: 4px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(231, 238, 231, 0.7);
}

.state-summary p {
  margin: 0;
  color: #33443a;
  font-size: 0.86rem;
  line-height: 1.38;
}

.state-summary strong {
  color: var(--green-dark);
}

.module-area {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.module-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.module-card {
  display: grid;
  gap: 8px;
  min-height: 244px;
  padding: 13px;
  border: 1px solid rgba(216, 207, 189, 0.9);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
}

.module-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 860;
}

.module-card h3 {
  margin: 0;
  font-size: 1rem;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.module-card strong {
  align-self: end;
  color: var(--green-dark);
  font-size: 0.82rem;
  line-height: 1.3;
}

.exercise-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exercise-list li {
  position: relative;
  padding-left: 18px;
  color: #33443a;
  font-size: 0.8rem;
  line-height: 1.3;
}

.exercise-list li::before {
  position: absolute;
  top: 0.58em;
  left: 0;
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 999px;
  background: var(--green);
}

.map-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-list li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: start;
  min-height: 68px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.map-list li:last-child {
  border-bottom: 0;
}

.discussion {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(246, 242, 232, 0.52);
}

.discussion-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.discussion h3 {
  margin: 0;
  font-size: 1.18rem;
}

.discussion-head span {
  color: var(--muted);
  font-size: 0.86rem;
}

.discussion-list {
  display: grid;
  gap: 8px;
}

.discussion-message {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(216, 207, 189, 0.82);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
}

.discussion-message > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 0.78rem;
  font-weight: 860;
}

.discussion-message strong {
  display: block;
  margin-bottom: 3px;
}

.discussion-message p {
  margin: 0;
  color: var(--muted);
  line-height: 1.38;
}

.discussion-form {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
}

.discussion-form input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.node-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #e9f0e9;
  color: var(--green-dark);
  font-weight: 860;
}

.node-copy strong {
  display: block;
  margin-bottom: 3px;
}

.node-copy span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.32;
}

.node-time {
  color: var(--coral);
  font-weight: 800;
  white-space: nowrap;
}

.node-action {
  display: inline-block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 0.9rem;
  font-weight: 760;
}

@media (max-width: 860px) {
  .nav-links {
    display: none;
  }

  .nav-action {
    display: none;
  }

  .user-pill strong {
    display: none;
  }

  .hero {
    min-height: 100svh;
    padding-top: 112px;
    align-items: start;
  }

  .builder {
    grid-template-columns: 1fr;
  }

  .map-list li {
    grid-template-columns: 38px 1fr;
  }

  .node-time {
    grid-column: 2;
  }

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

  .builder-section {
    height: auto;
    min-height: 100svh;
    align-content: start;
    padding-top: 96px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 14px 16px;
  }

  h1 {
    font-size: clamp(3rem, 17vw, 4.7rem);
  }

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

  .button {
    width: 100%;
  }

  .pace-control {
    grid-template-columns: 1fr;
  }

  .choice-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

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

  .map-header strong {
    text-align: left;
  }

  .discussion-head,
  .discussion-form {
    grid-template-columns: 1fr;
  }

  .discussion-head {
    align-items: start;
    flex-direction: column;
  }
}
