/* =============================================================
   style.css — 화면 꾸미기
   색을 바꾸고 싶으면 아래 :root 의 값만 고치면 됩니다.
   ============================================================= */
:root {
  --bg: #0b0a12;
  --panel: rgba(22, 19, 40, 0.94);
  --panel-solid: #16132a;
  --line: #e8d9a8;
  --text: #f6f1e3;
  --muted: #b3ab98;
  --accent: #e8b04a;
  --sel: #3b3366;
  --hp: #58c46a;
  --mp: #5a9be8;
  --gauge: #e8708e;
  --danger: #e05050;
  --u: 3;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;   /* 휴대폰에서 화면을 당겨 새로고침되지 않게 */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

#game {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#stage {
  position: relative;
  width: min(100vw, 177.78vh);
  aspect-ratio: 16 / 9;
  max-width: 100%;
  background: #000;
  overflow: hidden;
}
#screen {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#fade {
  position: absolute; inset: 0; pointer-events: none;
  background: #000; opacity: 0;
}

/* ---------------- 글자 UI ---------------- */
#ui {
  position: absolute; inset: 0;
  pointer-events: none;
  font-size: clamp(11px, calc(var(--u) * 5.4px), 24px);
  line-height: 1.45;
}
#ui > * { pointer-events: auto; }

