:root {
  color-scheme: light;
  --ink: #123e59;
  --ink-soft: #426176;
  --paper: #fffaf0;
  --sand: #f4dfad;
  --sand-2: #fbefd1;
  --sea: #0f8ba8;
  --sea-light: #64c7d9;
  --mint: #5fbf8f;
  --coral: #ff6b5f;
  --gold: #f2b84b;
  --purple: #7463d9;
  --line: rgba(18, 62, 89, 0.16);
  --shadow: 0 24px 70px rgba(18, 62, 89, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(100, 199, 217, 0.24), transparent 38rem),
    linear-gradient(135deg, #fffaf0 0%, #eaf8f9 52%, #fff3dd 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.top-actions,
.result-actions,
.quiz-controls,
.share-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  color: var(--ink);
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 18px;
  background: var(--coral);
  box-shadow: 4px 4px 0 var(--ink);
}

.secondary-button {
  padding: 0 16px;
  background: var(--sand);
}

.ghost-button {
  padding: 0 16px;
  background: rgba(255, 250, 240, 0.72);
}

.icon-button {
  display: grid;
  width: 42px;
  place-items: center;
  background: var(--paper);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.screen {
  display: none;
}

.screen-active {
  display: block;
}

.intro-screen {
  min-height: calc(100vh - 104px);
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  align-items: center;
  gap: clamp(24px, 6vw, 76px);
  padding: 36px 0 24px;
}

.intro-screen.screen-active {
  display: grid;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--sea);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  max-width: 12ch;
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.8rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 1.02;
}

h3 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.hero-line {
  max-width: 34rem;
  margin-bottom: 28px;
  color: var(--ink-soft);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 700;
}

.start-panel {
  max-width: 690px;
  padding: 22px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
}

.start-panel label,
.tool-field legend {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 900;
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
  font-weight: 800;
}

input:focus,
textarea:focus {
  box-shadow: 0 0 0 4px rgba(100, 199, 217, 0.35);
}

.tool-field {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-chip {
  min-height: 38px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.tool-chip.selected {
  border-color: var(--ink);
  background: var(--mint);
}

.passport-preview {
  position: relative;
  align-self: stretch;
  min-height: 520px;
  padding: 24px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 250, 240, 0.92)),
    repeating-linear-gradient(0deg, rgba(18, 62, 89, 0.05) 0 1px, transparent 1px 28px);
  box-shadow: 10px 10px 0 rgba(18, 62, 89, 0.2);
  overflow: hidden;
}

.passport-preview::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 36%;
  background:
    linear-gradient(170deg, transparent 0 22%, rgba(100, 199, 217, 0.65) 23% 44%, transparent 45%),
    linear-gradient(190deg, transparent 0 18%, rgba(15, 139, 168, 0.82) 19% 42%, transparent 43%),
    var(--sea-light);
}

.compass-art {
  position: relative;
  z-index: 1;
  display: block;
  width: min(82%, 310px);
  margin: 28px auto;
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(18, 62, 89, 0.16);
}

.passport-stamp {
  position: relative;
  z-index: 1;
  display: inline-block;
  transform: rotate(-5deg);
  padding: 8px 12px;
  border: 3px solid var(--coral);
  color: var(--coral);
  font-weight: 900;
}

.preview-lines {
  position: absolute;
  z-index: 1;
  right: 24px;
  bottom: 24px;
  left: 24px;
  padding: 16px;
  border: 2px solid rgba(18, 62, 89, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.9);
}

.preview-lines span,
.preview-lines strong {
  display: block;
}

.preview-lines span {
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 800;
}

.preview-lines strong {
  margin-top: 6px;
  font-size: 1.1rem;
}

.quiz-screen,
.result-screen {
  max-width: 1040px;
  margin: 44px auto 0;
}

.quiz-status,
.result-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.progress-meta {
  display: grid;
  min-width: 88px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--gold);
  font-weight: 900;
}

.progress-track {
  height: 14px;
  margin: 20px 0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--mint), var(--sea-light));
  transition: width 240ms ease;
}

.question-panel {
  padding: clamp(18px, 3vw, 28px);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
}

