:root {
  --pink: #ff6fae;
  --pink-l: #ffc2dc;
  --purple: #8a4fd8;
  --purple-l: #c9a6ff;
  --gold: #ffd77a;
  --orange: #ff8a1f;
  --cream: #fff6ee;
  --ink: #2a1236;
  --ok: #57f0b0;
  --ng: #ff5c7a;
  --glass: rgba(24, 8, 40, .78);
  --font: "Zen Maru Gothic", "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  --font-ui: "M PLUS Rounded 1c", var(--font);
  --font-logo: "Dela Gothic One", var(--font-ui);
  --hud-h: 50px;
  --msg-h: 172px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--cream);
  background: #14061f;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, a.vn-btn { font-family: var(--font-ui); }
[hidden] { display: none !important; }

/* ---------- 背景 ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-img {
  position: absolute; inset: -4%;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255,120,60,.45), transparent 60%),
    linear-gradient(180deg, #0b0420 0%, #2a0d4a 55%, #6a1f5e 100%);
  background-size: cover; background-position: 50% 58%; background-repeat: no-repeat;
  animation: bgDrift 38s ease-in-out infinite alternate;
  transition: filter .6s ease;
}
body:not(.on-title) .bg-img { filter: blur(1.2px) brightness(.9) saturate(1.1); }
body.on-title .bg-img { filter: brightness(.75) saturate(1.1); }
@keyframes bgDrift {
  from { transform: scale(1.02) translateX(-1.2%); }
  to { transform: scale(1.06) translateX(1.2%); }
}
.bg-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(8,2,16,.65) 100%);
}
.bg-tint { position: absolute; inset: 0; opacity: 0; transition: opacity .6s ease; pointer-events: none; }
.bg-tint.love { opacity: 1; background: radial-gradient(ellipse at 50% 50%, rgba(255,111,174,.15), rgba(255,60,140,.42)); }
.bg-tint.ng { opacity: 1; background: rgba(40, 0, 20, .35); }
.screen-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.screen-flash.go { animation: whiteFlash .5s ease-out; }
@keyframes whiteFlash { 0% { opacity: .7; } 100% { opacity: 0; } }

/* ---------- 画面 ---------- */
#app { position: relative; z-index: 1; min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; animation: fadeIn .45s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- VN風ボタン ---------- */
.vn-btn {
  position: relative; display: block; width: 100%;
  padding: 13px 22px; border: none; cursor: pointer;
  color: #fff; font-size: 17px; font-weight: 800; letter-spacing: .12em; text-align: center; text-decoration: none;
  background: linear-gradient(90deg, rgba(255,111,174,0) 0%, rgba(60,16,84,.88) 14%, rgba(60,16,84,.88) 86%, rgba(255,111,174,0) 100%);
  border-top: 1px solid rgba(255,194,220,.55); border-bottom: 1px solid rgba(255,194,220,.55);
  text-shadow: 0 0 8px rgba(255,111,174,.7);
  transition: transform .1s, background .2s, letter-spacing .2s;
}
.vn-btn span::before, .vn-btn span::after { content: "◆"; font-size: .55em; color: var(--pink); margin: 0 .9em; vertical-align: .2em; opacity: .9; }
.vn-btn:hover, .vn-btn:focus-visible {
  background: linear-gradient(90deg, rgba(255,111,174,0) 0%, rgba(160,40,120,.9) 14%, rgba(160,40,120,.9) 86%, rgba(255,111,174,0) 100%);
  outline: none; letter-spacing: .16em;
}
.vn-btn:active { transform: scale(.98); }
.vn-btn:disabled { opacity: .5; cursor: default; }
.vn-btn-small { font-size: 14px; padding: 9px 18px; }
.vn-btn-x span::before, .vn-btn-x span::after { color: #fff; }
.btn-stack { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* ---------- タイトル ---------- */
#screen-title { position: relative; height: 100dvh; overflow: hidden; }
.title-char {
  position: absolute; bottom: -2%; left: 50%;
  height: 86%; max-width: 128%; object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 30px rgba(255,111,174,.45));
  animation: titleCharIn 1s cubic-bezier(.2,.9,.3,1) both .15s;
}
@keyframes titleCharIn { from { opacity: 0; transform: translate(-40%, 0); } }
.title-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,3,20,.7) 0%, transparent 28%, transparent 48%, rgba(10,3,20,.92) 82%); pointer-events: none; }
.title-logo-wrap { position: relative; z-index: 2; text-align: center; padding: calc(28px + env(safe-area-inset-top)) 16px 0; }
.title-kicker { margin: 0 0 6px; color: var(--gold); font-family: var(--font-ui); font-weight: 800; letter-spacing: .3em; font-size: 11px; text-shadow: 0 0 10px rgba(255,215,122,.8); }
.title-logo {
  margin: 0; font-family: var(--font-logo); font-weight: 400; line-height: 1.12;
  font-size: clamp(36px, 10.5vw, 64px); color: #fff;
  text-shadow: 0 0 2px #fff, 0 3px 0 #c2287a, 0 0 18px rgba(255,111,174,.95), 0 0 42px rgba(138,79,216,.9);
  animation: logoIn 1s cubic-bezier(.2,1.4,.4,1) both;
}
.title-logo span { display: block; }
.title-logo span:last-child { color: #ffe6f1; }
@keyframes logoIn { from { transform: scale(.7); opacity: 0; filter: blur(6px); } }
.title-sub { margin: 10px 0 0; font-weight: 700; color: var(--pink-l); text-shadow: 0 0 8px rgba(0,0,0,.8); }
.title-menu {
  position: absolute; z-index: 2; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 440px); padding: 0 18px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  animation: fadeIn .8s ease both .5s;
}
.title-best { font-size: 13px; padding: 5px 14px; border-radius: 999px; background: rgba(0,0,0,.5); border: 1px solid rgba(255,215,122,.6); color: var(--gold); }