.dialog {
  position: absolute; left: 3%; right: 3%; bottom: 3.5%;
  min-height: 27%;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 0.75em 1em 0.9em;
  box-shadow: 0 0 0 2px #000, 0 6px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.dialog .name {
  position: absolute; top: -0.95em; left: 0.8em;
  background: var(--accent); color: #1a1420;
  padding: 0.05em 0.6em; border-radius: 4px;
  font-weight: 700; font-size: 0.9em;
}
.dialog .text { white-space: pre-wrap; word-break: keep-all; }
/* 초상화가 있는 대사: 왼쪽에 그림, 글자는 오른쪽으로 */
.dialog .face {
  position: absolute; left: 0.3em; bottom: 0.2em;
  height: 140%; width: 24%;
  object-fit: contain; object-position: left bottom;
  pointer-events: none;
}
.dialog.has-face { padding-left: 27%; }
.dialog.has-face .name { left: 27%; }
.dialog .more {
  position: absolute; right: 0.8em; bottom: 0.3em;
  color: var(--accent); font-size: 0.8em;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
/* '시스템' 메시지: 이세계 시스템 창 느낌의 파란 상자 */
.dialog.sys { background: rgba(14, 34, 72, 0.95); border-color: #8ec8ff; box-shadow: 0 0 0 2px #000, 0 0 14px rgba(110, 190, 255, 0.45); }
.dialog.sys .name { background: #8ec8ff; }
.dialog.sys .text { color: #e4f2ff; }

/* 현재 목표 (왼쪽 위) */
.objective {
  position: absolute; left: 11%; top: 3%; max-width: 62%;
  background: rgba(10, 8, 20, 0.62); border: 1px solid rgba(232, 217, 168, 0.5); border-radius: 5px;
  padding: 0.15em 0.6em; font-size: 0.74em; line-height: 1.35; pointer-events: none;
}
.objective b { color: var(--accent); margin-right: 0.2em; }
body.in-battle .objective { display: none; }

.toast {
  position: absolute; top: 4%; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25em 1em; font-size: 0.9em; white-space: nowrap;
  pointer-events: none; z-index: 9;
}
/* 목표 표시가 있을 때는 알림을 조금 아래로 (겹치지 않게) */
#ui:has(.objective:not([hidden])) .toast { top: 15%; }
/* 메뉴·상태창이 열려 있으면 알림을 화면 아래쪽에 (메뉴 글자를 가리지 않게) */
body:not(.in-battle) #ui:has(.menu, .status-win) .toast { top: auto !important; bottom: 3%; }

/* ---------------- 메뉴 ---------------- */
.menu {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 0.35em;
  box-shadow: 0 0 0 2px #000;
  max-height: 86%;
  min-width: 30%;
}
.menu-title { color: var(--accent); font-weight: 700; padding: 0.15em 0.6em 0.3em; }
.menu-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.menu .opt {
  appearance: none; border: 0; background: transparent; color: var(--text);
  font: inherit; text-align: left;
  display: flex; justify-content: space-between; gap: 1.2em;
  padding: 0.3em 0.7em; border-radius: 4px; cursor: pointer;
}
.menu .opt .r { color: var(--muted); font-size: 0.9em; white-space: nowrap; }
.menu .opt.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.menu .opt.off { color: #6d6880; }
.menu .opt:focus-visible { outline: 2px solid var(--accent); }
.menu-desc {
  border-top: 1px solid rgba(232, 217, 168, 0.3);
  margin-top: 0.3em; padding: 0.35em 0.6em 0.1em;
  color: var(--muted); font-size: 0.88em; min-height: 2.6em;
}
.menu.fmenu { right: 3%; top: 5%; }
.menu.fmenu.wide { width: 52%; }
.menu.ask { right: 3%; bottom: 34%; }
.menu.bmenu { left: 2.5%; bottom: 3%; width: 33%; max-height: 62%; }
.menu.bmenu .opt { padding-top: 0.16em; padding-bottom: 0.16em; }
.menu.bmenu.wide { width: 44%; }
.menu.title-menu { left: 50%; transform: translateX(-50%); bottom: 10%; min-width: 34%; }

/* ---------------- 정보 창 ---------------- */
.info {
  position: absolute;
  background: var(--panel); border: 2px solid var(--line); border-radius: 6px;
  box-shadow: 0 0 0 2px #000;
  padding: 0.6em 1em;
  overflow-y: auto;
}
.info.center { left: 50%; top: 50%; transform: translate(-50%, -50%); max-height: 88%; width: 70%; cursor: pointer; }
.info.side { left: 3%; top: 5%; width: 50%; max-height: 90%; }
.info h2, .info h3 { margin: 0.1em 0 0.4em; color: var(--accent); font-size: 1.15em; }
.info h3 small { color: var(--muted); font-weight: 400; font-size: 0.8em; margin-left: 0.4em; }
.info p { margin: 0.35em 0; }
.info .dim, .dim { color: var(--muted); }
.info-hint { text-align: right; color: var(--muted); font-size: 0.8em; margin-top: 0.4em; }
.info.side .info-hint { display: none; }
.st { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.st td { padding: 0.1em 0.4em 0.1em 0; }
.st td:nth-child(odd) { color: var(--muted); width: 22%; }
.sk { font-size: 0.92em; }
.quest { border-top: 1px solid rgba(232, 217, 168, 0.25); padding-top: 0.4em; margin-top: 0.4em; }
.quest.done { opacity: 0.6; }
.tag { font-size: 0.78em; border: 1px solid var(--muted); border-radius: 4px; padding: 0 0.4em; margin-left: 0.4em; color: var(--muted); }
.tag.ready { border-color: var(--accent); color: var(--accent); }

/* ---------------- 타이틀 ---------------- */
.title-screen { position: absolute; inset: 0; pointer-events: none; }
.title-screen .logo {
  position: absolute; left: 0; right: 0; top: 14%;
  text-align: center;
  text-shadow: 0 3px 0 #000, 0 0 12px rgba(0, 0, 0, 0.6);
}
.title-screen small { color: var(--accent); letter-spacing: 0.08em; font-size: 0.95em; }
.title-screen h1 { margin: 0.2em 0 0; font-size: 2.6em; line-height: 1.15; color: #fff6e0; }
.title-screen .chap { margin: 0.4em 0 0; color: #e4f2ff; font-size: 1em; }

/* ---------------- 상태창 ---------------- */
.status-win {
  position: absolute; inset: 3% 2.5%;
  display: flex; flex-direction: column;
  background: rgba(12, 26, 58, 0.96);
  border: 2px solid #8ec8ff; border-radius: 6px;
  box-shadow: 0 0 0 2px #000, 0 0 16px rgba(110, 190, 255, 0.4);
  font-size: 0.86em; z-index: 6;
}
.sw-head { display: flex; align-items: center; gap: 0.5em; padding: 0.3em 0.5em; border-bottom: 1px solid rgba(142, 200, 255, 0.4); }
.sw-title { color: #8ec8ff; font-weight: 700; white-space: nowrap; }
.sw-tabs { display: flex; gap: 0.25em; flex: 1; overflow-x: auto; }
.sw-tab, .sw-x, .sw-mem, .sw-row {
  appearance: none; font: inherit; color: var(--text); background: transparent; border: 0; cursor: pointer; text-align: left;
}
.sw-tab { padding: 0.15em 0.6em; border-radius: 4px; border: 1px solid rgba(142, 200, 255, 0.35); white-space: nowrap; }
.sw-tab.on { background: #8ec8ff; color: #0c1a3a; font-weight: 700; }
.sw-money { color: var(--accent); white-space: nowrap; font-size: 0.9em; }
.sw-x { width: 1.8em; height: 1.8em; border-radius: 4px; border: 1px solid rgba(142, 200, 255, 0.5); text-align: center; }
.sw-hint { background: rgba(232, 176, 74, 0.18); color: #ffe6b0; padding: 0.2em 0.7em; font-size: 0.9em; }
.sw-body { flex: 1; min-height: 0; display: flex; gap: 0.5em; padding: 0.4em 0.5em; }
.sw-party { width: 34%; display: flex; flex-direction: column; gap: 0.3em; overflow-y: auto; }
.sw-mem { display: grid; grid-template-columns: 2.2em 1fr; grid-template-rows: auto auto auto; column-gap: 0.4em; row-gap: 0.12em;
  padding: 0.25em 0.35em; border-radius: 5px; border: 1px solid rgba(142, 200, 255, 0.25); }
.sw-mem.on { background: rgba(142, 200, 255, 0.16); border-color: #8ec8ff; }
.sw-mem.ko { opacity: 0.55; }
.sw-mem img { grid-row: 1 / span 3; width: 2.2em; height: 2.2em; image-rendering: pixelated; align-self: center; }
.sw-mem .nm { font-weight: 700; white-space: nowrap; }
.sw-mem small { color: var(--muted); font-weight: 400; }
.sbar { position: relative; height: 1.05em; background: #000; border: 1px solid #44507a; border-radius: 3px; overflow: hidden; }
.sbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--hp); }
.sbar.mp i { background: var(--mp); }
.sbar.exp i { background: #e8b04a; }
.sbar b { position: relative; display: block; text-align: center; font-size: 0.72em; line-height: 1.45; text-shadow: 0 1px 0 #000; font-weight: 700; }
.sw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.sw-card { display: flex; gap: 0.8em; flex-wrap: wrap; }
.sw-st { border-collapse: collapse; flex: 1; min-width: 60%; }
.sw-st td { padding: 0.08em 0.4em 0.08em 0; vertical-align: middle; }
.sw-st td:first-child { color: #8ec8ff; width: 3.6em; white-space: nowrap; }
.sw-st .num { font-weight: 700; width: 2.6em; font-variant-numeric: tabular-nums; }
.sw-st .sbar { width: 100%; min-width: 6em; }
.sw-eq { font-size: 0.84em; line-height: 1.45; padding-top: 0.2em; display: grid; grid-template-columns: auto auto; gap: 0 1em; align-content: start; }
.sw-list { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 3em; overflow-y: auto; }
.sw-group { color: #8ec8ff; font-size: 0.82em; padding: 0.25em 0.3em 0.05em; border-bottom: 1px solid rgba(142, 200, 255, 0.25); }
.sw-row { display: flex; justify-content: space-between; gap: 1em; padding: 0.18em 0.5em; border-radius: 4px; }
.sw-row .r { color: var(--muted); white-space: nowrap; font-size: 0.92em; }
.sw-row.sel { background: rgba(142, 200, 255, 0.2); box-shadow: inset 3px 0 0 #8ec8ff; }
.sw-row.off { color: #7d86a8; }
.sw-desc { border-top: 1px solid rgba(142, 200, 255, 0.3); margin-top: 0.3em; padding: 0.3em 0.3em 0; font-size: 0.92em; min-height: 3.2em; }
.sw-desc .steps { margin: 0.25em 0; padding-left: 0.2em; list-style: none; }
.sw-desc .steps li.ok { color: #9be89b; }
.sw-foot { color: var(--muted); font-size: 0.75em; text-align: right; padding: 0.15em 0.6em 0.25em; }
.acc { color: var(--accent); }
.bad { color: var(--danger); }
.small { font-size: 0.85em; }
.tagf, .tagm, .taguse, .tagequip, .tagkey { font-size: 0.75em; border-radius: 3px; padding: 0 0.3em; }
.tagf { background: #2e6a46; } .tagm { background: #8a5a20; }
.taguse { background: #2e5a8a; } .tagequip { background: #5a4a8a; } .tagkey { background: #7a3a3a; }

/* ---------------- 제1장 클리어 ---------------- */
.chapter-clear {
  position: absolute; inset: 0; z-index: 6;
  background: radial-gradient(ellipse at center, rgba(40, 30, 70, 0.92), rgba(6, 4, 14, 0.97));
  display: flex; align-items: flex-start; justify-content: center; padding-top: 4%;
  animation: ccin 1.2s ease-out;
}
@keyframes ccin { from { opacity: 0; } to { opacity: 1; } }
.cc-inner { text-align: center; width: 86%; }
.cc-inner small { color: #8ec8ff; letter-spacing: 0.2em; }
.cc-inner h1 { margin: 0.1em 0 0.3em; color: #fff6e0; font-size: 1.9em; text-shadow: 0 3px 0 #000; }
.cc-cols { display: flex; gap: 1em; justify-content: center; text-align: left; }
.cc-cols > div { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(232, 217, 168, 0.35); border-radius: 6px; padding: 0.3em 0.9em; min-width: 38%; }
.cc-cols h3 { margin: 0.1em 0; color: var(--accent); font-size: 0.95em; }
.cc-cols ul { margin: 0.2em 0; padding-left: 1.1em; font-size: 0.9em; }
.cc-next { color: var(--muted); margin: 0.5em 0 0; }
.menu.cc-menu { left: 50%; transform: translateX(-50%); bottom: 4%; min-width: 46%; z-index: 7; }

/* ---------------- 전투 UI ---------------- */
.battle { position: absolute; inset: 0; pointer-events: none; }
.battle > * { pointer-events: auto; }
.bmsg {
  position: absolute; left: 4%; right: 4%; top: 3.5%;
  background: var(--panel); border: 2px solid var(--line); border-radius: 6px;
  padding: 0.35em 0.9em; text-align: center; min-height: 2.2em;
  box-shadow: 0 0 0 2px #000;
}
.bparty {
  position: absolute; right: 2.5%; bottom: 3%; width: 58%;
  background: var(--panel); border: 2px solid var(--line); border-radius: 6px;
  padding: 0.25em 0.5em; box-shadow: 0 0 0 2px #000;
  display: flex; flex-direction: column; gap: 0.12em;
  font-size: 0.78em;
}
.brow { display: grid; grid-template-columns: 5.2em 1fr 3.4em 4.2em; gap: 0.45em; align-items: center; padding: 0.05em 0.3em; border-radius: 4px; }
.brow.bhead { color: var(--muted); font-size: 0.72em; padding-top: 0; padding-bottom: 0; line-height: 1.1; }
.brow.bhead span { text-align: center; }
.brow.psn .bn { color: #d6a8ff; }
.brow.act { background: var(--sel); }
.brow.ko { opacity: 0.5; }
.bn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { position: relative; height: 1.25em; background: #000; border: 1px solid #5a5470; border-radius: 3px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--hp); transition: width 0.25s; }
.bar.mp i { background: var(--mp); }
.bar.g i { background: var(--gauge); }
.bar.atb { height: 0.8em; }
.bar.atb i { background: #c9c2a8; transition: none; }
.bar.atb.full i { background: var(--accent); animation: blink 0.6s steps(2) infinite; }
.bar i.low { background: var(--danger); }
.bar b { position: relative; display: block; text-align: center; font-weight: 700; font-size: 0.82em; line-height: 1.5; text-shadow: 0 1px 0 #000; font-variant-numeric: tabular-nums; }
.gauge { display: grid; grid-template-columns: 5.2em 1fr; gap: 0.45em; align-items: center; padding: 0.1em 0.3em; }
.gauge .gl { color: var(--gauge); font-size: 0.9em; white-space: nowrap; }

/* ---------------- 전투 창 꾸미기 (Ninja Adventure 나무 테두리, CC0) ----------------
   assets/ui/panel.png 의 테두리(5픽셀)를 게임 화면 배율(--u)만큼 키워서 씀.
   그림이 없으면 원래의 금색 테두리 창으로 보입니다. */
body.in-battle .bmsg,
body.in-battle .bparty,
body.in-battle .menu,
body.in-battle .dialog {
  border: calc(var(--u) * 4px) solid #9b513c;
  border-image: url("../assets/ui/panel.png") 5 fill / calc(var(--u) * 4px) stretch;
  border-radius: 0;
  background: transparent;
  box-shadow: 0 calc(var(--u) * 1px) 0 rgba(0, 0, 0, 0.35);
  image-rendering: pixelated;
  text-shadow: 0 1px 0 #3a1a10, 1px 0 0 #3a1a10;
}
/* 테두리 안쪽(주황 나무판) 위에 글자가 잘 보이게 어두운 나무색을 한 겹 */
body.in-battle .bmsg::before,
body.in-battle .bparty::before,
body.in-battle .menu::before,
body.in-battle .dialog::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: rgba(46, 26, 20, 0.88);
}
body.in-battle .bmsg, body.in-battle .bparty, body.in-battle .menu, body.in-battle .dialog { isolation: isolate; }
body.in-battle .menu .opt.sel { background: rgba(240, 103, 51, 0.55); box-shadow: inset 3px 0 0 #ffad55; }
body.in-battle .menu-title, body.in-battle .brow.bhead { color: #ffcf8a; }
body.in-battle .brow.act { background: rgba(240, 103, 51, 0.45); }
body.in-battle .bar { border-color: #131b1b; background: #2a1a14; border-radius: 2px; }
body.in-battle .bar.atb i { background: #ffd9a0; }

/* ---------------- 터치 버튼 ---------------- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#touch[hidden] { display: none; }
#touch > * { pointer-events: auto; position: absolute; }
#dpad {
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  width: 132px; height: 132px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  touch-action: none;
}
#dpad .arm {
  position: absolute; width: 44px; height: 44px;
  background: rgba(20, 18, 34, 0.55); border: 2px solid rgba(232, 217, 168, 0.55);
  border-radius: 8px;
}
#dpad .up { left: 44px; top: 0; }
#dpad .down { left: 44px; bottom: 0; }
#dpad .left { left: 0; top: 44px; }
#dpad .right { right: 0; top: 44px; }
#dpad[data-dir="up"] .up, #dpad[data-dir="down"] .down,
#dpad[data-dir="left"] .left, #dpad[data-dir="right"] .right { background: rgba(232, 176, 74, 0.7); }
#abtns {
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  width: 140px; height: 110px;
}
.tbtn {
  appearance: none; font: inherit; font-weight: 700; color: var(--text);
  background: rgba(20, 18, 34, 0.6); border: 2px solid rgba(232, 217, 168, 0.7);
  border-radius: 50%; touch-action: none; cursor: pointer;
}
.tbtn.down, .tbtn.on { background: rgba(232, 176, 74, 0.75); color: #1a1420; }
#abtns .a { position: absolute; right: 0; top: 0; width: 64px; height: 64px; font-size: 20px; }
#abtns .b { position: absolute; left: 0; bottom: 0; width: 56px; height: 56px; font-size: 18px; }
#touch .tmenu { right: max(14px, env(safe-area-inset-right, 0px)); top: max(10px, env(safe-area-inset-top, 0px)); width: 46px; height: 46px; border-radius: 10px; font-size: 20px; }
#touch .run { left: max(14px, env(safe-area-inset-left, 0px)); top: max(10px, env(safe-area-inset-top, 0px)); padding: 0 12px; height: 38px; border-radius: 10px; font-size: 13px; }
#touch .tstatus { right: max(14px, env(safe-area-inset-right, 0px)); top: calc(max(10px, env(safe-area-inset-top, 0px)) + 54px); width: 46px; height: 38px; border-radius: 10px; font-size: 13px; padding: 0; }

/* 소리 버튼: 평소에는 왼쪽 위 구석, 터치 버튼이 있으면 '달리기' 옆 */
#mute {
  position: fixed; z-index: 21;
  left: max(6px, env(safe-area-inset-left, 0px)); top: max(6px, env(safe-area-inset-top, 0px));
  width: 30px; height: 30px; border-radius: 8px; padding: 0;
  font-size: 16px; line-height: 1; opacity: 0.75;
}
#mute.off { color: var(--muted); }
body.has-touch #mute { left: calc(max(14px, env(safe-area-inset-left, 0px)) + 84px); top: max(10px, env(safe-area-inset-top, 0px)); width: 38px; height: 38px; }

#rotate { display: none; }

/* 가로 화면 + 터치 버튼: 버튼이 게임 화면을 가리지 않도록 양옆에 자리를 비움 */
@media (orientation: landscape) {
  body.has-touch #stage { width: min(calc(100vw - 300px), 177.78vh); }
  body.has-touch #dpad { width: 126px; height: 126px; }
  body.has-touch #dpad .arm { width: 42px; height: 42px; }
  body.has-touch #dpad .up, body.has-touch #dpad .down { left: 42px; }
  body.has-touch #dpad .left, body.has-touch #dpad .right { top: 42px; }
  body.has-touch #abtns { width: 128px; height: 108px; }
}

/* 세로 화면(휴대폰 세워서): 게임 화면은 위, 버튼은 아래 */
@media (orientation: portrait) {
  #game { align-items: flex-start; padding-top: max(8px, env(safe-area-inset-top, 0px)); }
  #dpad { bottom: max(60px, env(safe-area-inset-bottom, 0px)) !important; }
  #abtns { bottom: max(60px, env(safe-area-inset-bottom, 0px)) !important; }
  body.has-touch #rotate {
    display: block; position: fixed; left: 0; right: 0; top: calc(56.25vw + 16px);
    text-align: center; color: var(--muted); font-size: 13px; pointer-events: none;
  }
  #touch .tmenu, #touch .run, body.has-touch #mute { top: calc(56.25vw + 44px); }
  #touch .tstatus { top: calc(56.25vw + 48px); right: calc(max(14px, env(safe-area-inset-right, 0px)) + 54px); }
  /* 전투: 동료 표(최대 6명)를 게임 화면 바로 아래 빈 곳으로 옮겨 캐릭터를 가리지 않게 함.
     전투 중에는 달리기·소리·메뉴 버튼과 안내 글을 잠시 숨겨 자리를 만듦 */
  body.in-battle #touch .run, body.in-battle #touch .tmenu, body.in-battle #touch .tstatus, body.in-battle #mute, body.in-battle #rotate { display: none; }
  .bparty {
    position: fixed; left: 8px; right: 8px; width: auto; bottom: auto;
    top: calc(max(8px, env(safe-area-inset-top, 0px)) + 56.25vw + 8px);
    max-height: calc(100vh - 56.25vw - 250px); min-height: 0; overflow-y: auto;
    font-size: 12px; gap: 0.15em; z-index: 22;
  }
  body:not(.has-touch) .bparty { max-height: none; }
  #dpad { width: 156px; height: 156px; bottom: max(28px, env(safe-area-inset-bottom, 0px)); }
  #dpad .arm { width: 52px; height: 52px; }
  #dpad .up, #dpad .down { left: 52px; }
  #dpad .left, #dpad .right { top: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .dialog .more { animation: none; }
  .bar i { transition: none; }
  .bar.atb.full i { animation: none; }
}

/* ---------------- 미니게임 (제2장 축제: 고리 던지기) ---------------- */
.minigame {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); width: 70%; z-index: 6;
  background: var(--panel); border: 2px solid var(--line); border-radius: 6px; box-shadow: 0 0 0 2px #000;
  padding: 0.6em 1em; text-align: center; cursor: pointer;
}
.mg-title { color: var(--accent); font-weight: 700; margin-bottom: 0.4em; }
.mg-track { position: relative; height: 1.4em; background: #2a2340; border: 1px solid #000; border-radius: 3px; margin: 1.2em 0 0.5em; }
.mg-zone { position: absolute; top: 0; bottom: 0; background: linear-gradient(#ffe27a, #e0a830); }
.mg-arrow { position: absolute; top: -1.15em; transform: translateX(-50%); color: #ff6b6b; font-size: 1em; line-height: 1; }
.minigame.ok .mg-track { box-shadow: 0 0 0 2px #7cf09a; }
.mg-info { font-variant-numeric: tabular-nums; }
.mg-help { color: var(--muted); font-size: 0.75em; margin-top: 0.3em; }

/* v1.0.1: 상태창 위에서 여는 메뉴(장비 바꾸기·아이템 대상 고르기 등)가
   상태창(z-index 6) 뒤에 가려져 안 보이던 문제 수정 */
.status-win ~ .menu, .status-win ~ .dialog, #ui:has(.status-win) .menu { z-index: 8; }
