:root {
  --bg: #2b2233;
  --paper: #fff6e3;
  --paper-2: #f6e6c6;
  --ink: #3a2a24;
  --ink-soft: #7a6152;
  --line: #d9bb8c;
  --accent: #d85a30;
  --accent-ink: #fff;
  --good: #3b6d11;
  --bad: #a32d2d;
  --word: #185fa5;
  --locked: #9a8f86;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  position: relative;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--ink); color: var(--paper);
}
.room-title { font-family: 'Press Start 2P', monospace; font-size: 11px; line-height: 1.4; flex: 1; min-width: 0; margin-right: 8px; }
.icon-btn {
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 8px; padding: 6px 10px;
  font-weight: 800; font-size: 14px; white-space: nowrap;
}
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; font-size: 12px; text-align: center;
}

.scene { position: relative; width: 100%; aspect-ratio: 160 / 120; overflow: hidden; background: #000; }
.scene-bg, .sprite { image-rendering: pixelated; image-rendering: crisp-edges; }
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-layer { position: absolute; inset: 0; }

.hotspot {
  position: absolute; background: transparent;
  border: 2px dashed transparent; border-radius: 4px; padding: 0;
}
.hotspot:hover, .hotspot:focus-visible { border-color: rgba(255,255,255,.85); outline: none; }
.hotspot.new::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: #fff7c2; border: 2px solid var(--accent); border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(.8); opacity: .65; } 50% { transform: scale(1.25); opacity: 1; } }
.show-all .hotspot { border-color: rgba(255,255,255,.7); }

.sprite { position: absolute; width: 20%; aspect-ratio: 1; background: transparent; border: 0; padding: 0; }
.sprite img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.sprite.talk::before {
  content: '!'; position: absolute; left: 50%; top: -14px; transform: translateX(-50%);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 6px;
  font-family: 'Press Start 2P', monospace; font-size: 10px; padding: 3px 5px;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, -3px); } }

