/* =========================================================
   MONDQI ESCAPE — styles
   ========================================================= */

:root {
  --bg:        #060811;
  --ink:       #eef2ff;
  --ink-dim:   #8b94b8;
  --ink-faint: #4a5170;
  --accent:    #5b8cff;
  --accent-2:  #a78bfa;
  --good:      #22e3a1;
  --bad:       #ff4d6d;
  --gold:      #ffcf5c;
  --glass:     rgba(255, 255, 255, 0.045);
  --glass-2:   rgba(255, 255, 255, 0.08);
  --stroke:    rgba(255, 255, 255, 0.10);
  --radius:    22px;
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
             "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-jp);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.7;
  overflow-x: hidden;
}

button, input { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ============ 背景 ============ */

#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  filter: blur(70px);
  opacity: 0.5;
}

.blob { position: absolute; border-radius: 50%; mix-blend-mode: screen; }
.b1 {
  width: 60vw; height: 60vw;
  left: -8vw; top: -12vw;
  background: radial-gradient(circle at 40% 40%, #2b4bff, transparent 62%);
  animation: drift1 26s ease-in-out infinite alternate;
}
.b2 {
  width: 52vw; height: 52vw;
  right: -10vw; top: 6vh;
  background: radial-gradient(circle at 50% 50%, #b13bff, transparent 62%);
  animation: drift2 32s ease-in-out infinite alternate;
}
.b3 {
  width: 46vw; height: 46vw;
  left: 28vw; bottom: -22vw;
  background: radial-gradient(circle at 50% 50%, #00d4b1, transparent 62%);
  animation: drift3 38s ease-in-out infinite alternate;
}

@keyframes drift1 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(10vw,8vh,0) scale(1.18); } }
@keyframes drift2 { from { transform: translate3d(0,0,0) scale(1.05); } to { transform: translate3d(-8vw,12vh,0) scale(0.9); } }
@keyframes drift3 { from { transform: translate3d(0,0,0) scale(0.95); } to { transform: translate3d(6vw,-10vh,0) scale(1.2); } }

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

#fxCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
}

#flash {
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255,255,255,0.42), transparent 65%);
}
#flash.is-on { animation: flashHit 0.45s ease-out both; }
@keyframes flashHit {
  0% { opacity: 0; }
  18% { opacity: 0.75; }
  100% { opacity: 0; }
}

/* ============ 共通テキスト ============ */

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 0 16px;
  font-size: 10px;
  letter-spacing: 0.34em;
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.eyebrow .line {
  width: clamp(18px, 4vw, 46px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-faint));
}
.eyebrow .line:last-child { background: linear-gradient(270deg, transparent, var(--ink-faint)); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* ============ ボタン ============ */

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: min(320px, 86vw);
  padding: 17px 32px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, #4f7cff, #8b5cf6 55%, #d946ef);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 20px 60px -18px rgba(91,140,255,0.85), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.35s var(--ease-back), box-shadow 0.35s ease;
}
.btn-primary:hover { transform: translateY(-3px) scale(1.02); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary .btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sweep 3.8s ease-in-out infinite 1.2s;
}
@keyframes sweep {
  0% { transform: translateX(-120%); }
  38%, 100% { transform: translateX(120%); }
}
.btn-primary .btn-arrow { transition: transform 0.35s var(--ease-back); }
.btn-primary:hover .btn-arrow { transform: translateX(6px); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 26px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}
.btn-ghost:hover {
  color: var(--ink);
  border-color: rgba(255,255,255,0.28);
  background: var(--glass-2);
  transform: translateY(-2px);
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: var(--glass);
  color: var(--ink-dim);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-icon:hover {
  color: var(--ink);
  background: var(--glass-2);
  transform: translateX(-2px);
}

/* =========================================================
   HOME
   ========================================================= */

.page-home {
  display: flex;
  justify-content: center;
  padding: clamp(28px, 6vh, 64px) 20px 60px;
}

.home {
  position: relative;
  z-index: 2;
  width: min(760px, 100%);
  text-align: center;
}

.logo {
  position: relative;
  display: flex;
  justify-content: center;
  gap: clamp(1px, 0.5vw, 6px);
  margin: 0 0 14px;
  font-size: clamp(44px, 11vw, 96px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 0.94;
  font-family: "Helvetica Neue", Inter, var(--font-jp);
  perspective: 800px;
}

.logo-letter {
  display: inline-block;
  background: linear-gradient(180deg, #ffffff 0%, #c9d4ff 42%, #6a7bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 26px rgba(91,140,255,0.45));
  animation:
    letterIn 1s var(--ease-back) both,
    letterFloat 5.4s ease-in-out infinite;
  animation-delay: calc(0.1s + var(--i) * 0.07s), calc(1.1s + var(--i) * 0.2s);
}
@keyframes letterIn {
  0% { opacity: 0; transform: translate3d(0, 55px, 0) rotateX(-70deg) scale(0.6); }
  100% { opacity: 1; transform: none; }
}
@keyframes letterFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-1.2deg); }
}