.question-text {
  margin-bottom: 22px;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  font-weight: 900;
  line-height: 1.25;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option-button {
  min-height: 116px;
  padding: 16px;
  border: 2px solid rgba(18, 62, 89, 0.24);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  line-height: 1.45;
}

.option-button strong {
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--sand);
  font-size: 0.85rem;
}

.option-button.selected {
  border-color: var(--ink);
  background: #daf3f5;
  box-shadow: 4px 4px 0 var(--ink);
}

.quiz-controls {
  justify-content: space-between;
  margin-top: 18px;
}

.quiz-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.result-hero {
  padding: 28px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(125deg, rgba(255, 250, 240, 0.95), rgba(218, 243, 245, 0.95)),
    repeating-linear-gradient(90deg, rgba(18, 62, 89, 0.05) 0 1px, transparent 1px 42px);
  box-shadow: var(--shadow);
}

.result-diagnosis {
  max-width: 56rem;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.55;
}

.rank-badge {
  display: grid;
  min-width: 170px;
  min-height: 170px;
  place-items: center;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 7px 7px 0 var(--ink);
}

.result-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.profile-board,
.axis-board,
.skill-board,
.team-board,
.dungeon-board {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.9);
  padding: 20px;
}

.profile-board {
  grid-column: span 5;
  background: #fff6df;
}

.axis-board {
  grid-column: span 7;
}

.skill-board {
  grid-column: span 4;
  background: #eef9f2;
}

.team-board {
  grid-column: span 4;
  background: #eff7ff;
}

.dungeon-board {
  grid-column: span 4;
  background: #fff0ee;
}

.profile-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border-bottom: 1px solid rgba(18, 62, 89, 0.12);
}

.profile-row:last-child {
  border-bottom: 0;
}

.profile-row span {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 800;
}

.profile-row strong {
  overflow-wrap: anywhere;
  font-size: 1.12rem;
}

.profile-row.danger strong {
  color: #b03832;
}

.axis-item {
  display: grid;
  grid-template-columns: 118px 1fr 54px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.axis-label {
  color: var(--ink-soft);
  font-weight: 900;
}

.axis-bar {
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}

.axis-fill {
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--mint), var(--sea-light));
}

.axis-code {
  font-weight: 900;
  text-align: right;
}

.skill-board ul {
  margin: 0 0 18px;
  padding-left: 1.1rem;
  font-weight: 800;
  line-height: 1.75;
}

.weapon-list,
.teammate-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 2px solid rgba(18, 62, 89, 0.18);
  border-radius: 999px;
  background: #fff;
  font-weight: 850;
}

.team-board p,
.dungeon-board p {
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.6;
}

.system-note {
  margin-bottom: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(18, 62, 89, 0.16);
}

.result-actions {
  margin: 18px 0;
}

.share-area {
  display: none;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.9);
}

.share-area.visible {
  display: grid;
}

canvas {
  width: 100%;
  height: auto;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
}

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

textarea {
  min-height: 220px;
  padding: 14px;
  resize: vertical;
  color: var(--ink-soft);
  font-weight: 800;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 22px, 680px);
    padding-top: 8px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand small {
    display: none;
  }

  .intro-screen.screen-active {
    grid-template-columns: 1fr;
    padding-top: 18px;
  }

  h1 {
    max-width: 10ch;
  }

  .passport-preview {
    min-height: 360px;
  }

  .compass-art {
    width: min(70%, 250px);
    margin: 10px auto;
  }

  .name-row,
  .options-grid,
  .share-area.visible {
    grid-template-columns: 1fr;
  }

  .quiz-status,
  .result-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .rank-badge {
    min-width: 130px;
    min-height: 130px;
    justify-self: start;
  }

  .result-layout {
    grid-template-columns: 1fr;
  }

  .profile-board,
  .axis-board,
  .skill-board,
  .team-board,
  .dungeon-board {
    grid-column: span 1;
  }

  .axis-item {
    grid-template-columns: 88px 1fr 40px;
  }
}

@media (max-width: 520px) {
  .top-actions .ghost-button {
    display: none;
  }

  h1 {
    font-size: clamp(2.8rem, 18vw, 4.8rem);
  }

  .start-panel,
  .question-panel,
  .result-hero,
  .profile-board,
  .axis-board,
  .skill-board,
  .team-board,
  .dungeon-board {
    padding: 16px;
  }

  .option-button {
    min-height: 96px;
  }

  .profile-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }
}
