:root {
  --night: #0b1026; --ai: #1b2a5c; --shu: #ff5a3c; --kin: #ffc94a; --botan: #ff4f8b; --mizu: #5ad1e6; --kinari: #fdf6e3;
  --sky: "Dela Gothic One", "Hiragino Kaku Gothic StdN", sans-serif;
  --maru: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --min: "Shippori Mincho", "Hiragino Mincho ProN", serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #03040c; overflow: hidden; }
body { font-family: var(--maru); color: var(--kinari); user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#stage {
  position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; overflow: hidden; overflow: clip; contain: layout paint;
  transform: translate(-50%, -50%) scale(var(--k, 1)) translate(var(--sx, 0px), var(--sy, 0px));
  background: linear-gradient(#050818, #0d1638 55%, #1b2a5c);
}
.bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity .9s; }
.bg.on { opacity: 1; }
#stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 12;
  background: radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(2, 3, 12, .55)); }

#card { position: absolute; inset: 0; z-index: 1; opacity: 0; transition: opacity .7s; pointer-events: none;
  background: radial-gradient(circle at 50% 35%, #142056, #05081a 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 170px; }
#card.on { opacity: 1; }
#card small { font-family: var(--min); font-size: 46px; letter-spacing: .7em; text-indent: .7em; color: var(--kin); }
#card b { font-family: var(--sky); font-weight: 400; font-size: 220px; line-height: 1.2; letter-spacing: .06em;
  background: linear-gradient(#fff, #ffe9b0 55%, var(--shu)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 40px rgba(255, 150, 60, .5)); }

#sky, #glow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#sky { z-index: 2; }
#glow { z-index: 3; filter: blur(14px) brightness(1.25) saturate(1.8); mix-blend-mode: screen; opacity: .95; }

#rain { position: absolute; inset: -200px; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1s;
  background:
    repeating-linear-gradient(101deg, transparent 0 37px, rgba(190, 210, 255, .16) 37px 39px, transparent 39px 90px),
    repeating-linear-gradient(99deg, transparent 0 61px, rgba(190, 210, 255, .09) 61px 62px, transparent 62px 140px);
  animation: rain .5s linear infinite; }
.rain #rain { opacity: 1; }
@keyframes rain { to { transform: translate(-60px, 300px); } }

#char { position: absolute; z-index: 5; left: 1085px; bottom: -250px; height: 1180px; opacity: 0; transition: opacity .35s; pointer-events: none; }
#char.on { opacity: 1; }
#char.hop { animation: hop .32s ease-out; }
@keyframes hop { 0% { translate: 0 10px; } 45% { translate: 0 -10px; } 100% { translate: 0 0; } }
.cg #char { opacity: 0; }

#flash { position: absolute; inset: 0; z-index: 6; pointer-events: none; mix-blend-mode: screen; opacity: 0; }

/* ---- 文章の窓 ---- */
#msg { position: absolute; z-index: 9; left: 110px; right: 110px; bottom: 36px; height: 236px; padding: 40px 64px 0;
  background: linear-gradient(rgba(12, 17, 48, .86), rgba(6, 8, 26, .95)); border: 2px solid rgba(255, 201, 74, .5); border-radius: 20px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, .6), inset 0 0 60px rgba(27, 42, 92, .6);
  font-size: 40px; line-height: 1.62; letter-spacing: .03em; transition: opacity .35s, translate .35s; }
#msg.hide { opacity: 0; translate: 0 30px; pointer-events: none; }
#msg[data-who="n"] #text { font-family: var(--min); color: #e9e4f5; }
#name { position: absolute; left: 52px; top: -30px; padding: 2px 34px 4px; font-size: 30px; font-weight: 700; border-radius: 12px;
  background: var(--shu); color: #fff; box-shadow: 0 4px 18px rgba(255, 90, 60, .5); letter-spacing: .12em; }