.logo-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.85) 48%, transparent 58%);
  background-size: 250% 100%;
  background-position: 150% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  mix-blend-mode: overlay;
  pointer-events: none;
  animation: shine 4.8s ease-in-out infinite 1.3s;
}
@keyframes shine {
  0% { background-position: 190% 0; opacity: 0; }
  18% { opacity: 1; }
  52% { background-position: -60% 0; opacity: 0; }
  100% { background-position: -60% 0; opacity: 0; }
}

.logo-sub {
  margin: 0 0 26px;
  font-size: 11px;
  letter-spacing: 0.42em;
  font-weight: 700;
  color: var(--ink-dim);
  animation: fadeUp 0.9s var(--ease-out) both 0.75s;
}

.story-card {
  position: relative;
  margin: 0 0 30px;
  padding: clamp(18px, 3vw, 26px);
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(255,255,255,0.07), transparent 55%),
    rgba(12, 16, 32, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: clamp(13px, 1.6vw, 14.5px);
  line-height: 1.95;
  color: var(--ink-dim);
  text-align: left;
  animation: fadeUp 1s var(--ease-out) both 0.9s;
}
.story-card strong { color: var(--ink); }
.story-card .story-mark {
  display: block;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 10px;
}

.stage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
  text-align: left;
}

.stage-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  overflow: hidden;
  transition: transform 0.35s var(--ease-back), border-color 0.3s, background 0.3s, box-shadow 0.35s;
  animation: fadeUp 0.7s var(--ease-out) both;
  animation-delay: calc(1s + var(--i) * 0.07s);
}
.stage-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 160% at 0% 50%, color-mix(in srgb, var(--sc) 26%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s;
}
.stage-chip:hover {
  transform: translateY(-3px) translateX(3px);
  border-color: color-mix(in srgb, var(--sc) 55%, transparent);
  box-shadow: 0 16px 40px -20px var(--sc);
  background: var(--glass-2);
}
.stage-chip:hover::before { opacity: 0.7; }

.chip-no {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--sc);
  background: color-mix(in srgb, var(--sc) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 32%, transparent);
}

.chip-body { flex: 1 1 auto; min-width: 0; position: relative; }
.chip-title {
  display: block;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.chip-tag {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  font-weight: 700;
}
.chip-state {
  position: relative;
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.2em;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  color: var(--ink-faint);
}
.stage-chip.is-cleared .chip-state {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 45%, transparent);
  background: color-mix(in srgb, var(--good) 12%, transparent);
}
.stage-chip.is-cleared .chip-no { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeUp 0.9s var(--ease-out) both 1.3s;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  font-weight: 700;
}
.meta-line strong { color: var(--gold); letter-spacing: 0.06em; }

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: all 0.25s ease;
}
.sound-toggle:hover { color: var(--ink-dim); border-color: rgba(255,255,255,0.22); }
.sound-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
  transition: all 0.25s ease;
}
.sound-toggle[aria-pressed="false"] .sound-dot { background: var(--ink-faint); box-shadow: none; }

