/* Layout: full-bleed landscape stage with a slim top bar (day, stats, money, gauges, bag).
   Everything else (map, bag, mini-games, cards) opens as an overlay on top of the scene. */
:root {
  --paper-frame: url("../assets/ui/ui_button.webp") 84 fill / var(--pf, 10px) stretch;
  --night: #140e0a;
  --ink: #2b1d13;
  --ink-soft: #5a4532;
  --paper: #f0e3c6;
  --brass: #c79b55;
  --seal: #b23a2e;
  --mist: #f6ecd6;
  --shade: rgba(16, 10, 6, 0.74);

  --f-display: "Song Myung", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --f-body: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --f-ui: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-hand: "Nanum Pen Script", "Noto Sans KR", cursive;

  --side-w: 0px;
  --top-h: clamp(42px, 8.5vh, 64px);
  --gut-l: max(12px, env(safe-area-inset-left, 0px));
  --gut-r: max(12px, env(safe-area-inset-right, 0px));
  --gut-b: max(10px, env(safe-area-inset-bottom, 0px));
  /* dialog box: two lines tall by default, grows only for longer lines */
  --dlg-font: clamp(14px, 3.1vh, 25px);
  --dlg-bw: clamp(10px, 2vh, 18px);
  --dlg-pad: clamp(4px, 1.1vh, 11px);
  --dlg-min: calc(3 * var(--dlg-font) + 2 * var(--dlg-pad) + 2 * var(--dlg-bw));
  --dlg-maxw: 1180px;
  color-scheme: dark;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--mist);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
body { font-family: var(--f-ui); font-weight: 500; font-size: 16px; }
[hidden] { display: none !important; }
img { -webkit-user-drag: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; }

.game { position: fixed; inset: 0; overflow: hidden; background: var(--night); }

