/* =========================
   Foundation
========================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #1d1d1d;
  --muted: #777770;
  --soft: #a4a49e;
  --line: #e4e4de;
  --paper: #f7f7f4;
  --white: #ffffff;
  --accent: #d7ff45;
  --sky: #a9e5ff;
  --sky-deep: #61c5ed;
  --sky-hover: #2580ff;
  --danger: #a3392f;
}

html {
  min-width: 320px;
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #efefef;
  font-family:
    "Noto Sans JP",
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible + .answer-card-content {
  outline: 3px solid rgba(29, 29, 29, 0.34);
  outline-offset: 4px;
}

input:focus-visible + .answer-card-content {
  outline-color: rgba(255, 255, 255, 0.92);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}


/* =========================
   Question view
========================= */

.diagnosis-app {
  width: 100%;
  max-width: 750px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
}


/* =========================
   Cover view
========================= */

.cover-page {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  align-items: flex-end;
  overflow: hidden;
  color: var(--white);
  background: #0d2c2b;
}

.cover-page::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 22, 25, 0.04) 35%, rgba(4, 22, 25, 0.28) 62%, rgba(4, 22, 25, 0.92) 100%),
    linear-gradient(90deg, rgba(4, 22, 25, 0.12), rgba(4, 22, 25, 0));
  content: "";
}

.cover-image {
  position: absolute;
  z-index: -1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.cover-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 40px 22px max(30px, env(safe-area-inset-bottom));
}

.cover-title {
  margin: 0 0 28px;
  font-size: clamp(36px, 10vw, 52px);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.055em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.28);
}

.cover-title:focus,
.question-title:focus {
  outline: none;
}

.cover-title span {
  display: block;
}

.cover-start-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.18s ease, background 0.18s ease;
}

.cover-start-button:hover {
  color: var(--white);
  background: var(--sky-hover);
  transform: translateY(-2px);
}

.cover-start-button:active {
  transform: translateY(0);
}

.cover-start-arrow {
  font-size: 22px;
  line-height: 1;
}

.question-page {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px 18px 48px;
}

.question-container {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.question-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 42px;
}

.back-button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-self: start;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.back-label {
  display: none;
}

.back-button:hover:not(:disabled) {
  color: var(--ink);
}

.back-button:disabled {
  visibility: hidden;
}

.progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: #dfdfd9;
  border-radius: 999px;
}

.progress-value {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ink);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.progress-text {
  justify-self: end;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.question-step {
  margin: 0 0 22px;
  color: #8a8a84;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.question-header {
  margin-bottom: 30px;
}

.question-title {
  max-width: 100%;
  margin: 0;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.035em;
}

.question-description {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.answer-fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.answer-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.answer-option {
  position: relative;
  display: block;
  min-width: 0;
}

.answer-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.answer-card-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 14px 17px;
  overflow: hidden;
  color: var(--white);
  background-color: #171717;
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.54)),
    var(--answer-image);
  background-position: center, var(--answer-position, center);
  background-size: cover, cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  cursor: pointer;
  text-align: center;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.answer-list.is-binary {
  gap: 12px;
  height: clamp(380px, calc(100vh - 340px), 560px);
  height: clamp(380px, calc(100svh - 340px), 560px);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.answer-list.is-binary .answer-option,
.answer-list.is-binary .answer-card-content {
  height: 100%;
}

.answer-list.is-binary .answer-card-content {
  min-height: 0;
  padding: 26px 20px;
}

.answer-list.is-binary .answer-text {
  font-size: 18px;
  line-height: 1.6;
}

.answer-list.answer-count-4 .answer-card-content {
  min-height: clamp(108px, calc(18vh - 24px), 142px);
  min-height: clamp(108px, calc(18svh - 24px), 142px);
}

.answer-list.answer-count-5 .answer-card-content {
  min-height: clamp(100px, calc(16vh - 20px), 132px);
  min-height: clamp(100px, calc(16svh - 20px), 132px);
}

.answer-option:hover .answer-card-content {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.answer-option input:checked + .answer-card-content {
  color: var(--white);
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.68)),
    var(--answer-image);
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.78),
    0 10px 28px rgba(0, 0, 0, 0.18);
}

.answer-text {
  width: 100%;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
  text-align: center;
  text-wrap: balance;
}

.answer-list.is-transitioning {
  pointer-events: none;
}

.question-view {
  animation: view-in 0.35s ease both;
}


/* =========================
   Result view
========================= */

.result-page {
  min-height: 100vh;
  min-height: 100svh;
  padding: 18px 14px 64px;
}

.result-container {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.result-hero {
  color: var(--ink);
}

.result-heading {
  padding: 8px 8px 24px;
}

.result-visual {
  position: relative;
  min-height: clamp(390px, 68svh, 560px);
  overflow: hidden;
  background: #e8f5f7;
  border-radius: 18px;
}

.result-character-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  object-position: center;
}

.result-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.result-type-name {
  margin: 0;
  font-size: clamp(37px, 10vw, 52px);
  line-height: 1.22;
  letter-spacing: -0.05em;
}

.result-catchphrase {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 16px;
  width: fit-content;
  height: fit-content;
  padding: 18px 10px;
  margin: 0;
  color: var(--ink);
  background: var(--white);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.7;
  letter-spacing: 0.08em;
  transform: translateY(-50%);
  white-space: nowrap;
  writing-mode: vertical-rl;
}