.reset-link {
  margin-top: 22px;
  background: none;
  border: 0;
  padding: 4px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.reset-link:hover { color: var(--bad); }

/* =========================================================
   STAGE PAGE
   ========================================================= */

.page-stage {
  display: flex;
  justify-content: center;
  padding: clamp(14px, 2.6vh, 24px) 16px 48px;
}

.stage-shell {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.dots {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: all 0.4s var(--ease-back);
}
.dot.is-cleared {
  background: var(--good);
  box-shadow: 0 0 12px var(--good);
}
.dot.is-current {
  width: 26px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.62; }
}

.score-mini {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  font-weight: 700;
}
.score-mini strong {
  font-size: 17px;
  letter-spacing: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: transform 0.25s var(--ease-back), color 0.3s;
}
.score-mini strong.bump { transform: scale(1.18); color: var(--gold); }
.score-mini strong.drop { color: var(--bad); }

.stage-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- シーン ---------- */

.scene {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background:
    radial-gradient(120% 160% at 50% 0%, rgba(255,255,255,0.06), transparent 60%),
    rgba(9, 12, 24, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  min-height: 190px;
  display: grid;
  place-items: center;
  padding: 22px 18px;
  animation: sceneIn 0.8s var(--ease-out) both;
}
@keyframes sceneIn {
  from { opacity: 0; transform: scale(0.97) translateY(10px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(90% 120% at 50% 100%, transparent 55%, rgba(0,0,0,0.5));
}

/* --- Scene 1: 黒板 --- */

.scene-cipher { min-height: 232px; }

.chalkboard {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 22px 20px 26px;
  border-radius: 12px;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,0.05), transparent 60%),
    #12261f;
  border: 6px solid #2a1d14;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 14px 40px -18px #000;
}

.chalk-row {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3vw, 26px);
  margin-bottom: 18px;
}
.chalk-num {
  font-family: "Bradley Hand", "Comic Sans MS", var(--font-jp);
  font-size: clamp(30px, 7vw, 44px);
  font-weight: 700;
  color: #eafff4;
  text-shadow: 0 0 12px rgba(210, 255, 235, 0.45);
  opacity: 0;
  animation:
    chalkIn 0.8s var(--ease-out) both,
    chalkFlicker 4s ease-in-out infinite;
  animation-delay: calc(0.25s + var(--i) * 0.16s), calc(1.4s + var(--i) * 0.3s);
}
@keyframes chalkIn {
  0% { opacity: 0; transform: translateY(-10px) rotate(-4deg); filter: blur(4px); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes chalkFlicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 0.82; }
  52% { opacity: 1; }
}

.alpha-chart {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
  padding-top: 12px;
  border-top: 1px dashed rgba(230, 255, 240, 0.22);
}
.alpha-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 0;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  font-size: 9px;
  line-height: 1.2;
  color: #cfeee0;
  transform-origin: center;
  animation: tileFlip 0.55s var(--ease-back) both;
  animation-delay: calc(0.6s + var(--i) * 0.022s);
}
.alpha-tile b { font-size: 10px; font-weight: 800; letter-spacing: 0.02em; }
.alpha-tile span { opacity: 0.55; font-size: 8px; }
@keyframes tileFlip {
  from { opacity: 0; transform: rotateX(-80deg); }
  to { opacity: 1; transform: none; }
}

/* --- Scene 2: 数列 --- */

.scene-seq { min-height: 190px; perspective: 700px; }
.seq-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(6px, 1.6vw, 14px);
}
.seq-num {
  display: grid;
  place-items: center;
  width: clamp(40px, 9vw, 54px);
  height: clamp(40px, 9vw, 54px);
  border-radius: 14px;
  font-size: clamp(16px, 3.4vw, 20px);
  font-weight: 800;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  box-shadow: 0 0 26px -12px var(--accent);
  animation: seqPop 0.7s var(--ease-back) both, seqFloat 3.6s ease-in-out infinite;
  animation-delay: calc(0.2s + var(--i) * 0.14s), calc(1.2s + var(--i) * 0.2s);
}
@keyframes seqPop {
  from { opacity: 0; transform: translateY(18px) scale(0.6) rotateX(-40deg); }
  to { opacity: 1; transform: none; }
}
@keyframes seqFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.seq-question {
  display: grid;
  place-items: center;
  width: clamp(46px, 10vw, 60px);
  height: clamp(46px, 10vw, 60px);
  border-radius: 16px;
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 900;
  color: var(--gold);
  border: 1px dashed color-mix(in srgb, var(--gold) 60%, transparent);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  animation: qPulse 1.9s ease-in-out infinite;
}
@keyframes qPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,207,92,0.35); transform: scale(1); }
  50% { box-shadow: 0 0 0 12px rgba(255,207,92,0); transform: scale(1.06); }
}

/* --- Scene 3: サイコロ --- */