#msg[data-who="p"] #name { background: #2f9db3; box-shadow: 0 4px 18px rgba(90, 209, 230, .4); }
#msg[data-who="x"] #name { background: #55608c; box-shadow: none; }
#next { position: absolute; right: 44px; bottom: 22px; font-size: 26px; color: var(--kin); opacity: 0; }
#msg.done #next { opacity: 1; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { translate: 0 8px; opacity: .4; } }
.ask { color: #aab3d8; font-family: var(--min); }

#fuse { position: absolute; left: 60px; right: 60px; top: -12px; height: 8px; opacity: 0; transition: opacity .3s; }
#fuse.on { opacity: 1; }
#fuse i { position: absolute; left: 0; top: 0; height: 100%; width: 100%; border-radius: 4px;
  background: repeating-linear-gradient(60deg, #cdb58a 0 8px, #8d7650 8px 14px); }
#fuse i::after { content: ""; position: absolute; right: -22px; top: -18px; width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 12%, #ffd27a 22%, rgba(255, 110, 40, .8) 42%, transparent 70%); animation: fz .12s steps(2) infinite; }
@keyframes fz { 50% { scale: 1.35; rotate: 40deg; } }

/* ---- 言葉の玉 ---- */
#aim { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.aimT { font-family: var(--sky); paint-order: stroke; stroke: rgba(5, 8, 26, .8); stroke-width: 8px; }
.aimS { font-family: var(--maru); font-weight: 700; paint-order: stroke; stroke: rgba(5, 8, 26, .8); stroke-width: 6px; }
#rack { position: absolute; inset: 0; z-index: 10; pointer-events: none; display: none; }
#rack.on { display: block; }
.shell { position: absolute; width: 0; height: 0; pointer-events: auto; touch-action: none; cursor: grab;
  transition: transform .4s cubic-bezier(.3, 2.2, .5, 1); animation: pop .45s var(--d) cubic-bezier(.3, 1.8, .5, 1) both; }
.shell.drag { transition: none; cursor: grabbing; z-index: 3; }
@keyframes pop { from { scale: 0; opacity: 0; } to { scale: 1; opacity: 1; } }
.ball { position: absolute; left: -64px; top: -64px; width: 128px; height: 128px; border-radius: 50%;
  background:
    repeating-conic-gradient(from 20deg, rgba(60, 30, 10, .16) 0 2deg, transparent 2deg 30deg),
    radial-gradient(circle at 34% 28%, #f0d7a8, #b9864a 48%, #5b3416 86%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6), inset -8px -12px 26px rgba(40, 15, 0, .5), 0 0 0 0 rgba(255, 201, 74, .0); transition: box-shadow .2s; }
.ball::before { content: ""; position: absolute; left: 58px; top: -26px; width: 10px; height: 34px; border-radius: 5px; background: #cdb58a; rotate: 14deg; }
.shell:hover .ball, .shell.drag .ball { box-shadow: 0 10px 30px rgba(0, 0, 0, .6), inset -8px -12px 26px rgba(40, 15, 0, .5), 0 0 34px 6px rgba(255, 201, 74, .65); }
.tan { position: absolute; left: -40px; bottom: 96px; width: 80px; min-height: 170px; padding: 20px 0 16px; writing-mode: vertical-rl;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(90deg, #efe2c2, #fbf3de 40%, #efe2c2); color: #2b1a10; border-top: 10px solid var(--shu); border-radius: 3px;
  font-size: 36px; font-weight: 700; letter-spacing: .1em; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, .55); }
.tan::after { content: ""; position: absolute; left: 39px; bottom: -34px; width: 2px; height: 34px; background: #cdb58a; }
.shell.fired { animation: fired .5s ease-in forwards; pointer-events: none; }
@keyframes fired { to { translate: 0 -700px; opacity: 0; scale: .5; } }
.shell.away { animation: away .5s forwards; pointer-events: none; }
@keyframes away { to { opacity: 0; scale: .7; } }
.shell.dud { animation: dudroll 1.5s ease-in forwards; pointer-events: none; }
.shell.dud .ball { filter: brightness(.12) saturate(0); transition: filter .4s; }
.shell.dud .tan { opacity: 0; transition: opacity .4s; }
@keyframes dudroll { 30% { translate: 0 40px; rotate: 0deg; } 100% { translate: 700px 260px; rotate: 500deg; opacity: 0; } }

#hint { position: absolute; z-index: 11; left: 110px; top: 70px; padding: 20px 32px; font-size: 30px; line-height: 1.7; border-radius: 0 14px 14px 0;
  background: rgba(6, 8, 26, .78); border-left: 6px solid var(--kin); opacity: 0; translate: -20px 0; transition: opacity .4s, translate .4s; pointer-events: none; }
#hint.on { opacity: 1; translate: 0 0; }
#hint b { color: var(--kin); } #hint b.c0 { color: var(--mizu); } #hint b.c2 { color: var(--shu); }

/* ---- 線香花火の言葉 ---- */
#spk { position: absolute; inset: 0; z-index: 8; pointer-events: none; display: none; }
#spk.on { display: block; }
.sw { position: absolute; translate: -50% -50%; --p: 0; transition: opacity .6s; }
.sw span { font-family: var(--min); font-weight: 700; font-size: 62px; letter-spacing: .12em; white-space: nowrap;
  color: rgba(255, 236, 200, calc(.32 + var(--p) * .68)); text-shadow: 0 0 calc(var(--p) * 40px) rgba(255, 170, 70, .95); }
.sw::before { content: ""; position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; translate: -50% -50%; border-radius: 50%;
  background: conic-gradient(var(--kin) calc(var(--p) * 360deg), rgba(255, 255, 255, .1) 0);
  -webkit-mask: radial-gradient(circle, transparent 0 67%, #000 68% 69.5%, transparent 70.5%); mask: radial-gradient(circle, transparent 0 67%, #000 68% 69.5%, transparent 70.5%); }
.sw.said, .sw.gone { opacity: 0; }

/* ---- 上の表示 ---- */
#hud { position: absolute; z-index: 13; left: 0; right: 0; top: 0; padding: 22px 34px; display: none; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.playing #hud { display: flex; }
#chapter { font-family: var(--min); font-size: 26px; letter-spacing: .25em; color: rgba(253, 246, 227, .75); }
#dudCount { margin-left: 34px; font-size: 22px; color: rgba(253, 246, 227, .55); letter-spacing: .1em; }
#dudCount i { display: inline-block; width: 18px; height: 18px; margin-left: 6px; border-radius: 50%; vertical-align: -2px;
  background: radial-gradient(circle at 35% 30%, #555, #0a0a0a 70%); box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
#hudR button { pointer-events: auto; margin-left: 12px; padding: 6px 22px; font-size: 22px; border-radius: 30px; background: rgba(6, 8, 26, .6); border: 1.5px solid rgba(253, 246, 227, .35); }
#hudR button.on { background: var(--kin); color: #201400; border-color: var(--kin); }
#hudR button.off { opacity: .4; text-decoration: line-through; }

/* ---- タイトル ---- */
#titleScreen { position: absolute; inset: 0; z-index: 30; padding: 110px 0 0 130px; transition: opacity .8s; }
#titleScreen.off { opacity: 0; pointer-events: none; }
#titleScreen::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(4, 6, 20, .55), transparent 60%); }
h1 { font-family: var(--sky); font-weight: 400; font-size: 205px; line-height: 1.12; letter-spacing: .02em; }
h1 span { display: block; background: linear-gradient(100deg, #fff6d8 5%, var(--kin) 35%, var(--shu) 68%, var(--botan)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 34px rgba(255, 140, 60, .55)) drop-shadow(0 6px 0 rgba(60, 10, 30, .5)); animation: glowp 3.2s ease-in-out infinite; }
h1 span:nth-child(2) { margin-left: 150px; animation-delay: -1.6s; }
@keyframes glowp { 50% { filter: drop-shadow(0 0 60px rgba(255, 90, 140, .8)) drop-shadow(0 6px 0 rgba(60, 10, 30, .5)); } }
.tag { margin-top: 26px; font-family: var(--min); font-size: 38px; letter-spacing: .22em; }
.btns { margin-top: 56px; display: flex; gap: 28px; }
.btns button { padding: 16px 62px; font-size: 36px; font-weight: 700; letter-spacing: .18em; border-radius: 60px; color: #fff;
  background: rgba(8, 10, 30, .6); border: 2.5px solid var(--kin); transition: .2s; }
.btns button:first-child { background: linear-gradient(100deg, var(--shu), var(--botan)); border-color: transparent; box-shadow: 0 8px 40px rgba(255, 79, 139, .5); }
.btns button:hover { scale: 1.06; box-shadow: 0 0 44px rgba(255, 201, 74, .7); }
.how { margin-top: 44px; font-size: 24px; color: rgba(253, 246, 227, .72); letter-spacing: .08em; }
#titleEnds { margin-top: 12px; font-size: 22px; color: var(--kin); }
.copy { position: absolute; left: 130px; bottom: 34px; font-size: 20px; letter-spacing: .14em; color: rgba(253, 246, 227, .6); }

/* ---- 結末 ---- */
#endScreen { position: absolute; inset: 0; z-index: 25; opacity: 0; pointer-events: none; transition: opacity 1.6s;
  background: linear-gradient(90deg, rgba(4, 6, 20, .96) 0 38%, rgba(4, 6, 20, .5) 62%, rgba(4, 6, 20, .25)); }
#endScreen.on { opacity: 1; pointer-events: auto; }
.endIn { position: absolute; left: 130px; top: 120px; width: 860px; }
.endIn small { font-family: var(--min); font-size: 34px; letter-spacing: .6em; color: var(--kin); }
.endIn h2 { font-family: var(--sky); font-weight: 400; font-size: 170px; line-height: 1.2;
  background: linear-gradient(100deg, #fff6d8, var(--kin) 40%, var(--shu) 75%, var(--botan)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(255, 140, 60, .5)); }
.endIn .sub { font-family: var(--min); font-size: 34px; margin-top: 6px; }
.endIn .replay { margin-top: 60px; font-size: 26px; letter-spacing: .3em; color: var(--mizu); }
.endIn .replay::after { content: "　→"; }
.endIn .stat { margin-top: 12px; font-size: 30px; } .endIn .stat b { font-family: var(--sky); font-weight: 400; font-size: 44px; color: var(--kin); margin: 0 4px; }
.endIn .ends { margin-top: 40px; font-size: 24px; color: rgba(253, 246, 227, .7); }
.endIn .ends span { display: inline-block; margin: 10px 10px 0 0; padding: 4px 18px; border-radius: 30px; border: 1.5px solid rgba(253, 246, 227, .3); color: rgba(253, 246, 227, .4); }
.endIn .ends span.got { border-color: var(--kin); color: var(--kin); }
.endIn button { margin-top: 50px; padding: 14px 56px; font-size: 32px; font-weight: 700; letter-spacing: .18em; border-radius: 60px; background: rgba(8, 10, 30, .6); border: 2.5px solid var(--kin); }
.endIn .credit { margin-top: 44px; font-size: 20px; line-height: 1.9; color: rgba(253, 246, 227, .55); letter-spacing: .1em; }

#fade { position: absolute; inset: 0; z-index: 40; background: #03040c; opacity: 0; pointer-events: none; transition: opacity .8s; }
#fade.on { opacity: 1; }

/* 一枚絵のときは、右側の彼女に花火を重ねない */
.cg #sky, .cg #glow { -webkit-mask-image: linear-gradient(90deg, #000 52%, transparent 70%); mask-image: linear-gradient(90deg, #000 52%, transparent 70%); }
#stage[data-end] #sky, #stage[data-end] #glow { -webkit-mask-image: none; mask-image: none; }
#stage[data-end] .bg { filter: brightness(.3) saturate(.8); transition: opacity .9s, filter 1.6s; }