.result-profile {
  padding: 0 8px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.result-profile strong {
  color: var(--ink);
  font-weight: 850;
}

.share-section {
  padding: 0 8px;
  margin-top: 42px;
}

.share-title {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-align: center;
}

.share-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.share-button {
  display: inline-flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  color: var(--ink);
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: clamp(10px, 3vw, 12px);
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: transform 0.18s ease;
}

.share-button.is-x {
  color: var(--white);
  background: var(--ink);
  border-color: var(--ink);
}

.share-button.is-line {
  color: var(--white);
  background: #06c755;
  border-color: #06c755;
}

.share-button.is-copy {
  color: var(--white);
  background: var(--sky-hover);
  border-color: var(--sky-hover);
}

.share-button:hover {
  transform: translateY(-1px);
}

.recommend-section {
  padding-top: 38px;
}

.section-heading {
  margin: 0 0 28px;
  font-size: 30px;
  letter-spacing: -0.035em;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.product-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.product-rank {
  position: absolute;
  z-index: 3;
  top: -15px;
  left: 14px;
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  margin: 0;
  color: #484a46;
  background: #e2e3df;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.product-rank.is-pickup {
  color: #493512;
  background: #d7b765;
  border: 0;
}

.rank-crown {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
  color: #343530;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
  transform: translateY(-3px);
}

.rank-label {
  display: inline-flex;
  height: 18px;
  align-items: center;
  line-height: 1;
}

.product-rank.is-pickup .rank-crown {
  color: #3e321e;
}

.product-visual {
  position: relative;
  margin: 15px 0 18px;
}

.product-image-frame {
  display: grid;
  min-height: clamp(220px, 34vh, 340px);
  place-items: center;
  padding: 18px;
  overflow: hidden;
  background: #f7f7f4;
  border-radius: 10px;
}

.product-image {
  display: block;
  width: 100%;
  height: clamp(190px, 30vh, 300px);
  object-fit: contain;
  mix-blend-mode: multiply;
}

.product-name {
  min-height: 52px;
  padding-right: 0;
  margin: 0;
  font-size: 23px;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.recommend-score {
  --recommend-badge: #e8c458;

  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 0;
  isolation: isolate;
  display: flex;
  width: 104px;
  height: 104px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: transparent;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.08));
  pointer-events: none;
  transform: translateY(20%);
}

.recommend-score::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: var(--recommend-badge);
  content: "";
  -webkit-mask: url("assets/recommend-score-shape.svg") center / contain no-repeat;
  mask: url("assets/recommend-score-shape.svg") center / contain no-repeat;
}

.recommend-score span,
.recommend-score strong {
  position: relative;
  z-index: 1;
}

.recommend-score span {
  font-size: 9px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.recommend-score strong {
  margin-top: 2px;
  font-size: 27px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.05em;
}

.product-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
}

.product-metrics li {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 11px 10px;
  color: var(--muted);
  background: #f7f7f4;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.stars {
  color: #f2b600;
  font-size: clamp(13px, 3.9vw, 17px);
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.product-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.cta-button,
.retry-button,
.sell-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  gap: 8px;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.cta-button.is-used,
.sell-button {
  color: var(--white);
  background: var(--ink);
}

.cta-button.is-rental {
  color: var(--white);
  background: #53604c;
  border-color: #53604c;
}

.cta-button.is-affiliate {
  color: #555650;
  background: transparent;
  border-color: #b8b9b2;
}

.cta-button:hover,
.retry-button:hover,
.sell-button:hover {
  transform: translateY(-1px);
}

.cta-button.is-used:hover,
.sell-button:hover {
  color: var(--white);
  background: var(--sky-hover);
}

.cta-button.is-rental:hover {
  background: #687761;
  border-color: #687761;
}

.cta-button.is-affiliate:hover {
  color: var(--ink);
  background: #f2f2ed;
  border-color: var(--ink);
}

.result-footer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding-top: 48px;
}

.retry-panel,
.sell-panel {
  display: flex;
  min-height: 230px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px;
  color: var(--white);
  background-color: #18333a;
  background-image:
    linear-gradient(90deg, rgba(3, 16, 20, 0.4), rgba(3, 16, 20, 0.12)),
    url("assets/panels/review-answers.jpg");
  background-position: center;
  background-size: cover;
  border-radius: 14px;
}

.sell-panel {
  background-image:
    linear-gradient(90deg, rgba(3, 16, 20, 0.4), rgba(3, 16, 20, 0.12)),
    url("assets/panels/camera-sell.jpg");
}

.panel-title {
  margin: 0 0 24px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.45;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.32);
}

.retry-panel .retry-button,
.sell-panel .sell-button {
  color: var(--white);
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(2px);
}

.retry-panel .retry-button:hover,
.sell-panel .sell-button:hover {
  color: var(--white);
  background: var(--sky-hover);
  border-color: var(--sky-hover);
}

.result-error {
  padding: 24px;
  color: var(--danger);
  background: #fff4f2;
  border: 1px solid #f0cec9;
  border-radius: 14px;
  line-height: 1.7;
}


/* =========================
   Utility states
========================= */

.loading-screen {
  display: grid;
  min-height: 100vh;
  place-content: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 14px 18px;
  color: var(--white);
  background: var(--ink);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  font-size: 13px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 16px;
  color: var(--danger);
  background: var(--white);
  border: 1px solid currentColor;
  border-radius: 10px;
  text-align: center;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =========================
   Small smartphone
========================= */

@media (max-width: 360px) {
  .question-title {
    font-size: 25px;
  }

  .answer-list.is-binary {
    height: clamp(360px, calc(100svh - 320px), 500px);
  }

  .answer-list.is-binary .answer-text {
    font-size: 16px;
  }

  .result-type-name {
    font-size: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