.scene-cube { min-height: 240px; perspective: 900px; }
.cube-stage { width: 150px; height: 150px; perspective: 900px; }
.cube {
  position: relative;
  width: 150px;
  height: 150px;
  transform-style: preserve-3d;
  animation: cubeSpin 22s linear infinite;
}
@keyframes cubeSpin {
  0% { transform: rotateX(-20deg) rotateY(0deg); }
  100% { transform: rotateX(-20deg) rotateY(360deg); }
}
.face {
  position: absolute;
  inset: 0;
  padding: 16px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 7px;
  background: linear-gradient(150deg, #f4f7ff, #c3cbe8);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: inset 0 0 24px rgba(60, 80, 140, 0.28);
  backface-visibility: visible;
}
.pip { background: #12172a; border-radius: 50%; box-shadow: inset 0 2px 4px rgba(0,0,0,0.45); }
.f-front { transform: translateZ(75px); }
.f-back { transform: rotateY(180deg) translateZ(75px); }
.f-right { transform: rotateY(90deg) translateZ(75px); }
.f-left { transform: rotateY(-90deg) translateZ(75px); }
.f-top { transform: rotateX(90deg) translateZ(75px); }
.f-bottom { transform: rotateX(-90deg) translateZ(75px); }

/* --- Scene 4: 証言 --- */

.scene-witness { min-height: 260px; }
.witness-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, 1.6vw, 14px);
  width: 100%;
  max-width: 540px;
}
.witness {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: witnessIn 0.7s var(--ease-back) both;
  animation-delay: calc(0.25s + var(--i) * 0.18s);
}
@keyframes witnessIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
.bubble {
  position: relative;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.06);
  font-size: clamp(10px, 1.8vw, 12px);
  line-height: 1.5;
  text-align: center;
  min-height: 3.6em;
  display: grid;
  place-items: center;
  color: var(--ink);
  animation: bubbleFloat 4s ease-in-out infinite;
  animation-delay: calc(1s + var(--i) * 0.35s);
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-right: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
  transform: translateX(-50%) rotate(45deg);
}
@keyframes bubbleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.avatar {
  display: grid;
  place-items: center;
  width: clamp(38px, 7vw, 48px);
  height: clamp(38px, 7vw, 48px);
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  color: var(--sc);
  background: color-mix(in srgb, var(--sc) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 42%, transparent);
  box-shadow: 0 0 24px -10px var(--sc);
}
.w-name {
  font-size: 10px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--ink-dim);
}

/* --- Scene 5: 扉 --- */

.scene-door { min-height: 260px; }
.door-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vw, 34px);
  width: 100%;
  flex-wrap: wrap;
}
.door-frame {
  position: relative;
  width: clamp(96px, 22vw, 124px);
  height: clamp(150px, 34vw, 190px);
  border-radius: 10px 10px 4px 4px;
  background: #0a0d18;
  border: 5px solid #2c2333;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.9), 0 0 60px -20px var(--gold);
  overflow: hidden;
  animation: doorBreath 4.5s ease-in-out infinite;
}
@keyframes doorBreath {
  0%, 100% { box-shadow: inset 0 0 30px rgba(0,0,0,0.9), 0 0 50px -22px var(--gold); }
  50% { box-shadow: inset 0 0 30px rgba(0,0,0,0.9), 0 0 90px -14px var(--gold); }
}
.door-panel {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, #2b2136, #16101f 60%, #241a2d);
  display: grid;
  place-items: center;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: rgba(255, 220, 150, 0.55);
  border-left: 1px solid rgba(255,255,255,0.08);
}
.door-panel::before {
  content: "";
  position: absolute;
  right: 9px;
  top: 52%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
  animation: keyBlink 2.4s ease-in-out infinite;
}
@keyframes keyBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.door-seam {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 40%, rgba(255,215,130,0.28) 50%, transparent 60%);
  opacity: 0;
  animation: seamGlow 3.4s ease-in-out infinite;
}
@keyframes seamGlow {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.code-wall {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  width: min(260px, 100%);
}
.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04);
  font-size: 10px;
  color: var(--ink-faint);
  animation: fadeUp 0.6s var(--ease-out) both;
  animation-delay: calc(0.4s + var(--i) * 0.12s);
}
.code-item strong {
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 0.06em;
}

/* ---------- 謎パネル ---------- */