/* ---------- ガラスカード ---------- */
.glass-card {
  width: min(94vw, 560px); margin: auto; padding: 24px 18px;
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,194,220,.5); border-radius: 22px;
  box-shadow: 0 0 0 4px rgba(255,111,174,.08), 0 14px 50px rgba(0,0,0,.55);
}
#screen-howto, #screen-result { padding: calc(20px + env(safe-area-inset-top)) 0 calc(20px + env(safe-area-inset-bottom)); }
.howto h2 { margin: 0 0 14px; text-align: center; color: var(--pink-l); font-family: var(--font-ui); letter-spacing: .2em; }
.howto ol { padding-left: 1.3em; margin: 0 0 12px; line-height: 1.75; }
.howto li { margin-bottom: 8px; }
.howto em { color: var(--gold); font-style: normal; font-weight: 700; }
.howto-tip { font-size: 13px; color: var(--purple-l); margin: 0 0 12px; }
.howto-score { background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 14px; margin-bottom: 18px; font-size: 14px; text-align: center; }
.howto-score p { margin: 4px 0; }

/* ---------- ゲーム画面 ---------- */
#screen-game { position: relative; height: 100dvh; overflow: hidden; }
#screen-game.shake { animation: shake .5s ease; }
@keyframes shake {
  20% { transform: translateX(-9px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  height: calc(var(--hud-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, rgba(10,3,20,.85), rgba(10,3,20,0));
  transition: opacity .3s, transform .3s;
}
.hud-chip {
  flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 6px;
  padding: 5px 8px; border-radius: 999px;
  background: rgba(20,6,34,.7); border: 1px solid rgba(255,194,220,.35);
  font-family: var(--font-ui);
}
.hud-label { font-size: 10px; color: var(--purple-l); font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.hud-val { font-size: 16px; font-weight: 800; white-space: nowrap; }
.hud-love .hud-val { color: var(--pink); }
.hud-love .hud-label { color: var(--pink-l); }
.hud-val.bump { animation: bump .5s ease; display: inline-block; }
@keyframes bump { 40% { transform: scale(1.4); color: var(--gold); } }
.hud-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,194,220,.35); background: rgba(20,6,34,.7); color: #fff; font-size: 15px; cursor: pointer; }

.diff-badge {
  position: absolute; z-index: 5; top: calc(var(--hud-h) + env(safe-area-inset-top) + 4px); left: 10px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  background: rgba(0,0,0,.5); border: 1px solid currentColor; transition: opacity .3s;
}
.diff-badge.easy { color: var(--ok); }
.diff-badge.normal { color: var(--gold); }
.diff-badge.hard { color: var(--ng); }
.diff-badge.finale { color: var(--pink); }

/* 立ち絵：HUDの下〜メッセージウィンドウの上に収める（頭・足・小物を切らない） */
.char-wrap {
  position: absolute; z-index: 2; left: 0; right: 0;
  top: calc(var(--hud-h) + env(safe-area-inset-top) + 4px);
  bottom: calc(var(--msg-h) + env(safe-area-inset-bottom) + 8px);
  display: flex; justify-content: center; align-items: flex-end;
  transition: top .4s ease, bottom .4s ease;
  pointer-events: none;
}
.char-inner { position: relative; height: 100%; width: 100%; display: flex; justify-content: center; align-items: flex-end; }
.char-wrap.enter .char-inner { animation: charIn .7s cubic-bezier(.2,.9,.3,1) both; }
.char-wrap.leave .char-inner { animation: charOut .32s ease both; }
@keyframes charIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes charOut { to { opacity: 0; transform: translateX(-40px); } }
#char-img {
  max-height: 100%; max-width: 100%; width: auto; height: auto;
  object-fit: contain; object-position: center bottom;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 18px rgba(255,111,174,.35)) drop-shadow(0 8px 16px rgba(0,0,0,.5));
  animation: breathe 4.5s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.006, 1.012); } }
