:root {
  --ink: #f6f1e7;
  --ink-dim: #b9b3a6;
  --bg: #14121c;
  --panel: #1e1b28;
  --panel-2: #282436;
  --line: #3a3550;
  --accent: #ffcf4a;
  --danger: #ff4d5e;
  --ok: #4fd18b;
  --cyan: #3fd0c9;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', system-ui, sans-serif;
  --display: 'Dela Gothic One', 'M PLUS Rounded 1c', 'Hiragino Sans', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
#app { height: 100dvh; max-width: 1280px; margin: 0 auto; position: relative; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn { display: block; width: 100%; padding: 14px 18px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel-2); font-weight: 800; font-size: 1.05rem; cursor: pointer; transition: transform .12s, background .2s; }
.btn:hover { background: #34304a; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffdb6e, #ffb800); color: #2a1b00; border-color: #ffe9a8; box-shadow: 0 6px 0 #a06d00, 0 10px 24px rgba(255, 184, 0, .3); }
.btn.primary:active { box-shadow: 0 2px 0 #a06d00; transform: translateY(3px); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8f9a; border-color: #6b2b35; }

/* ---------------- title ---------------- */
.screen { position: absolute; inset: 0; }
.title { display: grid; place-items: end center; overflow: hidden; }
.title-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; animation: kenburns 24s ease-in-out infinite alternate; }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.1) translateY(-1.5%); } }
.title-veil { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(20, 18, 28, .18) 0, rgba(20, 18, 28, 0) 22%); }
.title-logo { position: absolute; top: calc(16px + var(--safe-t)); left: 0; right: 0; text-align: center; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .35)); }
.brand { font-family: var(--display); letter-spacing: .08em; font-size: clamp(.95rem, 3.6vw, 1.3rem); color: #fff; text-shadow: 0 2px 0 #b24a00, 0 0 18px rgba(255, 140, 0, .6); }
.brand b { color: var(--accent); font-weight: 400; }
.title-logo h1 { margin: 4px 0 0; font-family: var(--display); font-weight: 400; line-height: 1; color: #fff; -webkit-text-stroke: 2px #2a1b3a; paint-order: stroke fill; }
.title-logo h1 span { display: block; font-size: clamp(1.6rem, 7.5vw, 2.6rem); }
.title-logo h1 .big { font-size: clamp(3.4rem, 19vw, 6.2rem); color: var(--accent); text-shadow: 0 6px 0 #c4410b, 0 10px 30px rgba(255, 90, 0, .45); transform: rotate(-3deg); animation: wobble 3.2s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(-1deg) scale(1.04); } }
.title-menu { position: relative; width: min(92vw, 420px); display: grid; gap: 8px; padding-bottom: calc(14px + var(--safe-b)); }
/* darken only the strip behind the buttons, so the characters above stay bright */
.title-menu::before { content: ''; position: absolute; z-index: -1; left: calc(50% - 50vw); width: 100vw; top: -34px; bottom: 0; background: linear-gradient(180deg, rgba(20, 18, 28, 0), rgba(20, 18, 28, .82) 34px, rgba(20, 18, 28, .94)); pointer-events: none; }
.title-main { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.title-main .btn.primary { padding-top: 15px; padding-bottom: 15px; }
.btn.icon { width: 60px; padding: 5px 0 4px; display: grid; place-items: center; gap: 1px; font-size: .7rem; line-height: 1.1; background: rgba(20, 18, 28, .72); }
.btn.icon i { font-style: normal; font-size: 1.15rem; line-height: 1.15; }
.title-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
/* case select: sits where the "CASE ・ difficulty" pill was, so the title layout gains no height */
.case-tabs { margin-top: 8px; display: inline-flex; gap: 6px; padding: 3px; border-radius: 999px; background: rgba(20, 18, 28, .7); }
.case-tab { position: relative; display: inline-flex; align-items: baseline; padding: 3px 11px; border-radius: 999px; border: 0; background: transparent; color: #b9b0cc; font: inherit; font-weight: 800; font-size: .86rem; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.case-tab b { font-weight: 800; }
.case-tab span { font-weight: 700; }
.case-tab em { position: absolute; top: -9px; right: -4px; font-style: normal; font-weight: 800; font-size: .58rem; color: #fff; background: #ff4f7b; padding: 0 6px; border-radius: 999px; line-height: 1.5; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.case-tab.on { background: var(--accent); color: #2a1b00; }
@media (max-width: 420px) { .case-tabs { gap: 2px; } .case-tab { padding: 3px 8px; font-size: .8rem; } } /* three cases on one line */
.case-tab b i { font-style: normal; }
@media (max-width: 370px) { .case-tab:not(.on) b i { display: none; } } /* very narrow: the other cases show just their number */
.case-tab:not(.on):hover { color: #fff; }
.title[data-case="case003"] .title-logo h1 .big { color: #ffd1e1; text-shadow: 0 6px 0 #c2366a, 0 10px 30px rgba(255, 79, 123, .45); }
.btn.small { padding: 8px 10px; font-size: .85rem; border-radius: 12px; white-space: nowrap; background: rgba(20, 18, 28, .72); }
.title-note { margin: 6px 0 0; font-size: .72rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }

/* ---------------- game layout ---------------- */
.game { display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); }
.hud { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px 6px; background: linear-gradient(180deg, #0f0d16, #191624); border-bottom: 1px solid var(--line); }
.clock { display: grid; grid-template-columns: auto auto; align-items: end; line-height: 1; }
.clock-label { grid-column: 1 / 3; font-size: .62rem; color: var(--ink-dim); font-weight: 800; letter-spacing: .05em; }
.clock-num { font-family: var(--display); font-size: 2.1rem; color: #fff; min-width: 2.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.clock-unit { font-size: .8rem; margin-left: 2px; color: var(--ink-dim); padding-bottom: 4px; }
.clock.warn .clock-num { color: var(--accent); }
.clock.crit .clock-num { color: var(--danger); animation: pulse .6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); text-shadow: 0 0 12px rgba(255, 77, 94, .8); } }
.hud-mid { display: grid; gap: 6px; min-width: 0; }
.timeline { position: relative; height: 14px; border-radius: 7px; background: #2a2639; overflow: visible; }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 7px; background: linear-gradient(90deg, #6a5cff, #ff6a3d); }
.tl-cursor { position: absolute; top: -4px; width: 4px; height: 22px; margin-left: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 8px #fff; left: 0; }
.tl-mark { position: absolute; top: -7px; transform: translateX(-50%); font-size: .7rem; line-height: 1; display: grid; justify-items: center; }
.tl-mark i { font-style: normal; font-size: .85rem; filter: drop-shadow(0 1px 1px #000); }
.tl-mark b { font-size: .58rem; color: var(--ink-dim); position: absolute; top: 19px; white-space: nowrap; font-family: var(--display); font-weight: 400; }
.tl-mark.done { opacity: .35; }
.tl-mark.hot b { color: var(--danger); }
.boss-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin: 0; padding: 0; list-style: none; }
.boss-track li { font-size: .58rem; text-align: center; padding: 2px 0; border-radius: 6px; background: #221f30; color: #6f6a80; font-weight: 800; position: relative; }
.boss-track li.on { background: linear-gradient(180deg, #ffd55a, #e49b00); color: #2a1b00; }
.boss-track li.on::before { content: '🦁'; position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font-size: .8rem; animation: bob .8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -2px); } }
.boss-track li.past { background: #3a2a10; color: #a37a2a; }
.hud-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 1.1rem; cursor: pointer; }

.stage { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 44dvh; background: #000; overflow: hidden; flex: none; }
.scene { position: absolute; inset: 0; }
.scene.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); } 30%, 50%, 70% { transform: translate(-7px, 3px); } 40%, 60% { transform: translate(7px, -3px); } }
.scene.impact { animation: impact .5s ease-out; }
@keyframes impact { 0% { transform: scale(1.18); filter: brightness(1.8); } 100% { transform: scale(1); filter: none; } }
.scene.glitch { animation: glitch .7s steps(6); }
@keyframes glitch { 0% { filter: hue-rotate(0) saturate(1); transform: translateX(0); } 20% { filter: hue-rotate(90deg) saturate(3); transform: translateX(-6px) skewX(4deg); } 40% { filter: invert(.8); transform: translateX(5px); } 60% { filter: hue-rotate(-60deg) saturate(2); transform: translateX(-3px) skewX(-6deg); } 100% { filter: none; transform: none; } }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s ease; }
.layer.on { opacity: 1; }
.layer.slow { transition-duration: 1.1s; }
.scene.tint-calm .layer { filter: saturate(1.15) brightness(1.05); }
.scene.dim .layer { filter: brightness(.45) saturate(.7); }

.projector { position: absolute; left: 32.67%; top: 9.11%; width: 34.88%; height: 41.08%; overflow: hidden; background: #fff; transition: background .3s; container-type: inline-size; }
.projector .slide { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .25s; }
.slide-title { position: absolute; left: 4%; right: 4%; top: 4%; text-align: center; font-weight: 800; line-height: 1.15; font-size: 6.1cqw; white-space: nowrap; }
.projector.insult .slide-title { color: #e2231a; font-family: var(--display); font-weight: 400; transform: rotate(-2deg); background: rgba(255, 255, 255, .86); border-radius: 4px; padding: 1% 2%; }
.projector.official .slide-title { color: #fff; text-align: left; top: 36%; left: 8%; right: 40%; font-size: 6.4cqw; white-space: normal; text-shadow: 0 1px 2px #000; }
.projector.old .slide-title { color: #6b5e48; font-size: 5.2cqw; background: rgba(240, 230, 210, .9); }
.projector.black { background: #050505; }
.projector.black .slide, .projector.black .slide-title { opacity: 0; }
.projector.revert { animation: revert .6s steps(5); }
@keyframes revert { 0% { filter: invert(1); } 40% { filter: hue-rotate(180deg) saturate(4); } 100% { filter: none; } }

.monitor { position: absolute; left: 18.5%; top: 10.29%; width: 47.57%; height: 52.54%; padding: 3% 4%; color: #cfe7ff; font-size: clamp(.5rem, 2vw, .95rem); font-weight: 700; display: grid; align-content: start; gap: 4%; }
.monitor .win { background: rgba(255, 255, 255, .06); border: 1px solid rgba(160, 200, 255, .25); border-radius: 6px; padding: 3% 4%; }
.monitor .win h4 { margin: 0 0 3%; font-size: .9em; color: #8fc1ff; }
.monitor .row { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px dashed rgba(160, 200, 255, .15); }
.monitor .row.hit { color: #ffe27a; animation: hit 1s ease-in-out 2; }
@keyframes hit { 50% { background: rgba(255, 226, 122, .2); } }
.monitor .sw { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #e2363a; color: #fff; }
.monitor .sw.off { background: #3a4b5c; color: #9fb4c8; }

.holo { position: absolute; z-index: 2; left: 50%; top: 6%; transform: translateX(-50%); width: min(72%, 520px); background: linear-gradient(180deg, rgba(10, 40, 48, .92), rgba(6, 22, 30, .92)); border: 1px solid rgba(63, 208, 201, .6); border-radius: 10px; color: #c8fffb; padding: 10px 12px; font-size: clamp(.62rem, 2.4vw, .95rem); box-shadow: 0 0 22px rgba(63, 208, 201, .35); animation: holoIn .35s ease-out; }
@keyframes holoIn { from { opacity: 0; transform: translate(-50%, -6px) scale(.97); } }
.holo h4 { margin: 0 0 6px; font-size: .8em; letter-spacing: .08em; color: var(--cyan); }
.holo .big { font-family: var(--display); font-size: 1.6em; color: #fff; }
.holo .row { display: flex; gap: 8px; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed rgba(63, 208, 201, .25); }
.holo .row.hit { color: #ffe27a; }
.holo .badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .8em; background: var(--ok); color: #062; font-weight: 800; }
.holo.alert { border-color: rgba(255, 77, 94, .8); box-shadow: 0 0 22px rgba(255, 77, 94, .45); background: linear-gradient(180deg, rgba(60, 10, 18, .92), rgba(30, 6, 12, .92)); color: #ffd8dc; }
.holo.alert h4 { color: #ff8a96; }
.holo.erased .row { text-decoration: line-through; opacity: .45; }

.cast { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sprite { position: absolute; bottom: -6%; height: 88%; max-width: 46%; object-fit: contain; object-position: bottom; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2), filter .25s, opacity .25s; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
.sprite.left { left: 4%; }
.sprite.right { right: 4%; }
.sprite.far { height: 46%; bottom: 14%; right: 40%; }
.sprite.dim { filter: brightness(.55) saturate(.6) drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); transform: scale(.94); }
.sprite.enter { animation: popin .32s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes popin { from { transform: translateY(14%) scale(.92); opacity: 0; } }
.sprite.talk { animation: talk .5s ease-in-out; }
@keyframes talk { 30% { transform: translateY(-3%) scale(1.02); } }

.phone-banner { position: absolute; z-index: 2; left: 50%; top: 6%; transform: translateX(-50%); width: min(80%, 440px); background: rgba(250, 250, 255, .96); color: #1b1b22; border-radius: 16px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: clamp(.7rem, 2.6vw, 1rem); animation: drop .5s cubic-bezier(.2, .9, .3, 1.3); }
.phone-banner small { color: #777; display: block; }
@keyframes drop { from { transform: translate(-50%, -140%); } }

.cutin { position: absolute; inset: 0; z-index: 3; background: #000; animation: cutin .35s ease-out; }
.cutin img, .cutin video { width: 100%; height: 100%; object-fit: cover; display: block; }
.title-video { opacity: 0; transition: opacity .8s; animation: none; }
.title-video.on { opacity: 1; }
.cutin::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 6px #000, inset 0 0 60px rgba(0, 0, 0, .7); }
@keyframes cutin { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }

.pip { position: absolute; right: 8px; top: 8px; z-index: 4; display: flex; gap: 8px; align-items: center; background: rgba(20, 18, 28, .86); border: 1px solid #f08a24; border-radius: 12px; padding: 4px 10px 4px 4px; font-size: .7rem; max-width: 58%; }
.pip img { width: 40px; height: 40px; object-fit: cover; object-position: top; border-radius: 8px; background: #ffe2c2; }
.pip-bar { height: 6px; width: 100px; max-width: 100%; background: #3a2a1a; border-radius: 3px; margin: 3px 0; overflow: hidden; }
.pip-bar i { display: block; height: 100%; width: 0; background: #f08a24; transition: width .6s; }
.pip.done { border-color: var(--ok); animation: hit .8s 2; }

.caption { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; text-align: center; background: radial-gradient(ellipse at center, rgba(0, 0, 0, .55), rgba(0, 0, 0, .85)); animation: fadein .4s; }
.caption h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(1.3rem, 6.5vw, 2.6rem); color: #fff; letter-spacing: .02em; }
.caption p { margin: 6px 0 0; color: var(--accent); font-weight: 800; }
@keyframes fadein { from { opacity: 0; } }
.headline { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 22px 12px 8px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .78)); font-weight: 800; font-size: clamp(.85rem, 3.6vw, 1.15rem); text-shadow: 0 2px 2px #000; animation: slideup .3s ease-out; }
@keyframes slideup { from { transform: translateY(100%); } }
.stamp { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-8deg); font-family: var(--display); font-size: clamp(2.4rem, 13vw, 5rem); padding: 4px 22px; border: 6px solid currentColor; border-radius: 14px; background: rgba(0, 0, 0, .35); white-space: nowrap; animation: stamp .55s cubic-bezier(.2, 1.5, .4, 1); }
.stamp.win { color: var(--accent); text-shadow: 0 0 20px rgba(255, 200, 0, .7); }
.stamp.loss { color: var(--danger); }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-8deg) scale(3); opacity: 0; } }
.flash { position: absolute; inset: 0; z-index: 7; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .5s ease-out; }
.flash.red { background: #ff2a3c; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.timeskip { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(10, 8, 16, .82); border: 2px solid var(--accent); border-radius: 14px; padding: 10px 18px; text-align: center; font-weight: 800; min-width: 60%; }
.timeskip .plus { font-family: var(--display); font-size: 2rem; color: var(--accent); display: block; }
.timeskip.bad { border-color: var(--danger); }
.timeskip.bad .plus { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; margin: 0; list-style: none; overflow-x: auto; scrollbar-width: none; background: #17141f; border-bottom: 1px solid var(--line); flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #262236; font-size: .68rem; font-weight: 800; white-space: nowrap; border: 1px solid transparent; }
.chip.good { background: #12321f; color: #8ff0b6; border-color: #2a6d45; }
.chip.bad { background: #3a141b; color: #ff9aa5; border-color: #7a2633; }
.chip.warn { background: #3a2c10; color: #ffd36e; border-color: #75561a; }
.chip.changed { animation: chipPop .6s ease-out; }
@keyframes chipPop { 30% { transform: scale(1.15); } }

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--panel); padding-bottom: var(--safe-b); }
.dialog { position: relative; display: flex; gap: 10px; padding: 10px 12px 12px; cursor: pointer; min-height: 104px; border-bottom: 1px solid var(--line); user-select: none; -webkit-tap-highlight-color: transparent; }
.face { flex: none; width: 58px; height: 58px; border-radius: 14px; background: #2b2740 center 8% / 230% no-repeat; border: 2px solid var(--speaker, #555); }
.face.narr { background: #2b2740; border-color: transparent; display: none; }
.dialog-body { flex: 1; min-width: 0; padding-right: 22px; padding-bottom: 30px; }
.nameplate { display: inline-block; font-weight: 800; font-size: .82rem; padding: 2px 10px; border-radius: 8px; background: var(--speaker, #444); color: #1a1420; margin-bottom: 4px; }
.nameplate:empty { display: none; }
.nameplate.phone::after { content: ' 📞'; }
.text { margin: 0; font-size: clamp(1.02rem, 4.3vw, 1.2rem); line-height: 1.6; font-weight: 700; white-space: pre-wrap; word-break: break-word; }
.dialog.narration .text { color: #e9dfc8; font-weight: 500; font-style: normal; }
.dialog.prompt { cursor: default; min-height: 0; }
.dialog.prompt .text { font-size: .95rem; color: var(--ink-dim); }
.next { position: absolute; right: 100px; bottom: 9px; color: var(--accent); animation: bob2 .8s ease-in-out infinite; opacity: 0; }
.dialog.ready .next { opacity: 1; }
@keyframes bob2 { 50% { transform: translateY(3px); } }
.auto { position: absolute; right: 8px; bottom: 7px; border: 1px solid var(--line); background: #262236; color: var(--ink-dim); border-radius: 10px; min-width: 50px; height: 28px; padding: 0 8px; font-family: var(--display); font-size: .72rem; letter-spacing: .06em; cursor: pointer; }
.auto.on { background: var(--accent); color: #2a1b00; border-color: #ffe9a8; box-shadow: 0 0 12px rgba(255, 207, 74, .45); }
.auto.on::before { content: '▶ '; }
.dialog.prompt .auto, .dialog.prompt .next { display: none; }
/* skip-all lives at the screen edge, away from the tap-to-advance area, and always asks first */
.skipall { display: none; position: absolute; left: 6px; top: 6px; z-index: 7; border: 1px solid rgba(255, 255, 255, .25); background: rgba(10, 8, 16, .62); color: #e8e3f5; border-radius: 999px; padding: 4px 10px; font-size: .68rem; font-weight: 800; cursor: pointer; backdrop-filter: blur(2px); }
#game.talking .skipall { display: block; }
.skip-card h2 { margin: 0 0 6px; }
.skip-q { margin: 0 0 4px; font-weight: 800; }
.skip-note { margin: 0 0 14px; font-size: .82rem; color: var(--ink-dim); }

.actions { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; align-content: start; -webkit-overflow-scrolling: touch; }
.actions:empty { display: none; }
.act { position: relative; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 9px 10px; border-radius: 14px; border: 2px solid var(--line); background: linear-gradient(180deg, #2c2840, #231f33); cursor: pointer; transition: transform .1s, border-color .2s; animation: cardin .3s ease-out backwards; }
.act:hover { border-color: #6c63a8; }
.act:active { transform: scale(.97); }
.act .ic { grid-row: span 3; font-size: 1.4rem; line-height: 1; padding-top: 2px; }
.act .lb { font-weight: 800; font-size: .88rem; line-height: 1.3; }
.act .cost { font-size: .72rem; color: var(--accent); font-weight: 800; }
.act .cost em { font-style: normal; color: var(--ink-dim); font-weight: 700; margin-left: 4px; }
.act .help { font-size: .68rem; color: var(--ink-dim); line-height: 1.35; }
.act .warn { grid-column: 1 / 3; margin-top: 3px; font-size: .68rem; color: #ff9aa5; font-weight: 800; }
.act .key { position: absolute; right: 8px; top: 6px; font-size: .62rem; color: #6f6a80; }
.act.risky { border-color: #6b2b35; }
@keyframes cardin { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- overlays ---------------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: calc(14px + var(--safe-t)) 12px calc(14px + var(--safe-b)); background: rgba(8, 6, 14, .74); backdrop-filter: blur(4px); animation: fadein .25s; }
.card { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; display: grid; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.35rem; }
.card h3 { margin: 4px 0 0; font-size: .9rem; color: var(--accent); }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rules li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; background: var(--panel-2); border-radius: 12px; padding: 8px 10px; animation: cardin .35s ease-out backwards; }
.rules li i { font-style: normal; font-size: 1.4rem; }
.rules b { display: block; font-size: .92rem; }
.rules span { font-size: .8rem; color: var(--ink-dim); }
.win-cond { margin: 0; font-size: .85rem; background: #2a2412; border: 1px solid #6f5a1d; border-radius: 10px; padding: 8px 10px; }
.result-head { display: flex; gap: 14px; align-items: center; }
.rank { flex: none; width: 74px; height: 74px; border-radius: 18px; display: grid; place-items: center; font-family: var(--display); font-size: 2.6rem; background: #2c2840; border: 3px solid var(--line); }
.rank.S { color: #ffd84a; border-color: #ffd84a; box-shadow: 0 0 24px rgba(255, 216, 74, .5); }
.rank.A { color: #8ff0b6; border-color: #4fd18b; }
.rank.B { color: #9fd0ff; border-color: #5aa8f0; }
.rank.L { color: var(--danger); border-color: #7a2633; font-size: 1.6rem; }
.result-sub { color: var(--ink-dim); font-size: .85rem; margin-top: 4px; }
.unlock { background: linear-gradient(90deg, #3d2d00, #5a4300); border: 1px solid #ffd84a; color: #ffe9a8; border-radius: 10px; padding: 6px 10px; font-weight: 800; text-align: center; animation: chipPop .8s; }
.replay { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .82rem; }
.replay li { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; background: var(--panel-2); border-radius: 8px; padding: 6px 8px; align-items: center; }
.replay li .t { font-family: var(--display); color: var(--accent); font-size: .8rem; }
.replay li .n { font-size: .7rem; color: var(--ink-dim); }
.replay li.bad { border-left: 4px solid var(--danger); }
.replay li.good { border-left: 4px solid var(--ok); }
.tips { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; font-size: .86rem; line-height: 1.5; }
.result-btns { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.result-btns .primary { grid-column: 1 / 3; }
.endings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ending { border-radius: 12px; overflow: hidden; background: var(--panel-2); border: 2px solid var(--line); }
.ending img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.ending .lock { aspect-ratio: 16 / 9; display: grid; place-items: center; font-size: 2rem; color: #5a5470; background: repeating-linear-gradient(45deg, #221f30, #221f30 10px, #262236 10px, #262236 20px); }
.ending .cap { padding: 6px 8px; font-size: .78rem; font-weight: 800; }
.ending .cap small { display: block; color: var(--ink-dim); font-weight: 600; }
.ending.got { border-color: #6f5a1d; }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 700; background: var(--panel-2); padding: 12px; border-radius: 12px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.speed { border: 1px solid var(--line); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 12px 12px; }
.speed legend { font-size: .85rem; color: var(--ink-dim); padding: 0 4px; }
.speed label { display: flex; gap: 6px; align-items: center; font-weight: 700; }
.menu-card { width: min(360px, 100%); }
.log-card { width: min(640px, 100%); }
.log { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: .88rem; }
.log li b { color: var(--accent); margin-right: 6px; }
.log li.n { color: var(--ink-dim); }
.toast { position: absolute; z-index: 30; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: #2c2840; border: 1px solid var(--accent); padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: .85rem; animation: fadein .2s; }

/* ---------------- landscape / desktop ---------------- */
@media (min-width: 920px) and (min-aspect-ratio: 4 / 3) {
  .game { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, 1fr); grid-template-rows: auto auto auto 1fr; }
  .hud { grid-column: 1 / 3; grid-row: 1; }
  .stage { grid-column: 1; grid-row: 2 / 4; max-height: none; aspect-ratio: 16 / 9; }
  .panel { display: contents; }
  .dialog { grid-column: 1; grid-row: 4; background: var(--panel); border-top: 1px solid var(--line); padding: 16px 20px; min-height: 0; }
  .dialog .text { font-size: 1.3rem; }
  .face { width: 84px; height: 84px; }
  .chips { grid-column: 2; grid-row: 2; align-content: start; border-left: 1px solid var(--line); }
  .actions { grid-column: 2; grid-row: 3 / 5; grid-template-columns: 1fr; background: var(--panel); border-left: 1px solid var(--line); }
  .chip { font-size: .78rem; padding: 4px 10px; }
}
@media (max-width: 359px) { .actions { grid-template-columns: 1fr; } }

/* ---------------- reduced motion ---------------- */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; }
.reduce-motion .flash.go { animation: none; }
@media (prefers-reduced-motion: reduce) { .title-art, .title-logo h1 .big { animation: none; } }
