[hidden] { display: none !important; }

#diagnosis {
  --mx: 0;
  --my: 0;
  --sp: 0;
}

.diagnosis {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
  /* 回廊の最奥で見えていた「診断の世界」の光と同じ背景（style.css の --world-bg）。3D から切り替わっても背景は変わらない */
  background: var(--world-bg);
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.quiz-header, .quiz-card { position: relative; z-index: 1; }

/* 背景の幾何学装飾（質問の切り替えにわずかに反応する） */
/* 装飾は画面（ビューポート）基準で固定：回廊の最奥で見えていたリングと、到達後の診断画面のリングが常に同じ位置になる */
.quiz-deco { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.deco-ring { position: absolute; left: 50%; top: 52%; width: min(86vmin, 820px); aspect-ratio: 1; translate: -50% -50%; fill: none; stroke: #9e83bd; stroke-width: .35; opacity: .45; }
.deco-ring-b { width: min(62vmin, 600px); opacity: .32; stroke-width: .5; }
.deco-spark { position: absolute; left: var(--x); top: var(--y); width: 14px; height: 14px; color: #a587c6; opacity: .6; }

.quiz-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 4vw, 64px);
  min-height: var(--header);
  padding: 0 clamp(16px, 4vw, 70px);
  background: #fcf8fcd9;
  border-bottom: 1px solid #77618f25;
}

.quiz-brand { font-size: clamp(10px, 1.2vw, 16px); letter-spacing: .22em; }
.quiz-brand svg { width: clamp(23px, 3vw, 36px); }

#quiz-count {
  font: 600 clamp(.72rem, 1.2vw, .98rem)/1 system-ui, sans-serif;
  letter-spacing: .1em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#quiz-progress {
  appearance: none;
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e6daef;
  color: #7852a5;
}
#quiz-progress::-webkit-progress-bar { background: #e6daef; }
#quiz-progress::-webkit-progress-value { background: linear-gradient(90deg, #b698d3, #754b9f); box-shadow: 0 0 8px #9b6fd0; }
#quiz-progress::-moz-progress-bar { background: linear-gradient(90deg, #b698d3, #754b9f); }

.quiz-card {
  align-self: center;
  width: min(100%, 1160px);
  margin-inline: auto;
  padding: clamp(32px, 6vh, 75px) clamp(12px, 4vw, 40px);
  text-align: center;
}

.quiz-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 0 0 clamp(15px, 4vh, 36px);
  color: #645177;
  letter-spacing: .36em;
  font-size: .8rem;
}
.quiz-kicker::before, .quiz-kicker::after { content: ""; width: 34px; height: 1px; background: #aa94bd; }

/* 診断中の質問文は固定表示：アニメーション・変形・パララックスは一切かけない（高さは diagnosis.js が最長の質問に合わせて固定） */
#question-title { animation: none !important; transition: none !important; transform: none !important; filter: none !important; translate: none !important; }
#question-title {
  display: grid;
  place-items: center;
  min-height: 3.05em;
  max-width: 21em;
  margin: 0 auto;
  font-size: clamp(1.8rem, 3.45vw, 3.3rem);
  line-height: 1.55;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: normal;
  transform: none;
  text-wrap: balance;
  line-break: strict;
  word-break: keep-all;     /* 改行は diagnosis.js が入れた文節の切れ目（<wbr>）と句読点だけ */
  overflow-wrap: anywhere;  /* 切れ目のない長い語が画面幅を超えるときだけの保険 */
  animation: none !important;
  align-content: center;
}
/* 質問文の文節（diagnosis.js の phrased）：文節の途中では折り返さない */
.q-phrase { white-space: nowrap; }
.question-text { display: block; max-width: 100%; text-wrap: balance; }
.question-measure { display: block; grid-area: 1 / 1; width: 100%; text-wrap: balance; }