.puzzle-card {
  position: relative;
  padding: clamp(18px, 3vw, 28px);
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(255,255,255,0.06), transparent 55%),
    rgba(12, 16, 32, 0.74);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 34px 90px -46px rgba(0,0,0,0.95), inset 0 1px 0 rgba(255,255,255,0.07);
  animation: fadeUp 0.7s var(--ease-out) both 0.12s;
}
.puzzle-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 60%, transparent), transparent 45%, transparent 62%, color-mix(in srgb, var(--accent-2) 42%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.puzzle-card.is-solved { box-shadow: 0 30px 90px -42px var(--good), inset 0 1px 0 rgba(255,255,255,0.09); }

.puzzle-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.stage-label {
  font-size: 10px;
  letter-spacing: 0.28em;
  font-weight: 800;
  color: var(--accent);
}
.puzzle-tag {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.cleared-badge {
  display: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
}
.puzzle-card.is-solved .cleared-badge { display: inline-block; animation: popIn 0.5s var(--ease-back) both; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

.puzzle-title {
  margin: 0 0 10px;
  font-size: clamp(19px, 3.2vw, 25px);
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.puzzle-q {
  margin: 0 0 18px;
  font-size: clamp(13px, 1.9vw, 15px);
  line-height: 1.85;
  color: var(--ink-dim);
  text-wrap: pretty;
}

/* ---------- 入力 ---------- */

.answer-form { margin-bottom: 12px; }

.answer-field {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04);
  transition: border-color 0.25s, box-shadow 0.3s, background 0.25s;
}
.answer-field:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), 0 16px 40px -24px var(--accent);
  background: rgba(255,255,255,0.06);
}
.answer-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.answer-input::placeholder { color: var(--ink-faint); font-weight: 600; font-size: 13px; }

.btn-submit {
  flex: 0 0 auto;
  padding: 11px 22px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.25s var(--ease-back), filter 0.25s;
  box-shadow: 0 10px 26px -14px var(--accent);
}
.btn-submit:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-submit:active { transform: scale(0.97); }

.answer-field.shake { animation: fieldShake 0.42s ease both; border-color: var(--bad); }
@keyframes fieldShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
.answer-field.is-good { border-color: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 16%, transparent); }

.feedback {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.5s var(--ease-out), opacity 0.4s ease;
}
.feedback.is-open { grid-template-rows: 1fr; opacity: 1; }
.feedback > div { overflow: hidden; }
.feedback-body {
  margin-top: 4px;
  padding: 13px 15px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.8;
  border-left: 2px solid var(--accent);
  background: rgba(255,255,255,0.04);
  color: var(--ink-dim);
}
.feedback.is-good .feedback-body {
  border-left-color: var(--good);
  background: color-mix(in srgb, var(--good) 9%, transparent);
  color: #d6ffee;
}
.feedback.is-bad .feedback-body {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 9%, transparent);
  color: #ffdbe2;
}
.feedback-title {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin-bottom: 4px;
  color: var(--good);
}
.feedback.is-bad .feedback-title { color: var(--bad); }

/* ---------- ヒント ---------- */

.hint-area { margin-top: 14px; }

.hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px dashed var(--stroke);
  background: transparent;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.25s ease;
}
.hint-btn:hover:not(:disabled) {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}
.hint-btn:disabled { opacity: 0.4; cursor: default; }
.hint-cost { font-size: 9px; color: var(--ink-faint); letter-spacing: 0.1em; }

.hint-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.hint-item {
  display: flex;
  gap: 9px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 26%, transparent);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
  font-size: 12px;
  line-height: 1.75;
  color: #ffeec2;
  animation: hintIn 0.5s var(--ease-out) both;
}
.hint-item b {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--gold);
  padding-top: 3px;
}
@keyframes hintIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 次へ ---------- */

.btn-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--good) 34%, transparent);
  background: color-mix(in srgb, var(--good) 12%, transparent);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  transition: all 0.3s var(--ease-out);
  animation: fadeUp 0.6s var(--ease-out) both;
}
.btn-next:hover {
  background: color-mix(in srgb, var(--good) 22%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 16px 44px -20px var(--good);
}
.btn-next span { transition: transform 0.3s var(--ease-back); }
.btn-next:hover span { transform: translateX(6px); }

/* STAGE 5 クリア後の EXIT ボタン */
.btn-next.is-exit {
  position: relative;
  gap: 16px;
  padding: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: #ffe4ea;
  border-color: rgba(255, 77, 109, 0.55);
  background:
    linear-gradient(120deg, rgba(255, 77, 109, 0.22), rgba(255, 207, 92, 0.12));
  overflow: hidden;
  animation: exitIn 0.7s var(--ease-back) both, exitPulse 2.6s ease-in-out infinite 0.7s;
}
@keyframes exitIn {
  from { opacity: 0; transform: scale(0.92); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes exitPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.0); }
  50% { box-shadow: 0 0 46px -12px rgba(255, 77, 109, 0.75); }
}
.btn-next.is-exit::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  transform: translateX(-130%);
  animation: exitSweep 2.8s ease-in-out infinite 0.9s;
}
@keyframes exitSweep {
  0% { transform: translateX(-130%); }
  55%, 100% { transform: translateX(130%); }
}
.btn-next.is-exit::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 18px;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 12px var(--bad);
  animation: keyBlink 1.6s ease-in-out infinite;
}
.btn-next.is-exit:hover {
  background: linear-gradient(120deg, rgba(255, 77, 109, 0.32), rgba(255, 207, 92, 0.18));
  transform: translateY(-2px);
  box-shadow: 0 18px 50px -18px var(--bad);
}

