@font-face {
  font-family: "Hannari";
  src: url("fonts/HannariMincho-Regular.otf") format("opentype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* 薄暗い石レンガの壁に掛かった鏡。シンプルなレトロ：グラデーション・ぼかし・光の効果は使わない。
     平たい色・太い輪郭・ずらした影だけ。UI は羊皮紙・金・暗い紅。角は丸めない */
  --wall: #15110e;
  --text: #eadfca;
  --text-dim: #a8998a;
  --gold: #d8b46a;
  --gold-dim: #8c7442;
  --parch: #e9dcbf;
  --parch-2: #d9c7a2;
  --ink: #241810;
  --ink-dim: #6f5c48;
  --beni: #8e1b26;
  --beni-2: #a92733;
  --shadow: #060403;
  --brick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120'%3E%3Crect width='240' height='120' fill='%2316120f'/%3E%3Crect x='2' y='2' width='56' height='26' fill='%233a332e'/%3E%3Crect x='62' y='2' width='56' height='26' fill='%23342e29'/%3E%3Crect x='122' y='2' width='56' height='26' fill='%233a332e'/%3E%3Crect x='182' y='2' width='56' height='26' fill='%233a332e'/%3E%3Crect x='-28' y='32' width='56' height='26' fill='%233f3832'/%3E%3Crect x='212' y='32' width='56' height='26' fill='%233f3832'/%3E%3Crect x='32' y='32' width='56' height='26' fill='%23342e29'/%3E%3Crect x='92' y='32' width='56' height='26' fill='%23342e29'/%3E%3Crect x='152' y='32' width='56' height='26' fill='%23342e29'/%3E%3Crect x='2' y='62' width='56' height='26' fill='%23342e29'/%3E%3Crect x='62' y='62' width='56' height='26' fill='%233a332e'/%3E%3Crect x='122' y='62' width='56' height='26' fill='%233a332e'/%3E%3Crect x='182' y='62' width='56' height='26' fill='%233f3832'/%3E%3Crect x='-28' y='92' width='56' height='26' fill='%233a332e'/%3E%3Crect x='212' y='92' width='56' height='26' fill='%233a332e'/%3E%3Crect x='32' y='92' width='56' height='26' fill='%23342e29'/%3E%3Crect x='92' y='92' width='56' height='26' fill='%23342e29'/%3E%3Crect x='152' y='92' width='56' height='26' fill='%233f3832'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; background: var(--wall); }
[hidden] { display: none !important; }

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  padding: 24px 16px 40px;
  font-family: "Hannari", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  color: var(--text);
  background: var(--brick) center top / 240px 120px, var(--wall);
}
a { color: var(--gold); }

.room { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; text-align: center; }

/* 題の真鍮の札 */
.plaque {
  display: inline-block;
  margin: 0 0 6px;
  padding: 4px 18px 4px 24px;
  font-size: 15px;
  font-weight: normal;
  letter-spacing: .5em;
  color: #2a1c08;
  background: #c9a24f;
  border: 2px solid var(--shadow);
  box-shadow: 4px 4px 0 var(--shadow);
}

/* ---------- 鏡 ---------- */
.mirror { display: block; width: min(250px, 64vw); height: auto; margin: 0 auto; transition: width .4s; overflow: visible; }
body[data-screen="quiz"] .mirror { width: min(180px, 46vw); }
body[data-screen="answer"] .mirror { width: min(210px, 54vw); }
.mirror .face { opacity: .12; transition: opacity 1.2s steps(6); }
.mirror .eyes { opacity: 0; transition: opacity .4s .6s steps(2); }
.mirror.awake .face, .mirror.speak .face { opacity: 1; }
.mirror.awake .eyes, .mirror.speak .eyes { opacity: 1; }
.mirror .mouth-open { opacity: 0; }
.mirror.speak .mouth-open { opacity: 1; animation: talk .3s steps(1) infinite; }
.mirror.speak .mouth-closed { opacity: 1; animation: talk2 .3s steps(1) infinite; }
.mirror .smoke { animation: drift 6s steps(3) infinite alternate; }
.mirror .smoke2 { animation: drift 4s steps(2) infinite alternate-reverse; }
.mirror .iris { animation: look 7s steps(1) infinite; }
@keyframes talk { 50% { opacity: 0; } }
@keyframes talk2 { 0% { opacity: 0; } 50% { opacity: 1; } }
@keyframes drift { from { transform: translateX(-8px); } to { transform: translateX(8px); } }
@keyframes look { 0%, 100% { transform: translateX(0); } 55% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
/* 答える瞬間：顔が白く2回またたく */
.mirror.flash .face > path:first-child { animation: blink .9s steps(1); }
@keyframes blink { 0%, 50% { fill: #f4fff8; } 25%, 75% { fill: #c8cfc0; } }

/* 鏡のせりふ（鏡の下に浮かぶ文字） */
.speech {
  min-height: 3.6em;
  margin: 8px auto 16px;
  max-width: 440px;
  font-size: clamp(16px, 4.4vw, 18px);
  line-height: 1.8;
  color: #d6eee0;
  text-shadow: 2px 2px 0 var(--shadow);
}
.speech:not(:empty)::before { content: "「"; }
.speech.done::after { content: "」"; }
body[data-screen="start"] .speech { min-height: 0; margin: 0; }

.screen { position: relative; }
.desc { margin: 18px 0 14px; font-size: clamp(15px, 4.2vw, 17px); line-height: 1.9; text-shadow: 2px 2px 0 var(--shadow); }
.note { margin: 0 0 26px; font-size: 13px; color: var(--text-dim); line-height: 1.8; text-shadow: 2px 2px 0 var(--shadow); }

/* ---------- ボタン（太い枠とずらした影） ---------- */
button { font: inherit; color: inherit; cursor: pointer; }
.primary {
  display: inline-block;
  font-size: clamp(18px, 4.8vw, 21px);
  letter-spacing: .16em;
  color: #f6e2b0;
  background: var(--beni);
  border: 2px solid var(--shadow);
  outline: 2px solid #c9a24f;
  outline-offset: -6px;
  padding: 12px 38px 12px 42px;
  box-shadow: 5px 5px 0 var(--shadow);
  transition: transform .05s, box-shadow .05s;
}
.primary:hover { background: var(--beni-2); }
.primary:active { transform: translate(5px, 5px); box-shadow: 0 0 0 var(--shadow); }
.primary:disabled { opacity: .4; cursor: default; transform: none; box-shadow: 5px 5px 0 var(--shadow); }
.sub {
  font-size: 14px;
  padding: 7px 14px;
  color: var(--text);
  background: #1d1814;
  border: 2px solid var(--gold-dim);
  box-shadow: 3px 3px 0 var(--shadow);
}
.sub:active { transform: translate(3px, 3px); box-shadow: none; }
.sub:disabled { opacity: .35; cursor: default; }
.back {
  font-size: 13px;
  padding: 2px 12px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--text-dim);
}
.primary:focus-visible, .sub:focus-visible, .back:focus-visible, .choices button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

/* ---------- そなたの望み（タグ） ---------- */
.wishes {
  margin: 0 0 16px;
  padding: 10px 12px 12px;
  background: #1d1814;
  border: 2px solid var(--shadow);
  outline: 1px solid var(--gold-dim);
  outline-offset: -5px;
  box-shadow: 4px 4px 0 var(--shadow);
}
.wishes-lab { margin: 0 0 8px; font-size: 12px; letter-spacing: .3em; color: var(--gold); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0; font-size: 12px; }
.wishes .tags { justify-content: center; min-height: 28px; margin: 0; font-size: 14px; gap: 6px; }
.wishes .tags span, .wishes .tags button { padding: 2px 10px; border: 1px solid var(--shadow); }
.wishes .tags .base { background: var(--parch-2); color: var(--ink); }
.wishes .tags button { font-size: 14px; background: var(--beni); color: #f6e2b0; border-color: #c9a35a; box-shadow: 2px 2px 0 var(--shadow); }
.wishes .tags button::after { content: " ×"; font-size: 11px; opacity: .8; }
.wishes .tags button.new { animation: pop .35s steps(3); }
.wishes .tags .empty { border: 0; color: var(--text-dim); font-size: 13px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.count { margin: 0 0 12px; font-size: 13px; color: var(--text-dim); letter-spacing: .1em; text-shadow: 2px 2px 0 var(--shadow); }

/* ---------- 4択（羊皮紙の札） ---------- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 440px; margin: 0 auto; }
.choices button {
  min-height: 58px;
  font-size: clamp(15px, 4.2vw, 18px);
  padding: 10px 6px;
  color: var(--ink);
  background: var(--parch);
  border: 2px solid var(--shadow);
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform .05s, box-shadow .05s;
  overflow-wrap: anywhere;
}
.choices button small { display: block; font-size: 11px; color: var(--ink-dim); letter-spacing: .04em; }
.choices button:hover { background: #f3e7cc; }
.choices button:active, .choices button.picked { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--shadow); background: var(--beni); color: #f6e2b0; }
.choices button.picked small { color: #e8c9a0; }
.choices.wait button { pointer-events: none; }
.choices.wait button:not(.picked) { opacity: .5; }
.tools { display: flex; justify-content: center; gap: 10px; margin: 18px 0 22px; }
.ask { min-width: 12em; }

/* ---------- あなたの吹き出し（しっぽは下：画面の手前に立つあなたが言う） ---------- */
.bubble {
  position: relative;
  margin: 6px 0 34px;
  padding: 14px 16px;
  text-align: left;
  color: var(--ink);
  background: var(--parch);
  border: 2px solid var(--shadow);
  box-shadow: 5px 5px 0 var(--shadow);
}
.bubble::before, .bubble::after {
  content: "";
  position: absolute;
  right: 22%;
  border: solid transparent;
}
.bubble::before { bottom: -22px; margin-right: -14px; border-width: 22px 14px 0; border-top-color: var(--shadow); }
.bubble::after { bottom: -17px; margin-right: -11px; border-width: 17px 11px 0; border-top-color: var(--parch-2); }
.bubble .who { position: absolute; bottom: -12px; right: calc(22% + 22px); padding: 0 8px; font-size: 12px; letter-spacing: .2em; color: #f6e2b0; background: var(--beni); border: 1px solid var(--shadow); }
/* 呪文は大きく。吹き出しは画面の左右にはみ出すくらい */
.bubble { margin-left: -28px; margin-right: -28px; padding: 18px 26px; }
.bubble p { margin: 0; min-height: 1.4em; font-size: clamp(30px, 10.5vw, 58px); line-height: 1.35; letter-spacing: -.02em; overflow-wrap: anywhere; }
.bubble p.typing::after { content: "▍"; animation: caret .5s steps(1) infinite; color: var(--beni); }
@keyframes caret { 50% { opacity: 0; } }

/* ---------- 答え（羊皮紙のカード） ---------- */
.card {
  margin: 16px 0 0;
  padding: 14px 16px;
  text-align: left;
  color: var(--ink);
  background: var(--parch);
  border: 2px solid var(--shadow);
  box-shadow: 4px 4px 0 var(--shadow);
  animation: rise .5s steps(5) both;
}
.card.big {
  padding: 22px 18px 18px;
  text-align: center;
  border: 3px double var(--ink);
  outline: 2px solid var(--shadow);
  box-shadow: 6px 6px 0 var(--shadow);
}
.card .work { margin: 0 0 2px; font-size: 13px; color: var(--ink-dim); letter-spacing: .06em; overflow-wrap: anywhere; }
.card .kind { margin-left: .6em; padding: 0 5px; border: 1px solid var(--ink-dim); font-size: 11px; }
.card .name { margin: 0; font-size: 20px; font-weight: normal; line-height: 1.4; overflow-wrap: anywhere; }
.card.big .name { font-size: clamp(25px, 7vw, 32px); }
.card .name a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--ink-dim); }
.card .name a:hover { color: var(--beni); border-bottom-color: var(--beni); }
.card .name a::after { content: "↗"; font-size: .45em; vertical-align: super; margin-left: 3px; color: var(--ink-dim); }
.card .intro { margin: 8px 0 0; font-size: 15px; line-height: 1.8; }
.rank { display: inline-block; margin: 0 0 8px; padding: 1px 12px; font-size: 12px; letter-spacing: .25em; color: #f6e2b0; background: var(--beni); border: 1px solid var(--shadow); }
.card.big .tags { justify-content: center; }
.card .tags span { padding: 0 7px; border: 1px solid var(--ink-dim); color: var(--ink); background: #f3e9d2; }
.card .tags .hit { background: var(--beni); color: #f6e2b0; border-color: var(--shadow); }
.sub-h { margin: 30px 0 0; font-size: 14px; font-weight: normal; letter-spacing: .3em; color: var(--gold); text-shadow: 2px 2px 0 var(--shadow); }
.sub-h::before, .sub-h::after { content: " ― "; color: var(--gold-dim); }
.actions { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 30px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

footer { position: relative; z-index: 1; max-width: 560px; margin: 40px auto 0; text-align: center; font-size: 12px; color: var(--text-dim); line-height: 1.8; text-shadow: 2px 2px 0 var(--shadow); }
footer p { margin: 2px 0; }

.credit { margin: 26px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.8; text-shadow: 2px 2px 0 var(--shadow); }

/* ---------- 結果画面 ---------- */
body[data-screen="final"] .mirror-wrap, body[data-screen="final"] .speech { display: none; }
.final-lab { display: inline-block; margin: 6px 0 4px; padding: 2px 16px; font-size: 14px; letter-spacing: .4em; color: var(--ink); background: #c9a24f; border: 2px solid var(--shadow); box-shadow: 3px 3px 0 var(--shadow); }

/* ---------- バーン ---------- */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #0b0806;
  text-align: center;
  cursor: pointer;
}
.reveal.go { animation: flashbg .6s steps(1); }
.reveal.go .reveal-in { animation: shake .45s steps(6) .35s; }
@keyframes flashbg { 0% { background: #fffbe8; } 33% { background: #0b0806; } 50% { background: #fffbe8; } 66% { background: #0b0806; } }
@keyframes shake { 0% { transform: translate(0, 0); } 20% { transform: translate(-10px, 6px); } 40% { transform: translate(9px, -7px); } 60% { transform: translate(-7px, -4px); } 80% { transform: translate(6px, 5px); } 100% { transform: translate(0, 0); } }
.reveal-in { max-width: 560px; }
.r-rank { display: inline-block; margin: 0 0 14px; padding: 3px 16px; font-size: clamp(14px, 4vw, 18px); letter-spacing: .4em; color: #f6e2b0; background: var(--beni); border: 2px solid #c9a24f; opacity: 0; }
.r-work { margin: 0 0 6px; font-size: clamp(14px, 4vw, 18px); color: var(--text-dim); opacity: 0; }
.r-name { margin: 0; font-size: clamp(44px, 15vw, 96px); line-height: 1.15; color: #f6e2b0; text-shadow: 5px 5px 0 var(--beni), 9px 9px 0 var(--shadow); overflow-wrap: anywhere; opacity: 0; }
.r-tail { margin: 14px 0 0; font-size: clamp(18px, 5vw, 26px); color: var(--text); opacity: 0; }
.r-next { margin: 34px 0 0; font-size: 12px; letter-spacing: .2em; color: var(--text-dim); opacity: 0; }
.reveal.go .r-name { animation: slam .3s steps(3) .3s both; }
.reveal.go .r-rank { animation: appear .01s 1s both; }
.reveal.go .r-work { animation: appear .01s 1.2s both; }
.reveal.go .r-tail { animation: appear .01s 1.5s both; }
.reveal.go .r-next { animation: blinkon 1s steps(1) 2s infinite; }
@keyframes slam { 0% { opacity: 1; transform: scale(3.2); } 66% { opacity: 1; transform: scale(1.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes appear { to { opacity: 1; } }
@keyframes blinkon { 0% { opacity: 1; } 50% { opacity: 0; } }