.toast {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px;
  font-weight: 800; font-size: 16px; white-space: nowrap;
  animation: toastIn .25s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

.panel { flex: 1; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.dialog {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 12px;
  min-height: 120px;
}
.portrait { width: 56px; height: 56px; flex: none; border-radius: 8px; background: var(--paper-2); overflow: hidden; }
.portrait img { width: 100%; height: 100%; image-rendering: pixelated; }
.portrait.empty { display: none; }
.dialog-body { flex: 1; min-width: 0; }
.speaker { font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--accent); margin-bottom: 8px; }
.line { margin: 0; font-size: 19px; line-height: 1.55; font-weight: 700; color: #2a1c16; white-space: pre-line; }

.word {
  background: none; border: 0; padding: 0; font-weight: 800;
  color: var(--word); text-decoration: underline dotted 2px; text-underline-offset: 3px;
}
.word-pop {
  position: absolute; z-index: 20; max-width: 260px;
  background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px;
  font-size: 17px; font-weight: 700;
}
.word-pop b { color: #fac775; }

.next-btn, .primary {
  align-self: flex-end;
  background: var(--accent); color: var(--accent-ink);
  border: 3px solid var(--ink); border-radius: 10px;
  padding: 10px 20px; font-weight: 800; font-size: 17px;
}
.secondary {
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  padding: 12px 14px; font-weight: 800; font-size: 17px; line-height: 1.35; text-align: left;
}

.mission { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.mission .options { display: flex; flex-direction: column; gap: 8px; }
.mission .feedback { font-weight: 800; font-size: 17px; }
.mission .feedback.bad { color: var(--bad); }
.mission .feedback.good { color: var(--good); }
.mission input {
  font: inherit; font-size: 20px; font-weight: 800; padding: 8px 12px;
  border: 2px solid var(--ink); border-radius: 8px; background: #fff; width: 100%;
}
.code-row { display: flex; gap: 8px; }
.order-line {
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 48px; padding: 6px;
  border: 2px dashed var(--line); border-radius: 8px; background: #fff;
}
.spot-pic { position: relative; width: 100%; border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; background: #fff; }
.mission-pic { border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; background: #f8e8c4; margin-bottom: 8px; }
.mission-pic img { display: block; width: 100%; max-height: 44vh; object-fit: contain; image-rendering: pixelated; }
.spot-pic img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.spot { position: absolute; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.spot.found { border: 3px solid #e8403a; box-shadow: 0 0 0 2px #fff; animation: spot-pop .3s ease-out; }
.spot-count { font-weight: 800; font-size: 15px; color: var(--ink-soft); text-align: right; }
@keyframes spot-pop { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.err-letter { background: #fffdf5; border: 2px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: 'Comic Sans MS', 'Chalkboard SE', cursive; font-size: 17px; line-height: 1.7; }
.err-line { min-height: 1.2em; }
.err-word { font: inherit; padding: 0 2px; margin: 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink); cursor: pointer; }
.err-word:hover, .err-word:focus-visible { background: #ffeaa7; outline: none; }
.err-word.found { color: #e8403a; text-decoration: line-through 2px; background: transparent; cursor: default; }
.err-fix { margin-left: 2px; color: var(--good); font-weight: 800; }
.order-empty { color: var(--ink-soft); align-self: center; padding: 0 4px; }
.order-bank { display: flex; flex-wrap: wrap; gap: 6px; }
.order-card {
  font: inherit; font-size: 16px; font-weight: 700; padding: 6px 10px;
  border: 2px solid var(--ink); border-radius: 8px; background: var(--paper-2); color: var(--ink); cursor: pointer;
}
.order-card.placed { background: #fff7c2; }
.order-card:disabled { opacity: 0.25; cursor: default; }
.listen-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.listen-btn, .listen-words {
  font: inherit; font-size: 16px; font-weight: 800; padding: 8px 14px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 8px; color: var(--ink);
}
.listen-btn { background: #fff7c2; }
.listen-btn.playing { background: var(--accent); color: var(--accent-ink); animation: listen-pulse 0.8s ease-in-out infinite alternate; }
.listen-words { background: #fff; font-size: 14px; font-weight: 700; }
.listen-transcript {
  flex-basis: 100%; padding: 8px 10px; border: 2px dashed var(--line); border-radius: 8px;
  background: #fff; font-style: italic; color: var(--ink);
}
@keyframes listen-pulse { to { transform: scale(1.04); } }
.code-row input { width: 56px; text-align: center; font-family: 'Press Start 2P', monospace; font-size: 18px; }
.mission-tag { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--accent); }

.rooms {
  display: flex; flex-direction: column; gap: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--ink);
}
.map-row { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; }
.map-hall {
  height: 22px; margin: 0 -2px;
  background: repeating-linear-gradient(90deg, #c99a62 0 18px, #bb8c55 18px 20px);
  border-top: 3px solid #1f1814; border-bottom: 3px solid #1f1814;
  display: flex; align-items: center; justify-content: center;
}
.map-hall span { font-family: 'Press Start 2P', monospace; font-size: 8px; color: #6b4a2b; letter-spacing: 3px; }
.map-room, .map-stairs {
  position: relative; height: clamp(54px, 11vh, 100px); padding: 0; overflow: hidden;
  border: 3px solid #1f1814; background: #000;
}
.map-room.top { border-radius: 8px 8px 0 0; border-bottom-width: 0; }
.map-room.bottom { border-radius: 0 0 8px 8px; border-top-width: 0; }
.map-stairs {
  border-radius: 0 0 8px 8px; border-top-width: 0;
  background: repeating-linear-gradient(0deg, #8b7a6c 0 6px, #6e5f53 6px 9px);
}
.map-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.map-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 3px;
  background: rgba(31, 24, 20, .78); color: #fff;
  font-size: 12px; font-weight: 800; line-height: 1.15; text-align: center;
}
.map-room.top .map-name { bottom: 0; }
.map-room.bottom .map-name { top: 0; bottom: auto; }
.map-npc, .map-you {
  position: absolute; width: 40%; max-width: 44px; aspect-ratio: 1; image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.6));
}
.map-room.top .map-npc, .map-room.top .map-you { bottom: 14px; }
.map-room.bottom .map-npc, .map-room.bottom .map-you { bottom: 0; }
.map-npc { right: 2px; }
.map-you { left: 2px; animation: hop 0.9s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-3px); } }
.map-room.current { border-color: var(--accent); box-shadow: inset 0 0 0 2px #ffcf4a; }
.map-room.current .map-name { background: var(--accent); }
.map-room.locked .map-thumb { filter: grayscale(1) brightness(.35); }
.map-room.locked .map-name { color: var(--locked); }
.map-lock { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-size: 20px; }
.map-room.bottom .map-lock { top: 60%; }
.map-new {
  position: absolute; right: 3px; top: 3px; padding: 2px 4px; border-radius: 4px;
  background: #ffcf4a; color: var(--ink); font-family: 'Press Start 2P', monospace; font-size: 7px;
  animation: pulse 1.2s ease-in-out infinite;
}
.map-room.bottom .map-new { top: auto; bottom: 3px; }
.map-room:focus-visible { outline: 3px solid #ffcf4a; outline-offset: -3px; }
/* Narrow phones: keep long room names on one line. */
@media (max-width: 359px) {
  .map-name { font-size: 10px; letter-spacing: -0.2px; padding: 2px 1px; }
}
/* Short phones (iPhone SE): keep the whole map on screen. */
@media (max-height: 700px) {
  .map-room, .map-stairs { height: 56px; }
  .map-hall { height: 16px; }
  .map-hall span { font-size: 7px; }
  .panel { min-height: 140px; padding-top: 8px; padding-bottom: 8px; }
}

.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(43, 34, 51, .92);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px; overflow-y: auto;
}
.sheet {
  width: 100%; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.sheet h2 { font-family: 'Press Start 2P', monospace; font-size: 13px; margin: 0; line-height: 1.5; }
.sheet h3 { margin: 4px 0 0; font-size: 15px; color: var(--ink-soft); }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; border: 2px solid var(--ink); background: var(--paper-2); border-radius: 8px; padding: 8px 4px; font-weight: 800; font-size: 14px; }
.tabs button.on { background: var(--ink); color: var(--paper); }
.clue-card { background: var(--paper-2); border-radius: 8px; padding: 10px 12px; }
.clue-card b { display: block; font-size: 14px; }
.clue-card span { font-size: 16px; line-height: 1.45; }
.empty-note { color: var(--ink-soft); font-size: 16px; margin: 0; }
.words { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.words div { background: var(--paper-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.words b { display: block; color: var(--word); }

.grid-wrap { overflow-x: auto; }
table.deduce { border-collapse: collapse; width: 100%; font-size: 12px; }
.deduce th, .deduce td { border: 2px solid var(--ink); text-align: center; padding: 4px 2px; }
.deduce th { background: var(--paper-2); font-weight: 800; }
.deduce th.group { background: var(--ink); color: var(--paper); }
.deduce td button {
  width: 100%; min-height: 34px; border: 0; background: #fff;
  font-family: 'Press Start 2P', monospace; font-size: 12px;
}
.deduce td button.o { color: var(--good); }
.deduce td button.x { color: var(--bad); }
.grid-help { font-size: 13px; color: var(--ink-soft); margin: 0; }

.suspects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.suspect {
  border: 3px solid var(--ink); background: var(--paper-2); border-radius: 10px;
  padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.suspect .face {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Press Start 2P', monospace; font-size: 14px;
}
.suspect .sprite-face { width: 72px; height: 72px; border-radius: 10px; background: var(--paper); }
.suspect .sprite-face img { width: 100%; height: 100%; image-rendering: pixelated; }
.suspect:hover .sprite-face, .suspect:focus-visible .sprite-face { background: #fff; }
.suspect b { font-size: 15px; }
.ending-cast { display: flex; justify-content: center; gap: 6px; }
.ending-cast img { width: 72px; height: 72px; image-rendering: pixelated; }
.ending-cast img:nth-child(2) { animation: bob 1s ease-in-out infinite; }
.suspect small { font-size: 12px; color: var(--ink-soft); }

.stars { font-size: 32px; letter-spacing: 4px; color: #ef9f27; text-align: center; }
.title-card { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.title-card h1 { font-family: 'Press Start 2P', monospace; font-size: 16px; line-height: 1.6; margin: 0; }
.title-card .cast { display: flex; justify-content: center; gap: 4px; }
.title-card .cast img { width: 56px; height: 56px; image-rendering: pixelated; }

/* ---------- game feel ---------- */

.topbar-actions { display: flex; gap: 6px; }
.icon-btn.off { background: #6b5d63; color: #d3c9c2; }
.icon-btn.bump { animation: bump .45s ease-out; }
@keyframes bump { 30% { transform: scale(1.25); } 60% { transform: scale(.92); } }

.scene-inner { position: absolute; inset: 0; clip-path: circle(80% at 50% 50%); }
.scene-inner.iris-close { animation: irisClose .26s steps(6) forwards; }
.scene-inner.iris-open { animation: irisOpen .3s steps(7) forwards; }
@keyframes irisClose { from { clip-path: circle(80% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
@keyframes irisOpen { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(80% at 50% 50%); } }

.sprite:not(.talk) img { animation: idle 2.4s steps(2) infinite; }
@keyframes idle { 50% { transform: translateY(1.5%); } }

.ripple {
  position: absolute; z-index: 5; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border: 3px solid #fff7c2; border-radius: 50%; pointer-events: none;
  animation: ripple .45s ease-out forwards;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

.banner {
  position: absolute; left: 0; right: 0; top: 10%; z-index: 6; pointer-events: none;
  text-align: center; font-family: 'Press Start 2P', monospace; font-size: 13px;
  padding: 10px; color: var(--paper); background: rgba(58, 42, 36, .85);
  animation: bannerIn 1.9s ease-out forwards;
}
.banner.unlock { background: rgba(216, 90, 48, .92); top: 40%; }
@keyframes bannerIn {
  0% { transform: translateX(-100%); }
  15%, 80% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

.rooms button.fresh { animation: glow 1s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px #fac775; } }

.dialog { transition: background-color .2s; }
.flash-good { animation: flashGood .6s ease-out; }
.flash-bad { animation: flashBad .5s ease-out; }
@keyframes flashGood { 0% { background: #c0dd97; } }
@keyframes flashBad { 0% { background: #f7c1c1; } }
.shake { animation: shake .4s ease-in-out; }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.dialog.shake.flash-bad { animation: shake .4s ease-in-out, flashBad .5s ease-out; }

.panel { position: relative; }
.spark {
  position: absolute; z-index: 30; width: 6px; height: 6px; pointer-events: none;
  animation: spark .7s ease-out forwards;
}
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }

.clue-pop-layer {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18%; background: rgba(43, 34, 51, .55);
  animation: fadeIn .2s ease-out;
}
.clue-pop-layer.leaving { background: transparent; transition: background .3s; }
@keyframes fadeIn { from { opacity: 0; } }
.clue-pop {
  position: relative; width: 78%; max-width: 340px;
  transition: transform .45s cubic-bezier(.5, -0.2, .7, .4), opacity .45s;
  animation: popIn .45s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes popIn { from { transform: scale(.2) rotate(-8deg); opacity: 0; } }
.rays {
  position: absolute; left: 50%; top: 50%; width: 420px; height: 420px; margin: -210px 0 0 -210px;
  background: repeating-conic-gradient(rgba(250, 199, 117, .45) 0 12deg, transparent 12deg 30deg);
  border-radius: 50%; animation: spin 6s linear infinite; pointer-events: none;
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.leaving .rays { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.clue-pop-card {
  position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: 14px;
  padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 6px 0 var(--ink);
}
.clue-pop-tag {
  align-self: center; font-family: 'Press Start 2P', monospace; font-size: 12px;
  background: var(--accent); color: #fff; padding: 6px 10px; border-radius: 6px;
  animation: wiggle .6s ease-in-out .4s 2;
}
@keyframes wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.clue-pop-title { font-weight: 800; font-size: 18px; }
.clue-pop-text { font-weight: 700; font-size: 16px; line-height: 1.45; }
.clue-pop-tap { font-size: 12px; color: var(--ink-soft); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .3; } }

.confetti { position: absolute; inset: 0; z-index: 30; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 8px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  .scene-inner.iris-close, .scene-inner.iris-open, .sprite img, .rays, .confetti, .spark, .banner { animation-duration: .01s !important; }
}

/* ---------- anime portraits ---------- */

.portrait-stage { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.portrait-big {
  position: absolute; bottom: -6%; height: 100%; width: auto;
  filter: drop-shadow(0 0 2px rgba(58, 42, 36, .5));
  animation: portraitInL .28s cubic-bezier(.2, 1.2, .4, 1);
}
.portrait-big.left { left: -6%; }
.portrait-big.right { right: -6%; animation-name: portraitInR; }
.portrait-big.out { animation: portraitOut .25s ease-in forwards; }
@keyframes portraitInL { from { transform: translateX(-30%); opacity: 0; } }
@keyframes portraitInR { from { transform: translateX(30%); opacity: 0; } }
@keyframes portraitOut { to { opacity: 0; transform: translateY(6%); } }
.dialog.has-big .portrait { display: none; }

.cutin {
  position: absolute; inset: 0; z-index: 28; overflow: hidden; cursor: pointer;
  background: rgba(43, 34, 51, .55); animation: fadeIn .15s ease-out;
}
.cutin-band {
  position: absolute; left: -10%; right: -10%; top: 14%; height: 42%;
  background:
    repeating-linear-gradient(-60deg, rgba(255, 255, 255, .08) 0 14px, transparent 14px 28px),
    linear-gradient(90deg, #d85a30, #ef9f27);
  border-top: 4px solid var(--ink); border-bottom: 4px solid var(--ink);
  transform: skewY(-6deg);
  animation: bandIn .3s cubic-bezier(.2, 1, .3, 1);
}
.cutin.right .cutin-band { background:
    repeating-linear-gradient(60deg, rgba(255, 255, 255, .08) 0 14px, transparent 14px 28px),
    linear-gradient(270deg, #185fa5, #5dcaa5); transform: skewY(6deg); }
@keyframes bandIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.cutin-portrait {
  position: absolute; bottom: 44%; width: 74%; max-width: 360px; height: auto;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 99%);
  mask-image: linear-gradient(to bottom, #000 78%, transparent 99%);
  animation: cutPortraitL .38s cubic-bezier(.2, 1.3, .4, 1);
}
.cutin.left .cutin-portrait { left: -4%; }
.cutin.right .cutin-portrait { right: -4%; animation-name: cutPortraitR; }
@keyframes cutPortraitL { from { transform: translateX(-60%); opacity: 0; } }
@keyframes cutPortraitR { from { transform: translateX(60%); opacity: 0; } }
.cutin-text {
  position: absolute; top: 36%; z-index: 1; display: flex; flex-direction: column; gap: 8px;
  animation: cutText .4s .12s cubic-bezier(.2, 1.3, .4, 1) both;
}
.cutin.left .cutin-text { right: 4%; align-items: flex-end; text-align: right; }
.cutin.right .cutin-text { left: 4%; align-items: flex-start; }
@keyframes cutText { from { transform: scale(.4); opacity: 0; } }
.cutin-name {
  font-family: 'Press Start 2P', monospace; font-size: 12px;
  background: var(--ink); color: var(--paper); padding: 6px 10px; border-radius: 6px;
}
.cutin-caption {
  font-family: 'Press Start 2P', monospace; font-size: 20px; line-height: 1.3; color: #fff;
  max-width: 46vw; text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.cutin.leaving { animation: cutOut .3s ease-in forwards; }
@keyframes cutOut { to { opacity: 0; transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .portrait-big, .cutin, .cutin-band, .cutin-portrait, .cutin-text { animation-duration: .01s !important; }
}

/* ---------- case select ---------- */

.case-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.case-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px;
  align-items: center; text-align: left; width: 100%;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 12px; padding: 12px 14px;
}
.case-card:hover, .case-card:focus-visible { background: #fff; }
.case-num {
  grid-row: span 2; font-family: 'Press Start 2P', monospace; font-size: 10px; line-height: 1.4;
  background: var(--accent); color: #fff; padding: 8px 8px; border-radius: 8px; text-align: center; min-width: 64px;
}
.case-title { font-weight: 800; font-size: 16px; }
.case-meta { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.case-card.locked { opacity: .55; }
.case-card.locked .case-num { background: var(--locked); }
.mission-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.step-away { font: inherit; font-size: 14px; font-weight: 700; padding: 6px 10px; border: 2px solid #2a1c16; border-radius: 8px; background: #fff8e7; color: #2a1c16; cursor: pointer; }