/* ---------- stage ---------- */
.stage { position: absolute; inset: 0; }
.bg {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none;
  object-fit: cover; object-position: center;
  transition: opacity 0.35s ease;
}
.sprites { position: absolute; inset: 0; pointer-events: none; }
.sprite {
  position: absolute; bottom: 0;
  height: calc(86% * var(--scale, 1));
  max-width: none;
  transform: translateX(-50%);
  transition: left 0.4s ease, filter 0.25s ease, opacity 0.3s ease, transform 0.3s ease;
  filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.35));
}
.sprite.enter { opacity: 0; transform: translateX(-50%) translateY(3%); }
.sprite.dim { filter: brightness(0.62) saturate(0.8); }
.sprite.talk { animation: bob 0.35s ease; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(-1.2%); } }
.stage.shake { animation: shake 0.45s ease; }
@keyframes shake {
  20% { transform: translateX(-1.2%); } 40% { transform: translateX(1.2%); }
  60% { transform: translateX(-0.8%); } 80% { transform: translateX(0.6%); }
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: clamp(8px, 1.6vw, 22px);
  padding: 0 var(--gut-r) 0 var(--gut-l);
  background: url("../assets/ui/ui_topbar.webp") center / 100% 100% no-repeat;
  opacity: 0; pointer-events: none; transition: opacity 0.5s ease;
}
.game.hud-any .topbar { opacity: 1; pointer-events: auto; }
.dday { display: none; align-items: baseline; gap: 8px; white-space: nowrap; }
.dday-num { font-family: var(--f-display); font-size: clamp(20px, 4.6vh, 34px); color: var(--mist); line-height: 1; }
.dday-time { font-weight: 700; font-size: clamp(11px, 2.2vh, 15px); color: #e9d3a6; }
.game.hud-dday .dday { display: flex; }

.stats, .money { display: none; align-items: center; gap: clamp(6px, 1.2vw, 14px); }
.game.hud-stats .stats { display: flex; }
.game.hud-money .money { display: flex; }
.rice { display: none; align-items: center; gap: 3px; font-weight: 700; font-size: clamp(12px, 2.4vh, 17px); color: var(--mist); font-variant-numeric: tabular-nums; }
.rice img { height: clamp(20px, 4.4vh, 34px); width: auto; }
.rice span { font-weight: 500; font-size: 0.85em; color: #e9d3a6; }
.game.hud-rice .rice { display: flex; }
.stat, .money {
  font-weight: 700; font-size: clamp(12px, 2.4vh, 17px); color: var(--mist); font-variant-numeric: tabular-nums;
}
.stat { display: flex; align-items: center; gap: 3px; }
.stat img, .money img { height: clamp(20px, 4.4vh, 34px); width: auto; }
.stat.up b { animation: statup 0.9s ease 2; }
@keyframes statup { 50% { color: #ffd27a; transform: scale(1.3); } }
.money { gap: 3px; }
.money span { font-weight: 500; font-size: 0.85em; color: #e9d3a6; }

.gauges { margin-left: auto; display: flex; gap: clamp(8px, 1.6vw, 18px); }
.gauge { display: none; align-items: center; gap: 6px; font-weight: 700; font-size: clamp(11px, 2.2vh, 15px); color: #e9d3a6; }
.game.hud-grade #gGrade { display: flex; animation: rise 0.5s ease both; }
.game.hud-susp #gSusp { display: flex; animation: rise 0.5s ease both; }
.g-track {
  width: clamp(54px, 12vh, 120px); height: clamp(8px, 1.4vh, 12px);
  background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(199, 155, 85, 0.7); border-radius: 99px; overflow: hidden;
}
.g-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a77b3c, #e3bd72); transition: width 0.6s ease; }
.gauge.warn .g-fill { background: linear-gradient(90deg, #7d2a22, #c9473a); }
.gauge.pulse .g-track { animation: pulse 0.7s ease 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(227, 189, 114, 0.45); } }

.bag-btn {
  display: none; align-items: center; gap: 6px; flex: none;
  height: calc(var(--top-h) - 14px); padding: 0 14px 0 8px; overflow: hidden;
  border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(199, 155, 85, 0.75);
  font-weight: 700; font-size: clamp(12px, 2.3vh, 16px); color: #f3e0b8; white-space: nowrap;
}
.bag-btn img { height: 72%; width: auto; }
.game.hud-bag .bag-btn { display: flex; }
.bag-btn.flash { animation: pulse 0.8s ease 3; }
@media (max-height: 520px) {
  .bag-btn span { display: none; }
  .bag-btn { padding: 0 8px; }
  .g-label { display: none; }
}

/* ---------- dialog ---------- */
.dialog {
  position: absolute; z-index: 6;
  left: var(--gut-l); right: var(--gut-r); bottom: var(--gut-b);
  max-width: var(--dlg-maxw); margin: 0 auto;
  min-height: var(--dlg-min);
  box-sizing: border-box;
  border-style: solid; border-width: var(--dlg-bw);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / var(--dlg-bw) stretch;
  padding: var(--dlg-pad) clamp(10px, 2.2vw, 26px);
  color: var(--ink);
}
.nametag {
  position: absolute; top: calc(-1 * clamp(26px, 5.6vh, 44px)); left: clamp(4px, 1vw, 12px);
  --pf: 8px; border-style: solid; border-width: 8px;
  border-image: var(--paper-frame); padding: 0 6px;
  font-family: var(--f-ui); font-weight: 900; color: var(--ink);
  font-size: clamp(13px, 2.6vh, 20px); line-height: 1.25; white-space: nowrap;
}
.line {
  margin: 0; font-family: var(--f-body); font-weight: 700;
  font-size: var(--dlg-font); line-height: 1.5;
  white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere;
}
.dialog.narr .line { color: var(--ink-soft); }
.dialog.think .line { color: #3f2f63; }
.dialog.think .line::before { content: "( "; }
.dialog.think .line::after { content: " )"; }
.next {
  position: absolute; right: clamp(8px, 1.6vw, 18px); bottom: 2px;
  color: var(--ink-soft); font-size: clamp(11px, 2vh, 16px); opacity: 0;
}
.dialog.ready .next { opacity: 1; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

/* ---------- choices ---------- */
.choices {
  position: absolute; z-index: 7;
  left: var(--gut-l); right: var(--gut-r);
  top: var(--top-h); bottom: calc(var(--gut-b) + var(--dlg-min) + 8px);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: clamp(8px, 2vh, 16px);
  background: radial-gradient(ellipse at center, rgba(16, 10, 6, 0.55), transparent 70%);
}
.btn, .choice {
  --pf: clamp(9px, 1.6vh, 12px); border-style: solid; border-width: var(--pf);
  border-image: var(--paper-frame);
  background: none; padding: clamp(1px, 0.5vh, 5px) clamp(12px, 2vw, 22px);
  color: var(--ink); font-family: var(--f-body); font-weight: 700;
  font-size: clamp(15px, 3.2vh, 24px); line-height: 1.35;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.choice { width: min(100%, 34em); animation: rise 0.35s ease both; display: flex; align-items: center; justify-content: center; gap: 10px; }
.choice:nth-child(2) { animation-delay: 0.08s; }
.choice:nth-child(3) { animation-delay: 0.16s; }
.btn:active, .choice:active { transform: scale(0.97); filter: brightness(0.92); }
.req {
  flex: none; display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px; border-radius: 99px; background: var(--ink); color: #f3e0b8;
  font-family: var(--f-ui); font-size: 0.72em; font-weight: 700;
}
.req img { height: 1.3em; width: auto; }
.choice.locked { filter: grayscale(0.8) brightness(0.75); cursor: not-allowed; }
.choice.locked .req { background: var(--seal); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- tip, toast, card ping ---------- */
.tip {
  position: absolute; z-index: 19; top: calc(var(--top-h) + 10px);
  left: calc(var(--gut-l) + 4%); right: calc(var(--gut-r) + 4%);
  display: flex; gap: 10px; align-items: baseline;
  --pf: 9px; border-style: solid; border-width: 9px;
  border-image: var(--paper-frame); padding: 2px 10px;
  color: var(--ink); font-size: clamp(12px, 2.5vh, 18px); line-height: 1.45;
  animation: rise 0.3s ease both;
}
.tip b { white-space: nowrap; color: var(--seal); }
.tip b::before { content: "용어 · "; color: var(--ink-soft); font-weight: 500; }
.tip[data-kind="guide"] b::before { content: "안내 · "; }
.toast {
  position: absolute; z-index: 35; top: calc(var(--top-h) + clamp(52px, 10vh, 76px)); right: var(--gut-r);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 8px;
  background: rgba(20, 13, 8, 0.9); border: 1px solid var(--brass);
  font-weight: 700; font-size: clamp(12px, 2.4vh, 17px); color: var(--mist);
  animation: rise 0.25s ease both;
}
.toast img { height: 1.8em; width: auto; }
.cardping {
  position: absolute; z-index: 9; left: var(--gut-l); top: calc(var(--top-h) + 10px);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 8px; border-radius: 10px;
  background: rgba(16, 10, 6, 0.86); border: 1px solid rgba(199, 155, 85, 0.7);
  font-weight: 700; font-size: clamp(12px, 2.4vh, 17px); color: var(--mist);
  animation: pingin 0.35s ease both;
}
.cardping img { height: clamp(64px, 16vh, 130px); width: auto; border-radius: 5px; animation: waver 0.6s ease 0.35s 2; }
.cardping.out { animation: pingout 0.35s ease both; }
@keyframes pingin { from { opacity: 0; transform: translateX(-24px); } }
@keyframes pingout { to { opacity: 0; transform: translateX(-24px); } }
@keyframes waver {
  20% { transform: rotate(-6deg) scale(1.06); } 40% { transform: rotate(5deg) scale(1.06); }
  60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); }
}

/* glossary terms: dotted underline, tap to explain */
.term { text-decoration: underline dotted var(--seal); text-decoration-thickness: 2px; text-underline-offset: 0.2em; cursor: pointer; }
.sl-text .term { text-decoration-color: #f2c98a; }
.termpop {
  position: absolute; z-index: 36; box-sizing: border-box; max-width: min(340px, 72vw);
  --pf: 9px; border-style: solid; border-width: 9px;
  border-image: var(--paper-frame); padding: 1px 8px;
  color: var(--ink); font-weight: 500; font-size: clamp(12px, 2.4vh, 16px); line-height: 1.45;
  word-break: keep-all; text-shadow: none; text-align: left;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
  animation: rise 0.25s ease both;
}
.termpop b { display: block; color: var(--seal); font-weight: 900; font-size: 1.05em; }
.termpop::after { content: ""; position: absolute; left: var(--arrow-x, 50%); bottom: -17px; border: 8px solid transparent; border-top-color: #6b4423; transform: translateX(-50%); }
.termpop.below::after { bottom: auto; top: -17px; border-top-color: transparent; border-bottom-color: #6b4423; }

/* ---------- map ---------- */
.mapview {
  position: absolute; z-index: 18; left: 0; right: 0; top: var(--top-h); bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh;
  padding: 1vh var(--gut-r) var(--gut-b) var(--gut-l); box-sizing: border-box;
  background: #1a120c; animation: fade 0.35s ease both;
}
.map-head { display: flex; align-items: baseline; gap: 14px; font-weight: 700; font-size: clamp(14px, 3vh, 22px); }
.map-head b { font-family: var(--f-display); font-weight: 400; font-size: 1.3em; color: var(--mist); }
.map-head span { color: var(--brass); }
.map-box { position: relative; flex: 1; min-height: 0; aspect-ratio: 16 / 9; max-width: 100%; }
.map-img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.map-spots { position: absolute; inset: 0; }
.spot {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  --pf: 8px; border-style: solid; border-width: 8px;
  border-image: var(--paper-frame);
  background: none; padding: 0 10px; color: var(--ink); white-space: nowrap;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
  animation: rise 0.35s ease both;
}
.spot b { font-weight: 900; font-size: clamp(13px, 2.8vh, 20px); line-height: 1.2; }
.spot small { font-weight: 500; font-size: clamp(10px, 1.9vh, 14px); color: var(--ink-soft); line-height: 1.2; }
.spot.new::after {
  content: "NEW"; position: absolute; top: -14px; right: -18px;
  padding: 1px 6px; border-radius: 99px; background: var(--seal); color: #fff;
  font-size: 10px; font-weight: 900; letter-spacing: 0.04em;
}
.spot:active { transform: translate(-50%, -50%) scale(0.95); }

/* ---------- free-time intro popup ---------- */
.freeintro { z-index: 24; top: var(--top-h); background: rgba(16, 10, 6, 0.55); }
.free-panel { width: min(92%, 680px); }
.free-panel .note-body { gap: 0.9vh; max-height: calc(78vh - var(--top-h)); }
.fi-text { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.7vh, 19px); line-height: 1.6; word-break: keep-all; }
.fi-extra { margin: 0; padding: 6px 12px; border-radius: 8px; background: rgba(178, 58, 46, 0.12); color: var(--seal); font-weight: 700; font-size: clamp(12px, 2.5vh, 17px); line-height: 1.5; word-break: keep-all; }
.fi-extra:empty { display: none; }
.fi-spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12em), 1fr)); gap: 6px 10px; }
.fi-spot { position: relative; display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(43, 29, 19, 0.07); font-size: clamp(12px, 2.5vh, 17px); }
.fi-spot b { font-weight: 900; white-space: nowrap; }
.fi-spot small { color: var(--ink-soft); font-weight: 500; }
.fi-spot.new::after { content: "NEW"; margin-left: auto; padding: 0 6px; border-radius: 99px; background: var(--seal); color: #fff; font-size: 10px; font-weight: 900; align-self: center; }
.fi-go { align-self: center; margin-top: 0.6vh; }

/* ---------- market mini-game ---------- */
.carry { background: rgba(14, 9, 6, 0.6); justify-content: flex-start; padding-top: calc(var(--top-h) + 1vh); gap: 1vh; }
.cr-head { display: flex; gap: 14px; align-items: baseline; font-weight: 700; font-size: clamp(14px, 3vh, 22px); }
.cr-head b { font-family: var(--f-display); font-weight: 400; font-size: 1.4em; }
.cr-head span { color: var(--brass); font-variant-numeric: tabular-nums; }
.cr-field { position: relative; flex: 1; width: min(100%, 900px); }
.cr-sack { position: absolute; top: 4%; height: 20%; width: auto; transform: translateX(-50%); }
.cr-sack.drop { transition: top 0.32s ease-in; }
.cr-jige { position: absolute; bottom: 0; left: 50%; height: 46%; width: auto; transform: translateX(-50%); }
.cr-stack { position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; z-index: 1; }
.cr-stack img { height: clamp(40px, 12vh, 100px); width: auto; margin-top: -5vh; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4)); }
.cr-stack img:nth-child(even) { transform: translateX(8%) rotate(4deg); }
.cr-stack img:nth-child(odd) { transform: translateX(-6%) rotate(-3deg); }
.cr-msg { margin: 0 0 var(--gut-b); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); color: var(--mist); text-align: center; text-shadow: 0 2px 8px #000; }
.cr-msg.good { color: #ffd27a; }
.cr-msg.bad { color: #f0a48f; }

/* ---------- goal chip ---------- */
.goal {
  position: absolute; z-index: 8; top: calc(var(--top-h) + 6px); left: var(--gut-l);
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 99px;
  background: rgba(16, 10, 6, 0.82); border: 1px solid var(--brass);
  font-weight: 700; font-size: clamp(11px, 2.3vh, 16px); color: var(--mist); white-space: nowrap;
}
.goal b { padding: 1px 10px; border-radius: 99px; background: var(--seal); color: #fff; font-weight: 900; }
.goal.met b { background: #3f7a3a; }
.goal.met span::after { content: " ✓"; color: #9fd89a; }

/* ---------- stat check dice ---------- */
.dice { z-index: 45; background: rgba(10, 6, 4, 0.7); }
.dice-card {
  box-sizing: border-box; min-width: min(80vw, 360px); text-align: center; padding: clamp(10px, 2.4vh, 22px) clamp(14px, 3vw, 30px);
  border-style: solid; border-width: clamp(12px, 2.4vh, 22px);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / clamp(12px, 2.4vh, 22px) stretch;
  color: var(--ink); animation: rise 0.25s ease both;
}
.dice-card p { margin: 0; }
.dice-title { font-weight: 900; font-size: clamp(14px, 3vh, 21px); }
.dice-num { font-family: var(--f-display); font-size: clamp(48px, 14vh, 110px); line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.dice-rule { font-weight: 500; font-size: clamp(11px, 2.2vh, 15px); color: var(--ink-soft); }
.dice-res { margin-top: 0.6vh !important; font-family: var(--f-display); font-size: clamp(22px, 5vh, 40px); min-height: 1.2em; }
.dice-res.ok { color: #2f7a2c; animation: stamp 0.3s ease-out both; }
.dice-res.no { color: var(--seal); animation: stamp 0.3s ease-out both; }
.req.check { background: #2f4f7a; }

/* ---------- episode 3 mini-games ---------- */
.reap, .measure, .abacus, .rebut { background: #000; padding: 0; z-index: 28; }
.mg-bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.rp-stack {
  position: absolute; left: 50%; bottom: calc(var(--gut-b) + clamp(90px, 22vh, 170px)); transform: translateX(-50%);
  display: flex; flex-wrap: wrap-reverse; justify-content: center; gap: 2px; width: min(90%, 760px);
}
.rp-stack img { height: clamp(34px, 9vh, 70px); width: auto; animation: rise 0.3s ease both; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5)); }
.rp-bar {
  position: absolute; left: 50%; bottom: calc(var(--gut-b) + clamp(46px, 11vh, 80px)); transform: translateX(-50%);
  width: min(84%, 720px); height: clamp(26px, 6vh, 44px); border-radius: 99px;
  background: rgba(16, 10, 6, 0.75); border: 2px solid var(--brass); overflow: hidden;
}
.rp-zone { position: absolute; top: 0; bottom: 0; background: rgba(255, 210, 122, 0.55); }
.rp-zone i { position: absolute; top: 0; bottom: 0; left: 30%; width: 40%; background: rgba(255, 170, 40, 0.9); }
.rp-needle { position: absolute; top: -4px; bottom: -4px; width: 6px; margin-left: -3px; border-radius: 3px; background: #fff; box-shadow: 0 0 10px #fff; }
.rp-msg { left: 50% !important; transform: translateX(-50%); max-width: 90% !important; text-align: center; white-space: nowrap; }
.ms-ov { position: absolute; left: 1%; bottom: 0; height: 74%; width: auto; max-width: none; filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.7)); }
.ms-time { z-index: 2; }
.ms-row { position: absolute; left: 26%; right: 4%; top: 30%; bottom: 22%; display: flex; align-items: center; justify-content: space-around; }
.ms-box {
  background: none; border: 3px dashed transparent; border-radius: 14px; padding: 6px; width: clamp(90px, 22vh, 190px); aspect-ratio: 1;
  display: grid; place-items: center;
}
.ms-box img { width: 70%; height: auto; transform: scale(var(--s, 1)) rotate(var(--r, 0deg)); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55)); }
.ms-box:active { border-color: rgba(255, 241, 216, 0.7); }
.ms-box.hint { animation: hint 0.9s ease-in-out infinite alternate; }
@keyframes hint { to { border-color: rgba(255, 210, 122, 0.55); background: rgba(255, 210, 122, 0.12); } }
.ms-box.right { border-color: #6fd36a; background: rgba(111, 211, 106, 0.2); }
.ms-box.wrong { border-color: #c9473a; background: rgba(201, 71, 58, 0.2); }
.ms-msg { left: 50% !important; transform: translateX(-50%); max-width: 90% !important; text-align: center; }
.split { z-index: 28; padding-top: var(--top-h); }
.split-panel { width: min(94%, 860px); max-height: calc(100vh - var(--top-h) - 12px); }
.split-panel .note-body { max-height: calc(100vh - var(--top-h) - 60px); overflow-x: hidden; }
.sp-short { display: none; margin: 0; font-weight: 700; font-size: 13px; }
.sp-short b { color: var(--ink); }
.sp-short i { font-style: normal; color: var(--seal); }

.sp-ledger { display: grid; grid-template-columns: 1fr auto; gap: 2px 18px; font-weight: 700; font-size: clamp(12px, 2.5vh, 17px); font-variant-numeric: tabular-nums; }
.sp-ledger .neg { color: var(--seal); }
.sp-ledger .sum { border-top: 1px solid rgba(43, 29, 19, 0.35); padding-top: 2px; font-weight: 900; }
.sp-bins { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sp-bin { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 10px; background: rgba(43, 29, 19, 0.07); text-align: center; }
.sp-bin b { font-weight: 900; font-size: clamp(12px, 2.5vh, 17px); }
.sp-bin small { color: var(--ink-soft); font-weight: 500; font-size: clamp(10px, 2vh, 13px); line-height: 1.3; word-break: keep-all; }
.sp-ctrl { display: flex; align-items: center; gap: 8px; }
.sp-ctrl button {
  width: clamp(30px, 6vh, 40px); aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--ink); background: #f4ead2;
  font-weight: 900; font-size: clamp(16px, 3.4vh, 22px); color: var(--ink); line-height: 1; padding: 0;
}
.sp-ctrl button:disabled { opacity: 0.3; }
.sp-ctrl span { font-family: var(--f-display); font-size: clamp(22px, 5vh, 36px); min-width: 1.4em; font-variant-numeric: tabular-nums; }
.sp-cal { display: flex; flex-direction: column; gap: 4px; padding-top: 15px; }
.sp-bar { position: relative; height: 14px; border-radius: 99px; background: rgba(43, 29, 19, 0.15); overflow: visible; }
.sp-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #a77b3c, #e3bd72); transition: width 0.3s ease; }
.sp-bar i { position: absolute; right: 0; top: -16px; font-style: normal; font-weight: 900; font-size: 12px; line-height: 1; color: var(--seal); }
.sp-bar i::after { content: ""; position: absolute; right: 1px; top: 13px; width: 3px; height: 17px; border-radius: 2px; background: var(--seal); }
.sp-cal-text { margin: 0; font-weight: 700; font-size: clamp(12px, 2.6vh, 18px); }
.sp-warn { margin: 0; color: var(--seal); font-weight: 700; font-size: clamp(11px, 2.3vh, 15px); white-space: pre-line; line-height: 1.5; }
.sp-warn:empty { display: none; }
.badge { display: flex; flex-direction: column; padding: 4px 8px; border-radius: 8px; opacity: 0.5; }
.badge.got { opacity: 1; background: rgba(199, 155, 85, 0.18); }
.badge b { font-weight: 900; font-size: clamp(12px, 2.5vh, 17px); }
.badge small { color: var(--ink-soft); font-weight: 500; font-size: clamp(10px, 2vh, 14px); }
.fi-extra { white-space: pre-line; }

/* ---------- inspection mini-game ---------- */
.inspect { background: #120c08; padding: var(--top-h) 0 0; z-index: 28; }
.ins-box { position: relative; width: min(100%, calc((100vh - var(--top-h)) * 16 / 9)); aspect-ratio: 16 / 9; max-height: calc(100vh - var(--top-h)); }
.ins-bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.ins-det {
  position: absolute; right: 2%; bottom: 0; height: 92%; width: auto; max-width: none;
  transform-origin: bottom right; transform: scale(var(--near, 0.45)); opacity: 0.92;
  transition: transform 0.4s linear; filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.7));
}
.ins-head {
  pointer-events: none;
  position: absolute; top: calc(var(--top-h) + 6px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; align-items: baseline; padding: 6px 18px; border-radius: 10px;
  background: rgba(16, 10, 6, 0.85); border: 1px solid var(--brass); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); white-space: nowrap;
}
.ins-head b { font-family: var(--f-display); font-weight: 400; font-size: 1.3em; }
.ins-head span { color: #f0a48f; font-variant-numeric: tabular-nums; }
.ins-bag {
  position: absolute; left: 7%; top: 13%; width: 39%; height: 58%;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 1.4vh;
}
.ins-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: clamp(64px, 13vh, 110px);
  padding: 6px; border-radius: 10px; border: 2px solid transparent; background: rgba(240, 227, 198, 0.82);
  color: var(--ink); font-weight: 700; font-size: clamp(11px, 2.1vh, 15px); line-height: 1.2; text-align: center; word-break: keep-all;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.ins-item img { height: clamp(36px, 8vh, 64px); width: auto; }
.ins-item.sel { border-color: var(--seal); transform: scale(1.06); }
.ins-spots { position: absolute; inset: 0; pointer-events: none; }
.ins-spot {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  min-width: clamp(100px, 20vh, 170px); min-height: clamp(70px, 15vh, 120px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 12px; border: 3px dashed rgba(255, 241, 216, 0.85); background: rgba(16, 10, 6, 0.45);
  color: #fff1d8; font-weight: 900; font-size: clamp(12px, 2.4vh, 17px);
}
.ins-spot.ready { border-color: #ffd27a; background: rgba(255, 210, 122, 0.25); }
.ins-spot .ins-item { width: auto; padding: 4px 8px; }
.ins-msg {
  position: absolute; left: var(--gut-l); bottom: calc(var(--gut-b) + 6px); margin: 0; pointer-events: none;
  padding: 6px 14px; border-radius: 10px; background: rgba(16, 10, 6, 0.85);
  font-weight: 700; font-size: clamp(12px, 2.5vh, 18px); color: var(--mist); max-width: min(34%, 26em); word-break: keep-all;
}

.ins-item.risky { border-color: var(--seal); }
.ins-item em {
  font-style: normal; font-size: 10px; font-weight: 900; color: #fff; background: var(--seal);
  border-radius: 99px; padding: 0 6px; line-height: 1.5;
}
.ins-brief { position: absolute; inset: var(--top-h) 0 0; z-index: 3; display: flex; align-items: center; justify-content: center; background: rgba(16, 10, 6, 0.6); }
.brief-panel { max-width: min(92%, 640px); }
.brief-panel .note-body { max-height: calc(82vh - var(--top-h)); gap: 0.8vh; }
.brief-items { display: flex; gap: 10px; flex-wrap: wrap; }
.brief-items .ins-item { width: auto; flex-direction: row; gap: 6px; padding: 4px 10px; }
.brief-items .ins-item img { height: clamp(24px, 5vh, 40px); }
.brief-steps { margin: 0; padding-left: 1.4em; font-weight: 700; font-size: clamp(12px, 2.5vh, 17px); line-height: 1.6; }
.brief-steps b { color: var(--seal); }

/* ---------- episode 4 mini-games ---------- */
.ab-time { z-index: 2; }
.ab-stage {
  position: absolute; left: var(--gut-l); right: var(--gut-r); top: calc(var(--top-h) + clamp(64px, 13vh, 96px)); bottom: calc(var(--gut-b) + clamp(34px, 8vh, 56px));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 3vh, 26px); z-index: 1;
}
.ab-slip {
  box-sizing: border-box; min-width: min(86%, 520px); text-align: center; color: var(--ink);
  border-style: solid; border-width: var(--dlg-bw); border-image: url("../assets/ui/ui_dialog.webp") 48 fill / var(--dlg-bw) stretch;
  padding: clamp(2px, 1vh, 10px) clamp(14px, 3vw, 34px);
}
.ab-kicker { margin: 0; font-weight: 700; font-size: clamp(11px, 2.2vh, 15px); color: var(--seal); letter-spacing: 0.2em; }
.ab-sum { margin: 0; font-family: var(--f-display); font-size: clamp(24px, 7vh, 54px); line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ab-opts { display: flex; gap: clamp(8px, 2vw, 20px); flex-wrap: wrap; justify-content: center; }
.ab-opt { min-width: 6.5em; font-size: clamp(16px, 3.8vh, 28px); }
.ab-opt.right { filter: drop-shadow(0 0 10px #6fd36a) brightness(1.05); }
.ab-opt.wrong { filter: grayscale(0.6) brightness(0.7); }
.ab-tool { position: absolute; right: var(--gut-r); bottom: calc(var(--gut-b) + 2px); width: clamp(140px, 26vw, 300px); height: auto; max-width: none; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6)); }
.rb-bg { filter: brightness(0.55); }
.rb-wrap {
  position: absolute; left: var(--gut-l); right: var(--gut-r); top: calc(var(--top-h) + clamp(42px, 8.5vh, 66px)); bottom: var(--gut-b); z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.6vh, 14px);
}
.rb-paper {
  flex: 1 1 auto; min-height: 0; box-sizing: border-box; width: min(100%, 980px); color: var(--ink);
  border-style: solid; border-width: var(--dlg-bw); border-image: url("../assets/ui/ui_dialog.webp") 48 fill / var(--dlg-bw) stretch;
  padding: clamp(2px, 1vh, 12px) clamp(12px, 2.6vw, 34px); display: flex; flex-direction: column; justify-content: center; gap: clamp(4px, 1.2vh, 12px);
}
.rb-kicker { margin: 0; font-weight: 700; font-size: clamp(11px, 2.1vh, 15px); color: var(--seal); }
.rb-list {
  margin: 0; padding: 0 0 0 1.6em; min-height: 0; overflow: auto; font-family: var(--f-body); font-weight: 700;
  font-size: clamp(14px, 3.4vh, 30px); line-height: 1.85; word-break: keep-all;
}
.rb-list li { padding: 0 0.4em; border-radius: 6px; color: var(--ink-soft); opacity: 0.6; transition: background 0.2s ease, opacity 0.2s ease; }
.rb-list li::marker { color: var(--ink-soft); font-weight: 900; }
.rb-list li.cur { opacity: 1; color: var(--ink); background: rgba(255, 196, 92, 0.42); box-shadow: inset 4px 0 0 var(--seal); }
.rb-list li.done { opacity: 0.85; }
.rb-list li.done span { text-decoration: line-through; text-decoration-color: rgba(178, 58, 46, 0.9); text-decoration-thickness: 3px; }
.rb-x { height: 1.3em; width: auto; vertical-align: middle; margin-left: 0.3em; transform: rotate(-10deg); animation: rbx 0.3s ease-out both; }
@keyframes rbx { from { transform: rotate(-10deg) scale(2); opacity: 0; } }
.rb-res { margin: 0; font-weight: 700; font-size: clamp(12px, 2.5vh, 18px); line-height: 1.5; color: #7a2a20; word-break: keep-all; }
.rb-res.ok { color: var(--ink); }
.rb-tap { margin: 0; text-align: right; font-weight: 700; font-size: clamp(11px, 2vh, 14px); color: var(--ink-soft); animation: blink 1.4s steps(2) infinite; }
.rb-hand { flex: none; width: 100%; max-width: 1180px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(5px, 1vw, 12px); }
.rb-evidence {
  position: absolute; inset: var(--top-h) 0 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(6px, 1.8vh, 16px); padding: 0 var(--gut-r) 0 var(--gut-l); background: rgba(10, 6, 4, 0.84); text-align: center;
}
.rb-ev-kicker { margin: 0; font-weight: 900; font-size: clamp(12px, 2.4vh, 17px); color: #ffd27a; letter-spacing: 0.08em; }
.rb-ev-imgs { display: flex; gap: clamp(10px, 2vw, 24px); justify-content: center; }
.rb-ev-imgs figure { margin: 0; display: flex; flex-direction: column; gap: 6px; animation: evpop 0.4s ease-out both; }
.rb-ev-imgs figure:nth-child(2) { animation-delay: 0.12s; }
.rb-ev-imgs img { width: min(64vw, 620px); max-height: 46vh; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 4px solid #c79b55; box-shadow: 0 0 30px rgba(255, 210, 122, 0.35); }
.rb-ev-imgs figure:nth-child(2) img, .rb-ev-imgs figure:first-child:nth-last-child(2) img { width: min(42vw, 440px); }
.rb-ev-imgs figcaption { font-family: var(--f-display); font-size: clamp(16px, 3.4vh, 26px); color: #f3e0b8; }
@keyframes evpop { from { transform: scale(0.6) rotate(-3deg); opacity: 0; } }
.rb-ev-why { margin: 0; max-width: min(92%, 860px); font-family: var(--f-body); font-weight: 700; font-size: clamp(14px, 3vh, 22px); line-height: 1.6; color: #fff3dc; word-break: keep-all; }
.rb-ev-tap { margin: 0; font-weight: 700; font-size: clamp(11px, 2vh, 14px); color: #cdb98f; animation: blink 1.4s steps(2) infinite; }
.rb-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 5px; border-radius: 10px; text-align: center;
  background: #f0e3c6; border: 3px solid #c79b55; color: var(--ink); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}
.rb-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; }
.rb-card b { font-weight: 900; font-size: clamp(11px, 2.4vh, 16px); line-height: 1.25; word-break: keep-all; }
.rb-card small { font-weight: 500; font-size: clamp(10px, 1.9vh, 13px); line-height: 1.3; color: var(--ink-soft); word-break: keep-all; }
.rb-card:active { transform: scale(0.97); }
.rb-card.hint { animation: hint2 0.9s ease-in-out infinite alternate; }
@keyframes hint2 { to { border-color: #ffd27a; box-shadow: 0 0 18px #ffd27a; } }
.rb-card.wrong { animation: shake 0.4s ease; border-color: #c9473a; }
.rb-card.picked { border-color: #4f9a4b; box-shadow: 0 0 16px rgba(111, 211, 106, 0.8); transform: translateY(-6px); }

/* ---------- episodes 5-6 ---------- */
.hub { z-index: 26; padding-top: var(--top-h); background: rgba(16, 10, 6, 0.72); }
.hub-panel { width: min(94%, 1000px); }
.hb-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(6px, 1.2vw, 14px); margin-top: 0.6vh; }
.hb-card img.face { object-position: center top; background: #e6d6b4; }
.hb-card .hearts { color: var(--seal); letter-spacing: 1px; }
.hb-card.met { opacity: 0.45; }
.rhythm { background: #000; padding: 0; z-index: 28; }
.rh-crowd { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; z-index: 1; pointer-events: none; --glow: 0; }
.rh-crowd img {
  position: absolute; left: 50%; bottom: calc(var(--k) * 4.5vh); width: 106%; max-width: none; height: clamp(100px, 24vh, 210px);
  object-fit: cover; object-position: center top;
  transform: translateX(-50%) scale(calc(1 - var(--k) * 0.06)); transform-origin: bottom center;
  filter: brightness(calc(0.62 + var(--glow) * 0.45 - var(--k) * 0.1)); z-index: calc(10 - var(--k));
}
.rh-phrase {
  position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); box-sizing: border-box;
  top: calc(var(--top-h) + clamp(50px, 10vh, 90px)); z-index: 3; margin: 0; padding: 0.08em 0.7em; border-radius: 14px;
  background: rgba(16, 10, 6, 0.62); text-align: center; font-family: var(--f-display); font-size: clamp(22px, 6.4vh, 52px); line-height: 1.3; color: #fff3dc;
  text-shadow: 0 2px 10px #000; word-break: keep-all;
}
.rh-phrase span { opacity: 0.7; transition: opacity 0.15s ease, color 0.15s ease; }
.rh-phrase span.on { opacity: 1; color: #ffd27a; }
.rh-phrase span.off { opacity: 0.3; }
.rhythm.speech .rh-phrase { font-family: var(--f-body); font-weight: 700; font-size: clamp(18px, 4.6vh, 36px); }
.rh-lane {
  position: absolute; left: 0; right: 0; top: 50%; height: clamp(56px, 13vh, 96px); z-index: 4; overflow: hidden;
  background: rgba(16, 10, 6, 0.74); border-top: 2px solid var(--brass); border-bottom: 2px solid var(--brass);
}
.rh-hit {
  position: absolute; left: 18%; top: 50%; width: clamp(48px, 11vh, 84px); aspect-ratio: 1; border-radius: 50%;
  border: 4px solid #ffd27a; transform: translate(-50%, -50%); box-shadow: 0 0 18px rgba(255, 210, 122, 0.6);
}
.rh-note {
  position: absolute; top: 50%; transform: translate(-50%, -50%); padding: 0.15em 0.6em; border-radius: 99px; white-space: nowrap;
  background: #f0e3c6; color: var(--ink); border: 3px solid var(--seal); font-family: var(--f-display); font-size: clamp(16px, 4vh, 30px);
}
.rh-note.perfect { background: #ffd27a; transform: translate(-50%, -50%) scale(1.25); transition: transform 0.15s ease, opacity 0.3s ease; }
.rh-note.good { background: #e9d7a8; transition: opacity 0.3s ease; }
.rh-note.miss { opacity: 0.35; filter: grayscale(1); }
.rh-mem {
  position: absolute; left: 50%; top: calc(50% + clamp(56px, 13vh, 96px) + 10px); transform: translateX(-50%); z-index: 2; margin: 0;
  width: clamp(140px, 24vw, 300px); border: 4px solid #c79b55; border-radius: 10px; overflow: hidden; box-shadow: 0 0 22px rgba(0, 0, 0, 0.7);
}
.rh-mem img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; filter: sepia(0.35); }
.rh-mem.pop { animation: evpop 0.4s ease-out both; }
.rhythm .ch-msg { z-index: 5; }
.rhythm .ins-brief { z-index: 6; }
.rh-phrase:empty { display: none; }
.hope { z-index: 45; background: radial-gradient(ellipse at center, #3a2a18 0%, #120c08 72%); }
.hp-row { position: relative; width: min(92%, 900px); height: clamp(140px, 38vh, 320px); }
.hp-row img {
  position: absolute; top: 0; height: 100%; width: auto; max-width: none; left: calc(var(--k) * 19%);
  transition: left 1.2s ease, transform 1.2s ease, opacity 1.2s ease;
}
.hope.gather .hp-row img { left: 40%; transform: rotate(calc((var(--k) - 2) * 7deg)) scale(0.8); opacity: 0; }
.hp-card {
  position: absolute; left: 50%; top: 46%; height: clamp(170px, 46vh, 380px); width: auto; max-width: none;
  transform: translate(-50%, -50%); animation: evpop 0.6s ease-out both; filter: drop-shadow(0 0 30px rgba(255, 210, 122, 0.7));
}
.hp-text {
  position: absolute; left: var(--gut-l); right: var(--gut-r); bottom: calc(var(--gut-b) + clamp(34px, 8vh, 64px)); margin: 0;
  text-align: center; font-family: var(--f-display); font-size: clamp(18px, 4.6vh, 36px); color: #ffe7c2; word-break: keep-all;
}
.chase.night .ch-map { filter: brightness(0.5) contrast(1.1) saturate(0.7); }

/* ---------- episode 6 mini-games (visual cues only: no sound) ---------- */
.mimeo, .signal, .formation { background: #000; padding: 0; z-index: 28; -webkit-touch-callout: none; }
.mimeo .ins-brief, .signal .ins-brief, .formation .ins-brief { z-index: 8; }
.mm-bg { filter: brightness(0.5); }
.mm-stage {
  position: absolute; left: 50%; top: calc(var(--top-h) + clamp(48px, 10vh, 80px)); transform: translateX(-50%); z-index: 2;
  width: min(86vw, calc((100vh - var(--top-h) - clamp(130px, 28vh, 220px)) * 1.44)); aspect-ratio: 900 / 627; touch-action: none; cursor: grab;
}
.mm-frame { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; }
.mm-sheet { position: absolute; left: 14%; right: 14%; top: 15%; bottom: 15%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.mm-text {
  margin: 0; display: flex; flex-direction: column; gap: 0.15em; color: #1c140e; opacity: 0.32; font-family: var(--f-body); font-weight: 700;
  font-size: clamp(10px, 2.3vh, 18px); line-height: 1.35; word-break: keep-all; transition: opacity 0.3s ease, filter 0.3s ease;
}
.mm-text b { font-size: 1.12em; margin-bottom: 0.2em; }
.mm-sheet.printed .mm-text { opacity: 1; }
.mm-sheet.faint .mm-text { opacity: 0.12; }
.mm-sheet.smudge .mm-text { opacity: 0.85; filter: blur(2px); }
.mm-roller { position: absolute; top: 50%; left: 14%; width: 17%; height: auto; max-width: none; transform: translate(-50%, -50%) rotate(-90deg); pointer-events: none; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6)); }
.mm-roller.ready { animation: rollhint 0.8s ease-in-out infinite alternate; }
@keyframes rollhint { to { filter: drop-shadow(0 0 14px #ffd27a); margin-left: 2%; } }
.mm-meter {
  position: absolute; left: 50%; bottom: calc(var(--gut-b) + clamp(40px, 9vh, 64px)); transform: translateX(-50%); z-index: 3;
  width: min(80%, 460px); height: 18px; display: flex; align-items: center; justify-content: space-between; border-radius: 99px;
  background: linear-gradient(90deg, #c9473a 0 16%, #e3bd72 16% 22%, #6fd36a 22% 70%, #e3bd72 70% 76%, #c9473a 76% 100%);
  font-size: 11px; font-weight: 900; color: #fff; padding: 0 8px; box-sizing: border-box;
}
.mm-meter .mm-ok { display: none; }
.mm-meter b { position: absolute; top: -6px; width: 4px; height: 30px; margin-left: -2px; background: #fff; box-shadow: 0 0 6px #000; border-radius: 2px; }
.mm-warn {
  position: absolute; inset: var(--top-h) 0 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(6px, 1.6vh, 14px); background: rgba(40, 6, 4, 0.82); color: #fff3dc; text-align: center;
}
.mm-warn img { height: clamp(70px, 20vh, 150px); width: auto; animation: steps 0.6s ease-in-out infinite alternate; }
@keyframes steps { from { transform: translateY(-6px) rotate(-6deg); } to { transform: translateY(6px) rotate(6deg); } }
.mm-warn b { font-family: var(--f-display); font-size: clamp(24px, 6vh, 46px); color: #ffd27a; }
.mm-warn span { font-weight: 700; font-size: clamp(14px, 3vh, 22px); }
.mm-warn-time { width: min(60%, 320px); height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.mm-warn-time span { display: block; height: 100%; width: 100%; background: #c9473a; }
.mimeo.alarm .mm-bg { filter: brightness(0.25); }
.sg-cop {
  position: absolute; right: 6%; bottom: 0; height: 62%; width: auto; max-width: none; z-index: 2; transition: transform 0.3s ease, filter 0.3s ease;
  transform-origin: bottom center;
}
.signal[data-cop="away"] .sg-cop { transform: scaleX(-1); filter: brightness(0.45) saturate(0.5); }
.signal[data-cop="turn"] .sg-cop { filter: brightness(0.8); }
.signal[data-cop="look"] .sg-cop { filter: drop-shadow(0 0 22px rgba(201, 71, 58, 0.95)); }
.sg-look {
  position: absolute; left: 50%; top: calc(var(--top-h) + clamp(46px, 9vh, 72px)); transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 6px 18px; border-radius: 12px; font-weight: 900; font-size: clamp(15px, 3.4vh, 26px);
  background: rgba(16, 10, 6, 0.8); color: #9fe39a; border: 2px solid #4f9a4b; white-space: nowrap;
}
.sg-look img { height: 1.6em; width: auto; opacity: 0.35; }
.signal[data-cop="turn"] .sg-look { color: #ffd27a; border-color: #e3bd72; }
.signal[data-cop="look"] .sg-look { color: #ffb4a8; border-color: #c9473a; background: rgba(90, 14, 8, 0.85); animation: pulse 0.6s ease infinite alternate; }
.signal[data-cop="look"] .sg-look img { opacity: 1; }
.signal.hit { animation: shake 0.4s ease; }
.sg-track {
  position: absolute; left: 8%; right: 30%; bottom: calc(var(--gut-b) + clamp(46px, 10vh, 70px)); height: clamp(16px, 3.4vh, 26px); z-index: 3;
  border-radius: 99px; background: rgba(16, 10, 6, 0.75); border: 2px solid var(--brass); overflow: visible;
}
.sg-track span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #a77b3c, #e3bd72); transition: width 0.2s ease; }
.sg-track i { position: absolute; right: 0; top: -1.6em; font-style: normal; font-weight: 900; font-size: clamp(11px, 2.2vh, 15px); color: #ffd27a; }
.sg-bell {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: clamp(8px, 2vh, 18px) clamp(16px, 3vw, 32px); border-radius: 16px; background: rgba(16, 10, 6, 0.86); border: 3px solid #ffd27a;
  animation: evpop 0.3s ease-out both;
}
.sg-bell img { height: clamp(70px, 20vh, 150px); width: auto; animation: ring 0.25s ease-in-out infinite alternate; }
@keyframes ring { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
.sg-bell b { font-family: var(--f-display); font-size: clamp(20px, 5vh, 40px); color: #ffd27a; }
.formation { touch-action: none; }
.fm-police {
  position: absolute; left: 50%; top: calc(var(--top-h) + clamp(60px, 13vh, 110px)); width: 112%; height: auto; max-width: none; z-index: 2;
  transform: translateX(-50%) scale(0.58); transform-origin: top center; transition: transform 0.4s ease; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.7));
}
.fm-police.push { transform: translateX(-50%) scale(0.84); }
.formation.shake { animation: shake 0.5s ease infinite; }
.formation.step .fm-row { animation: rise 0.25s ease; }
.fm-road {
  position: absolute; left: 10%; right: 10%; top: calc(var(--top-h) + clamp(44px, 9vh, 70px)); height: clamp(12px, 2.6vh, 20px); z-index: 4;
  border-radius: 99px; background: rgba(16, 10, 6, 0.75); border: 2px solid var(--brass);
}
.fm-road span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #6fd36a, #e3bd72); transition: width 0.25s ease; }
.fm-road i { position: absolute; right: -4px; top: 130%; font-style: normal; font-weight: 900; font-size: clamp(11px, 2.2vh, 15px); color: #ffd27a; white-space: nowrap; }
.fm-banner {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 5; margin: 0; padding: 0.2em 0.8em; border-radius: 14px;
  font-family: var(--f-display); font-size: clamp(20px, 5.4vh, 44px); white-space: nowrap; color: #fff;
}
.fm-banner:empty { display: none; }
.fm-banner.push { background: rgba(140, 20, 12, 0.88); border: 3px solid #ffb4a8; }
.fm-banner.gap { background: rgba(30, 90, 30, 0.88); border: 3px solid #9fe39a; animation: pulse 0.5s ease infinite alternate; }
.fm-chant {
  position: absolute; left: 50%; top: 60%; transform: translateX(-50%); z-index: 5; margin: 0; max-width: calc(100% - 32px); padding: 0.1em 0.7em;
  border-radius: 12px; background: rgba(16, 10, 6, 0.7); font-family: var(--f-display); font-size: clamp(16px, 4vh, 32px); color: #ffd27a; text-align: center;
}
.fm-chant:empty { display: none; }
.fm-hold {
  position: absolute; left: 50%; top: calc(46% + clamp(30px, 6vh, 50px)); transform: translateX(-50%); z-index: 5;
  width: min(60%, 360px); height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden;
}
.fm-hold span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #e3bd72, #6fd36a); }
.fm-row {
  position: absolute; left: 50%; bottom: calc(var(--gut-b) + clamp(30px, 7vh, 54px)); transform: translateX(-50%); z-index: 4;
  display: flex; gap: clamp(4px, 1vw, 10px);
}
.fm-row figure { margin: 0; width: clamp(48px, 10vh, 86px); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fm-row img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 3px solid #ffd27a; background: #e6d6b4; }
.fm-row figure.face img { object-position: center top; }
.fm-row figcaption { font-weight: 900; font-size: clamp(10px, 2vh, 14px); color: #fff3dc; text-shadow: 0 1px 4px #000; }

/* ---------- ending: lights map and ending screen ---------- */
.lights { z-index: 30; padding: var(--top-h) 0 0; background: #07050a; }
.lt-wrap { width: 100%; height: 100%; box-sizing: border-box; display: flex; align-items: center; gap: clamp(8px, 1.4vw, 16px); padding: 6px var(--gut-r) var(--gut-b) var(--gut-l); }
.lt-map {
  position: relative; flex: none; aspect-ratio: 1672 / 941;
  width: min(calc(100% - clamp(200px, 27vw, 340px)), calc((100vh - var(--top-h) - 20px) * 1672 / 941));
}
.lt-img { display: block; width: 100%; height: 100%; max-width: none; border-radius: 8px; filter: brightness(0.7); transition: filter 1.8s ease; }
.lights.dawn .lt-img { filter: brightness(1.3) sepia(0.25); }
.lt-dots { position: absolute; inset: 0; pointer-events: none; }
.lt-dot { position: absolute; transform: translate(-50%, -50%); --s: clamp(10px, 2.2vh, 18px); }
.lt-dot i {
  display: block; width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle, #fff7d6 0%, #ffd27a 42%, rgba(255, 170, 40, 0) 74%);
  box-shadow: 0 0 calc(var(--s) * 1.6) calc(var(--s) * 0.6) rgba(255, 190, 80, 0.65);
  animation: lightpop 0.6s ease-out both, flicker 2.4s ease-in-out 0.6s infinite alternate;
}
.lt-dot.others i { background: radial-gradient(circle, #ffffff 0%, #dbe6ff 42%, rgba(160, 190, 255, 0) 74%); box-shadow: 0 0 calc(var(--s) * 1.4) calc(var(--s) * 0.5) rgba(190, 210, 255, 0.55); }
.lt-dot.big { --s: clamp(16px, 3.4vh, 28px); }
.lt-dot span { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); font-weight: 900; font-size: clamp(9px, 1.8vh, 12px); color: #f3e0b8; text-shadow: 0 1px 3px #000; white-space: nowrap; }
@keyframes lightpop { from { transform: scale(0); opacity: 0; } 60% { transform: scale(1.9); opacity: 1; } }
@keyframes flicker { to { opacity: 0.72; } }
.lights.dawn .lt-dot i { animation: dawnglow 1.8s ease forwards; }
@keyframes dawnglow { to { transform: scale(2.6); } }
.lt-year { position: absolute; left: 2%; top: 2%; margin: 0; font-family: var(--f-display); font-size: clamp(22px, 6vh, 48px); color: #ffd27a; text-shadow: 0 2px 8px #000; }
.lt-dawn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; font-family: var(--f-display); font-size: clamp(20px, 5.4vh, 42px); color: #fff3dc; text-shadow: 0 2px 12px #000; white-space: nowrap; animation: fade 1.2s ease both; }
.lt-dawn:empty { display: none; }
.lt-side { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.lt-count { margin: 0; font-weight: 900; font-size: clamp(11px, 2.2vh, 15px); color: #f3e0b8; }
.lt-card {
  box-sizing: border-box; display: flex; flex-direction: column; gap: clamp(3px, 0.8vh, 8px); color: var(--ink); overflow: auto;
  max-height: calc(100vh - var(--top-h) - 60px); border-style: solid; border-width: var(--dlg-bw);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / var(--dlg-bw) stretch; padding: clamp(4px, 1vh, 10px) clamp(8px, 1.4vw, 14px);
}
.lt-card.in { animation: rise 0.35s ease both; }
.lt-kind { margin: 0; font-weight: 900; font-size: clamp(10px, 2vh, 13px); color: #8a5a10; }
.lt-card.others .lt-kind { color: #3f5f8a; }
.lt-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; }
.lt-card img.face { object-position: center top; background: #e6d6b4; }
.lt-card h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(16px, 3.6vh, 26px); line-height: 1.25; }
.lt-text { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(12px, 2.5vh, 17px); line-height: 1.55; word-break: keep-all; }
.lt-card .btn { align-self: center; }
.lt-card .btn:disabled { filter: grayscale(0.7) brightness(0.85); cursor: default; }
.lt-read { height: 6px; border-radius: 99px; background: rgba(43, 29, 19, 0.15); overflow: hidden; }
.lt-read span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a77b3c, #e3bd72); }
.finale { z-index: 46; padding: var(--top-h) 0 0; background: #000; }
.fn-bg { filter: brightness(0.32); }
.fn-panel { position: relative; z-index: 1; display: flex; align-items: center; gap: clamp(12px, 3vw, 36px); width: min(94%, 1100px); }
.fn-card { flex: none; height: clamp(170px, 56vh, 460px); width: auto; max-width: none; filter: drop-shadow(0 0 30px rgba(255, 210, 122, 0.6)); animation: evpop 0.6s ease-out both; }
.fn-body { flex: 1; min-width: 0; max-height: calc(100vh - var(--top-h) - 24px); overflow: auto; display: flex; flex-direction: column; gap: clamp(4px, 1vh, 10px); color: #fff3dc; }
.fn-title { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 7vh, 56px); line-height: 1.15; color: #ffd27a; }
.fn-name { margin: 0; font-family: var(--f-display); font-size: clamp(18px, 4vh, 30px); }
.fn-line { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.6vh, 19px); color: #e8d5b0; }
.fn-body h3 { margin: 4px 0 0; font-size: clamp(12px, 2.4vh, 16px); color: #ffd27a; }
.fn-beliefs { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: clamp(11px, 2.2vh, 15px); }
.fn-beliefs li { display: flex; gap: 10px; }
.fn-beliefs b { flex: none; min-width: 15em; }
.fn-beliefs span { color: #e8d5b0; }
.fn-lights, .fn-count { margin: 0; font-weight: 700; font-size: clamp(12px, 2.4vh, 16px); line-height: 1.5; word-break: keep-all; }
.fn-last { margin: 4px 0; font-family: var(--f-display); font-size: clamp(18px, 4.4vh, 34px); line-height: 1.3; color: #fff; word-break: keep-all; }
.fn-hints { margin: 0; padding-left: 1.2em; font-size: clamp(11px, 2.2vh, 14px); color: #cdb98f; }
.fn-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- chase mini-game (top-down alley map) ---------- */
.chase { background: #0c0806; padding: var(--top-h) 0 0; z-index: 28; }
.ch-box { position: relative; width: min(100%, calc((100vh - var(--top-h)) * 16 / 9)); aspect-ratio: 16 / 9; max-height: calc(100vh - var(--top-h)); }
.ch-map { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.chase.danger .ch-box { box-shadow: inset 0 0 0 6px rgba(201, 71, 58, 0.75); }
.ch-nodes { position: absolute; inset: 0; }
.ch-node {
  position: absolute; transform: translate(-50%, -50%); width: clamp(16px, 3.6vh, 30px); aspect-ratio: 1; padding: 0;
  border-radius: 50%; border: 2px solid rgba(255, 241, 216, 0.55); background: rgba(16, 10, 6, 0.45); cursor: default;
}
.ch-node span {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 3px; white-space: nowrap;
  padding: 0 6px; border-radius: 6px; background: rgba(16, 10, 6, 0.8); color: #fff1d8;
  font-weight: 700; font-size: clamp(10px, 2vh, 14px); line-height: 1.5;
}
.ch-node.hide { border-color: #8fd18f; }
.ch-node.dead { border-color: #c9473a; }
.ch-node.dead span { background: rgba(140, 30, 25, 0.85); }
.ch-node.goal { width: clamp(24px, 5.4vh, 44px); border-color: #ffd27a; background: rgba(255, 210, 122, 0.35); }
.ch-node.can {
  cursor: pointer; border-color: #ffd27a; background: rgba(255, 210, 122, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 210, 122, 0.35), 0 0 18px rgba(255, 210, 122, 0.8); animation: glow 1s ease-in-out infinite alternate;
}
@keyframes glow { to { box-shadow: 0 0 0 7px rgba(255, 210, 122, 0.15), 0 0 24px rgba(255, 210, 122, 0.9); } }
.ch-token {
  position: absolute; transform: translate(-50%, -62%); width: clamp(34px, 8.5vh, 66px); aspect-ratio: 1; pointer-events: none;
  border-radius: 50%; overflow: hidden; border: 3px solid #fff1d8; background: #2b1d13; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transition: left 0.25s ease, top 0.25s ease;
}
.ch-token img { width: 100%; height: 280%; max-width: none; object-fit: cover; object-position: 50% 0; }
.ch-token.det { border-color: #c9473a; }
.ch-token.det.lost { opacity: 0.75; }
.ch-token i {
  position: absolute; right: -2px; top: -2px; width: 1.3em; height: 1.3em; border-radius: 50%; background: #ffd27a; color: var(--ink);
  font-style: normal; font-weight: 900; font-size: clamp(11px, 2.2vh, 16px); display: grid; place-items: center;
}
.ch-head {
  position: absolute; top: calc(var(--top-h) + 6px); left: 50%; transform: translateX(-50%); z-index: 2; pointer-events: none;
  display: flex; gap: 14px; align-items: baseline; padding: 6px 18px; border-radius: 10px;
  background: rgba(16, 10, 6, 0.85); border: 1px solid var(--brass); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); white-space: nowrap;
}
.ch-head b { font-family: var(--f-display); font-weight: 400; font-size: 1.3em; }
.ch-head span { color: #f0a48f; }
.ch-tools { position: absolute; right: var(--gut-r); bottom: calc(var(--gut-b) + 4px); z-index: 2; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.ch-tools .btn { font-size: clamp(13px, 2.8vh, 19px); }
.ch-tools .btn.on { filter: brightness(1.15) saturate(1.4); }
.ch-msg {
  position: absolute; left: var(--gut-l); bottom: calc(var(--gut-b) + 4px); margin: 0; z-index: 2; max-width: 55%; pointer-events: none;
  padding: 6px 14px; border-radius: 10px; background: rgba(16, 10, 6, 0.85);
  font-weight: 900; font-size: clamp(13px, 2.7vh, 19px); color: #ffd27a; word-break: keep-all;
}
.ch-msg:empty { display: none; }

/* ---------- interrogation mini-game ---------- */
.interro { background: #000; padding: 0; z-index: 28; }
.interro.shake { animation: shake 0.45s ease; }
.it-bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; filter: brightness(0.75); }
.it-det {
  position: absolute; left: 50%; bottom: 0; height: 88%; width: auto; max-width: none;
  transform-origin: bottom center; transform: translateX(-50%) scale(var(--near, 0.8)); transition: transform 0.6s ease;
  filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.9));
}
.it-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.it-flash.on { animation: itflash 0.45s ease-out; }
@keyframes itflash { 0% { opacity: 0.85; background: #fff; } 40% { background: #8a1f17; opacity: 0.35; } 100% { opacity: 0; } }
.it-time { position: absolute; top: calc(var(--top-h) + clamp(50px, 9vh, 70px)); left: 25%; right: 25%; height: 8px; border-radius: 99px; background: rgba(0, 0, 0, 0.5); overflow: hidden; }
.it-time span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #c9473a, #e3bd72); }
.it-box {
  position: absolute; left: var(--gut-l); right: var(--gut-r); bottom: var(--gut-b); min-height: var(--dlg-min); box-sizing: border-box;
  max-width: var(--dlg-maxw); margin: 0 auto;
  border-style: solid; border-width: var(--dlg-bw);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / var(--dlg-bw) stretch;
  padding: var(--dlg-pad) clamp(10px, 2.2vw, 26px); color: var(--ink);
}
.it-q { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: var(--dlg-font); line-height: 1.5; word-break: keep-all; }
.it-opts {
  position: absolute; left: var(--gut-l); right: var(--gut-r); bottom: calc(var(--gut-b) + var(--dlg-min) + 8px);
  display: flex; flex-direction: column; align-items: center; gap: clamp(6px, 1.4vh, 12px);
}
.it-opts .btn { width: min(100%, 26em); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 var(--gut-r) 0 var(--gut-l);
  box-sizing: border-box;
  background: var(--shade);
  animation: fade 0.3s ease both;
}
@keyframes fade { from { opacity: 0; } }
.tap-hint {
  position: absolute; bottom: calc(var(--gut-b) + 4px); left: 0; right: 0; margin: 0;
  text-align: center; font-weight: 500; font-size: clamp(11px, 2vh, 14px); color: #cdb98f;
  animation: blink 1.4s steps(2) infinite;
}

/* history notes & perks */
.note-panel {
  box-sizing: border-box; display: flex; gap: clamp(12px, 3vw, 32px); align-items: center;
  width: fit-content; max-width: min(94%, 980px); max-height: 82vh;
  border-style: solid; border-width: clamp(12px, 2.4vh, 22px);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / clamp(12px, 2.4vh, 22px) stretch;
  padding: clamp(4px, 1.4vh, 14px) clamp(8px, 1.8vw, 20px);
  color: var(--ink); animation: rise 0.35s ease both;
}
.note-img { flex: none; width: 42%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }
.note-img.icon { width: 24%; aspect-ratio: 1; object-fit: contain; box-shadow: none; }
.note-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.8vh; overflow: auto; max-height: calc(82vh - 6vh); }
.note-kicker { margin: 0; font-weight: 700; font-size: clamp(11px, 2.2vh, 15px); color: var(--seal); letter-spacing: 0.06em; }
.note-title { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(20px, 4.8vh, 36px); line-height: 1.2; }
.note-text { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(14px, 3vh, 21px); line-height: 1.7; word-break: keep-all; }
.ns-read {
  position: absolute; left: 50%; bottom: calc(var(--gut-b) + clamp(24px, 5vh, 34px)); transform: translateX(-50%);
  width: min(60%, 360px); height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); overflow: hidden;
}
.ns-read span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a77b3c, #e3bd72); }
.tap-hint.wait { animation: none; color: #e3bd72; }
.note-saved { margin: 0.6vh 0 0; font-weight: 500; font-size: clamp(11px, 2.1vh, 14px); color: var(--ink-soft); }

/* bag */
.bag { z-index: 40; }
.bag-panel { width: min(94%, 980px); align-items: stretch; flex-direction: column; gap: 1.2vh; height: min(80vh, 660px); }
#noteshow .note-panel { width: min(94%, 900px); }
.bag-tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid rgba(43, 29, 19, 0.2); padding-bottom: 8px; }
.bag-tabs button {
  background: none; border: 0; border-radius: 8px; padding: 6px 12px;
  font-weight: 700; font-size: clamp(12px, 2.5vh, 17px); color: var(--ink-soft);
}
.bag-tabs button.on { background: var(--ink); color: #f3e0b8; }
.bag-body { flex: 1; min-height: 0; overflow: auto; display: flex; gap: clamp(10px, 2vw, 24px); }
.bag-close { margin-top: 1.6vh; }
.bag-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bag-col h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(16px, 3.4vh, 24px); }
.row { display: flex; align-items: center; gap: 10px; font-size: clamp(13px, 2.7vh, 19px); }
.row img { height: 2em; width: 2em; object-fit: contain; flex: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-h { display: flex; align-items: baseline; gap: 10px; }
.row-h b { font-weight: 900; }
.row-v { font-weight: 900; color: var(--seal); font-variant-numeric: tabular-nums; }
.row small { color: var(--ink-soft); font-weight: 500; font-size: 0.82em; line-height: 1.35; }
.hearts { color: var(--seal); letter-spacing: 1px; }
.empty { color: var(--ink-soft); font-size: clamp(13px, 2.6vh, 18px); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; align-content: start; }
.item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 8px; background: rgba(43, 29, 19, 0.06); border: 0; color: var(--ink); }
.item img { height: clamp(44px, 10vh, 80px); width: auto; }
.item b { font-weight: 700; font-size: clamp(12px, 2.4vh, 16px); }
.item.on { background: rgba(178, 58, 46, 0.14); }
.item-desc { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.7vh, 19px); line-height: 1.6; }
.quest { display: flex; gap: 10px; align-items: baseline; font-size: clamp(13px, 2.7vh, 19px); }
.quest.done { color: var(--ink-soft); text-decoration: line-through; }
.quest::before { content: "□"; }
.quest.done::before { content: "■"; color: var(--seal); text-decoration: none; }
.bag .ci-row { margin: 0; justify-content: center; }
.bag .ci-item { width: clamp(56px, 13vw, 140px); }
.bag .ci-item span { color: var(--ink); }
.notes-list { flex: none; width: 30%; display: flex; flex-direction: column; gap: 6px; overflow: auto; border-right: 1px solid rgba(43, 29, 19, 0.2); padding-right: 10px; }
.notes-list button { text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 10px; font-weight: 500; font-size: clamp(12px, 2.5vh, 17px); color: var(--ink); line-height: 1.3; }
.notes-list button.on { background: rgba(178, 58, 46, 0.14); color: var(--seal); font-weight: 900; }

/* prologue slides */
.slide { background: #000; padding: 0; }
.sl-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover;
  filter: brightness(0.5) saturate(0.85); transition: opacity 0.5s ease;
  animation: drift 16s ease-in-out infinite alternate;
}
.sl-char { position: absolute; bottom: 0; right: 6%; height: 90%; width: auto; max-width: none; filter: drop-shadow(0 0 24px rgba(0, 0, 0, 0.6)); animation: rise 0.6s ease both; }
.sl-text {
  position: relative; margin: 0 auto; max-width: min(84%, 30em);
  text-align: center; font-family: var(--f-body); font-weight: 700; font-size: clamp(18px, 4.8vh, 38px); line-height: 1.75;
  color: #fff6e4; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85); word-break: keep-all;
}
.slide.with-char .sl-text { margin: 0 auto 0 8%; max-width: 50%; text-align: left; }
.sl-text.voice { font-family: var(--f-display); font-weight: 400; color: #ffe2b0; }
.sl-text.voice::before { content: "“"; }
.sl-text.voice::after { content: "”"; }
.skip-btn {
  position: absolute; z-index: 30; top: max(10px, env(safe-area-inset-top, 0px)); right: var(--gut-r);
  background: rgba(16, 10, 6, 0.6); border: 1px solid rgba(255, 241, 216, 0.5); border-radius: 99px;
  padding: 6px 14px; font-weight: 700; font-size: clamp(12px, 2.3vh, 16px); color: #fff1d8;
}

/* day card */
.daycard { background: #0d0907; gap: 1vh; text-align: center; z-index: 31; }
.dc-img { height: min(34vh, 40vw); width: auto; border-radius: 8px; margin-bottom: 1vh; animation: rise 0.6s ease both; }
.dc-num { font-family: var(--f-display); font-size: clamp(54px, 17vh, 140px); color: var(--mist); line-height: 1; letter-spacing: 0.02em; }
.dc-date { font-weight: 700; font-size: clamp(14px, 3vh, 22px); color: var(--brass); }
.dc-place { font-family: var(--f-body); font-weight: 700; font-size: clamp(14px, 3vh, 22px); color: #d8c7a6; }

/* notebook */
.nb-wrap { position: relative; height: min(84vh, 56vw); aspect-ratio: 1482 / 992; max-width: 100%; }
.nb-wrap img { width: 100%; height: 100%; max-width: none; }
.nb-text {
  position: absolute; left: 54%; right: 8%; top: 14%; margin: 0;
  font-family: var(--f-hand); color: #2c2a4a; font-size: clamp(20px, 6vh, 46px); line-height: 1.25;
  word-break: keep-all; transform: rotate(-1.5deg);
}

/* cards intro / overview */
.cardsintro h2, .result h2 { font-family: var(--f-display); font-weight: 400; margin: 0; }
.cardsintro h2 { font-size: clamp(20px, 5vh, 38px); color: var(--mist); }
.ci-row { display: flex; gap: clamp(6px, 1.6vw, 20px); margin: 2.4vh 0; max-width: 100%; }
.ci-item { display: flex; flex-direction: column; align-items: center; gap: 1vh; width: clamp(64px, 15vw, 170px); animation: rise 0.45s ease both; }
.ci-item img { width: 100%; height: auto; border-radius: 6px; }
.ci-item span { font-weight: 700; font-size: clamp(11px, 2.3vh, 17px); text-align: center; word-break: keep-all; line-height: 1.3; }
.ci-item.broken img { filter: grayscale(0.9) brightness(0.7); }
.ci-item.broken span { text-decoration: line-through; opacity: 0.7; }
.ci-item button { background: none; border: 0; padding: 0; width: 100%; }
.ci-foot { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); color: #e6d4ae; }

/* card show (crack / break) */
.cardshow { flex-direction: row; gap: clamp(16px, 5vw, 60px); background: rgba(10, 6, 4, 0.86); }
.cs-card img { height: min(70vh, 60vw); width: auto; max-width: none; border-radius: 10px; }
.cs-card.shake img { animation: shake 0.5s ease 2; }
.cs-card.flash img { animation: breakflash 0.6s ease; }
@keyframes breakflash { 0% { filter: brightness(3); transform: scale(1.06); } }
.cs-text { max-width: min(46vw, 30em); display: flex; flex-direction: column; gap: 1.6vh; }
.cs-text p { margin: 0; }
.cs-label { font-family: var(--f-display); font-size: clamp(22px, 5.4vh, 42px); color: var(--mist); }
.cs-label.broken { text-decoration: line-through; text-decoration-color: var(--seal); text-decoration-thickness: 3px; color: #cdbd9c; }
.cs-truth { font-family: var(--f-body); font-weight: 700; font-size: clamp(16px, 3.6vh, 28px); color: #f2c98a; line-height: 1.5; word-break: keep-all; }
.cs-common { font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); color: #d8c7a6; line-height: 1.6; word-break: keep-all; }
.cs-text .reveal { animation: rise 0.6s ease both; }

/* belief view */
.beliefview { gap: 1.4vh; z-index: 45; }
.beliefview img { height: min(62vh, 55vw); width: auto; max-width: none; border-radius: 10px; }
.bv-label { margin: 0; font-family: var(--f-display); font-size: clamp(18px, 4.4vh, 32px); }
.bv-truth { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); color: #f2c98a; }

/* exam */
.exam {
  display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto 1fr;
  align-items: center; justify-items: center;
  padding-top: calc(var(--top-h) * 0.2); padding-bottom: var(--gut-b);
  background: rgba(12, 8, 5, 0.86); z-index: 32;
}
/* a memory flashes big in front of the exam sheet, then shrinks into a photo clipped to its corner */
.ex-mem {
  position: absolute; z-index: 3; margin: 0; left: 50%; top: 42%; width: 150%;
  transform: translate(-50%, -50%) rotate(0deg);
  padding: 2.2% 2.2% 0; background: #f4ead2; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.75);
  transition: left 0.55s ease, top 0.55s ease, width 0.55s ease, transform 0.55s ease, box-shadow 0.55s ease;
  animation: memin 0.35s ease-out both; pointer-events: none;
}
.ex-mem img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; filter: sepia(0.25); }
.ex-mem figcaption {
  font-family: var(--f-hand); color: #2c2a4a; text-align: center; line-height: 1.2;
  font-size: clamp(18px, 4.6vh, 36px); padding: 0.5em 0 0.4em;
}
.ex-mem.pinned { left: 21%; top: 9%; width: 46%; transform: translate(-50%, -50%) rotate(-6deg); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45); }
.ex-mem.pinned figcaption { font-size: clamp(9px, 1.7vh, 14px); padding: 0.25em 0 0.2em; }
.ex-mem.pinned::before {
  content: ""; position: absolute; left: 50%; top: -7%; width: 9%; height: 16%; transform: translateX(-50%);
  border-radius: 3px; background: linear-gradient(#c7c7c7, #8d8d8d); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
@keyframes memin { from { opacity: 0; transform: translate(-50%, -50%) scale(1.08); } }
.ex-paper { z-index: 2; }
.ex-head { grid-column: 1 / -1; display: flex; gap: 16px; align-items: baseline; padding-top: 1vh; }
.ex-part { font-family: var(--f-display); font-size: clamp(16px, 3.6vh, 28px); color: var(--mist); }
.ex-prog { font-weight: 700; font-size: clamp(12px, 2.4vh, 18px); color: var(--brass); font-variant-numeric: tabular-nums; }
.ex-paper { position: relative; grid-column: 2; height: min(80vh, 62vw); aspect-ratio: 669 / 900; }
.ex-paper-img { width: 100%; height: 100%; max-width: none; }
/* exam sheet zones: question 20–50%, stamp 53–79%, feedback 83–93% (no overlap at any size) */
.ex-q {
  position: absolute; left: 11%; right: 11%; top: 20%; height: 30%; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); color: var(--ink); text-align: center;
  font-size: clamp(15px, 3.8vh, 30px); line-height: 1.45; word-break: keep-all; white-space: pre-line;
}
.ex-stamp {
  position: absolute; top: 53%; height: 26%; width: auto; aspect-ratio: 1; left: 50%;
  max-width: none; object-fit: contain; mix-blend-mode: multiply;
  transform: translateX(-50%); animation: stamp 0.25s ease-out both;
}
@keyframes stamp { from { transform: translateX(-50%) scale(1.8) rotate(-8deg); opacity: 0; } }
.ex-feedback {
  position: absolute; left: 6%; right: 6%; top: 83%; height: 10%; margin: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 900; font-size: clamp(13px, 2.8vh, 22px); color: var(--seal);
}
.stamp-btn {
  grid-row: 2; width: clamp(80px, 22vh, 190px); aspect-ratio: 1; padding: clamp(8px, 2vh, 18px);
  border-radius: 50%; border: 2px dashed rgba(240, 227, 198, 0.55); background: rgba(240, 227, 198, 0.1);
  transition: transform 0.12s ease, background 0.2s;
}
.stamp-btn img { width: 100%; height: 100%; object-fit: contain; }
.stamp-btn:active { transform: scale(0.92); background: rgba(240, 227, 198, 0.25); }
.stamp-btn:disabled { opacity: 0.4; cursor: default; }
#btnO { grid-column: 1; }
#btnX { grid-column: 3; }
.ex-timer { position: absolute; top: max(10px, 2vh); right: calc(var(--gut-r) + 4px); width: clamp(54px, 14vh, 110px); aspect-ratio: 829 / 900; }
.ex-timer img { width: 100%; height: 100%; max-width: none; }
.ex-timer span {
  position: absolute; left: 0; right: 0; top: 56%; transform: translateY(-50%); text-align: center;
  font-family: var(--f-display); font-size: clamp(18px, 5vh, 40px); color: var(--seal); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px #fff7e6;
}
.ex-timer.hurry { animation: shake 0.5s ease infinite; }

/* result board */
.rs-paper {
  position: relative; box-sizing: border-box; width: min(92%, 860px); max-height: 88vh; overflow: auto;
  padding: clamp(14px, 3.6vh, 34px) clamp(16px, 4vw, 44px);
  border-style: solid; border-width: clamp(12px, 2.4vh, 22px);
  border-image: url("../assets/ui/ui_dialog.webp") 48 fill / clamp(12px, 2.4vh, 22px) stretch;
  color: var(--ink); animation: rise 0.4s ease both;
}
.result h2 { font-size: clamp(17px, 4vh, 30px); text-align: center; }
.rs-sub { margin: 0.6vh 0 1.6vh; text-align: center; font-weight: 700; font-size: clamp(12px, 2.4vh, 17px); color: var(--seal); }
.rs-table { width: 100%; border-collapse: collapse; font-weight: 500; font-size: clamp(13px, 2.8vh, 20px); font-variant-numeric: tabular-nums; }
.rs-table th, .rs-table td { padding: 0.7vh 8px; border-bottom: 1px solid rgba(43, 29, 19, 0.25); text-align: center; }
.rs-table th { font-weight: 500; color: var(--ink-soft); }
.rs-table td:first-child, .rs-table th:first-child { text-align: left; }
.rs-table tr.me td { background: rgba(178, 58, 46, 0.12); font-weight: 900; }
.rs-table tr.jp td { background: rgba(199, 155, 85, 0.16); }
.rs-table .best { color: var(--seal); }
.rs-table .best::after { content: " 최고"; font-size: 0.7em; }
.rs-note { margin: 1.4vh 0 0; font-weight: 500; font-size: clamp(11px, 2.2vh, 15px); color: var(--ink-soft); line-height: 1.5; }

/* end screen */
.endscreen {
  flex-direction: row; gap: clamp(14px, 3vw, 40px); background: rgba(10, 6, 4, 0.94); z-index: 32;
  padding-top: max(10px, env(safe-area-inset-top, 0px)); padding-bottom: var(--gut-b);
}
.es-left img { height: min(62vh, 30vw); width: auto; max-width: none; border-radius: 10px; }
.es-right {
  max-width: min(60vw, 40em); max-height: calc(100% - 8px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 1vh; padding-right: 4px;
}
.es-kicker { margin: 0; font-weight: 700; color: var(--brass); font-size: clamp(12px, 2.4vh, 17px); letter-spacing: 0.1em; }
.es-title { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(22px, 5.6vh, 44px); text-decoration: line-through; text-decoration-color: var(--seal); }
.es-stats {
  margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4vh 18px; font-weight: 500; font-size: clamp(11px, 2.3vh, 16px);
}
.es-stats li { display: flex; gap: 8px; min-width: 0; }
.es-stats b { color: #e9d3a6; font-weight: 700; flex: none; min-width: 5.5em; }
.es-stats span { min-width: 0; overflow-wrap: anywhere; }
.es-ask, .es-next { display: flex; flex-direction: column; gap: 0.4vh; font-weight: 500; font-size: clamp(12px, 2.5vh, 18px); line-height: 1.5; word-break: keep-all; }
.es-ask b, .es-next b { color: var(--brass); font-weight: 700; }
.es-btns { display: flex; gap: 12px; flex-wrap: wrap; }

/* title */
.title { background: #000; justify-content: flex-start; padding: 0; z-index: 50; }
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; animation: drift 24s ease-in-out infinite alternate; }
@keyframes drift { to { transform: scale(1.06); } }
.title-logo { position: relative; margin-top: 7vh; text-align: center; text-shadow: 0 2px 18px rgba(80, 30, 10, 0.55); }
.title-kicker { margin: 0; font-family: var(--f-body); font-weight: 700; font-size: clamp(14px, 3.4vh, 26px); color: #fff1d8; letter-spacing: 0.12em; }
.title-name { margin: 0.6vh 0; font-family: var(--f-display); font-weight: 400; font-size: clamp(38px, 12vh, 112px); line-height: 1.12; color: #fff7ea; letter-spacing: 0.02em; }
.title-sub { margin: 0.4vh 0 0; font-weight: 700; font-size: clamp(13px, 2.8vh, 20px); color: #ffe7c2; }
.title-actions { position: relative; margin-top: auto; margin-bottom: 7vh; display: flex; flex-direction: column; align-items: center; gap: 1.2vh; }
.btn-big { font-size: clamp(17px, 4vh, 28px); padding: 0 clamp(20px, 4vw, 44px); min-width: 8em; }
.title-row { display: flex; gap: 10px; }
.chapter-list { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chapter-list .btn { font-size: clamp(14px, 3vh, 20px); }
.btn-plain { background: rgba(16, 10, 6, 0.55); border: 1px solid rgba(255, 241, 216, 0.5); border-radius: 99px; padding: 6px 16px; font-weight: 700; font-size: clamp(12px, 2.3vh, 16px); color: #fff1d8; }
.title-ep { position: absolute; left: var(--gut-l); bottom: var(--gut-b); margin: 0; font-weight: 700; font-size: clamp(11px, 2.1vh, 15px); color: #ffe7c2; text-shadow: 0 1px 6px #000; }

/* loading */
.loading { background: var(--night); gap: 2vh; animation: none; z-index: 60; }
.ld-name { margin: 0; font-family: var(--f-display); font-size: clamp(26px, 7vh, 60px); color: var(--mist); text-align: center; }
.ld-bar { margin: 0; width: min(60vw, 360px); height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 99px; overflow: hidden; }
.ld-bar span { display: block; height: 100%; width: 0; background: var(--brass); transition: width 0.2s; }
.ld-text { margin: 0; font-weight: 500; font-size: 14px; color: #cdb98f; }

/* portrait: ask to rotate */
.rotate {
  display: none; position: absolute; inset: 0; z-index: 70;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--night); text-align: center; padding: 0 24px;
}
.rotate img { width: min(56vw, 300px); height: auto; }
.rotate p { margin: 0; font-weight: 700; font-size: 18px; color: var(--mist); }
@media (orientation: portrait) and (max-width: 900px) {
  .rotate { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- short screens (phones in landscape): compact panels ---------- */
@media (max-height: 520px) {
  .split-panel .note-kicker { display: none; }
  .split-panel .note-title { font-size: 18px; }
  .split-panel .note-body { gap: 4px; }
  .sp-ledger { display: none; }
  .sp-short { display: block; }
  .sp-bin { padding: 3px 6px; }
  .sp-bin small { display: none; }
  .sp-ctrl span { font-size: 22px; }
  .sp-warn { font-size: 12px; }
  .split-panel .fi-go { margin-top: 2px; }
  .free-panel .note-kicker { display: none; }
  .free-panel .note-title { font-size: 18px; }
  .free-panel .fi-text { display: none; }
  .free-panel .note-body { gap: 4px; }
  .fi-spot { padding: 3px 8px; }
  .fi-extra { padding: 3px 10px; font-size: 12px; }
  .rb-card small { display: none; }
  .rb-card { padding: 3px; gap: 1px; }
  .rb-card b { font-size: 11px; }
  .rb-list li:not(.cur) { display: none; }
  .rb-list { font-size: 17px; line-height: 1.6; }
  .rb-res { font-size: 13px; }
  .rb-ev-imgs img { max-height: 40vh; }
  .rb-ev-why { font-size: 13px; }
  .ab-tool { display: none; }
  .hub-panel .fi-text { display: none; }
  .hb-card small:not(.hearts) { display: none; }
  .rh-phrase { font-size: 20px; }
  .rhythm.speech .rh-phrase { font-size: 15px; }
  .rh-note { font-size: 15px; }
  .mm-text { font-size: 9px; }
  .fm-banner { font-size: 18px; }
  .sg-look { font-size: 14px; }
  .lt-card img { display: none; }
  .lt-text { font-size: 11px; line-height: 1.45; }
  .fn-card { height: 46vh; }
  .fn-beliefs li { display: block; }
  .fn-beliefs b { min-width: 0; margin-right: 6px; }
}
