/* ---------- toasts on stage ---------- */
#toastStack { position: absolute; left: 50%; top: 54px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 5; width: min(92%, 640px); }
.tst {
  font-family: var(--pix); font-size: 15px; color: #fff;
  background: rgba(28, 22, 44, .78); border: 1px solid rgba(255, 255, 255, .22);
  padding: 6px 16px; border-radius: 999px; backdrop-filter: blur(4px);
  animation: tstIn .3s ease-out; text-align: center; max-width: 100%;
}
.tst.lv { border-color: #ffd981; }
.tst.floor { border-color: #a9b8ff; color: #e6ebff; }
.tst.bond { border-color: #f6a2b7; color: #ffe6ee; }
.tst.big { font-size: 17px; background: linear-gradient(90deg, rgba(90, 60, 150, .9), rgba(150, 90, 160, .9)); border-color: #fff1c4; }
.tst.diary { font-family: var(--ui); font-size: 14px; background: rgba(251, 243, 228, .94); color: var(--ink); border-color: var(--line); border-radius: 12px; }
.tst.out { opacity: 0; transform: translateY(-6px); transition: .5s; }
@keyframes tstIn { from { opacity: 0; transform: translateY(10px); } }
.toast.float { font-size: 16px; transform: translate(-50%, -50%); }

#stage.calamity #scene { box-shadow: 0 0 0 3px #fff, 0 0 60px 20px rgba(255, 255, 255, .6); transition: box-shadow 3s; }

.place .hb { display: block; font-size: 12px; color: #d9607e; font-family: var(--pix); }
.memoTag { margin-top: 5px; font-size: 11.5px; color: #6a52a8; background: #f2ecff; border-radius: 6px; padding: 2px 7px; display: inline-block; }
.card.memo { font-size: 12.5px; line-height: 1.8; }
.card.memo b { color: #6a52a8; font-weight: 700; margin-right: 4px; }

/* ---------- dialogue ---------- */
#dialogue { display: block; cursor: pointer; }
.dlg-bg { position: absolute; inset: 0; background: #000 center / cover no-repeat; image-rendering: pixelated; filter: brightness(.78) saturate(.95); }
#dialogue.narr .dlg-bg { filter: brightness(.6); }
.dlg-stage { position: absolute; inset: 0 0 0 0; pointer-events: none; }
.dlg-por {
  position: absolute; bottom: 150px; height: min(62vh, 560px); image-rendering: pixelated;
  opacity: 0; transition: opacity .3s, transform .3s, filter .3s; filter: brightness(.55) saturate(.8);
}
.dlg-por.left { left: max(2vw, calc(50% - 560px)); transform: translateX(-30px); }
.dlg-por.right { right: max(2vw, calc(50% - 560px)); transform: translateX(30px); }
.dlg-por.in { opacity: 1; transform: none; }
.dlg-por.talk { filter: none; }
.dlg-por.hop { animation: hop .35s; }
@keyframes hop { 40% { translate: 0 -14px; } }
.dlg-box {
  position: absolute; left: 50%; bottom: max(18px, var(--safe-b)); transform: translateX(-50%);
  width: min(960px, calc(100% - 24px)); min-height: 140px;
  background: rgba(251, 243, 228, .96); color: var(--ink);
  border: 3px solid var(--line-dark); border-radius: 16px;
  box-shadow: 0 0 0 3px #3a2c28, 0 14px 30px rgba(0, 0, 0, .5);
  padding: 22px 28px 20px;
}
.dlg-name {
  position: absolute; top: -18px; left: 22px;
  font-family: var(--pix); font-size: 18px; color: #fff;
  background: var(--c, #b79a73); border: 2px solid #fff; border-radius: 999px; padding: 2px 18px 3px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.dlg-text { font-size: 19px; line-height: 1.75; min-height: 3.5em; white-space: pre-wrap; }
#dialogue.narr .dlg-text { font-style: normal; color: #5a4a5e; }
.dlg-next { position: absolute; right: 18px; bottom: 10px; color: var(--gold-deep); animation: bob 1s infinite; font-size: 14px; }
.dlg-ctrl { position: absolute; right: 14px; top: 12px; display: flex; gap: 6px; }
.dlg-ctrl button { background: rgba(30, 24, 48, .6); color: #fff; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.dlg-ctrl button.on { background: #ffd981; color: #4a3520; }
.dlg-title {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; color: #fff;
  font-family: var(--pix); font-size: 34px; letter-spacing: .12em; opacity: 0; pointer-events: none;
  text-shadow: 0 3px 0 #3a2c50, 0 0 20px rgba(0, 0, 0, .6); transition: opacity .8s;
}
.dlg-title small { display: block; font-size: 16px; letter-spacing: .3em; opacity: .85; margin-bottom: 8px; }
.dlg-title.show { opacity: 1; }
.dlg-log { position: absolute; inset: 0; background: rgba(20, 16, 32, .9); z-index: 3; display: flex; justify-content: center; }
.dlg-log-in { width: min(800px, 94%); overflow: auto; padding: 40px 10px; color: #efe8ff; font-size: 16px; line-height: 1.7; }
.dlg-log-in b { display: block; font-size: 13px; color: #ffd981; }
.dlg-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.dlg-flash.flash.go { background: #fff; animation: flash .7s; }
.dlg-flash.white.go { background: #fff; animation: white 2.4s forwards; }
.dlg-flash.rewind.go { background: radial-gradient(circle, rgba(200, 180, 255, .0) 0%, rgba(200, 180, 255, .8) 100%); animation: flash 1.4s; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes white { 0% { opacity: 0; } 60% { opacity: 1; } 100% { opacity: 0; } }
#dialogue.shake { animation: shake .5s; }
@keyframes shake { 20% { translate: -6px 2px; } 40% { translate: 5px -3px; } 60% { translate: -4px 1px; } 80% { translate: 3px 2px; } }

/* ---------- overlay ---------- */
#overlay { display: flex; align-items: center; justify-content: center; background: rgba(20, 16, 32, .6); backdrop-filter: blur(2px); animation: screenIn .2s; }
#overlay.dark { background: rgba(250, 250, 255, .25); }
.ov-in { max-width: min(560px, 92vw); max-height: 92vh; overflow: auto; }
.ov-box {
  background: var(--paper); border: 3px solid var(--line-dark); border-radius: 16px;
  box-shadow: 0 0 0 3px #3a2c28, 0 20px 40px rgba(0, 0, 0, .5); padding: 24px 26px; text-align: center;
}
.ov-box h3 { margin: 0 0 8px; font-family: var(--pix); font-weight: 400; font-size: 22px; }
.ov-box p { margin: 6px 0; line-height: 1.7; }
.ov-box .small { font-size: 12px; color: var(--ink-soft); }
.ov-list { list-style: none; padding: 0; margin: 14px 0 18px; text-align: left; display: grid; gap: 8px; }
.ov-list li { display: flex; align-items: center; gap: 8px; background: #fffaf1; border: 2px solid var(--paper-3); border-radius: 10px; padding: 8px 12px; flex-wrap: wrap; }
.ov-list img { width: 26px; height: 26px; }
.ov-list b { font-family: var(--pix); font-size: 20px; font-weight: 400; }
.ov-list small { color: var(--ink-soft); font-size: 11px; width: 100%; padding-left: 34px; }
.ov-box.rewind { background: linear-gradient(#f7f3ff, #ece4ff); border-color: #6a52a8; }
.rw-clock { width: 90px; height: 90px; margin: 0 auto 10px; border-radius: 50%; border: 4px solid #6a52a8; position: relative; background: #fff; box-shadow: 0 0 20px rgba(140, 110, 230, .6); }
.rw-clock i { position: absolute; left: 50%; top: 50%; width: 4px; height: 34px; margin-left: -2px; background: #6a52a8; transform-origin: 50% 0; rotate: 180deg; animation: back 1.2s linear infinite; border-radius: 2px; }
.rw-clock i.m { height: 24px; width: 5px; animation-duration: 6s; }
@keyframes back { to { rotate: -180deg; } }

/* ---------- title ---------- */
#title { display: flex; align-items: center; justify-content: center; background: #1d1a2e; transition: opacity .7s; }
#title.out { opacity: 0; pointer-events: none; }
.ti-bg { position: absolute; inset: 0; background: url(../assets/bg/title_hd.webp) center / cover no-repeat; image-rendering: pixelated; animation: tiZoom 30s ease-in-out infinite alternate; }
@keyframes tiZoom { to { transform: scale(1.06); } }
.ti-in { position: relative; text-align: center; margin-top: 18vh; padding: 0 16px; }
.ti-logo { color: #fff; text-shadow: 0 3px 0 #2c2147, 0 0 24px rgba(30, 20, 60, .9); }
.ti-logo small { display: block; font-family: var(--pix); font-size: clamp(13px, 2vw, 18px); letter-spacing: .25em; color: #ffe3a3; }
.ti-logo { position: relative; padding: 18px 24px; }
.ti-logo::before { content: ""; position: absolute; inset: -10% -6%; background: radial-gradient(ellipse at center, rgba(28, 18, 56, .62), rgba(28, 18, 56, 0) 70%); z-index: -1; }
.ti-logo h1 { font-family: var(--pix); font-weight: 400; font-size: clamp(22px, 4.2vw, 50px); margin: 8px 0; letter-spacing: .06em; line-height: 1.3; }
.ti-logo .tl { display: block; }
.ti-logo .tw { display: inline-block; }
.ti-logo p { font-family: var(--pix); font-size: clamp(12px, 1.8vw, 17px); margin: 0; opacity: .92; }
.ti-btns { display: flex; gap: 14px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.ti-btns .btn { min-width: 180px; }
.ti-foot { margin-top: 18px; color: #fff; opacity: .7; font-size: 12px; text-shadow: 0 1px 2px #000; }

/* ---------- screens common ---------- */
.memChip { display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 3px 14px 3px 5px; font-size: 18px; margin-left: auto; }
.memChip img { width: 26px; height: 26px; }
.memChip + .close { margin-left: 10px; }

/* ---------- skill tree ---------- */
.st-body { overflow: hidden; touch-action: none; cursor: grab; }
.st-sky {
  position: absolute; inset: 0;
  background-image: url(../assets/ui/stars_far.webp), url(../assets/ui/stars_near.webp);
  background-size: cover, cover;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #141026;
  background-blend-mode: screen;
  image-rendering: pixelated;
  opacity: .38;
}
.st-body::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(40, 30, 80, .0) 0%, rgba(12, 9, 24, .75) 80%); pointer-events: none; z-index: 0; }
.st-world { z-index: 1; }
.st-detail, .st-center, .st-help { z-index: 2; }
.st-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.st-lines { position: absolute; overflow: visible; left: 0; top: 0; width: 1px; height: 1px; }
.st-lines line { stroke: rgba(255, 255, 255, .18); stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; }
.st-lines line.on { stroke: var(--c); stroke-width: 4; stroke-dasharray: none; filter: drop-shadow(0 0 4px var(--c)); }
.st-lines line.fog { stroke: rgba(255, 255, 255, .08); }
.st-node {
  position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: #241d3f; border: 3px solid rgba(255, 255, 255, .25);
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, box-shadow .2s;
}
.st-node i { width: 40px; height: 40px; background: url(../assets/icons/skills.webp) 0 0 / 800% 900% no-repeat; image-rendering: pixelated; opacity: .55; filter: grayscale(.6); }
.st-node:hover { transform: scale(1.1); }
.st-node.mid { width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 18px; rotate: 45deg; }
.st-node.mid i, .st-node.mid b, .st-node.mid em { rotate: -45deg; }
.st-node.mid i { width: 46px; height: 46px; }
.st-node.key { width: 84px; height: 84px; margin: -42px 0 0 -42px; border-width: 4px; }
.st-node.key i { width: 58px; height: 58px; }
.st-node.open { border-color: var(--c); }
.st-node.can { box-shadow: 0 0 0 4px rgba(255, 255, 255, .08), 0 0 18px var(--c); animation: canGlow 1.6s ease-in-out infinite; }
.st-node.can i { opacity: .9; filter: none; }
@keyframes canGlow { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .12), 0 0 28px var(--c); } }
.st-node.owned { background: radial-gradient(circle, #fffbe9 0%, var(--c) 120%); border-color: #fff; box-shadow: 0 0 16px var(--c); }
.st-node.owned i { opacity: 1; filter: none; }
.st-node.fog { background: rgba(255, 255, 255, .04); border-style: dashed; border-color: rgba(255, 255, 255, .2); }
.st-node.fog::after { content: "？"; color: rgba(255, 255, 255, .35); font-family: var(--pix); font-size: 20px; }
.st-node.sealed:not(.owned) { filter: saturate(.3) brightness(.8); }
.st-node.sel { outline: 3px solid #fff; outline-offset: 4px; }
.st-node b { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); font-size: 11px; background: #1d1830; color: #fff; padding: 0 6px; border-radius: 999px; border: 1px solid var(--c); font-weight: 700; white-space: nowrap; }
.st-node em { position: absolute; top: -8px; right: -8px; font-style: normal; font-size: 16px; }
.st-branch { position: absolute; transform: translate(-50%, -50%); font-family: var(--pix); font-size: 17px; letter-spacing: .15em; text-shadow: 0 0 8px currentColor; pointer-events: none; white-space: nowrap; opacity: .9; }
.st-detail {
  position: absolute; right: 16px; bottom: 16px; width: min(380px, calc(100% - 32px));
  background: rgba(32, 26, 56, .96); border: 2px solid #6c5fa8; border-radius: 14px; padding: 14px 16px; cursor: default;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.st-detail h3 { margin: 0; font-family: var(--pix); font-weight: 400; font-size: 20px; }
.st-dh { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.st-dh .rank { margin-left: auto; font-family: var(--pix); color: #ffd981; }
.st-dh .kind { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #3b355c; }
.st-dh .kind.key { background: #8a6a20; }
.st-dh .kind.mid { background: #4a3a8a; }
.st-detail .effs { margin: 8px 0; padding-left: 18px; line-height: 1.7; color: #fff3c4; }
.st-detail .effs small { color: #b9acd8; margin-left: 4px; }
.st-detail .flav { font-size: 13px; color: #c9bde6; line-height: 1.6; margin: 6px 0 10px; }
.st-detail .btn { width: 100%; }
.st-help { position: absolute; left: 16px; bottom: 14px; font-size: 12px; opacity: .55; pointer-events: none; }
.st-center { position: absolute; left: 16px; top: 14px; background: #3b355c; border: 2px solid #5a5288; color: #fff; border-radius: 10px; padding: 4px 12px; font-family: var(--pix); }
.st-burst { position: absolute; width: 10px; height: 10px; margin: -5px; border-radius: 50%; box-shadow: 0 0 0 0 #fff8d0; animation: burst .9s ease-out forwards; pointer-events: none; }
@keyframes burst { to { box-shadow: 0 0 0 90px rgba(255, 248, 208, 0); } }

/* ---------- gacha ---------- */
.ga-body { background: #1a1530 center / cover no-repeat; image-rendering: pixelated; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.ga-shade { position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(16, 12, 30, .85)); pointer-events: none; }
.ga-stage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 10px; }
.ga-panel { position: relative; text-align: center; padding: 20px 16px calc(28px + var(--safe-b)); max-width: 720px; }
.ga-lead { font-size: 15px; line-height: 1.7; color: #f1e9ff; text-shadow: 0 2px 4px #000; }
.ga-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.ga-info { font-size: 13px; color: #d9cff5; text-shadow: 0 1px 3px #000; }
.ga-info b { color: #ffd981; font-size: 16px; }
.ga-fall { position: absolute; inset: 0; overflow: hidden; }
.ga-fall i { position: absolute; top: -20%; width: 3px; height: 120px; background: linear-gradient(transparent, #fff); border-radius: 3px; animation: fall 1.2s ease-in forwards; }
.ga-fall i:nth-child(n) { left: calc(var(--x, 50) * 1%); }
.ga-fall.r4 i { background: linear-gradient(transparent, var(--r4)); box-shadow: 0 0 10px var(--r4); }
.ga-fall.r5 i { background: linear-gradient(transparent, var(--r5)); box-shadow: 0 0 14px var(--r5); }
.ga-fall i:nth-child(1) { left: 8%; animation-delay: .0s; } .ga-fall i:nth-child(2) { left: 18%; animation-delay: .2s; }
.ga-fall i:nth-child(3) { left: 27%; animation-delay: .1s; } .ga-fall i:nth-child(4) { left: 36%; animation-delay: .35s; }
.ga-fall i:nth-child(5) { left: 45%; animation-delay: .05s; } .ga-fall i:nth-child(6) { left: 52%; animation-delay: .25s; }
.ga-fall i:nth-child(7) { left: 60%; animation-delay: .15s; } .ga-fall i:nth-child(8) { left: 68%; animation-delay: .4s; }
.ga-fall i:nth-child(9) { left: 75%; animation-delay: .08s; } .ga-fall i:nth-child(10) { left: 83%; animation-delay: .3s; }
.ga-fall i:nth-child(11) { left: 90%; animation-delay: .18s; } .ga-fall i:nth-child(12) { left: 13%; animation-delay: .45s; }
.ga-fall i:nth-child(13) { left: 58%; animation-delay: .5s; } .ga-fall i:nth-child(14) { left: 40%; animation-delay: .55s; }
@keyframes fall { to { transform: translate(-80px, 130vh) rotate(18deg); } }
.ga-cards { display: grid; gap: 12px; justify-content: center; }
.ga-cards.n1 { grid-template-columns: 220px; }
.ga-cards.n10 { grid-template-columns: repeat(5, minmax(0, 132px)); }
.ga-card { aspect-ratio: 3 / 4; position: relative; perspective: 800px; cursor: pointer; animation: dealIn .4s backwards; animation-delay: var(--d); }
@keyframes dealIn { from { opacity: 0; transform: translateY(40px) scale(.8); } }
.ga-card .face { position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; transition: transform .5s; overflow: hidden; }
.ga-card .back { background: url(../assets/ui/card_back.webp) center / cover; border: 3px solid #d9cff5; image-rendering: pixelated; }
.ga-card.r4 .back { border-color: var(--r4); box-shadow: 0 0 16px var(--r4); }
.ga-card.r5 .back { border-color: var(--r5); box-shadow: 0 0 22px var(--r5); animation: r5glow 1s ease-in-out infinite; }
@keyframes r5glow { 50% { box-shadow: 0 0 36px var(--r5); } }
.ga-card .front { transform: rotateY(180deg); background: #1d1830; border: 3px solid var(--r3); }
.ga-card.r4 .front { border-color: var(--r4); }
.ga-card.r5 .front { border-color: var(--r5); }
.ga-card.open .back { transform: rotateY(180deg); }
.ga-card.open .front { transform: rotateY(360deg); }
.ga-card img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.ga-card .cn { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 6px 18px; background: linear-gradient(transparent, rgba(10, 8, 20, .9)); color: #fff; font-size: 12px; line-height: 1.3; text-align: center; }
.ga-card .cs { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--r5); letter-spacing: .1em; }
.ga-card em { position: absolute; top: 5px; left: 5px; font-style: normal; font-size: 11px; font-weight: 700; background: var(--rose); color: #fff; padding: 1px 7px; border-radius: 999px; }
.ga-card em.up { background: #6a52a8; }
.ga-after { display: flex; gap: 12px; }

/* ---------- album ---------- */
.al-body { padding: 16px; }
.al-slots { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-bottom: 18px; padding: 14px; background: rgba(255, 255, 255, .05); border-radius: 14px; border: 1px dashed rgba(255, 255, 255, .2); }
.al-slot { width: 96px; aspect-ratio: 3 / 4; border-radius: 10px; border: 2px dashed rgba(255, 255, 255, .25); display: grid; place-items: center; font-size: 12px; color: rgba(255, 255, 255, .4); position: relative; overflow: hidden; cursor: pointer; }
.al-slot.full { border-style: solid; border-color: var(--r3); }
.al-slot.r4 { border-color: var(--r4); } .al-slot.r5 { border-color: var(--r5); }
.al-slot img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.al-slot span { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(10, 8, 20, .8); color: #fff; font-size: 10px; padding: 2px 4px; text-align: center; }
.al-bonus { align-self: center; margin-left: auto; font-size: 13px; color: #ffd981; }
.al-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.al-card { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; border: 3px solid var(--r3); cursor: pointer; background: #241d3f; transition: transform .12s; }
.al-card:hover { transform: translateY(-3px); }
.al-card.r4 { border-color: var(--r4); } .al-card.r5 { border-color: var(--r5); }
.al-card.eq { box-shadow: 0 0 0 3px #fff, 0 0 16px #fff8d0; }
.al-card img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.al-card .cn { position: absolute; left: 0; right: 0; bottom: 14px; padding: 14px 6px 2px; background: linear-gradient(transparent, rgba(10, 8, 20, .9)); font-size: 11.5px; text-align: center; color: #fff; }
.al-card .cs { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; background: rgba(10, 8, 20, .9); text-align: center; font-size: 10px; color: var(--r5); }
.al-card .cs small { color: #fff; }
.al-card.none { cursor: default; background: repeating-linear-gradient(45deg, #221b3a, #221b3a 8px, #261f42 8px, #261f42 16px); opacity: .7; }
.al-card .q { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--pix); font-size: 40px; color: rgba(255, 255, 255, .2); }
.cd-wrap { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); background: var(--paper); border-radius: 16px; overflow: hidden; border: 4px solid var(--r3); max-width: 820px; box-shadow: 0 20px 40px rgba(0, 0, 0, .5); }
#overlay .ov-in:has(.cd-wrap) { max-width: min(860px, 94vw); }
.cd-wrap.r4 { border-color: var(--r4); } .cd-wrap.r5 { border-color: var(--r5); }
.cd-art img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.cd-text { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.cd-text h3 { margin: 0; font-family: var(--pix); font-weight: 400; font-size: 21px; }
.cd-text .cs { color: var(--gold-deep); letter-spacing: .1em; }
.cd-eff { font-size: 13px; background: #f2ecff; color: #4a3a8a; border-radius: 8px; padding: 6px 10px; }
.cd-story { font-size: 14.5px; line-height: 1.85; color: var(--ink); max-height: 40vh; overflow: auto; }
.cd-btns { display: flex; gap: 10px; margin-top: auto; }

/* ---------- bonds ---------- */
.bd-body { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; align-content: start; }
.bd-card { display: grid; grid-template-columns: 120px 1fr; gap: 12px; background: var(--paper); color: var(--ink); border-radius: 14px; padding: 12px; border: 3px solid var(--c); }
.bd-card.unmet { filter: grayscale(.7); opacity: .8; }
.bd-por { width: 120px; height: 140px; object-fit: cover; object-position: top; border-radius: 10px; background: var(--paper-2); image-rendering: pixelated; }
.bd-main h3 { margin: 0; font-family: var(--pix); font-weight: 400; font-size: 19px; }
.bd-main h3 small { font-family: var(--ui); font-size: 12px; color: var(--ink-soft); margin-left: 8px; }
.bd-lv { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.bd-lv b { font-size: 20px; font-weight: 800; color: #d9607e; min-width: 1.2em; }
.bd-lv .bar { flex: 1; margin: 0; }
.bd-lv .max { color: #d9607e; font-weight: 700; }
.bd-main p { font-size: 12.5px; line-height: 1.6; margin: 4px 0 8px; color: var(--ink-soft); }
.bd-eps { display: flex; flex-wrap: wrap; gap: 5px; }
.bd-ep { font-size: 11.5px; border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); background: #fff; }
.bd-ep.seen { background: #fff1d6; border-color: var(--gold-deep); }
.bd-ep.new { background: var(--rose); color: #fff; border-color: #b9566d; }
.bd-ep.lock { opacity: .55; }

/* ---------- journal ---------- */
.jn-body { padding: 0 16px 16px; max-width: 900px; margin: 0 auto; width: 100%; }
.jn-tabs { display: flex; gap: 6px; position: sticky; top: 0; padding: 12px 0; background: rgba(20, 16, 32, .96); z-index: 1; }
.jn-tabs button { background: #2f2a4c; border: 2px solid #4f477c; color: #fff; border-radius: 10px; padding: 5px 16px; font-family: var(--pix); }
.jn-tabs button.on { background: #ffd981; color: #4a3520; border-color: #fff1c4; }
.jn-ch { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; border: 1px solid rgba(255, 255, 255, .08); }
.jn-ch.seen { background: rgba(255, 233, 180, .08); border-color: rgba(255, 217, 129, .3); }
.jn-no { font-family: var(--pix); color: #ffd981; font-size: 13px; }
.jn-t { font-family: var(--pix); font-size: 17px; }
.jn-c { grid-column: 2; font-size: 12.5px; color: #c9bde6; line-height: 1.6; }
.jn-ch .btn { grid-row: 1 / span 2; grid-column: 3; }
.jn-d { background: var(--paper); color: var(--ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.jn-d b { font-size: 12px; color: var(--ink-soft); }
.jn-d p { margin: 4px 0 0; line-height: 1.7; }
.jn-empty { opacity: .6; }
.jn-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.jn-stats div { display: flex; justify-content: space-between; background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 10px 14px; }
.jn-stats b { font-family: var(--pix); font-weight: 400; color: #ffd981; }

/* ---------- settings ---------- */
.se-body { padding: 24px; max-width: 560px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.se-body label { display: flex; align-items: center; gap: 14px; font-family: var(--pix); }
.se-body input[type=range] { flex: 1; accent-color: #ffd981; }
.se-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.se-note { font-size: 12px; opacity: .6; }
.se-credit { font-size: 12px; line-height: 1.7; opacity: .75; border-top: 1px solid rgba(255, 255, 255, .15); padding-top: 12px; }

/* ---------- scratch ---------- */
.tk-lead { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; margin: 0 2px 10px; }
.tk-tiers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.tk-tier { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fffaf1; border: 2px solid var(--paper-3); border-radius: 10px; padding: 5px 2px; font-size: 11px; }
.tk-tier img { width: 40px; height: 30px; object-fit: contain; }
.tk-tier.on { border-color: var(--gold-deep); background: #fff1cf; }
.tk-tier.locked { opacity: .45; }
.tk-wrap { display: flex; justify-content: center; }
.tk-ticket {
  position: relative; width: min(300px, 100%); aspect-ratio: 1; border-radius: 14px; padding: 15px;
  background: var(--face) center / cover, #e9d9b4; image-rendering: pixelated;
  border: 3px solid var(--line-dark); box-shadow: 0 4px 0 var(--line-dark);
}
.tk-ticket.empty { display: grid; place-items: center; }
.tk-empty { background: rgba(255, 250, 241, .9); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.6; text-align: center; }
.tk-grid, .tk-foil, .tk-win { position: absolute; inset: 15px; width: calc(100% - 30px); height: calc(100% - 30px); }
.tk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tk-cell { background: rgba(255, 250, 238, .92); border-radius: 8px; display: grid; place-items: center; }
.tk-cell i { width: 74%; aspect-ratio: 1; background: url(../assets/ui/symbols.webp) 0 0 / 400% 200% no-repeat; image-rendering: pixelated; }
.tk-foil { border-radius: 8px; touch-action: none; cursor: crosshair; }
.tk-win { pointer-events: none; }
.tk-win line { stroke: #ff6f91; stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 3px #fff); }
.tk-result { position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); background: var(--paper); border: 2px solid var(--line-dark); border-radius: 999px; padding: 4px 16px; white-space: nowrap; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); animation: pop .3s; }
.tk-result b { font-family: var(--pix); font-weight: 400; font-size: 16px; }
.tk-result.win { background: linear-gradient(#fff3c4, #ffd981); }
.tk-actions { display: flex; gap: 8px; justify-content: center; margin: 28px 0 10px; flex-wrap: wrap; }
.tk-rules { font-size: 11.5px; color: var(--ink-soft); line-height: 1.7; background: #fffaf1; border-radius: 10px; padding: 8px 10px; }
.tk-rules .auto { color: #6a52a8; font-weight: 700; }

@media (max-width: 640px) {
  #toastStack { top: 8px; gap: 3px; width: 96%; }
  .tst { font-size: 11px; padding: 3px 10px; }
  .tst.big { font-size: 12px; }
  .tst.diary { font-size: 11px; }
  #toastStack .tst:nth-last-child(n+3) { display: none; }
  .dlg-por { height: 46vh; bottom: 170px; }
  .dlg-por.left { left: -6vw; } .dlg-por.right { right: -6vw; }
  .dlg-box { min-height: 150px; padding: 18px 16px 16px; }
  .dlg-text { font-size: 15.5px; }
  .dlg-name { font-size: 15px; }
  .screen header { flex-wrap: wrap; padding: 8px 10px; gap: 6px 10px; }
  .screen header .sub { display: none; }
  .screen header h2 { font-size: 18px; }
  .ga-cards.n10 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; width: 100%; }
  .ga-card .cn { font-size: 9px; padding: 10px 2px 14px; }
  .bd-body { grid-template-columns: 1fr; padding: 10px; }
  .bd-card { grid-template-columns: 84px 1fr; }
  .bd-por { width: 84px; height: 100px; }
  .cd-wrap { grid-template-columns: 1fr; }
  .cd-art { max-height: 40vh; overflow: hidden; }
  .al-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .al-slot { width: 72px; }
  .jn-ch { grid-template-columns: 1fr auto; }
  .jn-no { grid-column: 1 / -1; }
  .jn-c { grid-column: 1; }
  .jn-ch .btn { grid-row: 2 / span 2; grid-column: 2; }
}

/* 結末 */
#overlay.ending { background: radial-gradient(circle at 50% 30%, rgba(255, 236, 200, .85), rgba(255, 196, 150, .6) 45%, rgba(60, 40, 90, .75)); animation: endIn 2.4s ease; }
@keyframes endIn { from { opacity: 0; } to { opacity: 1; } }
.ov-box.ending { background: linear-gradient(#fffaf0, #fff0dc); border-color: #d99a5b; text-align: center; }
.end-kicker { font-family: var(--pix); letter-spacing: .3em; font-size: 12px; color: #c07a3a; }
.end-text { text-align: left; margin: 10px 0; font-size: 14px; }
.end-card { display: flex; gap: 12px; align-items: center; text-align: left; background: #fff; border: 2px solid #f0c27a; border-radius: 12px; padding: 10px; margin: 12px 0; box-shadow: 0 0 24px rgba(255, 200, 120, .6); }
.end-card img { width: 72px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; image-rendering: pixelated; }
.end-card small { display: block; color: #c07a3a; font-size: 11px; }
.end-card b { display: block; font-family: var(--pix); font-weight: 400; font-size: 18px; }
.end-card span { font-size: 12px; color: var(--ink-soft); }
.end-credit { font-size: 11px; color: var(--ink-soft); margin: 8px 0 14px; line-height: 1.7; }