.quiz-ornament { display: flex; align-items: center; justify-content: center; margin: clamp(12px, 3vh, 30px) auto 0; color: #8661ad; }
.quiz-ornament svg { width: 26px; height: 26px; }
.quiz-ornament::before, .quiz-ornament::after { content: ""; width: clamp(35px, 8vw, 100px); height: 1px; background: linear-gradient(90deg, transparent, #ad92c4); }
.quiz-ornament::after { transform: scaleX(-1); }

#answer-options {
  --disc: clamp(54px, 10vw, 140px);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 0 auto;
  gap: clamp(1px, 1vw, 14px);
}

.answer {
  --size: 1;
  --ring: #8665a9;
  --tint: #bfacd6;
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-rows: var(--disc) 1fr;
  justify-items: center;
  align-items: center;
  gap: clamp(7px, 1.4vh, 15px);
  padding: 0 0 .3rem;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.answer:nth-child(2), .answer:nth-child(6) { --size: .76; --ring: #977ab6; --tint: #d0bfe3; }
.answer:nth-child(3), .answer:nth-child(5) { --size: .55; --ring: #a58bbd; --tint: #decee9; }
.answer:nth-child(4) { --size: .36; --ring: #a392b8; --tint: #e2d8ec; }
.answer[aria-disabled="true"] { cursor: default; }
.answer-disc {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--disc) * var(--size));
  aspect-ratio: 1;
  border: 1.5px solid var(--ring);
  border-radius: 50%;
  background: radial-gradient(ellipse at 35% 20%, #fffcff, var(--tint) 135%);
  box-shadow: inset 0 -3px 10px #fff9, 0 3px 9px #69488619, 0 0 0 calc(var(--halo, 0) * 12px) rgb(176 132 220 / calc(var(--halo, 0) * .45));
  transition: scale .45s cubic-bezier(.25, 1.6, .5, 1), background .25s ease, box-shadow .35s ease, border-color .25s;
}
/* ガラス玉のハイライト（カーソル位置へ寄る） */
.answer-shine { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; background: radial-gradient(circle at var(--hx, 34%) var(--hy, 24%), #ffffffe6 0, #ffffff55 18%, #fff0 46%); transition: opacity .3s; }
.answer-ripple { position: absolute; inset: -2px; border-radius: 50%; border: 1.5px solid #a77ad6; pointer-events: none; }
.answer-disc svg { width: 47%; min-width: 10px; fill: none; stroke: #fff; stroke-width: 2; opacity: 0; }
.answer[aria-pressed="true"] .answer-disc { background: radial-gradient(ellipse at 29% 22%, #9b72c1, #583b7e 79%); box-shadow: inset 0 0 8px #ead1ff60, 0 0 0 3px #be9cda45; }
.answer[aria-pressed="true"] svg { opacity: 1; }
.answer[aria-pressed="true"] .answer-shine { opacity: .35; }
.answer svg { position: relative; transition: opacity .2s; }
.answer[aria-pressed="true"] .answer-label { color: #5b3a86; }
/* 前の質問に戻ったとき、以前の回答を示す小さな目印 */
.answer-label { position: relative; }
/* レイアウトに場所を取らせない（表示しても回答ボタンや質問文の位置は動かない） */
.answer.is-recalled .answer-label::after { content: "前回の回答"; position: absolute; top: 100%; left: 50%; translate: -50% 0; margin-top: 3px; white-space: nowrap; font-size: .72em; letter-spacing: .06em; color: #8a67b2; font-weight: 600; pointer-events: none; }

.answer-label {
  align-self: start;
  color: #352448;
  font-weight: 700;
  font-size: clamp(.78rem, 1.35vw, 1.16rem);
  line-height: 1.36;
  word-break: normal;
  overflow-wrap: normal;
}
.answer-label::before { content: ""; display: block; margin: 0 auto 7px; width: 1px; height: clamp(6px, 1.5vh, 15px); background: #af9abd; }
/* ホバー：小さい円ほど大きく反応し、目盛り線が伸びる */
.answer:nth-child(1), .answer:nth-child(7) { --lift: 1.05; }
.answer:nth-child(2), .answer:nth-child(6) { --lift: 1.08; }
.answer:nth-child(3), .answer:nth-child(5) { --lift: 1.12; }
.answer:nth-child(4) { --lift: 1.18; }
/* ホバーで目盛り線が伸びる演出は scaleY で描く（高さを変えないので、回答列や質問文の位置は動かない） */
.answer-label::before { transform-origin: 50% 0; transition: transform .35s cubic-bezier(.25, 1.5, .5, 1), background .3s; }
@media (hover: hover) {
  .answer:hover:not([aria-disabled="true"]) .answer-disc { scale: var(--lift); border-color: #6f4b98; box-shadow: inset 0 -3px 10px #fff9, 0 8px 22px #69488633; }
  .answer:hover:not([aria-disabled="true"]) .answer-label::before { transform: scaleY(1.5); background: #7d5aa6; }
}
.answer:active:not([aria-disabled="true"]) .answer-disc { scale: .93; }

/* 操作ボタン：前の質問／次の質問／最初からやり直す は同じ部品（.quiz-btn）。次の質問だけが主ボタン（.is-primary）。
   2列のグリッドで、右列（次の質問・最初からやり直す）は同じ列の右端に揃う */
.quiz-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  justify-content: space-between;
  align-items: center;
  gap: 12px clamp(12px, 3vw, 32px);
  width: min(100%, 560px);
  margin: clamp(20px, 5vh, 52px) auto 0;
}
#previous-question { grid-column: 1; grid-row: 1; justify-self: start; }
#next-question { grid-column: 2; grid-row: 1; justify-self: stretch; }
#restart-quiz { grid-column: 2; grid-row: 2; justify-self: stretch; }
.quiz-btn, .dialog-actions button {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-width: 168px; min-height: 48px; padding: 10px 20px;
  border: 1px solid #a48bb9; border-radius: 4px; background: #fffb; color: var(--ink);
  font: 700 .9rem/1.2 var(--serif); letter-spacing: .1em; cursor: pointer;
  transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .25s ease, translate .25s ease, scale .15s ease;
}
.quiz-btn-icon { display: inline-block; font-family: system-ui, sans-serif; transition: translate .3s cubic-bezier(.3, 1.6, .5, 1); }
.quiz-btn.is-primary { background: #3a2a52; border-color: #3a2a52; color: #fff; }
@media (hover: hover) {
  /* 診断中の操作ボタンは位置を動かさず、色・枠線・影だけで反応する */
  .quiz-btn:hover:not(:disabled), .dialog-actions button:hover { background: #fff; border-color: #6f4b98; box-shadow: 0 6px 16px #3b215e1f; }
  .quiz-btn.is-primary:hover:not(:disabled) { background: #4b3565; border-color: #4b3565; }
  #previous-question:hover:not(:disabled) .quiz-btn-icon { translate: -3px 0; }
  #next-question:hover:not(:disabled) .quiz-btn-icon { translate: 3px 0; }
  #restart-quiz:hover:not(:disabled) .quiz-btn-icon { rotate: -40deg; transition: rotate .4s ease; }
}
.quiz-btn:active:not(:disabled), .dialog-actions button:active { scale: .97; translate: 0 0; box-shadow: none; }
.quiz-btn:focus-visible { outline: 2px solid #9460d1; outline-offset: 3px; }
.quiz-btn:disabled { opacity: .4; cursor: default; }
.quiz-btn.is-primary:disabled { background: #fffb; border-color: #a48bb9; color: inherit; }
/* 回答がまだ1つもないときは「やり直す」対象がないので出さない（場所は確保したまま） */
#restart-quiz:disabled { visibility: hidden; }
#storage-note { font-size: .85rem; color: #673a75; }

#completion-view { padding: clamp(10px, 5vh, 48px) 0; }
.completion-star { width: 58px; height: 58px; color: #8861ad; }
#completion-title { font-size: clamp(2rem, 5vw, 4rem); margin: .32em 0 .5em; letter-spacing: .14em; }
#completion-view p { font-size: clamp(.9rem, 2.2vw, 1.22rem); line-height: 2; }
#question-title:focus, #completion-title:focus { outline: none; }

#restart-dialog { width: min(440px, 92vw); border: 1px solid #b49ac8; border-radius: 8px; padding: 24px; background: #fcf7ff; color: var(--ink); }
#restart-dialog::backdrop { background: #2316328a; }
#restart-title { margin-top: 0; font-size: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.dialog-actions button[value="restart"] { background: #4b3565; color: white; }

@media (prefers-reduced-motion: reduce) {
  .answer-disc, .answer-label::before { transition: none; }
}

@media (min-width: 651px) { .label-break { display: none; } }

@media (max-width: 650px) {
  .quiz-card { padding-inline: 6px; }
  #question-title { width: 100%; padding-inline: 10px; font-size: clamp(1.3rem, 5.35vw, 2.05rem); letter-spacing: .03em; }
  #answer-options { --disc: min(11.6vw, 60px); gap: 0; }
  /* 「どちらでも／ない」のように、改行は <br class="label-break"> の位置だけ（語の途中で3行に割れないように）。狭い画面では列の幅を少しはみ出してよい */
  .answer-label { font-size: clamp(.62rem, 2.75vw, .95rem); letter-spacing: -.02em; word-break: keep-all; overflow-wrap: normal; white-space: nowrap; }
  .quiz-actions { padding-inline: 10px; gap: 10px; }
  .quiz-btn { min-width: 0; width: 100%; padding-inline: 12px; font-size: .86rem; letter-spacing: .06em; }
  .quiz-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer { min-height: 76px; }
  .quiz-ornament { margin-bottom: 14px; }
}

/* 高さの低い画面（ノートPCのブラウザなど）：55問の最長の質問（3行）でも、質問画面が1画面に収まるよう上下の余白だけを詰める（文字の大きさは変えない） */
@media (max-height: 880px) and (min-width: 651px) {
  .quiz-card { padding-block: clamp(14px, 3svh, 40px); }
  .quiz-kicker { margin-bottom: clamp(10px, 2.2svh, 28px); }
  .quiz-ornament { margin-top: clamp(8px, 1.6svh, 22px); }
}

/* XREA 広告欄（画面下端）の上までを診断画面として使う */
.diagnosis { min-height: calc(100svh - var(--ad-h, 0px)); }
.quiz-deco { bottom: var(--ad-h, 0px); }