.char-wrap.joy .char-inner { animation: joy .7s ease; }
@keyframes joy { 25% { transform: translateY(-14px); } 50% { transform: translateY(0); } 70% { transform: translateY(-6px); } }
.char-wrap.glow #char-img, .char-wrap.glow .silhouette { animation: glow 1s ease, breathe 4.5s ease-in-out infinite; }
@keyframes glow { 40% { filter: drop-shadow(0 0 20px #fff6c8) drop-shadow(0 0 40px var(--gold)) brightness(1.15); } }
.char-wrap.hurt .char-inner { animation: hurt .5s ease; }
@keyframes hurt { 30% { transform: translateX(-10px) rotate(-1deg); } 60% { transform: translateX(8px); } }

.char-placeholder { height: 100%; max-width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.silhouette { height: 100%; width: auto; filter: drop-shadow(0 0 18px rgba(255,111,174,.4)); }
.ph-label { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; font-family: var(--font-ui); }
.ph-appearance {
  position: absolute; left: 50%; top: 38px; transform: translateX(-50%);
  width: min(88vw, 380px);
  background: rgba(255,246,238,.94); color: var(--ink);
  border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.55; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.ph-appearance::before { content: "👀 見た目メモ（画像準備中のため）"; display: block; font-size: 11px; color: var(--purple); margin-bottom: 2px; }

/* 演出 */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.heart { position: absolute; bottom: 30%; font-size: 26px; animation: heartUp 2s ease-out forwards; }
@keyframes heartUp {
  0% { transform: translateY(0) scale(.4); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-340px) scale(1.2) rotate(var(--rot, 0deg)); opacity: 0; }
}
.sparkle { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff6c8; box-shadow: 0 0 12px var(--gold); animation: spark .9s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.result-flash {
  position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%);
  z-index: 8; pointer-events: none; white-space: nowrap;
  font-family: var(--font-logo); font-size: clamp(38px, 11vw, 64px); opacity: 0;
}
.result-flash.show { animation: flash 1.2s ease forwards; }
.result-flash.ok { color: #fff8d8; text-shadow: 0 0 4px #fff, 0 4px 0 #b06a00, 0 0 30px var(--gold); }
.result-flash.ng { color: #fff; text-shadow: 0 4px 0 #7a1030, 0 0 22px var(--ng); }
.result-flash.love { color: #ffe0ee; text-shadow: 0 4px 0 #c2287a, 0 0 30px var(--pink), 0 0 60px var(--pink); }
@keyframes flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  32% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%); }
}

.result-flash.boom {
  font-size: clamp(46px, 14vw, 88px); font-style: italic; color: #ffe14d; top: 30%;
  text-shadow: 4px 4px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0 0 30px rgba(255,90,0,.85);
}
.result-flash.boom.show { animation: boomFlash 1.5s ease forwards; }
@keyframes boomFlash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.6) rotate(-8deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(.95) rotate(-6deg); }
  24% { transform: translate(-50%, -50%) scale(1.05) rotate(-6deg); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1) rotate(-6deg); }
}
/* 吹っ飛ばし */
.char-wrap.ko .char-inner { animation: koFly 1.1s cubic-bezier(.3,0,.8,.4) forwards; }
@keyframes koFly {
  0% { transform: none; }
  12% { transform: translateX(-10px) scale(1.04); }
  100% { transform: translate(140%, -120%) rotate(540deg) scale(.15); opacity: 0; }
}
/* 落ち込んで帰っていく */
.char-wrap.sulk .char-inner { transition: transform 2.6s ease-in, opacity 2.6s ease-in, filter 1.2s; transform: translate(60%, 4%) scale(.9); opacity: 0; filter: grayscale(.7) brightness(.8); }

/* ---------- 選択肢（VN風） ---------- */
.choice-layer {
  position: absolute; z-index: 6; left: 10px; right: 10px;
  bottom: calc(var(--msg-h) + env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  transition: opacity .3s;
}
.question { display: flex; flex-direction: column; gap: 8px; }
.q-text { margin: 0 0 2px; text-align: center; font-family: var(--font-ui); font-weight: 800; font-size: 15px; color: var(--gold); text-shadow: 0 0 8px rgba(0,0,0,.95), 0 0 2px #000; letter-spacing: .06em; }
.q-text span::before { content: "― "; } .q-text span::after { content: " ―"; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  width: 100%; position: relative;
  padding: 12px 34px; min-height: 50px;
  color: #fff; font-family: var(--font); font-size: 16px; font-weight: 700; line-height: 1.45; text-align: center;
  white-space: normal; word-break: break-word;
  background: linear-gradient(90deg, rgba(40,10,60,.0) 0%, rgba(40,10,60,.86) 9%, rgba(40,10,60,.86) 91%, rgba(40,10,60,0) 100%);
  border: none; border-top: 1px solid rgba(255,194,220,.6); border-bottom: 1px solid rgba(255,194,220,.6);
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  cursor: pointer; opacity: 0; transform: translateX(-24px);
  animation: choiceIn .38s cubic-bezier(.2,.9,.3,1) forwards;
  transition: background .2s, transform .1s;
}
.choice:nth-child(2) { animation-delay: .07s; } .choice:nth-child(3) { animation-delay: .14s; }
@keyframes choiceIn { to { opacity: 1; transform: none; } }
.choice .key { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-family: var(--font-ui); font-size: 12px; font-weight: 800; color: var(--pink); }
.choice:hover:not(:disabled), .choice:focus-visible {
  outline: none;
  background: linear-gradient(90deg, rgba(160,40,120,0) 0%, rgba(160,40,120,.92) 9%, rgba(160,40,120,.92) 91%, rgba(160,40,120,0) 100%);
}
.choice:disabled { cursor: default; opacity: .4 !important; }
.choice.correct { opacity: 1 !important; background: linear-gradient(90deg, transparent 0%, rgba(176,120,0,.92) 9%, rgba(176,120,0,.92) 91%, transparent 100%); border-color: var(--gold); box-shadow: 0 0 22px rgba(255,215,122,.5); }
.choice.wrong { opacity: 1 !important; background: linear-gradient(90deg, transparent 0%, rgba(150,20,50,.92) 9%, rgba(150,20,50,.92) 91%, transparent 100%); border-color: var(--ng); }
.choice.correct::after { content: "◯"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-weight: 800; color: #fff6c8; }
.choice.wrong::after { content: "✕"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-weight: 800; }

.hint-note {
  align-self: center; max-width: 560px;
  background: rgba(255,246,238,.95); color: var(--ink);
  border-radius: 12px; border-left: 5px solid var(--gold);
  padding: 8px 12px; font-size: 13.5px; line-height: 1.55; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
  animation: fadeIn .3s ease;
}
.hint-tag { display: inline-block; background: var(--gold); color: #4a2a00; font-family: var(--font-ui); font-size: 10px; font-weight: 800; padding: 1px 8px; border-radius: 999px; margin-right: 6px; letter-spacing: .1em; }
.vn-btn-next { animation: fadeIn .3s ease; font-size: 18px; padding: 15px; }

/* ---------- メッセージウィンドウ ---------- */
.msg-window {
  position: absolute; z-index: 6;
  left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
  height: var(--msg-h);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(36,10,56,.86), rgba(16,4,30,.93));
  border: 1.5px solid rgba(255,194,220,.7);
  box-shadow: inset 0 0 0 4px rgba(255,111,174,.08), inset 0 0 0 5px rgba(255,194,220,.18), 0 10px 30px rgba(0,0,0,.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; flex-direction: column;
  padding: 18px 16px 8px;
  transition: opacity .3s, transform .3s;
}
.name-plate {
  position: absolute; top: -15px; left: 14px;
  padding: 4px 18px 4px 14px; border-radius: 10px 999px 999px 10px;
  background: linear-gradient(90deg, #ff4f9a, #9a4fe0);
  font-family: var(--font-ui); font-size: 14px; font-weight: 800; letter-spacing: .06em; color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.4), 0 0 14px rgba(255,111,174,.5);
}
.name-plate::before { content: "♥ "; font-size: .8em; color: #ffe0ee; }
.name-plate.me { background: linear-gradient(90deg, #ffb347, #ff7a3d); color: #3a1500; }
.name-plate.me::before { content: "▶ "; color: #3a1500; }
.name-plate.empty { display: none; }
.affection {
  position: absolute; top: -12px; right: 14px;
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(16,4,30,.92); border: 1px solid rgba(255,194,220,.55);
  font-family: var(--font-ui); font-size: 10px; font-weight: 800; color: var(--pink-l);
}
.aff-bar { width: 62px; height: 7px; border-radius: 999px; background: rgba(255,255,255,.15); overflow: hidden; }
.aff-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #ff9ec8, #ff3d8a); transition: width .8s cubic-bezier(.2,.9,.3,1); }
.aff-heart { color: rgba(255,255,255,.3); font-size: 13px; transition: color .3s; }
.affection.max .aff-heart { color: var(--pink); animation: beat .8s ease infinite; }
@keyframes beat { 30% { transform: scale(1.35); } }
.msg-body { flex: 1; min-height: 0; overflow-y: auto; cursor: pointer; outline: none; position: relative; padding-right: 18px; }
.msg-body:focus-visible { box-shadow: 0 0 0 2px var(--pink); border-radius: 8px; }
.line { margin: 0; font-size: 16.5px; line-height: 1.75; font-weight: 700; letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: pre-wrap; }
.msg-window.narr .line { text-align: center; color: var(--gold); padding-top: 6px; }
.msg-window.narr.ok .line { color: #fff6c8; }
.msg-window.narr.ng .line { color: #ffb3c2; }
.msg-window.narr.love .line { color: #ffc2dc; text-shadow: 0 0 10px rgba(255,111,174,.9); }
.next-mark { position: absolute; right: 2px; bottom: 2px; font-size: 12px; color: var(--pink); animation: nextBob 1s ease-in-out infinite; }
.next-mark.off { visibility: hidden; }
@keyframes nextBob { 50% { transform: translateY(4px); opacity: .5; } }
.msg-tools { display: flex; justify-content: flex-end; gap: 6px; padding-top: 4px; }
.tool-btn {
  border: 1px solid rgba(255,194,220,.45); background: rgba(255,255,255,.06); color: var(--pink-l);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.tool-btn small { margin-left: 4px; color: var(--purple-l); font-size: 10px; }
.tool-btn:hover { background: rgba(255,111,174,.2); }
#btn-hint { color: var(--gold); border-color: rgba(255,215,122,.7); animation: hintPulse 2.2s ease-in-out infinite; }
@keyframes hintPulse { 50% { box-shadow: 0 0 12px rgba(255,215,122,.5); } }

/* ウィンドウを隠して立ち絵をじっくり見るモード */
#screen-game.ui-hidden .hud,
#screen-game.ui-hidden .msg-window,
#screen-game.ui-hidden .choice-layer,
#screen-game.ui-hidden .diff-badge { opacity: 0; pointer-events: none; }
#screen-game.ui-hidden .msg-window { transform: translateY(20px); }
#screen-game.ui-hidden .char-wrap { top: calc(8px + env(safe-area-inset-top)); bottom: calc(8px + env(safe-area-inset-bottom)); }
#screen-game.ui-hidden .ph-appearance { opacity: 1; }
.ui-restore {
  position: absolute; inset: 0; z-index: 9; background: transparent; border: none;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  color: #fff; font-family: var(--font-ui); font-size: 13px; font-weight: 800; cursor: pointer;
  text-shadow: 0 0 6px #000, 0 0 2px #000;
}

/* ---------- 不正解カットイン ---------- */
.cutin {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 0, 6, .6); cursor: pointer;
}
.cutin-burst {
  position: absolute; inset: -20%;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.16) 0deg 4deg, transparent 4deg 12deg);
  animation: burstSpin 6s linear infinite;
}
@keyframes burstSpin { to { transform: rotate(360deg); } }
.cutin-frame {
  position: relative; width: min(94vw, 640px);
  border: 6px solid #fff; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 4px #c8102e, 0 0 60px rgba(200,16,46,.8), 0 20px 50px rgba(0,0,0,.7);
  transform: rotate(-3deg);
}
.cutin-frame img { display: block; width: 100%; height: auto; }
.cutin.in { animation: cutinBg .25s ease both; }
.cutin.in .cutin-frame { animation: cutinSlam .45s cubic-bezier(.2,1.6,.4,1) both, cutinShake .45s ease .4s; }
.cutin.out { animation: cutinOut .28s ease forwards; }
@keyframes cutinBg { from { background: rgba(255,255,255,.9); } }
@keyframes cutinSlam { 0% { transform: rotate(-3deg) scale(2.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-3deg) scale(1); } }
@keyframes cutinShake {
  20% { transform: rotate(-3deg) translate(-12px, 4px); } 40% { transform: rotate(-3deg) translate(10px, -4px); }
  60% { transform: rotate(-3deg) translate(-6px, 2px); } 80% { transform: rotate(-3deg) translate(4px, 0); }
}
@keyframes cutinOut { to { opacity: 0; } }

/* ---------- 不気味演出・ゲームオーバー ---------- */
body.eerie .bg-img { filter: grayscale(.7) brightness(.4) blur(2.5px) !important; transition: filter 2.5s ease; }
.bg-tint.eerie { opacity: 1; transition: opacity 2.5s ease; background: radial-gradient(ellipse at 50% 40%, rgba(40,0,0,.1) 20%, rgba(70,0,0,.85) 100%); }
#screen-game.eerie .hud, #screen-game.eerie .diff-badge { opacity: .25; transition: opacity 1.5s; }
#screen-game.eerie .msg-window { border-color: #7a0010; background: rgba(12,0,2,.94); box-shadow: 0 0 40px rgba(160,0,20,.5); }
#screen-game.eerie .name-plate { background: linear-gradient(90deg, #5a0010, #2a0008); }
#screen-game.eerie .line { color: #ffb8b8; letter-spacing: .08em; }
#screen-game.eerie .affection { opacity: 0; }
#screen-game.eerie #char-img { filter: brightness(.75) saturate(.6) drop-shadow(0 0 24px rgba(200,0,20,.7)); animation: none; }
#screen-game.eerie .char-inner { transform: scale(1.06); transform-origin: 50% 30%; transition: transform 6s ease; }
.choice.eerie { opacity: 1 !important; background: linear-gradient(90deg, transparent 0%, rgba(60,0,8,.95) 9%, rgba(60,0,8,.95) 91%, transparent 100%); border-color: #7a0010; color: #ff9a9a; }
.gameover {
  position: absolute; inset: 0; z-index: 25;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 45%, #2a0006 0%, #000 70%);
  animation: fadeIn 1.6s ease both;
}
.go-title {
  margin: 0; font-family: var(--font-logo); font-size: clamp(44px, 13vw, 84px); letter-spacing: .06em;
  color: #d0102a; text-shadow: 0 0 18px rgba(208,16,42,.9), 0 4px 0 #3a0008;
  animation: goPulse 2.4s ease-in-out infinite;
}
@keyframes goPulse { 50% { text-shadow: 0 0 34px rgba(255,30,60,1), 0 4px 0 #3a0008; } }
.go-sub { margin: 0 0 18px; color: #ffb8b8; font-weight: 700; font-size: 16px; line-height: 1.7; white-space: pre-line; animation: fadeIn 2s ease both .8s; }
.go-btns { width: min(100%, 400px); animation: fadeIn 1s ease both 1.6s; }
.gameover .vn-btn span::before, .gameover .vn-btn span::after { color: #d0102a; }
/* 暗転 */
#screen-game.blackout .char-wrap, #screen-game.blackout .diff-badge, #screen-game.blackout .hud { opacity: 0; transition: opacity 2.4s ease; }
#screen-game.blackout::after { content: ""; position: absolute; inset: 0; z-index: 5; background: #000; opacity: .85; pointer-events: none; animation: fadeIn 2.4s ease both; }
/* 特別エンディング */
.gameover.abduct .go-title { font-family: var(--font-logo); font-size: clamp(30px, 9vw, 64px); color: #fff; text-shadow: 3px 3px 0 #000, 0 0 24px rgba(255,111,174,.9); animation: shoutIn .5s cubic-bezier(.2,1.6,.4,1) both, shoutShake .5s ease .5s; }
@keyframes shoutIn { from { transform: scale(2.4); opacity: 0; } }
@keyframes shoutShake { 20% { transform: translate(-8px, 2px); } 40% { transform: translate(7px, -2px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }
/* 先輩エンディング */
.gameover.abduct { background: #000; }
.gameover.abduct .go-sub { color: #ffe0ea; white-space: pre-line; }
.gameover.abduct #btn-go-result { order: -1; } /* 特別エンディングは「結果を見る」を先に */
.gameover.abduct #btn-go-result { font-size: 17px; padding: 13px 22px; }
.gameover.abduct .vn-btn span::before, .gameover.abduct .vn-btn span::after { color: var(--pink); }
.result-note { margin: 2px 0 8px; font-size: 14px; font-weight: 700; color: #ffb3c8; }
.result-list li.leftbehind { border-left-color: rgba(255,111,174,.4); background: rgba(255,111,174,.05); }
.result-list li.leftbehind .rl-thumb img { filter: grayscale(.6); opacity: .7; }
.result-list li.leftbehind .rl-status { color: rgba(255,179,200,.8); }
.result-list li.abductor { border-left-color: #ff6fae; background: rgba(255,111,174,.18); }
.result-list li.abductor .rl-status { color: #ff6fae; }
.choice.chosen { opacity: 1 !important; background: linear-gradient(90deg, transparent 0%, rgba(200,60,120,.92) 9%, rgba(200,60,120,.92) 91%, transparent 100%); border-color: var(--pink); }
.result-list li.unreached { opacity: .45; border-left-color: rgba(255,255,255,.2); }
.result-list li.gameover-row { border-left-color: #d0102a; background: rgba(120,0,20,.25); }
.result-list li.gameover-row .rl-status { color: #ff6b81; }

/* ---------- 結果 ---------- */
.result { text-align: center; }
.result-kicker { margin: 0; color: var(--gold); letter-spacing: .3em; font-size: 12px; font-weight: 800; font-family: var(--font-ui); }
.result-headline { margin: 4px 0 2px; font-size: clamp(18px, 5.5vw, 24px); display: flex; flex-direction: column; align-items: center; }
.rh-num { font-family: var(--font-logo); font-weight: 400; font-size: 1.4em; color: #fff; }
.rh-num b { font-weight: 400; font-size: 1.7em; color: var(--pink); text-shadow: 0 0 18px rgba(255,111,174,.8); }
.result-rank {
  display: inline-block; margin: 6px 0 14px; padding: 6px 22px; border-radius: 999px;
  background: linear-gradient(90deg, #ff4f9a, #9a4fe0); color: #fff; font-weight: 800; font-size: 18px; font-family: var(--font-ui);
  box-shadow: 0 0 22px rgba(255,111,174,.55);
}
.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.result-stats div { background: rgba(255,255,255,.07); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; }
.result-stats span { font-size: 11px; color: var(--purple-l); }
.result-stats b { font-size: 18px; font-family: var(--font-ui); }
.result-best { font-size: 13px; color: var(--gold); margin: 6px 0 12px; min-height: 1em; }
.result-list { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.result-list li { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05); border-radius: 12px; padding: 6px 10px; border-left: 4px solid rgba(255,92,122,.6); }
.result-list li.ok { border-left-color: var(--pink); background: rgba(255,111,174,.13); }
.rl-num { font-weight: 800; width: 20px; text-align: center; color: var(--purple-l); font-size: 13px; font-family: var(--font-ui); }
.rl-thumb { flex: none; position: relative; width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,.4); display: grid; place-items: center; overflow: hidden; border: 2px solid rgba(255,194,220,.6); }
.rl-thumb img { position: absolute; top: 0; left: -50%; width: 200%; height: auto; }
.rl-thumb svg { height: 42px; width: auto; }
.rl-thumb.miss { font-size: 18px; color: rgba(255,255,255,.35); border-color: rgba(255,255,255,.15); }
.rl-body { flex: 1; min-width: 0; line-height: 1.35; }
.rl-name { font-weight: 700; font-size: 14px; }
.rl-sub { font-size: 12px; color: rgba(255,246,238,.75); }
.rl-status { font-size: 12px; font-weight: 800; white-space: nowrap; font-family: var(--font-ui); }
.result-list li.ok .rl-status { color: var(--pink); }
.result-list li:not(.ok) .rl-status { color: rgba(255,255,255,.5); }
.copy-msg { min-height: 1.2em; font-size: 13px; color: var(--ok); margin: 10px 0 0; }
.copy-fallback { width: 100%; height: 90px; margin-top: 8px; border-radius: 10px; padding: 8px; font-family: inherit; }

.credit { text-align: center; font-size: 11px; color: rgba(255,246,238,.6); padding-top: 4px; display: flex; flex-direction: column; gap: 4px; align-items: center; font-family: var(--font-ui); }
.credit-link { color: var(--pink-l); }

/* ---------- PC・横長画面 ---------- */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  :root { --msg-h: 184px; --hud-h: 58px; }
  .hud { padding-left: max(16px, calc(50vw - 600px)); padding-right: max(16px, calc(50vw - 600px)); }
  .hud-chip { flex: 0 1 220px; }
  .hud .hud-icon { margin-left: auto; }
  .msg-window { left: 50%; right: auto; width: min(980px, calc(100vw - 40px)); transform: translateX(-50%); padding: 22px 26px 10px; }
  #screen-game.ui-hidden .msg-window { transform: translate(-50%, 20px); }
  .line { font-size: 18px; }
  .char-wrap { left: 0; right: 0; transition: top .4s ease, bottom .4s ease, right .5s cubic-bezier(.2,.9,.3,1); }
  #screen-game.asking .char-wrap { right: min(44vw, 520px); }
  #screen-game.ui-hidden .char-wrap { right: 0; }
  .choice-layer {
    left: auto; right: max(24px, calc(50vw - 560px)); width: min(440px, 40vw);
    top: calc(var(--hud-h) + 20px); bottom: calc(var(--msg-h) + 24px);
    justify-content: center;
  }
  .result-flash { left: 30%; }
  .title-char { left: 68%; height: 94%; }
  .title-shade { background: linear-gradient(90deg, rgba(10,3,20,.85) 0%, rgba(10,3,20,.4) 45%, transparent 70%); }
  .title-logo-wrap { position: absolute; left: 7vw; top: 14vh; text-align: left; padding: 0; }
  .title-logo { font-size: clamp(48px, 5.6vw, 82px); }
  .title-menu { left: 7vw; transform: none; bottom: 9vh; width: 400px; padding: 0; align-items: stretch; }
  .title-best { align-self: flex-start; }
  .credit { align-items: flex-start; }
  .result .credit { align-items: center; }
}

/* 背の低いスマホ */
@media (max-height: 700px) and (max-width: 899px) {
  :root { --msg-h: 150px; --hud-h: 44px; }
  .hud-val { font-size: 14px; }
  .line { font-size: 15px; line-height: 1.6; }
  .choice { padding: 9px 30px; font-size: 14.5px; min-height: 42px; }
  .choices, .choice-layer { gap: 6px; }
  .hint-note { font-size: 12.5px; padding: 6px 10px; }
  .ph-appearance { font-size: 12px; padding: 6px 10px; }
  .msg-window { padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
