/* 供物 - OFFERING -
   縦長（スマホ）を基準にした1枚の舞台（#stage）。大きさは舞台の幅・高さに対する割合（cqw / cqh）で決めるので、
   PC の横長画面でも、中央に同じ縦長の舞台がそのまま出る。 */
:root {
  --ink: #1d120b; --paper: #d9c59a; --gold: #a88a4a; --red: #7a1a14; --bone: #e8dcc0;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Noto Serif JP", "Source Han Serif JP", Georgia, "Times New Roman", serif;
  --light: 1;      /* 部屋の明るさ（灯っている蝋燭の割合） */
  --sub-scale: 1;  /* 字幕の大きさ（設定） */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #020201; color: var(--bone); font-family: var(--serif); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
/* 広告帯（#adbar）の高さ。#app をその分だけ縮めて、盤面・ボタンに被らせない。広告が出ない（adbar-empty）ときは 0 に戻す */
:root { --adbar-res: calc(100px + env(safe-area-inset-bottom, 0px)); }
:root:has(#adbar.adbar-empty) { --adbar-res: 0px; }
#adbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; height: var(--adbar-res); padding-bottom: env(safe-area-inset-bottom, 0px); background: #020201; display: flex; justify-content: center; align-items: center; overflow: hidden; touch-action: manipulation; }
#adbar.adbar-empty { display: none; }
#app { position: fixed; inset: 0 0 var(--adbar-res) 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, #0d0906 0%, #020201 70%); }
#stage { position: relative; width: min(100vw, calc((100dvh - var(--adbar-res)) * 0.5625)); height: calc(100dvh - var(--adbar-res)); max-height: calc(100vw * 2.3); overflow: clip; contain: paint; container-type: size; background: #030201; user-select: none; -webkit-user-select: none; }
.screen { position: absolute; inset: 0; }
/* 日本語は文節で折り返し、行の長さをそろえる（単語の途中で切らない） */
.sub, .devilsub, .story-text, .ov-box, .bar, .title-menu, .end-card, .guide { word-break: auto-phrase; text-wrap: balance; line-break: strict; }

/* ---------- タイトル ---------- */
.title-bg { position: absolute; inset: 0; background: #050403 url(img/title_bg.webp) center / cover no-repeat; filter: brightness(.8); }
.title-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(#000c 0%, #0000 30%, #0000 55%, #000e 88%); }
.title-box { position: absolute; top: 9cqh; left: 0; right: 0; text-align: center; }
.title-ja { margin: 0; font-size: 26cqw; font-weight: 600; letter-spacing: .12em; text-indent: .12em; color: #cdb98a; text-shadow: 0 0 6cqw #000, 0 0 1.4cqw #7a1a1466; line-height: 1.1; }
.title-en { margin: 1cqh 0 0; font-size: 4.2cqw; letter-spacing: .9em; text-indent: .9em; color: var(--gold); opacity: .8; }
.title-menu { position: absolute; bottom: 9cqh; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 1.6cqh; }
.title-menu button, .end-menu button { min-width: 46cqw; padding: 1.3cqh 4cqw; font-size: 4.6cqw; letter-spacing: .2em; text-indent: .2em; color: #cbbf9f; border-top: 1px solid #a88a4a44; border-bottom: 1px solid #a88a4a44; background: #0006; transition: color .3s, border-color .3s, background .3s; }
.title-menu button:hover, .end-menu button:hover, .title-menu button:focus-visible { color: #f4e8c8; border-color: #a88a4acc; background: #1a0d08aa; outline: none; }
.ver { position: absolute; right: 2cqw; bottom: .8cqh; margin: 0; font-size: 2.4cqw; color: #a88a4a66; font-family: Georgia, serif; }

/* ---------- 部屋 ---------- */
.room { position: absolute; inset: 0 0 auto 0; height: 52cqh; overflow: hidden; }
.room-bg { position: absolute; inset: -2% -6%; background: url(img/bg_room.webp) 50% 22% / cover no-repeat; animation: roomdrift 23s ease-in-out infinite alternate; }
@keyframes roomdrift { from { transform: translate(-.4%, 0) scale(1.01); } to { transform: translate(.5%, -.3%) scale(1.025); } }
.wallword { position: absolute; left: 6cqw; top: 15cqh; max-width: 30cqw; font-size: 3cqw; color: #c9b68a; opacity: 0; transform: rotate(-4deg); letter-spacing: .1em; filter: blur(.3px); transition: opacity 4s; mix-blend-mode: soft-light; pointer-events: none; }
.wallword.on { opacity: .5; }
.doorfig { position: absolute; right: 9cqw; top: 13cqh; width: 9cqw; height: 22cqh; background: radial-gradient(ellipse at 50% 16%, #000 0 14%, #0000 15%), radial-gradient(ellipse at 50% 62%, #000 0 44%, #0000 62%); opacity: 0; filter: blur(1.2px); transition: opacity 5s; pointer-events: none; }
.doorfig.on { opacity: .55; }
.cpu { position: absolute; left: 50%; top: 5.5cqh; width: 60cqw; aspect-ratio: 2 / 3; transform: translateX(-50%); transform-origin: 50% 100%; animation: breathe 4.6s ease-in-out infinite; filter: brightness(calc(.55 + .5 * var(--cpu-light, 1))); transition: filter 1.2s, opacity 2.5s; }
.cpu.fast { animation-duration: 2.3s; }
.cpu.tremble { animation: breathe 2.1s ease-in-out infinite, tremble .13s linear infinite; }
.cpu.gone { opacity: 0; }
@keyframes breathe { 0%, 100% { transform: translateX(-50%) scale(1, 1); } 50% { transform: translateX(-50%) scale(1.006, 1.014); } }
@keyframes tremble { 0% { translate: 0 0; } 25% { translate: .12cqw 0; } 75% { translate: -.12cqw .05cqw; } 100% { translate: 0 0; } }
.cpu-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .45s; -webkit-mask-image: linear-gradient(#000 78%, #0000 100%); mask-image: linear-gradient(#000 78%, #0000 100%); }
.cpu-img.on { opacity: 1; }
.cpu-img.quick { transition-duration: .07s; }

/* ---------- 卓 ---------- */
.table { position: absolute; left: -10cqw; right: -10cqw; top: 41.5cqh; bottom: -6cqh; background: #1a0f08 url(img/table.webp) 50% 0 / 100% auto; transform-origin: 50% 0; transform: perspective(70cqh) rotateX(32deg) scale(1.12, 1.2); }
.table::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: .5cqh; background: linear-gradient(#000, #6b4a2a55 60%, #0000); }
.table::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 70% 42% at 50% 38%, #ffb96a26 0%, #0000 70%), linear-gradient(#000e 0%, #0008 9%, #0002 30%, #0000 60%, #0007 100%); }
.dark { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 85% 60% at 50% 56%, #0000 30%, #000 100%); opacity: calc(.3 + .65 * (1 - var(--light))); transition: opacity 1.6s; }
.vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 18cqw 4cqw #000; transition: box-shadow 2.5s, background 2.5s; }
.vignette.close { box-shadow: inset 0 0 60cqw 45cqw #000; background: #000a; }
.vignette.black { box-shadow: inset 0 0 90cqw 90cqw #000; background: #000; }

/* ---------- 蝋燭 ---------- */
.candles { position: absolute; left: 0; right: 0; pointer-events: none; }
.cpu-candles { top: 37.6cqh; }
.p-candles { top: 64.5cqh; }
.candle { position: absolute; width: var(--cw); aspect-ratio: 1 / 1.08; transform: translateX(-50%); filter: brightness(.5); transition: filter 1s; --burn: 0; }
.candle.lit { filter: brightness(1); }
/* 蝋燭の絵（candle.webp）を2枚に分けて重ねる。
   軸（stick）：絵の上 78% だけを見せる窓。中の .wax を下へ沈めると、上の芯と垂れた蝋はそのままに、軸が短くなったように見える。
   受け皿（dish）：絵の下 24% だけ。軸の継ぎ目を隠すため、軸より手前に重ねる。
   --burn は使った割合（0=新品 1=燃え尽き）。軸が受け皿の縁（上から約 74%）まで沈むと、ちょうど見えなくなる */
.stick, .dish, .wax { position: absolute; inset: 0; display: block; }
.stick { clip-path: inset(0 0 22% 0); }
.wax, .dish { background: url(img/candle.webp) center bottom / contain no-repeat; }
.wax { transform: translateY(calc(var(--burn) * 74%)); transition: transform 1.2s ease-in-out; }
.dish { clip-path: inset(76% 0 0 0); }
/* 燃え尽きた蝋燭：軸は無く、受け皿と溶けた跡だけ。消えているだけの物（暗いが軸がある）と見分けがつく */
.candle.burnt .stick { opacity: 0; transition: opacity 1.2s; }
.candle.burnt .dish { clip-path: inset(83% 0 0 0); filter: brightness(.7) saturate(.6); }
.candle.burnt::before { content: ""; position: absolute; left: 30%; right: 30%; bottom: 13%; height: 6%; border-radius: 50%; background: radial-gradient(ellipse, #2a1a0e 0 45%, #0000 72%); }
.cpu-candles .candle { --cw: 9.5cqw; }
.p-candles .candle { --cw: 13.5cqw; }
/* 相手の蝋燭3本は左奥にまとめる（自分の3本は右手前。真ん中の列はカードのために空ける） */
.cpu-candles .candle:nth-child(1) { left: 7cqw; top: .5cqh; } .cpu-candles .candle:nth-child(2) { left: 15cqw; top: 1.5cqh; } .cpu-candles .candle:nth-child(3) { left: 23cqw; top: .2cqh; } .cpu-candles .candle:nth-child(4) { left: 31cqw; top: 1.1cqh; }
/* 自分の蝋燭3本は右手前にまとめる。真ん中に置くと、祭壇に出したカードと重なるため */
.p-candles .candle:nth-child(1) { left: 62cqw; top: 1.2cqh; } .p-candles .candle:nth-child(2) { left: 71.5cqw; top: 3.4cqh; } .p-candles .candle:nth-child(3) { left: 81cqw; top: .4cqh; } .p-candles .candle:nth-child(4) { left: 90.5cqw; top: 2.6cqh; }
.flame { position: absolute; left: 50%; bottom: calc(80% - var(--burn) * 74%); width: 26%; aspect-ratio: 2 / 3; background: url(img/flame.webp) center bottom / contain no-repeat; transform-origin: 50% 100%; translate: -50% 0; opacity: 0; scale: .2; transition: opacity .5s, scale .6s, bottom 1.2s ease-in-out; filter: drop-shadow(0 0 calc(var(--cw) * .12) #ff9a3c); }
.candle.lit .flame { opacity: 1; scale: 1; animation: flick 2.9s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes flick { 0%, 100% { transform: scale(1, 1) skewX(0deg); } 18% { transform: scale(.94, 1.07) skewX(2.5deg); } 34% { transform: scale(1.03, .95) skewX(-2deg); } 52% { transform: scale(.97, 1.1) skewX(1.2deg); } 71% { transform: scale(1.04, .97) skewX(-3deg); } 86% { transform: scale(.96, 1.04) skewX(1deg); } }
.glow { position: absolute; left: 50%; bottom: calc(55% - var(--burn) * 74%); width: 330%; aspect-ratio: 1; translate: -50% 35%; border-radius: 50%; background: radial-gradient(circle, #ffb05a40 0%, #ff8a2a18 30%, #0000 68%); opacity: 0; transition: opacity 1s; mix-blend-mode: screen; }
.candle.lit .glow { opacity: 1; animation: glowp 3.7s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes glowp { 0%, 100% { scale: 1; } 40% { scale: 1.06; } 65% { scale: .96; } }
.candle.flare .flame { animation: flare 1.6s ease-out; }
@keyframes flare { 0% { transform: scale(1); } 25% { transform: scale(1.5, 2.1); } 100% { transform: scale(1); } }
.candle.waver .flame { animation: waver .9s ease-in-out; }
@keyframes waver { 0% { transform: skewX(0) scale(1); } 20% { transform: skewX(14deg) scale(.8, 1.2); } 45% { transform: skewX(-18deg) scale(.7, 1.25); } 70% { transform: skewX(10deg) scale(.5, .9); } 100% { transform: skewX(0) scale(.2); } }
.smoke { position: absolute; left: 50%; bottom: calc(82% - var(--burn) * 74%); width: 14%; height: 70%; translate: -50% 0; background: linear-gradient(#0000, #cfc6b455 60%, #cfc6b422); border-radius: 50%; filter: blur(calc(var(--cw) * .04)); opacity: 0; transform-origin: 50% 100%; }
.candle.smoking .smoke { animation: smoke 3.6s ease-out forwards; }
@keyframes smoke { 0% { opacity: 0; transform: scaleY(.2) skewX(0); } 15% { opacity: .8; } 100% { opacity: 0; transform: scaleY(1.7) skewX(-14deg) translateX(30%); } }
.candle.target { pointer-events: auto; cursor: pointer; }
.candle.target::after { content: ""; position: absolute; inset: -8% -8% -4%; border: 1px solid #c9a55a99; border-radius: 50% 50% 14% 14%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- カード ---------- */
.card { position: relative; width: var(--w); aspect-ratio: 2 / 3; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.3, .7, .3, 1), translate .35s, opacity .4s, filter .4s; }
.face { position: absolute; inset: 0; border-radius: 5.5% / 3.7%; backface-visibility: hidden; -webkit-backface-visibility: hidden; background-size: 100% 100%; box-shadow: 0 .5cqw 1.6cqw #000c; overflow: hidden; }
.face.back { background-image: url(img/card_back.webp); }
.face.front { transform: rotateY(180deg); background-color: var(--paper); }
.card.up .face.front { transform: none; } .card.up .face.back { transform: rotateY(180deg); }
.card.flipping { transform: rotateY(180deg); }
.num { position: absolute; font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: calc(var(--w) * .2); line-height: 1; color: #24150c; text-shadow: 0 0 1px #24150c88; letter-spacing: -.04em; }
.num.tl { left: 7%; top: 4.5%; } .num.br { right: 7%; bottom: 4.5%; transform: rotate(180deg); }
.card.flat { transform: perspective(70cqw) rotateX(46deg); }
.cpuhand { position: absolute; left: 50%; top: 45.2cqh; translate: -50% 0; display: flex; gap: 1.2cqw; --w: 8.6cqw; }
.cpuhand .card { transform: perspective(60cqw) rotateX(55deg); }
.cpuhand .card.out { opacity: 0; translate: 0 4cqh; }
.cpuhand .peek { position: absolute; left: 50%; top: -55%; translate: -50% 0; font: 700 3.6cqw Georgia, serif; color: #e9c98a; text-shadow: 0 0 1.4cqw #c0281c, 0 0 .4cqw #000; }
.cpuhand .peek.maybe { opacity: .5; }
.cpuhand .peek.maybe::after { content: "?"; font-size: .7em; }
/* 祭壇の2枚は同じ大きさ（14cqw）。手前の1枚を大きくすると、真ん中の蝋燭の炎に重なるため */
.altar { position: absolute; left: 50%; top: 49.5cqh; translate: -50% 0; --w: 14cqw; display: flex; flex-direction: column; align-items: center; gap: .3cqh; }
/* 置き場の高さは、寝かせたカードの見た目の高さに合わせて固定する（カード本来の高さで広がると、下の蝋燭まで届いてしまう） */
.slot { width: var(--w); height: calc(var(--w) * 1.08); display: grid; place-items: center; }
.slot .card { animation: laydown .5s ease-out; }
@keyframes laydown { from { opacity: 0; translate: 0 var(--from, 6cqh); } }
.slot .card.reveal .face.front { animation: revealf .7s ease-in-out forwards; } .slot .card.reveal .face.back { animation: revealb .7s ease-in-out forwards; }
@keyframes revealf { from { transform: rotateY(180deg); } to { transform: rotateY(0); } }
@keyframes revealb { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
.slot .card.lose { filter: brightness(.55) sepia(.6) hue-rotate(-30deg) saturate(2); }
.slot .card.leave { opacity: 0; translate: -26cqw 2cqh; scale: .5; transition: all .7s ease-in; }
.deck { position: absolute; left: 80cqw; top: 50.5cqh; --w: 11cqw; }
.deck .card:nth-child(2) { position: absolute; left: .6cqw; top: -.5cqw; }
.deck.swap .card { animation: deckswap .9s ease-in-out; }
@keyframes deckswap { 40% { translate: -8cqw 3cqh; opacity: .4; } }
.pile { position: absolute; left: 3cqw; top: 50.5cqh; width: 21cqw; height: 11cqh; }
.pile-cards { position: absolute; left: 2cqw; top: 0; --w: 10.5cqw; display: block; width: 14cqw; height: 9cqh; }
.pile-cards .card { position: absolute; left: 0; top: 0; }
.pile-label { position: absolute; left: 0; right: 0; top: 8.2cqh; font-size: 2.5cqw; white-space: nowrap; color: #c9a55a; letter-spacing: .08em; opacity: .9; text-shadow: 0 0 1cqw #000; }
.pile:hover .pile-label { opacity: 1; color: #e2c98d; }

/* ---------- アイテム ---------- */
.items { position: absolute; left: 0; right: 0; top: 52.5cqh; pointer-events: none; }
.item { position: absolute; width: 14cqw; aspect-ratio: 1; pointer-events: auto; background: center bottom / contain no-repeat; filter: drop-shadow(0 1cqw 1.2cqw #000) brightness(.92); transition: translate .35s, filter .35s, opacity .6s, scale .6s; animation: itemin 1.2s ease-out; }
.item[data-pos="0"] { left: 25.5cqw; } .item[data-pos="1"] { left: 60.5cqw; }
.item.lighter { background-image: url(img/item_lighter.webp); scale: .78; } .item.ask { background-image: url(img/item_idol.webp); } .item.scale { background-image: url(img/item_scale.webp); }
.item.sel { translate: 0 -1.5cqh; filter: drop-shadow(0 0 2.4cqw #e2b25a) brightness(1.15); }
.item.taken { opacity: 0; translate: 0 -12cqh; scale: .6; }
.item.used { opacity: 0; scale: 1.25; }
.item.fade { opacity: 0; transition-duration: 1.6s; }
.items.locked .item { pointer-events: none; }
@keyframes itemin { from { opacity: 0; translate: 0 -5cqh; filter: brightness(0); } }
.devilhand { position: absolute; left: 50%; top: -60cqh; width: 46cqw; z-index: 4; translate: -50% 0; pointer-events: none; filter: brightness(.55) drop-shadow(0 0 3cqw #000); opacity: 0; transform-origin: 50% 80%; transition: top 1.6s cubic-bezier(.4, 0, .3, 1), opacity 1s; } /* z-index 4：卓の上のカード・蝋燭・アイテムより手前、操作の帯（5）より奥 */
.devilhand.reach { top: 8cqh; opacity: 1; }
.devilhand.grab { top: -8cqh; opacity: 1; width: 70cqw; }
/* 自分が負けた時：まず相手の頭上にゆっくり現れ（loom）、次に指先を中心に一気に大きくなって画面をふさぐ（seize）。暗幕や手札より手前に出す */
.devilhand.loom { top: -10cqh; opacity: 1; width: 58cqw; z-index: 12; filter: brightness(.5) drop-shadow(0 0 3cqw #000); transition: top 2.4s cubic-bezier(.3, 0, .4, 1), opacity 1.6s; }
.devilhand.seize { top: 12cqh; opacity: 1; width: 58cqw; z-index: 12; transform: scale(4.6); filter: brightness(.16) drop-shadow(0 0 3cqw #000); transition: top .5s cubic-bezier(.7, 0, .9, .5), transform .5s cubic-bezier(.7, 0, .9, .5), filter .5s ease-in; }

/* ---------- 手札 ---------- */
.hand { position: absolute; left: 0; right: 0; bottom: 1.4cqh; height: 29.4cqw; display: flex; justify-content: center; --w: 18.8cqw; transition: filter .6s, opacity .6s; }
.hand .card { margin: 0 -.5cqw; cursor: pointer; transform: rotate(calc(var(--i) * 2.6deg)) translateY(calc(var(--i) * var(--i) * .4cqw)); transform-origin: 50% 160%; }
.hand .card.sel { translate: 0 -5cqw; filter: drop-shadow(0 0 2cqw #e2b25a99); z-index: 2; }
.hand .card.mark { translate: 0 -3cqw; filter: drop-shadow(0 0 2cqw #b8322299); }
.hand .card.played { opacity: 0; translate: 0 -30cqw; pointer-events: none; } /* 見えなくなった札が、上にある物（ガイドなど）への押下を横取りしないように */
.hand.wait { filter: brightness(.55) saturate(.7); pointer-events: none; }
.hand .card.dealt { animation: dealin .5s ease-out backwards; animation-delay: calc(var(--k) * .11s); }
@keyframes dealin { from { opacity: 0; translate: 0 -40cqw; } }

/* ---------- 文字 ---------- */
.sub { position: absolute; left: 5cqw; right: 5cqw; top: 33cqh; min-height: 5cqh; display: grid; place-items: center; text-align: center; font-size: calc(4.5cqw * var(--sub-scale)); line-height: 1.5; color: #efe6cf; text-shadow: 0 0 1.2cqw #000, 0 0 .5cqw #000, 0 .2cqw .4cqw #000; opacity: 0; transition: opacity .5s; pointer-events: none; }
.sub.on { opacity: 1; }
.sub.you { top: 76cqh; color: #b9ad92; font-size: calc(3.8cqw * var(--sub-scale)); }
.devilsub { position: absolute; left: 7cqw; right: 7cqw; top: 20cqh; text-align: center; font-size: calc(4.8cqw * var(--sub-scale)); line-height: 1.7; letter-spacing: .14em; color: #b33a2c; text-shadow: 0 0 2cqw #000, 0 0 .6cqw #000, 0 0 3cqw #5a0c08; opacity: 0; transition: opacity 1.2s; pointer-events: none; }
.devilsub.on { opacity: 1; }
/* 合計と判定の名前。右手前の蝋燭の真上に来るので、少し上げ、暗い下地を敷いて読めるようにする */
.sum { position: absolute; left: 66cqw; top: 52.6cqh; width: 33cqw; z-index: 3; padding: .4cqh 0 .8cqh; border-radius: 3cqw; background: radial-gradient(ellipse at 50% 55%, #000c 0%, #0008 55%, #0000 75%); text-align: center; opacity: 0; transition: opacity .6s; pointer-events: none; text-shadow: 0 0 1.5cqw #000, 0 0 .5cqw #000; }
.sum.on { opacity: 1; }
.sum b { display: block; font: 700 11cqw Georgia, serif; color: #e6d3a3; line-height: 1; }
.sum span { display: block; font-size: 3.7cqw; font-weight: 600; letter-spacing: .1em; color: #d8c79c; white-space: nowrap; }
.sum.bad b { color: #c0453a; } .sum.bad span { color: #e0796c; } .sum.perfect b { color: #f3d98f; text-shadow: 0 0 3cqw #e2a53c; }
.bar { position: absolute; left: 3cqw; right: 3cqw; bottom: calc(34.4cqw + 2.6cqh); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1cqh 2cqw; min-height: 5cqh; pointer-events: none; }
.bar > * { pointer-events: auto; }
.bar:has(p) { padding: 1.2cqh 2cqw 1.4cqh; background: linear-gradient(#0000, #0a0604e6 18%, #0a0604e6 82%, #0000); }
.bar p { width: 100%; margin: 0; text-align: center; font-size: 3.3cqw; color: #cdbf9d; text-shadow: 0 0 1.2cqw #000, 0 0 .4cqw #000; }
.bar p b { color: #e6cf94; font-weight: 600; margin-right: .6em; }
.btn { padding: .9cqh 3.2cqw; font-size: 3.6cqw; letter-spacing: .08em; color: #e3d5ae; background: #120a06dd; border: 1px solid #a88a4a88; border-radius: .6cqw; box-shadow: 0 0 2cqw #000; }
.btn:hover { border-color: #e2c98d; } .btn.main { color: #f6e7bd; border-color: #c9a55a; background: #2a120cdd; padding: 1.1cqh 8cqw; font-size: 4.4cqw; letter-spacing: .4em; text-indent: .4em; }
.btn.ghost { border-color: #a88a4a33; color: #a99c7e; } .btn:disabled { opacity: .35; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: 1.2cqh 3cqw; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.hud-menu { pointer-events: auto; font-size: 6cqw; color: #a88a4a99; width: 9cqw; height: 9cqw; }
.hud-round { font: 3.6cqw Georgia, serif; letter-spacing: .2em; color: #a88a4a; opacity: .8; }
.banner { position: absolute; inset: 0; display: grid; place-items: center; background: #000; font-size: 6.4cqw; letter-spacing: .4em; text-indent: .4em; color: #b9a26a; opacity: 0; pointer-events: none; transition: opacity 1.1s; }
.banner.on { opacity: 1; pointer-events: auto; }
/* 相手が替わる時の1文。題字より小さく、字間も詰める */
.banner.line { padding: 0 10cqw; font-size: 4.4cqw; letter-spacing: .08em; text-indent: 0; line-height: 1.9; text-align: center; color: #d6cbb0; word-break: auto-phrase; text-wrap: balance; line-break: strict; }

/* ---------- 1戦目のガイド ---------- */
/* 1文は、操作の帯のすぐ上・左寄せの決まった場所に出す。z-index 5 は操作の帯と同じ（手札の選んだ札 z-index 2 より手前）。
   左 41cqw までに収めるのは、祭壇（中央）と自分の蝋燭（右手前）に重ねないため。
   下端は「捧げる」ボタン（帯の下端 34.4cqw + 2.6cqh から、高さ約 6.4cqw + 2.2cqh）より上、
   上端は「捧げられた供物」の山の文字とアイテムの下（「捧げられた供物」の山のボタンの下端 61.5cqh）より下になるように、高さの上限を決めている */
.guide { --guide-bottom: calc(40.8cqw + 5.2cqh); position: absolute; z-index: 5; left: 2.5cqw; width: 38.5cqw; bottom: var(--guide-bottom); max-height: calc(100cqh - 61.6cqh - var(--guide-bottom)); overflow: hidden; padding: .4cqh 2.2cqw;  background: #0a0604e6; border: 1px solid #a88a4a66; border-radius: .6cqw; box-shadow: 0 0 3cqw #000; color: #d8cba6; text-shadow: 0 0 .4cqw #000; animation: fadein .5s ease-out; }
.guide.note { cursor: pointer; } /* 効果のガイドは、押すと閉じる */
.guide-text { margin: 0; font-size: 3.1cqw; line-height: 1.3; }
.guide-off { position: absolute; left: 12cqw; top: calc(1.2cqh + 1.5cqw); font-size: 2.8cqw; letter-spacing: .06em; color: #a99c7e; padding: 1cqw 2cqw; text-decoration: underline; text-decoration-color: #a88a4a55; text-underline-offset: .3em; text-shadow: 0 0 1cqw #000; } /* 左上のメニュー（≡）の隣。小さく、目立たせない */
/* 光の枠：物そのものには触れず、外側に細い線を重ねるだけ（押す操作の邪魔をしない） */
.guide-ring { position: absolute; z-index: 6; pointer-events: none; border: 1px solid #d4b26acc; border-radius: 1.2cqw; box-shadow: 0 0 2.4cqw #c9a55a55, inset 0 0 1.6cqw #c9a55a33; animation: guidepulse 1.6s ease-in-out infinite; transition: left .3s, top .3s, width .3s, height .3s; }
@keyframes guidepulse { 50% { opacity: .45; } }
/* アイテムの説明が帯に出ている間は、ガイドを引っ込める（説明が2つ並ばないように） */
#scr-game:has(#bar > p) :is(.guide, .guide-ring) { visibility: hidden; }
.calm .guide-ring { animation: none; }
@media (prefers-reduced-motion: reduce) { .guide-ring, .guide { animation: none; } }

/* ---------- 物語（導入・結末） ---------- */
#scr-story { background: #000; }
.story-bg { position: absolute; inset: 0; background: center / cover no-repeat; opacity: 0; transition: opacity 4s; }
.story-bg.on { opacity: .75; }
.story-bg.dim.on { opacity: .32; filter: saturate(.4); }
.story-text { position: absolute; left: 9cqw; right: 9cqw; top: 30cqh; font-size: calc(4.3cqw * var(--sub-scale)); line-height: 2; text-align: center; color: #d6cbb0; opacity: 0; transition: opacity 1.2s; text-shadow: 0 0 2cqw #000, 0 0 .6cqw #000; }
.story-text.on { opacity: 1; } .story-text.devil { color: #b33a2c; letter-spacing: .14em; font-size: calc(4.8cqw * var(--sub-scale)); }
.story-text.quote { color: #efe6cf; }
.end-card { position: absolute; left: 0; right: 0; top: 6cqh; text-align: center; animation: fadein 3s ease-out; }
@keyframes fadein { from { opacity: 0; } }
/* リザルト：見出し → 生かせた人数 → 相手ごとの結果（3人×2段）→ そのほかの数字 → ボタン */
.result { padding: 0 7cqw; word-break: auto-phrase; line-break: strict; }
.res-kicker { margin: 0; font: 3.2cqw Georgia, serif; letter-spacing: .5em; text-indent: .5em; color: #8d7a4c; }
.res-title { margin: 1.2cqh 0 .6cqh; font-size: 9cqw; font-weight: 600; letter-spacing: .14em; text-indent: .14em; color: #cdb98a; text-wrap: balance; }
.res-title.clear { color: #f0d995; text-shadow: 0 0 3cqw #a8742a88; }
.res-count { margin: 0 0 2.2cqh; font-size: 5cqw; color: #e6d3a3; }
.res-list { list-style: none; margin: 0 0 2cqh; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6cqh 3cqw; }
.res-list li { display: flex; flex-direction: column; align-items: center; gap: .6cqh; position: relative; }
.res-no { position: absolute; left: 1cqw; top: 0; font: 3cqw Georgia, serif; color: #a8946a; z-index: 1; text-shadow: 0 0 1cqw #000; }
/* 顔の小さな絵：立ち絵の上の方（顔）だけを丸く切り出す */
.res-face { width: 19cqw; aspect-ratio: 1; border-radius: 50%; border: 1px solid #a88a4a66; background: #120a06 50% 15% / 195% auto no-repeat; }
.res-word { font-size: 3.2cqw; color: #cfc3a4; white-space: nowrap; }
.res-list .res-saved .res-face { border-color: #d4b26acc; }
.res-list .res-saved .res-word { color: #e6cf94; }
.res-list .res-lost .res-face { filter: grayscale(1) brightness(.55); }
.res-list .res-lost .res-word { color: #9d8f72; }
.res-list .res-died .res-face { filter: grayscale(.6) brightness(.4) sepia(.5) hue-rotate(-30deg); border-color: #7a1a14; }
.res-list .res-died .res-word { color: #c0453a; }
.res-list .res-unmet .res-face { filter: brightness(.12); }
.res-list .res-unmet .res-word { color: #6f6142; }
.res-stats { display: grid; grid-template-columns: auto auto; justify-content: center; gap: .4cqh 4cqw; margin: 0; font-size: 3.4cqw; line-height: 1.5; text-align: left; color: #b9ad92; }
.res-stats dt { color: #8d7a4c; } .res-stats dd { margin: 0; color: #d6cbb0; }
.end-menu { margin-top: 3.5cqh; display: flex; flex-direction: column; align-items: center; gap: 1.6cqh; }
.skip { position: absolute; right: 4cqw; bottom: 3cqh; font-size: 3.2cqw; color: #8d7a4c99; letter-spacing: .2em; padding: 1.5cqh 2cqw; }

/* ---------- 重ねる画面 ---------- */
.overlay { position: absolute; inset: 0; background: #000d; display: grid; place-items: center; z-index: 20; animation: fadein .3s; }
.ov-box { width: 88cqw; max-height: 88cqh; overflow-y: auto; padding: 3cqh 5cqw; background: #0d0805 linear-gradient(#1a100a66, #0000); border: 1px solid #a88a4a55; box-shadow: 0 0 10cqw #000; font-size: 3.6cqw; line-height: 1.8; color: #cfc3a4; }
.ov-box h3 { margin: 0 0 2cqh; text-align: center; font-size: 4.8cqw; letter-spacing: .3em; text-indent: .3em; color: #cdb98a; font-weight: 600; }
.ov-box ul { margin: 0; padding-left: 1.2em; } .ov-box li { margin-bottom: .7em; }
.ov-box .row { display: flex; align-items: center; justify-content: space-between; gap: 3cqw; margin: 1.8cqh 0; }
.ov-box .foot { margin-top: 3cqh; display: flex; justify-content: center; gap: 3cqw; flex-wrap: wrap; }
/* 小さい画面（375×667）でもスクロールせずに「始める」まで見えるよう、行間と余白を詰める */
.rules { font-size: 3.4cqw; line-height: 1.6; } .rules h3 { margin-bottom: 1.4cqh !important; } .rules .foot { margin-top: 1.6cqh !important; }
.rules p { margin: 0 0 1cqh; text-wrap: wrap; } /* 均等割り（balance）だと、1文が早く折れて「悪魔／のものになる」のように割れるため */ .rules .rules-goal { color: #e6d3a3; }
.rules-axis { margin-bottom: .6cqh !important; font-size: 3cqw; color: #a8946a; text-align: center; }
/* 合計の帯：3〜23 を1マスずつ。色は結果の種類 */
.rules-strip { display: grid; grid-template-columns: repeat(21, 1fr); gap: .3cqw; margin-bottom: 1.4cqh; }
.rules-strip span { font: 600 2.5cqw Georgia, serif; text-align: center; padding: .7cqh 0; border-radius: .6cqw; color: #f1e6c8; }
.k-ruin { background: #5a1410; } .k-short, .k-over { background: #8a3b22; } .k-safe { background: #3c4a2c; } .k-thirteen { background: #8a6a1e; color: #fff4cf; }
.rules-rows { display: grid; grid-template-columns: auto 1fr; gap: .6cqh 3cqw; margin: 0 0 1.4cqh; align-items: center; line-height: 1.4; }
.rules-rows dt { font: 600 3.3cqw Georgia, serif; padding: .3cqh 2cqw; border-radius: 1cqw; text-align: center; color: #f1e6c8; white-space: nowrap; }
.rules-rows dd { margin: 0; }
.ov-box input[type=range] { flex: 1; accent-color: #a88a4a; } .ov-box input[type=checkbox] { width: 5cqw; height: 5cqw; accent-color: #a88a4a; }
.seg { display: flex; } .seg button { padding: .5cqh 3cqw; border: 1px solid #a88a4a55; color: #a99c7e; } .seg button.on { background: #3a2212; color: #f0e2ba; border-color: #c9a55a; }
.grid12 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1.4cqw; margin: 1cqh 0 2cqh; --w: 11.6cqw; }
.grid12 .card { width: 100%; } .grid12 .card.gone { filter: brightness(.3) saturate(.3); } .grid12 .card.gone .num { text-decoration: line-through; color: #000; }
.grid12 .card.mine::after { content: ""; position: absolute; inset: -3%; border: 1px solid #c9a55a; border-radius: 6%; }
.seq { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 1cqh 1.4cqw; align-items: center; --w: 11cqw; margin-bottom: 1.5cqh; }
.seq .who { font-size: 3.1cqw; color: #a88a4a; padding-right: 1cqw; } .seq .tno { text-align: center; font: 2.8cqw Georgia, serif; color: #6f6142; } .seq .card { width: 100%; }
.seq .ph { aspect-ratio: 2 / 3; border: 1px dashed #a88a4a33; border-radius: 6%; }
.note { font-size: 2.9cqw; color: #8d7f61; text-align: center; margin: 0; }
.debug { position: fixed; left: 0; top: 0; width: min(30vw, 460px); max-height: 100vh; overflow: hidden; margin: 0; padding: 8px; font: 11px/1.45 ui-monospace, Menlo, monospace; color: #9fd09f; background: #000c; z-index: 50; white-space: pre-wrap; pointer-events: none; }

/* ---------- ゆらぎを抑える設定 ---------- */
.calm .flame, .calm .glow, .calm .room-bg, .calm .cpu.tremble { animation: none !important; }
.calm .cpu { animation-duration: 7s; }
@media (prefers-reduced-motion: reduce) { .room-bg { animation: none; } }