/* =========================================================
   CLEAR
   ========================================================= */

.page-clear {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}

.clear-wrap {
  position: relative;
  z-index: 2;
  width: min(600px, 100%);
  text-align: center;
}

.escape-door {
  position: relative;
  width: clamp(110px, 26vw, 140px);
  height: clamp(170px, 40vw, 210px);
  margin: 0 auto 26px;
  perspective: 800px;
}
.door-light {
  position: absolute;
  inset: 0;
  border-radius: 8px 8px 0 0;
  background: radial-gradient(circle at 50% 60%, #fffbe8, #ffd166 35%, transparent 72%);
  filter: blur(6px);
  animation: lightPulse 3s ease-in-out infinite;
}
@keyframes lightPulse {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.door-leaf {
  position: absolute;
  inset: 0;
  border-radius: 8px 8px 0 0;
  border: 4px solid #2c2333;
  background: linear-gradient(120deg, #2b2136, #16101f 60%, #241a2d);
  transform-origin: left center;
  animation: doorOpen 2.2s cubic-bezier(0.3, 0.9, 0.2, 1) forwards 0.4s;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.7);
}
@keyframes doorOpen {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(-108deg); }
}
.door-leaf::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px var(--gold);
}

.clear-title {
  margin: 0 0 6px;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff, #ffd166 70%, #ff9a3f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeUp 0.8s var(--ease-out) both 1.2s;
}
.clear-sub {
  margin: 0 0 26px;
  font-size: 13px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  animation: fadeUp 0.8s var(--ease-out) both 1.35s;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 26px;
  animation: fadeUp 0.8s var(--ease-out) both 1.5s;
}
.stat {
  padding: 14px 8px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--glass);
}
.stat span {
  display: block;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 4px;
}
.stat strong {
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.stat.accent strong { color: var(--gold); }

.clear-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: fadeUp 0.8s var(--ease-out) both 1.7s;
}

/* =========================================================
   EXTRA STAGES / 声
   ========================================================= */

.extra-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 14px;
  animation: fadeUp 0.7s var(--ease-out) both;
}
.extra-head .line {
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--stroke), transparent);
}
.extra-head span {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.3em;
  font-weight: 800;
  color: var(--ink-faint);
}
.extra-head .extra-count { color: var(--bad); }

.locked-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  margin-bottom: 26px;
  border-radius: 16px;
  border: 1px dashed var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.7;
  text-align: left;
  animation: fadeUp 0.7s var(--ease-out) both 1.5s;
}
.locked-panel .lock {
  font-size: 18px;
  opacity: 0.55;
  filter: grayscale(1);
  animation: lockShake 4s ease-in-out infinite;
}
@keyframes lockShake {
  0%, 86%, 100% { transform: rotate(0deg); }
  90% { transform: rotate(-9deg); }
  94% { transform: rotate(9deg); }
}

/* ---- 声の主 ---- */

.voice {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 26px;
  background: radial-gradient(circle at 50% 42%, rgba(30, 8, 26, 0.88), rgba(3, 3, 9, 0.98) 68%);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
  text-align: center;
}
.voice.is-on {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.voice-inner { max-width: 540px; }

.voice-eye {
  position: relative;
  width: clamp(86px, 18vw, 120px);
  height: clamp(44px, 9vw, 60px);
  margin: 0 auto 26px;
  border-radius: 50% 50% 48% 52% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 55%, #ff4d6d 0%, #a3163c 38%, #2a0a18 72%);
  box-shadow: 0 0 70px -6px rgba(255, 77, 109, 0.75), inset 0 0 26px rgba(0, 0, 0, 0.8);
  animation: eyeBreathe 3.6s ease-in-out infinite;
}
.voice-eye::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24%;
  height: 64%;
  border-radius: 50%;
  background: #06030a;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 22px rgba(255, 120, 150, 0.55);
  animation: eyeBlink 5.4s ease-in-out infinite;
}
.voice-eye::after {
  content: "";
  position: absolute;
  inset: -14px -18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 77, 109, 0.18);
  animation: eyeRing 4s ease-in-out infinite;
}
@keyframes eyeBreathe {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.25); }
}
@keyframes eyeBlink {
  0%, 92%, 100% { transform: translate(-50%, -50%) scaleY(1); }
  95% { transform: translate(-50%, -50%) scaleY(0.06); }
}
@keyframes eyeRing {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(1.12); opacity: 0.7; }
}

