:root {
  color-scheme: light;
  --ink: #24190f;
  --muted: #6e5f4d;
  --paper: #fff3d2;
  --panel: #fff9e8;
  --line: #3a2a1b;
  --green: #178047;
  --green-soft: #e7f7df;
  --red: #cc392d;
  --red-soft: #ffe5dc;
  --blue: #3346c7;
  --blue-soft: #e7ebff;
  --orange: #db7b1d;
  --orange-soft: #ffefd1;
  --gold: #f2bd37;
  --shadow: 10px 10px 0 rgba(52, 38, 21, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(135deg, #6c8f66 0%, #c5a15b 52%, #6a79b8 100%);
  background-size:
    24px 24px,
    24px 24px,
    auto;
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1220px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: center;
}

.diagnosis-stage {
  min-height: min(760px, calc(100vh - 56px));
  padding: clamp(18px, 3vw, 34px);
  border: 4px solid var(--line);
  border-radius: 8px;
  outline: 3px solid rgba(255, 249, 232, 0.85);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.diagnosis-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(36, 25, 15, 0.05), transparent 24%),
    linear-gradient(0deg, rgba(242, 189, 55, 0.1), transparent 36%);
  pointer-events: none;
}

.topbar,
.progress-wrap,
.question-area {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #2a2017;
  color: #fff8df;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3.8vw, 48px);
  line-height: 1.08;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.34);
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 3px solid #fff8df;
  border-radius: 8px;
  background: var(--gold);
  color: #24190f;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.28);
  display: grid;
  place-items: center;
}

.quest-status {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.quest-status span {
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff5d8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 3px 3px 0 rgba(52, 38, 21, 0.16);
}

.progress-wrap {
  margin: 18px 0 18px;
}

.progress-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.progress-track {
  height: 16px;
  border: 3px solid var(--line);
  border-radius: 6px;
  background: #7a6242;
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #4ec66a, #f2bd37, #5b6df1);
  transition: width 260ms ease;
}

.step-dots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.step-dot {
  height: 7px;
  border: 1px solid rgba(36, 25, 15, 0.28);
  border-radius: 2px;
  background: rgba(111, 102, 92, 0.24);
}

.step-dot.active {
  background: var(--gold);
}

.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.screen {
  animation: screenIn 260ms ease both;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-kicker {
  width: fit-content;
  margin: 0 0 14px;
  padding: 8px 12px;
  border: 3px solid var(--line);
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(52, 38, 21, 0.16);
}

.question-title {
  margin: 0;
  max-width: 760px;
  font-size: clamp(27px, 3.5vw, 42px);
  line-height: 1.22;
}

.question-lead {
  margin: 14px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(15px, 1.8vw, 18px);
  font-weight: 700;
  line-height: 1.75;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 26px;
}

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

.choice-card {
  min-height: 202px;
  padding: 18px;
  border: 4px solid currentColor;
  border-radius: 8px;
  background: var(--paper);
  color: var(--green);
  cursor: pointer;
  text-align: left;
  box-shadow: 6px 6px 0 rgba(52, 38, 21, 0.18);
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  min-width: 0;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.choice-card:hover,
.choice-card:focus-visible {
  transform: translate(-2px, -4px);
  box-shadow: 9px 10px 0 rgba(52, 38, 21, 0.22);
}

.choice-card:focus-visible {
  outline: 3px solid rgba(24, 22, 20, 0.2);
  outline-offset: 3px;
}

.choice-card.red {
  color: var(--red);
  background: var(--red-soft);
}

.choice-card.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.choice-card.orange {
  color: var(--orange);
  background: var(--orange-soft);
}

.choice-card.green {
  color: var(--green);
  background: var(--green-soft);
}

.choice-number {
  width: fit-content;
  min-width: 52px;
  height: 42px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 3px solid rgba(36, 25, 15, 0.78);
  border-radius: 6px;
  background: currentColor;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.choice-title {
  margin: 0;
  color: currentColor;
  font-size: clamp(19px, 2.2vw, 25px);
  font-weight: 900;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.choice-text {
  margin: 12px 0 0;
  color: #24201b;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.history-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.history-chip {
  padding: 8px 11px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff5d8;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.result-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: stretch;
  margin-top: 24px;
}

.result-main,
.action-stack {
  border-radius: 8px;
  border: 4px solid currentColor;
  background: #fff;
  box-shadow: 6px 6px 0 rgba(52, 38, 21, 0.18);
}

.result-main {
  padding: clamp(22px, 3vw, 34px);
  color: var(--green);
}

.result-main.red {
  color: var(--red);
  background: var(--red-soft);
}

.result-main.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.result-main.orange {
  color: var(--orange);
  background: var(--orange-soft);
}

.result-main.green {
  color: var(--green);
  background: var(--green-soft);
}

.result-badge {
  width: fit-content;
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: currentColor;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.result-title {
  margin: 0;
  color: currentColor;
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.result-copy {
  margin: 16px 0 0;
  color: #25201c;
  font-size: clamp(15px, 1.8vw, 18px);
  font-weight: 800;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.action-stack {
  padding: 20px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-title {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.4;
}

.action-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  min-width: 0;
}

.action-step {
  min-width: 66px;
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.action-item p {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.65;
  min-width: 0;
  overflow-wrap: anywhere;
}

.result-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  border: 3px solid var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(52, 38, 21, 0.16);
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.memo-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  border: 2px dashed currentColor;
  background: rgba(255, 255, 255, 0.72);
  color: #24201b;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
}

.memo-box[hidden] {
  display: none;
}

.map-panel {
  align-self: stretch;
  min-height: 0;
  padding: 16px;
  border-radius: 8px;
  border: 4px solid var(--line);
  background: #fff9e8;
  box-shadow: 8px 8px 0 rgba(52, 38, 21, 0.2);
  display: flex;
  flex-direction: column;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.map-label,
.map-chip {
  font-weight: 900;
}

.map-label {
  font-size: 16px;
}

.map-chip {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  font-size: 12px;
}

.map-panel img {
  width: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: 8px;
  border: 3px solid var(--line);
  background: #fff;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .diagnosis-stage {
    min-height: auto;
  }

  .map-panel {
    max-height: none;
  }

  .map-panel img {
    max-height: 560px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 520px);
    padding: 10px 0 18px;
  }

  .diagnosis-stage {
    padding: 18px;
  }

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

  .choice-card {
    min-height: 152px;
  }

  .action-item {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: center;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
  }
}
