/* AMIX GAMES PIXEL SIDE */
:root {
  --bg: #070812; --fg: #dfe8ee; --dim: #8fa3b3; --line: #3a566b; --acc: #f2c84b; --red: #ee6a50; --panel: rgba(7, 8, 18, .88);
  /* iOS 26 の Safari で下端がツールバーに隠れる分 */
  --tb: max(0px, calc(100% - 100svh));
  --jp: 'DotGothic16', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  --en: 'Press Start 2P', 'DotGothic16', monospace;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font: 400 15px/1.6 var(--jp); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

#app { position: fixed; inset: 0; bottom: var(--tb); overflow: hidden; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#stage canvas { position: absolute; display: block; image-rendering: crisp-edges; image-rendering: pixelated; will-change: transform; }

/* 上の表示 */
#hud { position: absolute; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 8px; pointer-events: none; }
#hud .sp { flex: 1; }
.brand { font: 400 9px/1.5 var(--en); letter-spacing: .08em; color: var(--dim); text-shadow: 0 2px 0 #000; }
.brand b { display: block; font-weight: 400; font-size: 12px; color: var(--acc); }
#hearts { font-size: 20px; letter-spacing: .1em; color: var(--red); text-shadow: 0 2px 0 #000; margin-left: 8px; }
#seen { font-size: 13px; color: var(--fg); text-shadow: 0 2px 0 #000; white-space: nowrap; }
.hb { pointer-events: auto; min-width: 44px; min-height: 40px; padding: 4px 12px; background: var(--panel); border: 2px solid var(--line); border-radius: 0; font-size: 14px; }
.hb:hover { border-color: var(--fg); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

#boss { position: absolute; left: 50%; top: calc(58px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); width: min(420px, 78vw); text-align: center; pointer-events: none; }
#boss:not([hidden]) { animation: bossHudIn .2s steps(4) both; }
@keyframes bossHudIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #boss:not([hidden]) { animation: none; } }
#boss p { font-size: 14px; letter-spacing: .3em; text-shadow: 0 2px 0 #000; }
.bar { height: 12px; border: 2px solid var(--fg); background: #000; padding: 2px; }
.bar i { display: block; height: 100%; width: 100%; background: var(--red); transition: width .15s steps(4); }

#hint, #toast { position: absolute; left: 50%; transform: translateX(-50%); padding: 6px 14px; background: var(--panel); border: 2px solid var(--line); white-space: nowrap; pointer-events: none; max-width: 94vw; }
#hint { bottom: 26px; color: var(--acc); }
#battleHelp { position: absolute; right: 16px; bottom: 16px; padding: 6px 9px; background: rgba(7, 8, 18, .65); color: var(--dim); font-size: 11px; line-height: 1.9; text-align: right; white-space: pre-line; pointer-events: none; text-shadow: 0 1px 2px #000; }
@media (pointer: coarse) { #battleHelp { display: none !important; } }
#toast { top: calc(104px + env(safe-area-inset-top, 0px)); border-color: var(--acc); white-space: normal; text-align: center; }

/* 櫓の上（主観）：照準・降りるボタン・切りかえと被弾の合図 */
#aim { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; filter: drop-shadow(0 0 0 #000) drop-shadow(1px 1px 0 #000) drop-shadow(-1px -1px 0 #000);
  background: linear-gradient(#fff, #fff) 50% 0 / 2px 9px no-repeat, linear-gradient(#fff, #fff) 50% 100% / 2px 9px no-repeat, linear-gradient(#fff, #fff) 0 50% / 9px 2px no-repeat, linear-gradient(#fff, #fff) 100% 50% / 9px 2px no-repeat, linear-gradient(var(--acc), var(--acc)) 50% 50% / 2px 2px no-repeat; }
#btnDown { position: absolute; right: 12px; top: calc(60px + env(safe-area-inset-top, 0px)); }
#stage.cut canvas { animation: cut .4s steps(5) both; }
@keyframes cut { from { opacity: 0; } to { opacity: 1; } }
body.fp #stage.hit::before { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse closest-side at 50% 50%, transparent 52%, rgba(150, 20, 38, .12) 74%, rgba(196, 36, 54, .48) 90%, rgba(238, 72, 70, .72) 100%);
  animation: fpHit .5s steps(6) forwards; }
@keyframes fpHit { from { opacity: 1; } to { opacity: 0; } }
@keyframes hit { to { opacity: 0; } }
#stage.boom::after { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .26); pointer-events: none; animation: hit .16s steps(2) forwards; }
body.fp #stage { cursor: crosshair; }

/* 敗北：倒れる姿を見せてから暗転。ゲームの時間で進め、一時停止中は止める。 */
#defeat { position: absolute; inset: 0; z-index: 18; display: grid; place-items: center; pointer-events: none; --shade: 0; --label: 0; }
#defeat > i { position: absolute; inset: 0; background: #070812; opacity: var(--shade); }
#defeat > p { position: relative; text-align: center; opacity: var(--label); text-shadow: 0 3px 0 #070812, 0 0 18px #070812; }
#defeat small { display: block; margin-bottom: 12px; color: #d78b87; font: 400 11px/1.5 var(--en); letter-spacing: .2em; }
#defeat b { display: block; color: #f4e4d9; font-size: clamp(28px, 6vw, 42px); font-weight: 400; letter-spacing: .22em; padding-left: .22em; }
body.defeating :is(#hud, #boss, #pad, #hint, #toast, #battleHelp, #btnDown, #aim) { visibility: hidden; }
body.defeating #pause { z-index: 20; }
body.defeating #btnMenu2 { display: none; }

/* 社の紹介 */
#card { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(600px, calc(100% - 24px)); display: flex; gap: 12px; padding: 10px; background: var(--panel); border: 2px solid var(--fg); box-shadow: 0 4px 0 #000; }
#card img { width: 200px; height: 130px; flex: none; object-fit: cover; image-rendering: auto; border: 2px solid var(--line); background: #000; }
.ct { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.cno { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--dim); }
.cno span:first-child { color: var(--acc); }
#card h2 { font-weight: 400; line-height: 1.35; margin: 2px 0; }
#card h2 b { display: block; font: 400 13px/1.5 var(--en); color: #fff; overflow-wrap: anywhere; }
#card h2 span { font-size: 14px; color: var(--fg); }
/* 説明は RPG の会話窓のように1文字ずつ出し、入りきらない分は次のページへ送る（「…」で切らない） */
#cardDesc { font-size: 14px; line-height: 1.6; height: calc(1.6em * 2); color: var(--fg); overflow: hidden; margin-top: 4px; cursor: pointer; }
#cardRest { visibility: hidden; }
.cf { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#cardMore { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); min-height: 20px; }
#cardMore i { font-style: normal; color: var(--acc); visibility: hidden; }
#card.more #cardMore i { visibility: visible; animation: cardMore .7s steps(2) infinite; }
#cardMore b { font-weight: 400; }
@keyframes cardMore { 50% { transform: translateY(3px); } }
#card.ready .go { animation: cardGo .8s steps(2) infinite; }
@keyframes cardGo { 50% { border-color: #fff; box-shadow: 0 3px 0 #7a4a1c, 0 0 0 2px #fff3a8; } }
@media (prefers-reduced-motion: reduce) { #card.more #cardMore i, #card.ready .go { animation: none; } }
.go { display: inline-block; min-width: 120px; min-height: 40px; padding: 7px 18px; text-align: center; text-decoration: none; background: var(--acc); color: #1a1206; border: 2px solid #fff3a8; box-shadow: 0 3px 0 #7a4a1c; pointer-events: auto; }
.go:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a4a1c; }

/* 指の操作部 */
#pad { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); height: 150px; pointer-events: none; }
#stick { position: absolute; left: 10px; bottom: 0; width: 150px; height: 150px; pointer-events: auto; touch-action: none; border: 2px solid rgba(223, 232, 238, .4); background: rgba(7, 8, 18, .35); }
#knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; background: var(--fg); border: 2px solid #000; pointer-events: none; }
.pb { position: absolute; pointer-events: auto; touch-action: none; border: 2px solid #fff3a8; background: var(--acc); color: #1a1206; box-shadow: 0 4px 0 #7a4a1c; font-size: 15px; }
#btnA { right: 14px; bottom: 14px; width: 92px; height: 92px; }
#btnB { right: 118px; bottom: 0; width: 70px; height: 70px; background: var(--fg); border-color: #fff; box-shadow: 0 4px 0 #3a566b; }
.pb.down { transform: translateY(3px); box-shadow: 0 1px 0 #7a4a1c; }
@media (pointer: fine) { #pad { display: none !important; } }

/* 入口・一時停止 */
.scr { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(7, 8, 18, .55); }
.gp { width: min(440px, 100%); padding: 26px 20px 20px; text-align: center; background: var(--panel); border: 2px solid var(--fg); box-shadow: 0 6px 0 #000; }
.g1 { font: 400 11px/1.6 var(--en); letter-spacing: .14em; color: var(--dim); }
.gp h1 { font: 400 clamp(24px, 7.4vw, 34px)/1.3 var(--en); color: var(--acc); text-shadow: 0 4px 0 #7a4a1c; margin: 4px 0 12px; }
.gp h2 { font-weight: 400; font-size: 20px; letter-spacing: .2em; margin-bottom: 12px; }
.lead { margin-bottom: 16px; }
.load { height: 10px; border: 2px solid var(--line); padding: 1px; margin: 0 auto 10px; width: 70%; }
.load i { display: block; height: 100%; width: 0; background: var(--acc); }
.btn { display: block; width: 100%; min-height: 50px; margin-top: 10px; background: var(--acc); color: #1a1206; border: 2px solid #fff3a8; border-radius: 0; box-shadow: 0 4px 0 #7a4a1c; font-size: 18px; }
.btn:disabled { background: #2a2c3a; color: var(--dim); border-color: var(--line); box-shadow: none; cursor: default; }
.btn.sub { background: transparent; color: var(--fg); border-color: var(--line); box-shadow: none; }
.btn:not(:disabled):active { transform: translateY(2px); box-shadow: 0 2px 0 #7a4a1c; }
.keys { margin-top: 14px; font-size: 12px; color: var(--dim); }
.links { margin-top: 10px; font-size: 12px; color: var(--dim); line-height: 2; }

/* 討伐証明書：重ねる面そのものを縦にスクロールできるようにし、上端から並べる（上が見切れない） */
#cert { position: absolute; inset: 0; z-index: 30; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: rgba(4, 5, 12, .9); padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); opacity: 0; transition: opacity .25s; user-select: auto; -webkit-user-select: auto; }
#cert.on { opacity: 1; }
.cw { width: min(460px, 100%); margin: 0 auto; transform: translateY(12px); transition: transform .25s; }
#cert.on .cw { transform: none; }
@media (prefers-reduced-motion: reduce) { #cert, .cw { transition: none; } }
.ch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ch h2 { font-weight: 400; font-size: 18px; letter-spacing: .2em; color: var(--acc); }
.ctab { display: flex; gap: 8px; margin-bottom: 10px; }
.ctab .hb[aria-pressed="true"] { border-color: var(--acc); color: var(--acc); }
#certImg { display: block; width: 100%; height: auto; border: 2px solid var(--line); background: #0c0e1c; -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
#certNote { margin-top: 8px; font-size: 13px; color: var(--dim); text-align: center; }
.cb { margin-top: 4px; }
a.btn, a.btn:visited { display: flex; align-items: center; justify-content: center; color: #1a1206; text-decoration: none; }

/* ゲームの一覧（JS が動けば重ねて開く画面、動かなければそのままのページ） */
#list { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
html.js #list { display: none; position: fixed; inset: 0; bottom: var(--tb); max-width: none; z-index: 20; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--bg); padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, calc(50% - 480px)) 40px; }
html.js.list-open #list { display: block; }
html:not(.js) #app { display: none; }
html:not(.js) #btnClose { display: none; }
.lh { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 1; }
.lh h2 { font: 400 13px/1.6 var(--en); color: var(--acc); }
#games { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.g { border: 2px solid var(--line); background: #0c0e1c; display: flex; flex-direction: column; }
.g a { display: flex; flex-direction: column; gap: 4px; padding: 0 0 8px; text-decoration: none; flex: 1; }
.g a:hover .en { color: var(--acc); }
.g img { width: 100%; height: auto; aspect-ratio: 480 / 312; display: block; border-bottom: 2px solid var(--line); background: #000; }
.gt, .gm, .g .desc { padding: 0 10px; }
.g .en { display: block; font: 400 12px/1.6 var(--en); font-weight: 400; color: #fff; overflow-wrap: anywhere; margin-top: 6px; }
.g .ja { font-size: 14px; }
.gm { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 12px; color: var(--dim); }
.g .desc { font-size: 13px; line-height: 1.55; }
.g[data-kids] .gm::after { content: 'KIDS'; color: #1a1206; background: #ffb84a; padding: 0 6px; }
.warp { margin: 0 10px 10px; min-height: 40px; background: transparent; border: 2px solid var(--line); border-radius: 0; font-size: 14px; }
.warp:hover { border-color: var(--acc); color: var(--acc); }
.foot { margin-top: 24px; font-size: 12px; color: var(--dim); text-align: center; }

/* 指で操作する端末・せまい画面：紹介は上に出す（下は操作部） */
@media (pointer: coarse), (max-width: 640px) {
  #card { bottom: auto; top: calc(58px + env(safe-area-inset-top, 0px)); gap: 8px; padding: 8px; }
  #card img { width: 112px; height: 73px; }
  #card h2 b { font-size: 11px; }
  #cardDesc { font-size: 13px; height: calc(1.6em * 3); }
  .cf { padding-top: 8px; }
  .go { min-width: 96px; }
  #hint { bottom: auto; top: calc(58px + env(safe-area-inset-top, 0px)); }
  #seen { font-size: 12px; }
  .brand span { display: none; }
}
@media (pointer: coarse) { #boss { top: calc(56px + env(safe-area-inset-top, 0px)); } #toast { top: calc(110px + env(safe-area-inset-top, 0px)); } }

/* ═════════ UI 素材で作る見た目（Franuka「UI asset pack」。使う部品だけ image/ に置いている）═════════
   部品は 16px のマス目のドット絵。枠は border-image で9分割し、整数倍に拡大して補間なしで見せる */
:root { --ink: #2b1d33; --pageink: #4a2418; --pagesub: #8a4a2a; }
#app { cursor: url(../image/cursor.png) 2 2, auto; }
#app button, #app a { cursor: url(../image/hand.png) 10 2, pointer; }
#card, #toast, #hint, .gp, .btn, .hb, .go, .pb, #boss p, .bar, .hrt, .st, #bk, #bk *, #bkTabs button, #btnMenu img, .gdv, .cdv { image-rendering: pixelated; }
html.js #list { display: none !important; }

/* 窓：青い枠（紹介・知らせ）と、蔦の枠（一時停止） */
#card, #toast { background: none; box-shadow: none; border: 32px solid transparent; border-image: url(../image/box-blue.png) 16 fill / 32px stretch; color: var(--ink); }
#card { padding: 0; gap: 12px; }
#card img { border-color: #4c6885; align-self: center; }
#card h2 b { color: #1c1e3a; }
#card h2 span, #cardDesc { color: var(--ink); }
.cno { color: #4c4a72; }
.cno span:first-child { color: #8a2a3a; }
.cdv { display: block; flex: none; height: 8px; margin: 3px 0 1px; background: url(../image/div-gold.png) left center / 96px 32px no-repeat; filter: brightness(.55) saturate(1.4); }
#cardMore { color: #4c4a72; }
#cardMore i { width: 20px; height: 20px; background: url(../image/tick-down.png) center / 32px 32px no-repeat; }
#toast { padding: 0 4px; margin-top: -8px; }
#hint { background: none; border: solid transparent; border-width: 9px 15px; border-image: url(../image/banner-plain.png) 3 5 fill / 9px 15px stretch; padding: 7px 12px 8px; line-height: 1.5; color: var(--ink); }
.gp { background: none; box-shadow: none; border: 32px solid transparent; border-image: url(../image/box-vine.png) 16 fill / 32px stretch; padding: 6px 6px 2px; color: #fff; }

/* ボタン：金（主な操作）と青（そのほか） */
.btn, .go { background: none; box-shadow: none; border: solid transparent; border-width: 15px 24px; border-image: url(../image/btn-gold.png) 5 8 fill / 15px 24px stretch; border-radius: 0; color: #4a2408; min-height: 48px; padding: 0 6px; font-size: 16px; line-height: 18px; text-shadow: 0 1px 0 #ffe08a; }
.btn:not(:disabled):hover, .btn:focus-visible, .go:hover, .go:focus-visible { border-image-source: url(../image/btn-gold-on.png); }
.btn:not(:disabled):active, .go:active { border-image-source: url(../image/btn-gold-down.png); transform: none; box-shadow: none; }
.btn:disabled { background: none; border-color: transparent; box-shadow: none; filter: grayscale(.9) brightness(.75); }
a.btn, a.btn:visited, .go, .go:visited { color: #4a2408; }
#card.ready .go { animation: goBlink .8s steps(2) infinite; }
@keyframes goBlink { 50% { filter: brightness(1.18); } }
.btn.sub, .hb { background: none; box-shadow: none; border: 15px solid transparent; border-image: url(../image/btn-blue.png) 5 fill / 15px stretch; border-radius: 0; color: #fff; min-height: 48px; padding: 0 4px; line-height: 18px; text-shadow: 0 2px 0 #1c2a44; }
.btn.sub:not(:disabled):hover, .btn.sub:focus-visible, .hb:hover, .hb:focus-visible, .ctab .hb[aria-pressed="true"] { border-image-source: url(../image/btn-blue-on.png); border-color: transparent; color: #fff; }
.btn.sub:not(:disabled):active, .hb:active { border-image-source: url(../image/btn-blue-down.png); }
#btnMenu { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
#btnMenu img { width: 24px; height: 24px; margin: -4px 0; }
#btnA { border: 32px solid transparent; border-image: url(../image/box-orange.png) 16 fill / 32px stretch; background: none; box-shadow: none; color: #4a2408; padding: 0; }
#btnB { border: 32px solid transparent; border-image: url(../image/box-blue.png) 16 fill / 32px stretch; background: none; box-shadow: none; color: var(--ink); padding: 0; font-size: 13px; }
.pb.down { transform: translateY(2px); filter: brightness(.82); box-shadow: none; }

/* 上の表示：ロゴ・体力・訪ねた社・ボスの名前と体力 */
#logoS { display: block; width: 168px; height: 28px; image-rendering: pixelated; filter: drop-shadow(0 2px 0 #000); }
@media (max-width: 640px) { #logoS { width: 84px; height: 14px; } }
.brand b { margin-top: 3px; }
#hearts { display: flex; gap: 2px; font-size: 0; }
.hrt { display: inline-block; width: 24px; height: 24px; background: url(../image/heart-empty.png) center / 100% no-repeat; }
.hrt.on { background-image: url(../image/heart.png); }
.st { display: inline-block; width: 16px; height: 16px; margin-right: 4px; vertical-align: -2px; background: url(../image/star-empty.png) center / 100% no-repeat; }
.st.on { background-image: url(../image/star.png); }
#boss p { display: inline-block; height: 32px; line-height: 30px; padding: 0 12px; margin-bottom: 2px; border: solid transparent; border-width: 0 32px; border-image: url(../image/banner-gem.png) 0 16 fill / 0 32px stretch; color: #fff; text-shadow: 0 2px 0 #1c2a44; }
.bar { height: 30px; padding: 0; background: none; border: 10px solid transparent; border-image: url(../image/btn-blue-down.png) 5 fill / 10px stretch; }
.bar i { background: linear-gradient(#ffb09a 0 3px, #ee6a50 3px); }

/* 入口：ドットのロゴ・題・TAP TO ENTER */
#gate { flex-direction: column; background: rgba(7, 8, 18, .46); cursor: url(../image/hand.png) 10 2, pointer; }
.gt { display: flex; flex-direction: column; align-items: center; text-align: center; }
#logo { width: 560px; height: 136px; image-rendering: pixelated; filter: drop-shadow(0 4px 0 #3d2414); }
#gate h1 { font: 400 34px/1.3 var(--en); letter-spacing: .14em; color: #fff; text-shadow: 0 4px 0 #1c2a44; margin: 14px 0 4px; }
.gdv { display: block; width: 144px; height: 26px; background: url(../image/div-flourish.png) center / 144px 48px no-repeat; }
#gate .lead { margin: 6px 0 22px; text-shadow: 0 2px 0 #000; }
#btnStart { background: none; border: 0; min-height: 48px; padding: 12px 20px; font: 400 16px/1.6 var(--en); letter-spacing: .12em; color: var(--acc); text-shadow: 0 3px 0 #000; }
#btnStart:disabled { color: var(--dim); }
#gate.ready #btnStart { animation: enterBlink 1.1s steps(2) infinite; }
@keyframes enterBlink { 50% { opacity: .2; } }
#gate .keys, #gate .links { position: absolute; left: 0; right: 0; margin: 0; text-align: center; text-shadow: 0 2px 0 #000; }
#gate .keys { bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
#gate .links { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding: 0 12px; font-size: 12px; line-height: 1.9; color: var(--fg); cursor: auto; }
#gate .links .cg { white-space: nowrap; }
@media (max-width: 640px) { #logo { width: 280px; height: 68px; } #gate h1 { font-size: 22px; } #btnStart { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { #gate.ready #btnStart, #card.ready .go { animation: none; } }

/* 本のメニュー：魔導書。--k は本の拡大率（game 側で画面に合わせて決める） */
#book { position: absolute; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; overflow: hidden; background: rgba(4, 5, 12, .8); --k: 3; user-select: none; -webkit-user-select: none; }
#bk { position: relative; flex: none; width: calc(256px * var(--k)); height: calc(160px * var(--k)); margin-top: calc(10px * var(--k)); background: url(../image/book.png) 0 0 / 100% 100% no-repeat; transition: transform .25s steps(5); }
#bk.anim { background-image: none; }
#bk.anim > .pg, #bk.anim > #bkTabs { visibility: hidden; }
#bkAnim { position: absolute; left: 0; bottom: 0; width: 100%; display: none; background-repeat: no-repeat; pointer-events: none; }
#bk.anim #bkAnim { display: block; background-size: calc(2048px * var(--k)) 100%; animation: bkStrip .38s steps(8) both; }
#bk.opening #bkAnim, #bk.closing #bkAnim { height: calc(240px * var(--k)); }
#bk.next #bkAnim, #bk.prev #bkAnim { height: calc(176px * var(--k)); }
#bk.opening #bkAnim { background-image: url(../image/book-open.png); animation-duration: .64s; }
#bk.closing #bkAnim { background-image: url(../image/book-close.png); animation-duration: .52s; }
#bk.next #bkAnim { background-image: url(../image/book-next.png); }
#bk.prev #bkAnim { background-image: url(../image/book-prev.png); }
@keyframes bkStrip { from { background-position-x: 0; } to { background-position-x: calc(-2048px * var(--k)); } }
#bkClose { position: absolute; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); }
#bkPages { display: none; position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(360px, calc(100% - 32px)); gap: 12px; }
#book.one #bkPages { display: flex; }
#bkPages .hb { flex: 1; color: var(--fg); font-size: 13px; }
#bkPages .hb:disabled { opacity: .35; cursor: default; }
#book.one #bk { transform: translateX(calc(64px * var(--k))); }
#book.one.right #bk { transform: translateX(calc(-64px * var(--k))); }

.pg { position: absolute; top: calc(13px * var(--k)); width: calc(88px * var(--k)); height: calc(108px * var(--k)); display: flex; flex-direction: column; overflow: hidden; color: var(--pageink); font-size: calc(4.1px * var(--k)); line-height: 1.5; }
#bkL { left: calc(28px * var(--k)); }
#bkR { left: calc(140px * var(--k)); }
.pg h3 { flex: none; display: flex; justify-content: space-between; align-items: baseline; font-size: 1.25em; font-weight: 400; letter-spacing: .2em; margin: 0 0 .4em; padding-bottom: .15em; border-bottom: calc(.6px * var(--k)) solid #c4703a; }
.pg h3 small { font-size: .6em; letter-spacing: 0; color: var(--pagesub); }
.pg h3.h2 { margin-top: .7em; }
.rows { list-style: none; padding: 0; margin: 0; flex: 1; display: flex; flex-direction: column; gap: calc(.8px * var(--k)); min-height: 0; }
.row { width: 100%; min-height: calc(13.4px * var(--k)); display: flex; align-items: center; gap: .45em; padding: .1em .3em; text-align: left; background: none; border: calc(.6px * var(--k)) solid transparent; border-radius: 0; color: inherit; font: inherit; }
.row:hover { background: #ffc48e; }
.row[aria-pressed="true"] { background: #ffd4a8; border-color: #c4703a; }
.row .st { width: calc(6px * var(--k)); height: calc(6px * var(--k)); margin: 0; flex: none; }
.row .no { flex: none; font: 400 .58em var(--en); color: #a8502a; }
.row .t { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.row .t b { font: 400 .55em/1.5 var(--en); overflow-wrap: anywhere; }
.row .t span { font-size: .92em; }
.pager { flex: none; display: flex; justify-content: center; align-items: center; gap: 1em; font-size: .85em; }
.pgb { min-width: 2.6em; min-height: 2.2em; background: none; border: 0; color: #a8502a; font: inherit; font-size: 1.15em; }
.pgb:disabled { opacity: .25; }
.cv { flex: none; width: 100%; height: auto; aspect-ratio: 480 / 312; image-rendering: auto; background: #000; border: calc(.8px * var(--k)) solid #7a3f2a; }
.meta { flex: none; margin-top: .35em; font-size: .7em; color: var(--pagesub); }
.pg h3.ti { display: block; border: 0; margin: .1em 0 0; padding: 0; letter-spacing: 0; font-size: 1em; }
.ti b { display: block; font: 400 .7em/1.5 var(--en); overflow-wrap: anywhere; }
.ti span { font-size: .95em; }
.dv { flex: none; display: block; height: calc(5px * var(--k)); background: url(../image/div-gold.png) center / calc(48px * var(--k)) calc(16px * var(--k)) no-repeat; filter: brightness(.5) saturate(1.5); }
.ds { flex: 1; min-height: 0; overflow: auto; font-size: .86em; }
.acts { flex: none; display: flex; gap: .5em; margin-top: .4em; }
.pg .btn { width: auto; flex: 1; margin: 0; min-height: 44px; font-size: max(13px, .95em); border-width: 13px 16px; border-image-width: 13px 16px; padding: 0 2px; }
.pg .btn.sub { border-width: 13px; border-image-width: 13px; }
.back { display: none; flex: none; align-self: flex-start; min-height: 40px; margin: -.4em 0 .2em; padding: 0 .4em; background: none; border: 0; color: #a8502a; font: inherit; font-size: .9em; }
#book.one .back { display: block; }
.k { margin-top: .5em; font-size: .7em; color: var(--pagesub); }
.v { font-size: 1.15em; }
.stars { line-height: 1; }
.stars .st { width: calc(7px * var(--k)); height: calc(7px * var(--k)); margin: 0; }
.pg .hrt { width: calc(8px * var(--k)); height: calc(8px * var(--k)); }
.note { margin-top: .5em; font-size: .7em; line-height: 1.5; color: var(--pagesub); }
.boss h4 { font-weight: 400; font-size: 1.05em; margin: .2em 0 0; }
.boss p { font-size: .86em; }
.boss .btn { margin-top: .4em; flex: none; width: 100%; }
.ck { display: flex; align-items: center; gap: .5em; min-height: 44px; padding: .2em 0; text-align: left; background: none; border: 0; color: inherit; font: inherit; }
.ck i { flex: none; width: calc(9px * var(--k)); height: calc(9px * var(--k)); background: url(../image/check-off.png) center / 178% no-repeat; }
.ck[aria-checked="true"] i { background-image: url(../image/check-on.png); }
dl.keys { display: grid; grid-template-columns: auto 1fr; gap: .1em .8em; margin: 0; font-size: .74em; color: var(--pageink); }
dl.keys dt { color: var(--pagesub); }
dl.keys dd { margin: 0; }
.pg .links { display: flex; flex-direction: column; margin: .3em 0; }
.pg .links a { padding: .35em 0; color: #7a2a1c; }

/* しおり（章の切りかえ） */
#bkTabs { position: absolute; left: calc(30px * var(--k)); top: calc(124px * var(--k)); display: flex; gap: calc(3px * var(--k)); }
#bkTabs button { width: calc(24px * var(--k)); height: calc(32px * var(--k)); padding: 0; border: 0; background: url(../image/tab01.png) center top / calc(32px * var(--k)) calc(32px * var(--k)) no-repeat; color: #fff; font: inherit; font-size: calc(4.4px * var(--k)); }
#bkTabs .t2 { background-image: url(../image/tab05.png); }
#bkTabs .t3 { background-image: url(../image/tab03.png); }
#bkTabs .t1[aria-pressed="true"] { background-image: url(../image/tab01-on.png); }
#bkTabs .t2[aria-pressed="true"] { background-image: url(../image/tab05-on.png); }
#bkTabs .t3[aria-pressed="true"] { background-image: url(../image/tab03-on.png); }
#bkTabs button[aria-pressed="true"] { transform: translateY(calc(2px * var(--k))); }
#bkTabs span { display: block; margin: calc(4px * var(--k)) auto 0; writing-mode: vertical-rl; letter-spacing: .08em; line-height: 1; text-shadow: 0 1px 0 rgba(0, 0, 0, .55); }

/* 語りかけの窓（はじめて入ったとき）。文字送りは紹介と同じ */
#say { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(640px, calc(100% - 24px)); z-index: 5; image-rendering: pixelated; border: 32px solid transparent; border-image: url(../image/box-blue.png) 16 fill / 32px stretch; color: var(--ink); cursor: url(../image/hand.png) 10 2, pointer; }
#sayText { height: calc(1.7em * 3); font-size: 16px; line-height: 1.7; white-space: pre-line; overflow: hidden; }
#sayRest { visibility: hidden; }
#sayMore { position: absolute; right: -6px; bottom: -10px; width: 20px; height: 20px; background: url(../image/tick-down.png) center / 32px 32px no-repeat; visibility: hidden; }
#say.more #sayMore { visibility: visible; animation: cardMore .7s steps(2) infinite; }
body.say #pad { display: none !important; }
@media (max-width: 640px) { #sayText { font-size: 15px; } }

/* せまい画面の本：右ページは縦に送れるようにし、「遊ぶ」を題のすぐ下に置く（説明はその下で読める） */
#book.one #bkR { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#book.one .rows, #book.one #bkL:not([data-tab="games"]) { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#book.one #bkR[data-tab="games"] .cv { order: 1; }
#book.one #bkR[data-tab="games"] .meta { order: 2; }
#book.one #bkR[data-tab="games"] .ti { order: 3; }
#book.one #bkR[data-tab="games"] .acts { order: 4; margin: .5em 0 .2em; }
#book.one #bkR[data-tab="games"] .dv { order: 5; }
#book.one #bkR[data-tab="games"] .ds { order: 6; flex: none; overflow: visible; font-size: 1em; padding-bottom: 1em; }

/* ───────── 音のボタン（入口）・語りかけの演出 ───────── */
#btnSound { position: absolute; right: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); font: 400 9px/1.6 var(--en); letter-spacing: .06em; cursor: pointer; }
#btnSound[aria-pressed="false"] { filter: grayscale(1) brightness(.8); }
/* 上下の帯：語りの間だけ下りてくる（コマ送りで） */
.lb { position: absolute; left: 0; right: 0; height: 0; background: #05060e; z-index: 4; pointer-events: none; transition: height .7s steps(10); }
.lb.t { top: 0; } .lb.b { bottom: 0; }
body.say .lb { height: max(8vh, 40px); }
body.say .lb.b { height: max(13vh, 76px); }
body.say #hud { visibility: hidden; }
#saySkip { position: absolute; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 6; font-size: 13px; }
#say { animation: sayIn .45s steps(6) both; }
@keyframes sayIn { from { transform: translate(-50%, 28px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
#sayWho { position: absolute; left: -14px; top: -52px; padding: 5px 10px 6px; border: solid transparent; border-width: 9px 15px; border-image: url(../image/banner-plain.png) 3 5 fill / 9px 15px stretch; font: 400 13px/1.4 var(--jp, inherit); letter-spacing: .2em; color: var(--ink); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { #say { animation: none; } .lb { transition: none; } }
/* 指のボタン：枠の絵は 32px のまま、文字の入る幅を広げる（「決定」「しゃがむ」が折れないように） */
#btnA, #btnB { border-width: 10px; white-space: nowrap; line-height: 1.2; }
#btnB { border-width: 8px; font-size: 12px; }

/* ───────── 指の操作部：丸いスティックと、読める大きさのボタン（2026-11-17） ───────── */
#stick { border-radius: 50%; border: 3px solid rgba(223, 232, 238, .55); background: radial-gradient(circle, rgba(7, 8, 18, .2) 0 38%, rgba(7, 8, 18, .5) 39% 100%); }
#knob { width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 3px solid #1c2a44; background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--fg) 19% 100%); box-shadow: 0 3px 0 rgba(0, 0, 0, .45); }
#btnA { right: 12px; bottom: 34px; width: 96px; height: 96px; font-size: 16px; }
#btnB { right: 116px; bottom: 0; width: 88px; height: 88px; border: 10px solid transparent; border-image: url(../image/box-blue.png) 16 fill / 32px stretch; font-size: 15px; color: var(--ink); }
#btnB.down, #btnA.down { filter: brightness(.82); transform: translateY(2px); }

/* せまい画面・指の端末：戦いの間は、体力を2段めの左、ボスの名前と体力をその下へ（メニューを押し出さない・ヒントと重ねない） */
@media (pointer: coarse), (max-width: 640px) {
  #hud { flex-wrap: wrap; row-gap: 6px; }
  #hearts { order: 5; flex: 0 0 100%; margin-left: 0; }
  #hearts .hrt { width: 20px; height: 20px; }
  #boss { top: calc(88px + env(safe-area-inset-top, 0px)); width: min(420px, 88vw); }
  #boss p { height: 28px; line-height: 26px; font-size: 13px; }
  #btnDown { top: calc(54px + env(safe-area-inset-top, 0px)); }
  body[data-state="walk"] #hint { top: auto; bottom: calc(190px + env(safe-area-inset-bottom, 0px)); }
  #toast { top: calc(158px + env(safe-area-inset-top, 0px)); }
}
/* 本の設定の右ページ：リンクと権利表記は中央に */
#bkR[data-tab="set"] .links { align-items: center; }
#bkR[data-tab="set"] .links ~ .note { text-align: center; }

/* ───────── ボスの名前の演出：上下に帯が下り、名前が1枚の札で出る ───────── */
body.cine .lb { height: max(8vh, 40px); }
body.cine .lb.b { height: max(10vh, 52px); }
#bossIntro { position: absolute; left: 0; right: 0; top: 60%; z-index: 5; text-align: center; pointer-events: none; image-rendering: pixelated; }
#bossIntro small { display: block; font: 400 10px/1.6 var(--en); letter-spacing: .5em; text-indent: .5em; color: var(--acc); text-shadow: 0 2px 0 #000; animation: biSub .5s steps(5) both; }
#bossIntro b { display: inline-block; margin-top: 4px; padding: 6px 4px 8px; font-weight: 400; font-size: clamp(26px, 6.4vw, 44px); line-height: 1.3; letter-spacing: .14em; text-indent: .14em; color: #fff; text-shadow: 0 4px 0 #1c2a44, 0 0 0 #000, 3px 0 0 #070812, -3px 0 0 #070812, 0 -3px 0 #070812; animation: biName .55s steps(6) both; }
#bossIntro i { display: block; width: min(320px, 70vw); height: 12px; margin: 2px auto 0; background: url(../image/div-flourish.png) center / auto 100% no-repeat; animation: biSub .5s .2s steps(5) both; }
#bossIntro.out { animation: biOut .35s steps(4) both; }
@keyframes biName { from { opacity: 0; transform: scale(1.6); letter-spacing: .6em; } to { opacity: 1; transform: scale(1); letter-spacing: .14em; } }
@keyframes biSub { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes biOut { to { opacity: 0; transform: translateY(-10px); } }
body.cine #hint, body.cine #toast { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { #bossIntro b, #bossIntro small, #bossIntro i { animation: none; } }
/* 討伐の札：金の文字 */
#bossIntro.win small { color: #fff; letter-spacing: .6em; text-indent: .6em; }
#bossIntro.win b { color: var(--acc); text-shadow: 0 4px 0 #7a4a1c, 3px 0 0 #070812, -3px 0 0 #070812, 0 -3px 0 #070812; }
#bossIntro.win b::after { content: '　討伐'; color: #fff; }
#bossIntro.allClear { top: 44%; }
#bossIntro.allClear b { font-size: clamp(20px, 5vw, 36px); line-height: 1.7; white-space: pre-line; animation: biSub .6s steps(6) both; }
#bossIntro.allClear b::after { content: none; }
/* 名前の札のうしろに暗い帯（明るい地面の上でも読める）。名前の間はボスの体力の帯を隠す */
#bossIntro::before { content: ''; position: absolute; left: 0; right: 0; top: -14px; bottom: -14px; z-index: -1; background: linear-gradient(90deg, rgba(5, 6, 14, 0), rgba(5, 6, 14, .78) 22%, rgba(5, 6, 14, .78) 78%, rgba(5, 6, 14, 0)); animation: biSub .4s steps(4) both; }
body.cine #boss, body.cine #hearts { visibility: hidden; }
/* 指のボタン：枠の絵に余白があるぶん大きくし、回避は白い文字に影を付けて読めるようにする */
#btnA { right: 6px; bottom: 40px; width: 104px; height: 104px; font-size: 17px; }
#btnB { right: 112px; bottom: 0; width: 96px; height: 96px; font-size: 15px; color: #fff; text-shadow: 0 2px 0 #1c2a44, 2px 0 0 #1c2a44, -2px 0 0 #1c2a44, 0 -2px 0 #1c2a44; }
@media (max-width: 350px) { #stick { width: 128px; height: 128px; } #btnB { right: 104px; width: 86px; height: 86px; font-size: 14px; } }
/* 前ぶれ：主人公の頭の上の「！？」。前ぶれの間はボスの体力の帯を出さない */
#bang { position: absolute; z-index: 4; transform: translate(-50%, -100%); font-weight: 400; font-size: 26px; line-height: 1; letter-spacing: -.1em; color: #fff; text-shadow: 0 3px 0 #1c2a44, 2px 0 0 #070812, -2px 0 0 #070812, 0 -2px 0 #070812; pointer-events: none; animation: bang .5s steps(4) infinite alternate; }
@keyframes bang { from { margin-top: 0; } to { margin-top: -6px; } }
body.omen #boss { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { #bang { animation: none; } }
/* 文字の出る窓（語り・知らせ・紹介）：地の色を少し明るくして、文字を読みやすくする（枠の絵はそのまま、内側にだけ白を重ねる） */
#say, #toast, #card { isolation: isolate; }
#say::before, #toast::before, #card::before { content: ''; position: absolute; inset: -3px; z-index: -1; background: rgba(255, 255, 255, .34); pointer-events: none; }