.voice-line {
  min-height: 1.5em;
  margin: 0 0 10px;
  font-size: clamp(22px, 5.2vw, 34px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ffe6ec;
  text-shadow: 0 0 34px rgba(255, 60, 100, 0.6);
}
.voice-line:empty::after {
  content: "▌";
  animation: caret 0.9s steps(1) infinite;
}
@keyframes caret { 0%, 50% { opacity: 1; } 50.1%, 100% { opacity: 0; } }

.voice-sub {
  margin: 14px 0 26px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.voice-sub.is-in { opacity: 1; transform: none; }

#voiceBtn {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
  border-color: rgba(255, 77, 109, 0.35);
  color: #ffd8e0;
}
#voiceBtn.is-in { opacity: 1; transform: none; }

/* =========================================================
   STAGE 6〜15 のシーン
   ========================================================= */

/* 鏡 */
.scene-mirror { min-height: 200px; }
.mirror-frame {
  position: relative;
  padding: 20px clamp(22px, 6vw, 42px);
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.015));
  box-shadow: 0 0 60px -20px var(--accent), inset 0 0 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.mirror-frame::after {
  content: "";
  position: absolute;
  inset: -50% -120%;
  background: linear-gradient(105deg, transparent 45%, rgba(255, 255, 255, 0.35) 50%, transparent 55%);
  animation: mirrorSweep 5.5s ease-in-out infinite;
}
@keyframes mirrorSweep {
  0% { transform: translateX(-40%); }
  55%, 100% { transform: translateX(40%); }
}
.mirror-word {
  display: inline-block;
  font-family: "Helvetica Neue", Inter, sans-serif;
  font-size: clamp(26px, 6.6vw, 44px);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #dbe6ff;
  text-shadow: 0 0 22px rgba(140, 180, 255, 0.55);
  transform: scaleX(-1);
}

/* 時計 */
.scene-clock { min-height: 210px; }
.clock-wrap {
  transform: scaleX(-1);
  filter: drop-shadow(0 0 26px rgba(120, 170, 255, 0.35));
}
.clock-wrap svg {
  width: clamp(130px, 30vw, 168px);
  height: auto;
  animation: clockBob 4.2s ease-in-out infinite;
}
@keyframes clockBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.clock-face { fill: rgba(12, 18, 34, 0.92); stroke: rgba(255, 255, 255, 0.18); stroke-width: 2; }
.clock-tick { stroke: rgba(255, 255, 255, 0.32); stroke-width: 2; }
.clock-num { fill: rgba(220, 230, 255, 0.72); font-size: 9px; font-weight: 700; text-anchor: middle; }
.hand-hour { stroke: #dfe8ff; stroke-width: 4; stroke-linecap: round; }
.hand-min { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.hand-dot { fill: #ffffff; }

/* 天秤 */
.scene-balance { min-height: 200px; }
.balance-stack { display: flex; flex-direction: column; gap: 10px; }
.balance-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  animation: fadeUp 0.6s var(--ease-out) both, sway 4.4s ease-in-out infinite;
  animation-delay: calc(0.15s + var(--i) * 0.14s), calc(1s + var(--i) * 0.3s);
}
@keyframes sway {
  0%, 100% { transform: rotate(0deg); }
  35% { transform: rotate(-0.8deg); }
  70% { transform: rotate(0.8deg); }
}
.eq-chip { font-size: clamp(15px, 3.4vw, 21px); letter-spacing: 0.08em; }
.eq-op { color: var(--gold); font-weight: 900; font-size: 15px; }

/* シーザー暗号 */
.scene-shift { min-height: 190px; }
.shift-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.rule-card {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px dashed color-mix(in srgb, var(--gold) 60%, transparent);
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.2em;
  font-weight: 800;
  animation: qPulse 2.4s ease-in-out infinite;
}
.tiles, .ana-tiles { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.tile {
  width: clamp(34px, 8vw, 46px);
  height: clamp(42px, 10vw, 56px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 900;
  font-size: clamp(16px, 4vw, 22px);
  color: #e6edff;
  animation: tileFlip 0.6s var(--ease-back) both;
  animation-delay: calc(0.2s + var(--i) * 0.09s);
}

/* 等式 */
.scene-equations { min-height: 210px; }
.eq-list { display: flex; flex-direction: column; gap: 5px; }
.eq-line {
  padding: 3px 16px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(15px, 3.4vw, 19px);
  letter-spacing: 0.1em;
  color: #cfe0ff;
  animation: fadeUp 0.5s var(--ease-out) both;
  animation-delay: calc(0.15s + var(--i) * 0.12s);
}
.eq-line.is-q { color: var(--gold); background: color-mix(in srgb, var(--gold) 9%, transparent); }

/* 漢字 */
.scene-kanji { min-height: 200px; }
.kanji-merge { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.kanji-row { display: flex; gap: 10px; }
.kanji-char {
  width: clamp(42px, 9vw, 54px);
  height: clamp(42px, 9vw, 54px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 800;
  color: #e8f0ff;
  animation: kanjiIn 0.6s var(--ease-back) both;
  animation-delay: calc(0.2s + var(--i) * 0.2s);
}
@keyframes kanjiIn {
  from { opacity: 0; transform: translateY(-16px) rotate(-9deg) scale(0.72); }
  to { opacity: 1; transform: none; }
}

/* 蓮 */
.scene-lily { min-height: 200px; }
.lily-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  width: min(300px, 78vw);
}
.pad {
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
  animation: padIn 0.5s var(--ease-back) both, padGlow 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 11ms), calc(1.2s + var(--i) * 24ms);
}
@keyframes padIn {
  from { opacity: 0; transform: scale(0.2); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes padGlow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* 数字の表 */
.scene-grid { min-height: 210px; }
.num-table { border-collapse: separate; border-spacing: 6px; }
.num-table td {
  width: clamp(38px, 8vw, 48px);
  height: clamp(38px, 8vw, 48px);
  text-align: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  font-size: clamp(15px, 3.6vw, 19px);
  font-weight: 800;
  color: #e6edff;
  animation: fadeUp 0.5s var(--ease-out) both;
}
.num-table td.q {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  animation: qPulse 2s ease-in-out infinite;
}

/* アナグラム */
.scene-anagram { min-height: 200px; }
.ana-tile {
  width: clamp(36px, 8vw, 48px);
  height: clamp(46px, 10vw, 58px);
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 900;
  font-size: clamp(17px, 4vw, 22px);
  color: #e6edff;
  animation: tileShuffle 3.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.2s);
}
@keyframes tileShuffle {
  0%, 62%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-8px) rotate(-5deg); }
  46% { transform: translateY(4px) rotate(4deg); }
}

/* 数字の奔流 */
.scene-numbers { min-height: 190px; }
.num-rush { position: relative; width: 100%; max-width: 420px; height: 150px; overflow: hidden; }
.num-rush span {
  position: absolute;
  left: calc(var(--x) * 1%);
  bottom: -30px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(200, 215, 255, 0.55);
  animation: rushUp linear infinite;
  animation-duration: calc(6s + var(--d) * 1.4s);
  animation-delay: calc(var(--i) * -0.7s);
}
@keyframes rushUp {
  0% { transform: translateY(0); opacity: 0; }
  18% { opacity: 1; }
  85% { opacity: 0.8; }
  100% { transform: translateY(-190px); opacity: 0; }
}

/* ============ レスポンシブ ============ */

@media (max-width: 560px) {
  .alpha-tile b { font-size: 8px; }
  .alpha-tile span { display: none; }
  .alpha-chart { grid-template-columns: repeat(13, 1fr); gap: 2px; }
  .chalkboard { padding: 16px 12px 18px; border-width: 4px; }
  .chalk-row { gap: 10px; margin-bottom: 12px; }
  .witness-row { gap: 4px; }
  .bubble { font-size: 9.5px; padding: 6px 6px; }
  .code-wall { width: 100%; }
  .door-stage { gap: 14px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat { padding: 12px 4px; }
  .btn-primary { min-width: 0; width: 100%; }
  .btn-ghost { width: 100%; }
  .clear-actions { flex-direction: column; }
  .clear-actions > * { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .blob { animation: none !important; }
  .cube { animation: none !important; transform: rotateX(-20deg) rotateY(-32deg); }
  .door-leaf { animation: none !important; transform: rotateY(-108deg); }
}
