:root {
  color-scheme: dark;
  --paper: #242638;
  --ink: #f3eee0;
  --gold: #ffd878;
  --status-height: calc(72px + env(safe-area-inset-top, 0px));
  --menu-height: calc(86px + env(safe-area-inset-bottom));
}
/* 번역문은 긴 단어도 줄바꿈하고 언어별 글꼴로 표시한다. */
html:not([lang="ko"]) body { font-family: system-ui, sans-serif; overflow-wrap: anywhere; }
html[lang="ja"] body { font-family: "Noto Sans JP", sans-serif; }
html[lang="zh-TW"] body { font-family: "Noto Sans TC", sans-serif; }
html[lang="th"] body { font-family: "Noto Sans Thai", sans-serif; }
html[lang="vi"] body { font-family: "Noto Sans", sans-serif; }
.translated-title { display: none; }
html:not([lang="ko"]) .title-logo:not([data-l10n="ok"]) { display: none; }
html:not([lang="ko"]) .title-logo[data-l10n="ok"] ~ .translated-title { display: none; }
html:not([lang="ko"]) .title-screen .translated-title { display: block; position: absolute; top: 10%; left: 5%; width: 90%; font-size: 36px; line-height: 1.15; text-shadow: 0 3px 8px #000; pointer-events: none; }
html:not([lang="ko"]) header strong { font-size: 14px; }
html:not([lang="ko"]) .battle-top { flex-wrap: wrap; }
html:not([lang="ko"]) .battle-top button { min-width: 0; white-space: normal; font-size: 13px; }
html:not([lang="ko"]) .story-text { overflow-wrap: anywhere; word-break: normal; }
html:not([lang="ko"]) .inn-scene { overflow-x: clip; }
html:not([lang="ko"]) #cards .portrait strong { font-size: 11px; }
html:not([lang="ko"]) .title-start, html:not([lang="ko"]) .depart-button,
html:not([lang="ko"]) .vs-screen > p { font-family: inherit; }
.title-screen {text-align:center;padding:28px 4px 48px}
.title-screen h1 {font-size:40px;color:var(--gold);margin:24px 0}
.title-mark {width:210px;
  height:210px;
  margin:30px auto;
  border-radius:50%;
  border:6px solid var(--gold);
  background:#b87846;
  display:grid;
  place-items:center;
  font-size:52px;
  font-weight:800;
  color:#242638}
.title-mark img {width:100%;height:100%;object-fit:contain}
.title-screen .primary {width:100%;margin-top:24px;font-size:20px}
.tutorial {padding:14px;
  margin:12px 0;
  border:2px solid var(--gold);
  border-radius:12px;
  background:#493b29;
  color:#fff0c2;
  font-size:16px}
.tutorial button {display:block;margin-top:10px}
#skill-guide {position:relative;margin:8px 0;text-align:center}
#share-panel {width:min(95vw,440px);
  max-height:94dvh;
  background:#242638;
  color:#f3eee0;
  border:2px solid #b87846;
  border-radius:16px;
  padding:16px}
#share-image {display:block;width:100%;height:auto}
#share-actions {display:flex;gap:8px;flex-wrap:wrap}
.guide-link {color:var(--gold);font-size:13px}
.orak-next {margin-top:20px}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #151723;
  color: var(--ink);
  font-family: "Apple SD Gothic Neo","Noto Sans KR","Malgun Gothic",system-ui,sans-serif;
}
main.orak-stage {
  max-width: 520px;
  min-height: 100dvh;
  margin: auto;
  padding: 14px 12px calc(18px + env(safe-area-inset-bottom));
  background: var(--paper);
}
header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
header a {
  color: var(--gold);
  text-decoration: none;
}
header span {
  margin-left: auto;
  font-size: 12px;
  color: #b6b8c9;
}
#wallet {
  padding: 10px;
  background: #32354a;
  border-radius: 10px;
  font-size: 14px;
}
nav {
  display: flex;
  gap: 5px;
  margin: 12px 0;
  overflow-x: auto;
}
button {
  font: inherit;
  color: inherit;
  background: #41465f;
  border: 1px solid #626b89;
  border-radius: 9px;
  padding: 10px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.is-pressing {
  transform: scale(0.97);
}
button.primary {
  background: #665127;
  border-color: var(--gold);
}
h1 {
  font-size: 25px;
}
h2 {
  font-size: 19px;
}
p {
  line-height: 1.6;
}
.hint,
small {
  color: #c1c5d4;
  font-size: 12px;
}
small {
  display: block;
  margin: 4px 0;
}
.row {
  display: flex;
  gap: 9px;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #30344a;
  border-radius: 10px;
  margin: 8px 0;
}
.row > div {
  flex: 1;
}
.row button {
  flex-shrink: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}
.stars {
  color: var(--gold);
}
.slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.slots button {
  font-size: 13px;
  min-height: 64px;
}
.battle-top {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.battle-top span {
  flex: 1;
}
.battle-top button {
  padding: 6px;
}
canvas {
  width: 100%;
  display: block;
  background: #202e3c;
  margin-top: 8px;
  border-radius: 12px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.portrait {
  padding: 8px 4px;
  font-size: 12px;
  min-width: 0;
}
.portrait strong {
  display: block;
}
.portrait small {
  font-size: 10px;
}
.bar {
  height: 6px;
  background: #191b28;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.bar i {
  display: block;
  height: 100%;
  background: #71db9c;
}
.bar.energy i {
  background: #83b9ff;
}
.ready {
  border-color: #ffd878;
  box-shadow: 0 0 12px #ffd87866;
  animation: glow 1s infinite alternate;
}
@keyframes glow {
  to {
    box-shadow: 0 0 20px #ffd878aa;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ready {
    animation: none;
  }
}
#cutin {
  min-height: 26px;
  margin: 5px 0;
  color: var(--gold);
  font-weight: 700;
  text-align: center;
}
dialog {
  max-width: 340px;
  width: 90%;
  background: #30344a;
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 16px;
}
dialog::backdrop {
  background: #0009;
}
[hidden] {
  display: none !important;
}
#notice {
  color: var(--gold);
  min-height: 26px;
}
#screen {
  padding-bottom: 8px;
}
.selected {
  border-color: var(--gold);
}

.locked {
  opacity: 0.45;
}
.portrait:disabled {
  opacity: 0.8;
}
html,
body {
  overscroll-behavior: none;
  touch-action: manipulation;
}
#fight {
  margin: 14px -8px 0;
}
#canvas {
  border: 1px solid #697181;
  border-radius: 14px;
}
.cards {
  gap: 6px;
  margin: 8px 5px;
}
.portrait {
  min-height: 148px;
  background: linear-gradient(#3e455e, #292d40);
}
.face {
  display: flex;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin: 0 auto 7px;
  align-items: center;
  justify-content: center;
  color: #19202d;
  font-size: 24px;
  font-weight: 800;
  border: 2px solid #fff5;
  overflow: hidden;
}
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait.down {
  filter: grayscale(1);
  opacity: 0.45;
}
.settings {
  display: flex;
  gap: 7px;
  margin: 16px 0;
}
.settings button {
  font-size: 12px;
  padding: 6px 12px;
}
body:has(#fight:not([hidden])) #wallet {
  font-size: 12px;
}
.result-stars {
  font-size: 42px;
  color: #ffd878;
}
.result-stars span {
  display: inline-block;
  animation: star-rise 0.4s both;
}
@keyframes star-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.5);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.bracket {
  list-style: none;
  padding: 0 0 0 12px;
}
.bracket li {
  position: relative;
  padding: 13px 10px;
  margin: 0 0 6px;
  border-left: 3px solid #53596d;
  background: #30344a;
  border-radius: 0 9px 9px 0;
  font-size: 14px;
}
.bracket li.current {
  border: 1px solid #ffd878;
  border-left: 4px solid #ffd878;
  background: #5a492c;
}
.bracket li.current:after {
  content: "이번 경기";
  float: right;
  font-size: 10px;
  color: #ffd878;
}
.bracket li.won {
  border-left-color: #71db9c;
}
.bracket li.won:before {
  content: "";
  position: absolute;
  left: -3px;
  top: 100%;
  height: 7px;
  width: 3px;
  background: #71db9c;
}
.raid {
  background: #8f2330;
  padding: 60px 20px;
  text-align: center;
  font: bold 36px serif;
  color: #ffe1bc;
  border-radius: 16px;
  animation: raid-in 0.4s;
}
@keyframes raid-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.gallery canvas {
  margin: 0;
}
.gallery small { display: block; }
.row > .face { flex-shrink: 0; margin: 0 10px 0 0; }
.slots .face { margin-bottom: 5px; }
.gallery small {
  text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .result-stars span {
    animation-name: star-appear;
  }
  .raid {
    animation: none;
  }
}
@keyframes star-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
/* 결과판도 전투 레이아웃을 유지하여 캔버스 크기를 보존한다. */
#fight.finished #cards, #fight.finished #cutin, #fight.finished > .hint { display: none; }
body.battling header, body.battling #wallet { display: none; }
body.battle-result { overflow-y: auto; }
body.battle-result main.orak-stage { height: auto; min-height: 100dvh; overflow: visible; }
body.battle-result #fight { flex: none; touch-action: pan-y; }
body.battle-result #canvas { flex: none; }
#cards { display: flex; }
#cards .portrait { flex: 1; }
#cards .bar { height: 8px; border: 1px solid #101320; box-sizing: border-box; }
#cards .face { width: 54px; height: 54px; }
body.battling {
  overflow: hidden;
}
body.battling #fight {
  touch-action: none;
}
#canvas {
  height: 50dvh;
}
body.battling main.orak-stage {
  padding-top: 4px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
body.battling header {
  padding: 4px 0;
}
body.battling #fight {
  margin-top: 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
body:not(:has(.inn-screen)) .settings,
body.battling .settings,
body.battling #notice,
body.battling .guide-link {
  display: none;
}
body.battling #canvas {
  flex: 1;
  min-height: 0;
  height: 0;
}
body.battling .battle-top,
body.battling #cards,
body.battling header,
body.battling #wallet {
  flex-shrink: 0;
}
body.battling #cutin {
  min-height: 22px;
  margin: 3px 0 0;
  font-size: 12px;
}
body.battling #fight > .hint {
  margin: 2px 5px 0;
  font-size: 11px;
}
body.battling #skill-guide {
  position: absolute;
  bottom: 180px;
  left: 8px;
  right: 8px;
}
@media (max-height: 680px) {
  body.battling .portrait { min-height: 118px; padding: 6px 3px; }
  body.battling .face { width: 38px; height: 38px; margin-bottom: 4px; }
  body.battling #cutin { min-height: 18px; }
  body.battling #skill-guide { bottom: 150px; }
}
body.storying {
  overflow: hidden;
}
#story {
  position: fixed;
  inset: 0;
  z-index: 20;
  max-width: 520px;
  margin: auto;
  padding: max(16px, calc(env(safe-area-inset-top, 0px) + 4px)) 16px calc(20px + env(safe-area-inset-bottom));
  background: #171d2b;
  display: flex;
  flex-direction: column;
}
.story-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--gold);
}
.story-top strong {
  font-size: 18px;
}
.story-top button {
  font-size: 12px;
}
#story-picture {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid #ffffff25;
  border-radius: 20px;
  margin: 16px 0;
  background: #10131c;
}
.story-frame { position: absolute; inset: 0; animation: story-enter .35s ease-out both; }
.story-art { width: 100%; height: 100%; object-fit: cover; animation: story-drift 8s linear .35s forwards; }
.story-backdrop { filter: blur(10px) brightness(.55); transform: scale(1.08); animation: none; }
.story-cutin { position: absolute; inset: 5% 0 0; width: 100%; height: 95%; object-fit: contain; }
.story-loader {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: #10131cf2; color: #ddd3bf; font-size: 14px;
}
.story-brush {
  width: 42px; height: 6px; background: #dcc18a;
  border-radius: 70% 20% 60% 10%; transform: rotate(-14deg);
  animation: story-brush 1.2s ease-in-out infinite;
}
.story-loading #story-dialogue, .story-loading #story-count { visibility: hidden; }
#story-dialogue button {
  width: 100%; min-height: 160px; padding: 18px 20px; text-align: left;
  background: #2c3046; border-color: #b59c65; line-height: 1.8;
}
#story-dialogue strong { display: flex; align-items: center; gap: 10px; color: var(--gold); margin-bottom: 10px; }
.story-speaker-face { width: 32px; height: 32px; object-fit: cover; border-radius: 50%; }
#story-dialogue .story-text { display: block; font-size: 18px; word-break: keep-all; min-height: 65px; }
.story-narration .story-text { font-style: italic; }
#story-count { margin: 10px 0 0; text-align: center; font-size: 12px; color: #dcc18a;
  animation: story-hint 1.2s ease-in-out infinite; }
@keyframes story-enter {
  from { opacity: 0; transform: scale(1.06); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes story-drift { from { transform: scale(1); } to { transform: scale(1.02); } }
@keyframes story-brush { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes story-hint { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .story-frame { animation-name: story-fade; }
  .story-art { animation: none; }
  .story-brush, #story-count { animation: none; }
}
@keyframes story-fade { from { opacity: 0; } to { opacity: 1; } }


.inn-screen { background: linear-gradient(#171c28a8, #171c28df), url("sprites/bg-inn.webp") center top / cover;
   border-radius: 14px;
   }

/* 폰 게임의 공통 상태 띠와 다섯 칸 메뉴는 화면 가장자리에 고정한다. */
main.orak-stage { position: relative; height: auto; overflow: visible; min-height: 100dvh;
  padding: calc(var(--status-height) + 8px) 12px calc(var(--menu-height) + 16px); }
main.orak-stage > header, .guide-link { display: none; }
#wallet { position: fixed; z-index: 12; top: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 520px); height: var(--status-height); border-radius: 0; display: flex; align-items: center;
  gap: 9px; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px; background: linear-gradient(#2e201cef, #1d1511dc);
  border-bottom: 1px solid #b99656; box-shadow: 0 3px 15px #0005; }
#wallet .face { width: 46px; height: 46px; border: 2px solid #d3ad65; border-radius: 50%; }
.power-value small { margin: 0; color: #dfc99c; font-size: 10px; }
.power-value strong { font-size: 25px; color: #ffe5aa; line-height: 1.2; }
.wallet-resources { margin-left: auto; display: grid; gap: 2px; font-size: 13px; font-weight: 700; }
.wallet-resources > span { display: flex; align-items: center; gap: 6px; }
.wallet-resources .game-icon { width: 25px; height: 25px; font-size: 12px; }
.game-icon { display: grid; place-items: center; width: 48px; height: 48px; flex-shrink: 0; }
.game-icon img { width: 100%; height: 100%; object-fit: contain; }
.wood-badge { border-radius: 50%; color: #ffe9b6; font-family: 'Gungsuh', "AppleMyungjo","Noto Serif KR", serif; font-weight: bold;
  background: radial-gradient(ellipse at 35% 28%, #a4773d, #4a2a18 75%);
  border: 2px solid #c89b52; box-shadow: inset 0 0 0 3px #38201477, 0 3px 5px #0006; }
#nav { position: fixed; z-index: 15; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 520px); margin: 0; padding: 8px 5px calc(8px + env(safe-area-inset-bottom));
  height: var(--menu-height); display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; overflow: visible;
  background: linear-gradient(#38271aef, #17110fff); border-top: 2px solid #b78a49; }
#nav .menu-item { position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 0; border: 0; border-radius: 6px; background: transparent; font-size: 11px; }
#nav .selected { background: #c49b4a22; color: #ffe6a9; }
.menu-item.tower-locked .game-icon { opacity: .38; filter: grayscale(.8); }
.menu-lock { position: absolute; top: 15px; font-size: 16px; font-style: normal; }
#hub-back { position: fixed; z-index: 16; top: calc(var(--status-height) + 8px);
  left: max(12px, calc((100vw - 520px) / 2 + 12px)); margin: 0; padding: 4px 9px; min-height: 32px;
  background: #30251be6; color: #ffe6b2; border-color: #98784b; font-size: 12px; }
#notice { position: fixed; z-index: 25; bottom: 90px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 90vw; pointer-events: none; border-radius: 12px;
  background: #20160ee8; color: #ffe6b2; padding: 8px 12px; font-size: 12px; text-align: center; }
#notice:empty { display: none; }
.selected-stage { outline: 2px solid var(--gold); }
/* 키 아트 전체를 탭할 수 있고 장식은 입력을 가로채지 않는다. */
body.at-title main.orak-stage { padding: 0; }
.title-screen { position: relative; padding: 0; height: 100dvh; overflow: hidden;
  background: url('sprites/ui-title.webp') center / cover; text-align: center; }
.title-logo { position: absolute; width: 88%; left: 6%; top: 9%; height: auto;
  animation: logo-enter .6s ease-out both; pointer-events: none; }
.arcade-back { position: absolute; z-index: 3; top: max(14px, env(safe-area-inset-top)); left: 12px;
  color: #fff0cf; font-size: 12px; text-decoration: none; padding: 9px 12px;
  background: #211914b8; border: 1px solid #c4a27666; border-radius: 20px; }
.title-start { position: absolute; bottom: 13%; left: 10%; width: 80%; border: 0;
  background: transparent; text-shadow: 0 2px 5px #000, 0 0 10px #000; font-size: 23px;
  color: #fff0c7; font-family: 'Gungsuh', "AppleMyungjo","Noto Serif KR", serif; animation: start-blink 2.8s ease-in-out infinite; }
.title-reset { position: absolute; right: 15px; bottom: 25px; font-size: 12px;
  border-color: #d7bf8666; background: #24190daa; color: #e6d1a6; }
.title-petal { position: absolute; top: -5%; left: var(--x); width: 9px; height: 15px;
  border-radius: 80% 0 80% 0; background: #ffd3c2b3; pointer-events: none;
  animation: petal-fall var(--duration) var(--delay) linear infinite; }
@keyframes logo-enter { from { opacity: 0; transform: scale(1.15); } to { opacity: 1; transform: scale(1); } }
@keyframes start-blink { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes petal-fall { to { transform: translate(65px, 110dvh) rotate(310deg); } }
/* 객잔 바닥의 협객과 상자는 목록 없이 장면 위에서 직접 누른다. */
body:has(.inn-screen) main.orak-stage { padding: calc(var(--status-height) + 8px) 0 calc(var(--menu-height) + 16px);
  background: url('sprites/ui-inn.webp') center / cover; }
.inn-screen { background: none; border-radius: 0; }
.inn-scene { position: relative; height: calc(100dvh - 154px - env(safe-area-inset-top, 0px)); min-height: 460px; }
.inn-party { position: absolute; left: 0; right: 0; top: 50%; height: 33%; }
.inn-hero { position: absolute; width: 19%; height: 100%; padding: 0; border: 0;
  left: calc(7% + var(--slot) * 19%); top: calc((var(--slot) / 2) * 13%);
  background: transparent; overflow: visible; }
.inn-hero:nth-child(2n) { top: -20%; }
.inn-hero canvas { position: absolute; top: 14%; left: -20%; width: 200%; height: auto;
  display: block; pointer-events: none; background: transparent; }
.inn-hero > span { position: absolute; left: 50%; transform: translateX(-50%); bottom: -4%;
  font-size: 12px; color: #ffeac0; white-space: nowrap; pointer-events: none;
  text-shadow: 0 2px 4px #000; background: #2d1c1199; padding: 2px 8px; border-radius: 12px; }
.treasure-chest { position: absolute; top: 30%; right: 17%; width: 76px; height: 70px;
  display: grid; place-items: center; background: transparent; border: 0; padding: 0; z-index: 4; }
.treasure-chest .game-icon { width: 70px; height: 64px; border-radius: 12px 12px 6px 6px; }
.treasure-chest .wood-badge { font-size: 20px; border-width: 3px;
  background: linear-gradient(#8d622e 0 33%, #d0a054 34% 40%, #674018 41%); }
.chest-lid { position: absolute; top: 3px; width: 66px; height: 24px; border: 2px solid #e0b86b;
  border-radius: 9px 9px 0 0; background: linear-gradient(#ac7b3f, #5c361c); opacity: 0;
  transform-origin: 50% 100%; pointer-events: none; }
#chest-ad { position: absolute; top: calc(40% + 22px); right: 2%; width: 56%; display: flex; justify-content: center; z-index: 5; }
#chest-ad .orak-ad-btn { min-height: 40px; padding: 6px 10px; font-size: 13px; }
#chest-ad .orak-ad-done { color: #ffe3a0; text-shadow: 0 2px 4px #000; font-size: 12px; }
#chest-time { position: absolute; top: 40%; right: 5%; width: 47%; text-align: center;
  color: #ffe3a0; text-shadow: 0 2px 4px #000; font-size: 11px; }
.chest-ready { animation: chest-bounce 1.8s ease-in-out infinite; filter: drop-shadow(0 0 9px #ffcf67); }
.chest-opening { animation: chest-shake .5s ease-in-out; filter: drop-shadow(0 0 16px #ffd96a); }
.chest-opening .chest-lid { opacity: 1; animation: lid-open .5s .5s ease-out both; }
.depart-button { position: absolute; bottom: 5%; left: 7%; width: 86%; min-height: 64px;
  font: bold 20px 'Gungsuh', '궁서', serif; color: #ffecc6; border: 2px solid #d4a54c;
  border-radius: 12px 4px; background: linear-gradient(110deg, #533017, #8b5026, #422714);
  box-shadow: 0 4px 14px #0008, inset 0 0 0 3px #2a190e88; }
body:has(.inn-screen) .settings { position: absolute; top: 80px; right: 10px; margin: 0; opacity: .8; }
body:has(.inn-screen) .settings button { min-height: 30px; padding: 4px 8px; font-size: 10px; }
.reward-flight { position: fixed; z-index: 30; left: calc(50% + 35px); top: 38dvh;
  pointer-events: none; animation: reward-flight .8s ease-in both; }
.flight-iron { animation-delay: .08s; --target-y: -32dvh; }
.flight-silver { --target-y: -35dvh; }
@keyframes chest-bounce { 0%, 65%, 100% { transform: translateY(0); } 80% { transform: translateY(-9px); } }
@keyframes chest-shake { 25%, 75% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes lid-open { from { transform: rotateX(0); } to { transform: translateY(-20px) rotate(-25deg); } }
@keyframes reward-flight {
  0% { opacity: 0; transform: translate(0, 0) scale(.5); }
  20% { opacity: 1; transform: translate(-30px, -50px) scale(1); }
  100% { opacity: 0; transform: translate(95px, var(--target-y)) scale(.4); }
}
body.at-title #wallet, body.at-title #nav { display: none; }
/* 소리 단추는 시작 화면에서도 보인다(톱니 왼쪽) */
body.at-title .settings { display: flex; top: max(14px, env(safe-area-inset-top)); }
body.battling main.orak-stage { padding-top: 76px; }
body.battling #wallet { display: flex; }
@media (prefers-reduced-motion: reduce) {
  .title-logo, .title-start, .title-petal, .chest-ready, .chest-opening,
  .chest-opening .chest-lid, .reward-flight { animation: none; }
  .title-petal { display: none; }
  .chest-opening .chest-lid { transform: translateY(-20px) rotate(-25deg); }
}
/* 타이틀 아래의 밝은 그림을 눌러 읽기 쉬운 시작 글자를 만든다. */
.title-screen::after { content: ''; position: absolute; inset: 75% 0 0;
  background: linear-gradient(transparent, #100b09e8); pointer-events: none; }
.title-start { z-index: 2; font-size: 36.8px; font-weight: 900; line-height: 1.3;
  -webkit-text-stroke: 1.2px #20110b; paint-order: stroke fill;
  text-shadow: 2px 2px 0 #20110b, -2px -2px 0 #20110b, 0 4px 8px #000, 0 0 16px #000;
  animation: none; }
.title-reset { z-index: 2; }
/* 협객 몸 크기를 1.5배로 키워 바닥에 두 줄로 세운다. */
.inn-party { top: 0; height: 100%; }
.inn-hero { width: 50%; height: 254px; left: 0; top: calc(63% - 254px); z-index: 2; }
.inn-hero:nth-child(2n) { left: 50%; top: calc(63% - 254px); }
.inn-hero:nth-child(n+3) { top: calc(85% - 254px); z-index: 3; }
.inn-hero canvas { width: 220px; height: auto; left: calc(50% - 110px); top: 0; }
.inn-hero > span { bottom: -4px; }
/* 설정은 톱니 하나에서 열고 닫는 작은 판에 모은다. */
.settings, body:has(.inn-screen) .settings { position: fixed; z-index: 24; top: calc(var(--status-height) + 8px);
  right: max(10px, calc((100vw - 520px) / 2 + 10px)); margin: 0; opacity: 1; }
#settings-toggle, body:has(.inn-screen) #settings-toggle { width: 46px; height: 46px; border-radius: 14px;
  font-size: 26px; padding: 0; color: #ffe5aa; background: #302016e8; border: 1px solid #a6814a; }
#settings-panel { position: absolute; right: 0; top: 48px; width: 140px; padding: 10px;
  background: #251a13f5; border: 1px solid #bd9856; border-radius: 10px; box-shadow: 0 6px 20px #0008; }
#settings-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#settings-panel[hidden] { display: none; }
#settings-panel button:not(.orak-tool) { width: 100%; font-size: 14px; margin: 4px 0; }
/* 장 그림은 화면 폭에 맞춰 고정 비율로 펼치고 길 위 판을 눌러 출정한다. */
body:has(.map-screen) main.orak-stage { padding: calc(var(--status-height) + 8px) 0 calc(var(--menu-height) + 16px);
  overflow: hidden; }
body:has(.map-screen) .settings { display: none; }
.map-header { height: 48px; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding-left: 70px; color: #ffe8b4; background: #302015; border-bottom: 1px solid #bc9655; }
.map-header strong { font-size: 15px; }
.map-header button { padding: 0 6px; font-size: 28px; min-width: 32px; background: transparent; border: 0; }
.map-viewport { position: relative; height: calc(100dvh - var(--status-height) - var(--menu-height) - 72px);
  overflow-y: auto; overflow-x: hidden;
  background: #201b14; touch-action: pan-y; overscroll-behavior: contain; }
.chapter-map { position: relative; width: 100%; aspect-ratio: 2 / 3; margin: 180px 0;
  background-position: center; background-size: 100% 100%; }
.map-trails { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-trails line { stroke-width: 7; stroke-linecap: round; stroke-dasharray: 2 19; }
.trail-cleared { stroke: #ffd573; filter: drop-shadow(0 1px 2px #351b0e); }
.trail-locked { stroke: #d6c9a980; }
.map-node { position: absolute; transform: translate(-50%, -50%); width: 48px; height: 48px;
  min-height: 0; border: 2px solid #bd8c37; border-radius: 50%; padding: 0;
  background: radial-gradient(circle at 35% 25%, #ffe7a5, #ab6924); color: #25170d;
  box-shadow: 0 3px 7px #0009; display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 3; }
.map-node .node-number { font-size: 13px; font-weight: 900; line-height: 1.1; }
.map-node small { font-size: 10px; color: #633308; line-height: 1.3; }
.node-next { width: 58px; height: 58px; border: 3px solid #fff0ad;
  box-shadow: 0 0 18px #ffd469, 0 0 0 5px #ffc96140; animation: node-bounce 1.3s ease-in-out infinite; }
.node-locked { background: #4f453de0; border-color: #968778; color: #ded3c4; opacity: .68; }
.node-locked small { color: #ded3c4; }
.boss-node { width: 96px; height: 96px; border-width: 3px; }
.map-node canvas { width: 100%; height: 100%; border-radius: 50%; position: absolute; inset: 0; }
.map-node:has(canvas) .node-number, .map-node:has(canvas) small { position: relative; z-index: 1;
  background: #28170ce0; color: #ffe5a0; border-radius: 6px; padding: 1px 4px; }
.map-node:has(canvas) .node-number { margin-top: 60%; }
.map-mandu { position: absolute; width: 100px; height: auto; transform: translate(-50%, -90%);
  pointer-events: none; z-index: 4; }
.departure-card { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: 82px;
  width: min(100%, 520px); padding: 20px 20px 14px; border: 2px solid #caa259; border-radius: 22px 22px 0 0;
  color: #ffe9bd; background: linear-gradient(#3c2a1cf5, #21170ffc); box-shadow: 0 -8px 28px #0008;
  animation: card-rise .2s ease-out; }
.departure-card > strong { display: block; padding-right: 28px; font-size: 19px; }
.departure-card p { font-size: 13px; margin: 12px 0; }
.departure-card .power-short { color: #ff8c80; }
.card-close { position: absolute; top: 8px; right: 10px; padding: 0; width: 36px; background: transparent; }
.map-enemies { display: flex; gap: 14px; margin: 12px 0; }
.map-enemies > div { position: relative; width: 84px; text-align: center; }
.map-enemies canvas { width: 56px; height: 56px; border-radius: 50%; background: #dbc48a;
  border: 2px solid #bd9652; }
.map-enemies small { font-size: 10px; display: block; }
.map-enemies .game-icon { position: absolute; right: 0; top: 30px; width: 26px; height: 26px; }
.map-reward { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.map-reward .game-icon { width: 28px; height: 28px; }
.map-actions { display: flex; gap: 10px; margin-top: 12px; }
.map-actions button { flex: 1; }
.bracket-label { position: absolute; left: 50%; transform: translateX(-50%); font-size: 12px;
  color: #ffe7a2; background: #2d190de0; padding: 2px 12px; border-radius: 8px; }
.tournament-map { background-color: #26180c; }
.tournament-map { margin: 0; }
.bracket-winner { position: absolute; top: 32%; left: 50%; transform: translateX(-50%);
  padding: 3px 14px; border: 1px solid #b99154; border-radius: 6px;
  background: #35251ee8; color: #d9bc81; font-size: 12px; font-weight: 900; }
.bracket-winner.champion { background: linear-gradient(#fff0a8, #d8a234); color: #42250c;
  box-shadow: 0 0 14px #ffcc6770; }
.raid-label { position: absolute; top: 1%; left: 5%; color: #ffce92; font-size: 13px;
  background: #431b12e8; padding: 3px 9px; border-radius: 6px; }
.tournament-map .boss-node { width: 72px; height: 72px; }
.tournament-map .raid-node { border-color: #ff842e; background: radial-gradient(#ffd783, #a52f16);
  box-shadow: 0 0 0 3px #ffb12e60, 0 0 14px #ff531d; }
.tournament-map .raid-node.node-locked { background: #4f322be0; }
.tournament-map .map-trails .raid-trail { stroke-dasharray: 2 19; stroke-width: 7; }
.tournament-map::before { content: ''; position: absolute; inset: 0; background: #1c100d50; }
.tournament-map .map-trails line { stroke-dasharray: none; stroke-width: 5; }
.tournament-map .map-mandu { width: 80px; }
.tournament-map .map-node:not(.boss-node) { width: 56px; height: 56px; }
@keyframes node-bounce { 50% { transform: translate(-50%, calc(-50% - 5px)); } }
@keyframes card-rise { from { margin-bottom: -200px; } to { margin-bottom: 0; } }
/* 용봉대전은 북소리와 양쪽 대표의 그림으로 승부를 예고한다. */
.vs-screen { position: fixed; z-index: 21; inset: 0 auto 0 50%;
  transform: translateX(-50%); width: min(100%, 520px); overflow: hidden;
  background: linear-gradient(#110b0966, #110b09aa), url('sprites/ui-arena.webp') center / cover; }
.vs-word { position: absolute; top: 43%; left: 50%; transform: translate(-50%, -50%) rotate(-8deg);
  font: italic 900 58px Georgia, serif; color: #ffe596; -webkit-text-stroke: 2px #6d2710;
  text-shadow: 0 6px 0 #36150e, 0 0 25px #ffb146; z-index: 2; }
.vs-screen > p { position: absolute; top: 72%; width: 100%; margin: 0; text-align: center;
  font: bold 30px 'Gungsuh', serif; color: #ffe6b7; text-shadow: 0 3px 6px #000; }
.vs-names { position: absolute; top: 63%; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  text-align: center; font-size: 22px; font-weight: 900; color: #ffe5b3;
  -webkit-text-stroke: 3px #21130d; paint-order: stroke fill; text-shadow: 0 3px 4px #000; }
.vs-names span { min-width: 0; padding: 0 6px; line-height: 1.25; word-break: keep-all; }
.vs-fighter { position: absolute; top: 20%; height: 42%; width: 48%; }
.vs-fighter.ally { left: 0; animation: vs-left .4s ease-out both; }
.vs-fighter.opponent { right: 0; animation: vs-right .4s ease-out both; }
.vs-fighter img { width: 100%; height: 100%; object-fit: fill; object-position: center bottom;
  filter: drop-shadow(0 8px 10px #0008); }
.vs-fighter.opponent img { transform: scaleX(-1); }
@keyframes vs-left { from { translate: -100% 0; } to { translate: 0 0; } }
@keyframes vs-right { from { translate: 100% 0; } to { translate: 0 0; } }
/* 그림 카드 화면은 상태 띠와 메뉴 사이의 공간을 채운다. */
#screen.cards-screen { padding: 40px 0 0; }
.cards-screen h1 { font-size: 23px; margin: 12px 0 16px; color: #ffe5aa; }
body:has(.cards-screen) .settings { display: none; }
.hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hero-tile { position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; min-width: 0; border: 2px solid var(--element); border-radius: 16px;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--element) 35%, #252234), #17151f 80%);
  box-shadow: inset 0 0 20px #0005, 0 5px 10px #0003; overflow: hidden; }
.hero-tile:disabled { opacity: 1; }
.card-sprite { width: 100%; height: 180px; object-fit: cover; object-position: left bottom; pointer-events: none; }
.hero-tile strong { font-size: 19px; }
.hero-tile small { font-size: 11px; margin-top: 4px; }
.silhouette { filter: brightness(0); opacity: .8; }
.stars { color: #ffda72; letter-spacing: 2px; }
.element-badge { position: absolute; top: 9px; left: 9px; width: 34px; height: 34px; object-fit: contain; z-index: 2; }
.hero-level { position: absolute; right: 10px; top: 12px; color: #fff1cf; z-index: 2; }
.red-dot, .has-alert::after { position: absolute; right: 5px; top: 4px; width: 10px; height: 10px;
  background: #ff4b50; border: 2px solid #ffd6ae; border-radius: 50%; box-shadow: 0 0 8px #f33; content: ''; }
.wallet-party { position: relative; padding: 0; min-height: 38px; border: 0; background: transparent; }
.wallet-party .game-icon { width: 30px; height: 30px; }
.power-value strong { font-size: 22px; }
.wallet-resources { font-size: 11px; }
.hero-showcase { position: relative; margin: 0 -12px; height: 330px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 55%, var(--element), #252137 80%); touch-action: pan-y; }
.hero-demonstration { width: 100%; height: 270px; padding: 0; border: 0; background: transparent; }
.detail-cutin { height: 270px; width: 100%; object-fit: contain; }
.detail-action { display: none; height: 270px; object-fit: contain; }
.hero-demonstration:has(.demonstrating) .detail-cutin { display: none; }
.detail-action.demonstrating { display: block; }
.detail-caption { height: 60px; padding: 6px 0; background: #15111ed9; text-align: center; }
.hero-showcase .detail-caption h1 { margin: 0; font-size: 23px; line-height: 28px; }
.detail-caption p { margin: 3px 0 0; font-size: 12px; color: #ffe4b2; }
.detail-prev, .detail-next { position: absolute; top: 45%; background: #17141e88; font-size: 28px;
  width: 36px; padding: 0; border-color: #ffe3a155; }
.detail-prev { left: 9px; } .detail-next { right: 9px; }
.detail-power { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 0 8px; }
.detail-power strong { font-size: 32px; color: #ffe0a0; }
.stat-bars { display: grid; gap: 5px; }
.stat-meter { position: relative; display: flex; align-items: center; gap: 8px; height: 27px;
  border-radius: 6px; overflow: hidden; background: linear-gradient(90deg, #987943 var(--fill), #332c3a var(--fill)); }
.stat-meter img { width: 25px; height: 25px; object-fit: contain; }
.stat-meter span { font-size: 12px; text-shadow: 0 1px 3px #000; }
.skill-name { display: block; color: #ffdb87; margin-top: 10px; }
.skill-desc { margin: 4px 0 10px; font-size: 11px; }
.upgrade-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.upgrade-button { width: 100%; padding: 5px 2px; display: flex; flex-direction: column; align-items: center;
  border-color: #b79154; background: linear-gradient(#4d3b30, #251b23); }
.upgrade-button img, .upgrade-button b { width: 35px; height: 35px; object-fit: contain; font-size: 30px; }
.upgrade-button small { font-size: 11px; }
.upgrade-cost { display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 10px; }
.upgrade-cost img { width: 18px; height: 18px; object-fit: contain; }
.upgrade-tile.unavailable { opacity: .4; }
.upgrade-beam { position: absolute; inset: 0 18%; pointer-events: none;
  background: linear-gradient(90deg, transparent, #fff6a7cf, #fff, #fff6a7cf, transparent);
  animation: upgrade-light 1.6s ease-out forwards; mix-blend-mode: screen; }
.upgrade-gain { position: absolute; top: 58%; left: 0; width: 100%; text-align: center;
  color: #fff3a7; font-size: 19px; text-shadow: 0 2px 5px #462500; animation: gain-rise 1.6s ease-out forwards; }
@keyframes upgrade-light { 0% { opacity: 0; scale: .2 1; } 25% { opacity: .9; } 100% { opacity: 0; scale: 1.4 1; } }
@keyframes gain-rise { from { translate: 0 25px; opacity: 1; } to { translate: 0 -45px; opacity: 0; } }
.formation-field { position: relative; height: 240px; margin: 0 -12px 10px;
  background-position: center; background-size: cover; border-bottom: 2px solid #a08248; }
.formation-field::before { content: ''; position: absolute; inset: 0;
  background: linear-gradient(#20152511, #20152599); }
.formation-slot { position: absolute; width: 42%; height: 115px; background: transparent; border: 0; padding: 0; }
.formation-slot::before { content: ''; position: absolute; bottom: 17px; left: 10%; width: 80%; height: 28px;
  border: 2px solid #d3b477; border-radius: 50%; background: radial-gradient(#b29c6880, #382b2388); }
.formation-slot.empty::before { border-style: dashed; }
.slot-0 { left: 9%; top: 119px; } .slot-1 { right: 3%; top: 119px; }
.slot-2 { left: 9%; top: 3px; } .slot-3 { right: 3%; top: 6px; }
.formation-slot .card-sprite { position: absolute; bottom: 20px; left: 0; height: 95px; }
.formation-slot strong { position: absolute; bottom: 0; left: 0; width: 100%; text-shadow: 0 2px 3px #000; }
.formation-slot.empty strong { bottom: 18px; font-size: 35px; }
.row-label { position: absolute; left: 6px; writing-mode: vertical-rl; padding: 6px 3px;
  background: #21182bcb; border-left: 2px solid #c7a770; color: #ffecbe; font-size: 11px; }
.row-label.back { top: 48px; } .row-label.front { top: 164px; }
.auto-party { width: 100%; }
.formation-hint { font-size: 12px; text-align: center; margin: 8px 0 2px; }
.face-strip, .album-strip { display: flex; gap: 10px; overflow-x: auto; padding: 6px 0 12px; touch-action: pan-x; }
.face-tile { position: relative; flex: 0 0 110px; min-width: 0; height: 140px; padding: 20px 6px 6px;
  border: 2px solid var(--element);
  background: linear-gradient(#46404d, #211a28); display: flex; flex-direction: column; align-items: center; }
.face-tile:disabled { opacity: .7; } .face-tile.selected { box-shadow: inset 0 0 15px #ffd76966; opacity: 1; }
.face-portrait { width: 76px; height: 76px; object-fit: cover; border-radius: 50%; }
.face-tile .element-badge { width: 24px; height: 24px; left: 3px; top: 3px; }
.face-tile .hero-level { font-size: 10px; top: 5px; right: 5px; }
.face-tile strong { font-size: 13px; margin-top: 4px; }
.affinity { display: flex; gap: 4px; min-height: 14px; font-size: 10px; }
.favorable { color: #8fe0a3; } .unfavorable { color: #ff9393; }
.training-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.training-card { position: relative; min-height: 150px; display: flex; flex-direction: column; justify-content: end;
  gap: 5px; padding: 12px 8px; background: radial-gradient(var(--element), #242638);
  background-position: center; background-size: cover; border: 2px solid var(--element); border-radius: 14px;
  overflow: hidden; text-shadow: 0 2px 5px #000; }
.training-card::before { content: ''; position: absolute; inset: 45% 0 0;
  background: linear-gradient(transparent, #15111ee8); }
.training-card strong, .training-card small { position: relative; z-index: 1; }
.training-card strong { font-size: 16px; } .training-card small { font-size: 10px; }
.training-card.open { grid-column: 1 / -1; min-height: 240px; }
.training-card.locked { filter: grayscale(.8); opacity: .45; }
.training-actors { position: absolute; inset: 20px 0 40px; display: flex; justify-content: center; }
.training-actors .card-sprite { min-width: 0; width: 50%; height: 100%; }
.training-rewards { display: flex; gap: 12px; justify-content: center; padding: 12px; }
.training-reward { position: relative; width: 65px; text-align: center; }
.training-reward img { width: 60px; height: 60px; object-fit: contain; }
.training-reward .flying-scroll { position: absolute; left: 12px; top: 0; width: 35px;
  animation: scroll-flight 1s ease-out forwards; }
@keyframes scroll-flight { from { translate: 0 -130px; opacity: 1; } to { translate: 0 20px; opacity: 0; } }
body:has(.cards-screen.map-screen) main.orak-stage {
  padding: calc(var(--status-height) + 8px) 12px calc(var(--menu-height) + 16px); overflow: visible; }
.tower-scene { position: relative; height: 440px; margin: 0 -12px;
  background-size: cover; background-position: center; }
.tower-scene::before { content: ''; position: absolute; inset: 0; background: #10102133; }
.tower-platform { position: absolute; transform: translate(-50%, -50%); width: 65px; min-height: 32px;
  padding: 3px; border-radius: 50%; background: #363145e8; border: 2px solid #82758f; font-size: 12px; }
.tower-platform.cleared { color: #ffe6a5; background: #765b25e8; border-color: #f2c668; }
.tower-platform.next { box-shadow: 0 0 20px #ffe4a8; border-color: #fff0b0; animation: node-glow 1.5s infinite; }
.tower-platform.boss { border-color: #df8674; }
.tower-platform canvas { width: 35px; height: 35px; display: block; margin: -22px auto 0; }
.tower-platform:disabled { opacity: .7; }
.tower-controls { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.tower-controls button { padding: 5px 18px; min-height: 34px; }
.tower-challenge { width: 100%; font-size: 17px; }
.tower-scene.locked { background-blend-mode: luminosity; background-color: #252535; opacity: 1; }
.tower-scene.locked::before { background: #161526a0; backdrop-filter: blur(3px); }
.tower-lock { position: absolute; top: 33%; width: 100%; text-align: center; font-size: 70px; }
.tower-lock-message { position: absolute; top: 57%; width: 100%; text-align: center; color: #ffe5aa; }
.album-heading { font-size: 15px; color: #e8c58b; margin: 18px 0 4px; }
.album-card { flex: 0 0 210px; padding: 0; overflow: hidden; background: #271f2c; border-color: #987b4f; }
.album-card > img { width: 210px; height: 120px; object-fit: cover; display: block; }
.album-card > strong { display: block; padding: 9px; font-size: 12px; text-align: left; }
.album-card.locked img { filter: blur(3px) grayscale(1); opacity: .35; }
.album-card:disabled { opacity: .8; }
body.battling #wallet, body.in-versus #wallet, body.in-versus #nav { display: none; }
body.battling main.orak-stage { padding-top: env(safe-area-inset-top, 0px); }
@media (prefers-reduced-motion: reduce) {
  .tower-platform.next, .vs-fighter { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .map-node, .departure-card, .vs-screen img { animation: none; }
}
/* 지도 협객의 투명 캔버스에는 공통 전장 배경색을 적용하지 않는다. */
.map-mandu, .map-node canvas { background: transparent; border: 0; border-radius: 0; }
.map-node canvas { border-radius: 50%; }
.map-node:disabled { opacity: .68; }
/* 타이틀 바탕의 입력 영역은 다른 화면 버튼의 누름 모양과 분리한다. */
.title-touch { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; }
.title-logo { z-index: 1; }
/* 다음 도전 판은 가까운 잠긴 판보다 위에서 터치를 받는다. */
.node-next { z-index: 6; }
/* 전투 조작은 두루마리와 세 개의 원형 단추로 구성한다. */
.battle-top { align-items: center; gap: 8px; padding: 5px 2px; }
.battle-top #wave { display: flex; align-items: center; gap: 8px; margin-right: auto;
  padding: 10px 13px; border: 1px solid #b58c52; border-radius: 16px 5px;
  background: linear-gradient(90deg, #50311c, #b28b4c 7%, #dbc18a 13%, #c9a467 87%, #50311c);
  color: #392515; box-shadow: 0 3px 5px #0008; }
#wave i { width: 9px; height: 9px; border: 1px solid #8c6d49; border-radius: 50%; background: #987b5680; }
#wave i.past { background: #e9b947; border-color: #a77625; }
#wave i.current { width: 13px; height: 13px; background: #fff1c1; border: 2px solid #7b4c23;
  box-shadow: 0 0 6px #fff1b5, 0 0 12px #ffd35b; }
#wave small { margin-left: 3px; font-size: 14px; font-weight: 700; color: #3a2410; }
.battle-top button { position: relative; width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: 2px solid #b7955b; border-radius: 50%; font: bold 19px Georgia, serif;
  color: #ffe5a0; background: radial-gradient(at 35% 25%, #65492c, #22180f); }
#auto { font-size: 32px; }
#auto.locked::after { content: '🔒'; position: absolute; right: -3px; bottom: -3px; font-size: 13px; }
#auto.ready, .result-main.ready { box-shadow: 0 0 18px #ffd96a, inset 0 0 12px #ffdf8580; }
/* 멈춘 전장 위에 결과를 한 화면으로 띄운다. */
body.battling.battle-result { overflow: hidden; }
body.battling.battle-result main.orak-stage { height: 100dvh; min-height: 0; overflow: hidden; padding: 0; }
body.battling.battle-result #wallet, body.battling.battle-result #nav { display: none; }
body.battling.battle-result #fight { flex: 1; margin: 0; touch-action: none; }
body.battling.battle-result #canvas { flex: 1; height: 0; }
#fight.finished .battle-top, #fight.finished #cards, #fight.finished #cutin,
#fight.finished > .hint { visibility: hidden; }
#fight .result-panel { position: fixed; inset: 0; z-index: 20; width: min(100%, 520px); height: 100dvh;
  margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 24px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #77502680, #16121de8 70%); border: 0; border-radius: 0; }
#fight .result-title { margin: 0; color: #ffda77; font: bold 76px 'Gungsuh', '궁서', serif;
  letter-spacing: 12px; -webkit-text-stroke: 1px #765023;
  text-shadow: 0 4px 0 #382011, 0 8px 14px #000, 0 0 24px #f9b447;
  animation: result-reveal .45s cubic-bezier(.2,1.5,.5,1) both; }
.result-stars { font-size: 43px; line-height: 1.1; color: #ffdc76; text-shadow: 0 3px 4px #000; }
.result-mvp { position: relative; width: 100%; flex: 1; min-height: 130px; max-height: 300px;
  background: radial-gradient(ellipse, #f3cc7840, transparent 70%); }
.result-mvp > img { width: 100%; height: 100%; object-fit: contain; }
.result-mvp > strong { position: absolute; bottom: 0; left: 12%; width: 76%; padding: 6px;
  background: linear-gradient(90deg, transparent, #a97432, #392713, transparent); color: #ffe5a0;
  text-align: center; }
.result-rewards { display: flex; justify-content: center; gap: 20px; padding: 10px 0; }
.result-rewards span { display: flex; align-items: center; gap: 6px; color: #ffdf91; }
.result-rewards img { width: 30px; height: 30px; object-fit: contain; }
#fight .result-main { width: 100%; min-height: 60px; margin: 0; font-size: 21px; color: #ffe9b3;
  border: 2px solid #cc9d52; border-radius: 9px;
  background: repeating-linear-gradient(2deg, #5e351e, #5e351e 7px, #6e4227 8px, #6e4227 10px);
  box-shadow: inset 0 0 0 3px #382315, 0 4px 0 #20120c, 0 7px 15px #0007; }
.result-actions { display: flex; justify-content: center; gap: 20px; }
#fight .result-actions button { display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 62px; height: 70px; min-height: 0; margin: 0; padding: 6px; border-radius: 50%;
  border: 1px solid #b7975c; background: radial-gradient(at 35% 25%, #735333, #261a10); }
.result-actions img { width: 38px; height: 38px; object-fit: contain; }
.result-actions small { font-size: 11px; }
.result-next { width: 100%; margin-top: auto; display: flex; justify-content: space-around; gap: 8px; }
.result-next .orak-next-title { display: none; }
.result-next .orak-next-card { display: flex; flex: 1; min-width: 0; flex-direction: column;
  gap: 4px; padding: 3px; background: transparent; border: 0; margin: 0; text-decoration: none; }
.result-next .orak-next-icon { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 14px; }
.result-next .orak-next-icon img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; }
.result-next .orak-next-text { min-width: 0; flex: none; text-align: center; }
.result-next .orak-next-text strong { display: block; max-width: 90px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: #ccb992; }
.result-next .orak-next-sub, .result-next .orak-next-arrow { display: none; }
#fight .result-panel[data-outcome='lose'] { background: radial-gradient(ellipse, #582327a0, #110e18ed 70%); }
#fight [data-outcome='lose'] .result-title { color: #b34445; -webkit-text-stroke-color: #3e151c;
  text-shadow: 0 4px 0 #220b12, 0 8px 14px #000; }
.result-down { width: 100%; height: min(30dvh, 240px); object-fit: contain; margin: auto 0 0; }
.defeat-advice { width: 100%; padding: 16px 10px; border: 1px solid #94724d; border-radius: 12px;
  background: #31241ce6; text-align: center; color: #eed4a3; }
.upgrade-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.upgrade-row .face { width: 54px; height: 54px; }
#fight .upgrade-action { flex: 1; margin: 0; padding: 12px 8px; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid #dfb85a;
  background: linear-gradient(#624528, #35251b); color: #ffe5a0; animation: upgrade-glow 2.4s ease-in-out infinite; }
.upgrade-arrow { font-size: 23px; line-height: 1; color: #ffdc76; }
@keyframes upgrade-glow { 0%, 100% { box-shadow: 0 0 4px #ffd96a30; }
  50% { box-shadow: 0 0 14px #ffd96a80, inset 0 0 8px #ffdf8520; } }
@keyframes result-reveal { from { opacity: 0; transform: scale(.45); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .result-title, .result-stars span, #fight .upgrade-action { animation: none; } }

/* 결과·이야기에서도 홈 단추는 한 줄을 차지해 그림과 조작을 가리지 않는다. */
.story-top > .orak-home-button { order: -1; }
.battle-top { margin-left: 8px; margin-right: 8px;
  padding-left: max(2px, env(safe-area-inset-left, 0px));
  padding-right: max(2px, env(safe-area-inset-right, 0px)); }
.battle-top #wave { min-width: 0; gap: 4px; padding-left: 8px; padding-right: 8px; overflow: hidden; }
.battle-top > button { flex-shrink: 0; }
.result-panel > .orak-home-button { align-self: flex-start; }

/* 대결 소개는 fixed 덮개라 그 안에 홈 단추를 넣어야 가려지지 않는다. */
.vs-screen > .orak-home-button { position: absolute; z-index: 1;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px)); }
#story-skip-slot button{white-space:nowrap}

/* Star rewards and the shared record book reserve space outside the scrolling map. */
#nav { grid-template-columns:repeat(6,minmax(0,1fr)); }
#nav .menu-item { min-width:44px; min-height:44px; }
#nav .menu-item > span:last-child { max-width:100%; overflow-wrap:normal; word-break:normal; hyphens:auto; }
#nav .game-icon { width:38px; height:38px; }
.star-bar { display:flex; align-items:center; justify-content:space-around; gap:4px; padding:4px 8px; min-height:60px; background:#30251b; color:#ffe1a0; }
.star-bar strong { white-space:nowrap; font-size:14px; }
.star-chest { display:flex; align-items:center; gap:2px; padding:3px; min-width:60px; min-height:48px; font-size:12px; }
.star-chest .game-icon { width:27px; height:27px; }
.star-chest.ready { box-shadow:0 0 10px #ffd86c; border-color:#ffe6a2; }
.star-chest.opened { opacity:.7; }
.map-screen:has(.star-bar) .map-viewport { height:calc(100dvh - var(--status-height) - var(--menu-height) - 140px); }
.star-reward { width:min(320px,90vw); padding:20px; color:#ffe6b0; background:#30251b; border:2px solid #b78a49; border-radius:12px; }
.star-reward::backdrop { background:#0009; }
.title-stamp { border:2px solid #bb7657; padding:10px; color:#ffd089; }
.weekly-rule, #tower-rule-hud { display:block; padding:8px; margin:0; background:#473122; color:#ffe6a9; text-align:center; font-size:12px; }
#tower-rule-hud[hidden] { display:none; }
.tower-week { margin:6px 0; text-align:center; }
#screen .osc-label { word-break:normal; overflow-wrap:normal; hyphens:auto; }
.map-header button, #hub-back, .card-close, .tower-controls button, .tower-platform { min-width:44px; min-height:44px; }

#screen .osc-header { position:static; height:auto; background:none; }

#nav .menu-item > span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#screen .osc-title, #screen .osc-sub { overflow-wrap:normal; word-break:normal; hyphens:auto; }

/* Seven hub entries retain a 44px target at 360px. */
#nav { grid-template-columns:repeat(7,minmax(0,1fr)); }
#nav .menu-item { padding-inline:1px; font-size:10px; }
.duel-screen { margin:12px auto; padding:16px; max-width:480px; background:#261e17ed; border:1px solid #b99a60; border-radius:12px; color:#ffe6b5; text-align:center; overflow-wrap:normal; word-break:normal; hyphens:auto; }
.duel-screen h1 { font-size:24px; margin:8px 0; }
.duel-screen p { margin:14px 0; }
.duel-screen button { min-height:44px; min-width:80px; margin:6px; }
.duel-opponents { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; }
.duel-opponents figure { margin:0; min-width:0; }
.duel-opponents img { width:100%; aspect-ratio:1; object-fit:contain; }
.duel-opponents figcaption { font-size:11px; }

#nav [data-menu="duel"] > span:last-child { white-space:normal; word-break:keep-all; line-height:12px; }

.duel-opponents figcaption { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.battle-tools{display:flex;justify-content:flex-end;gap:6px;flex-shrink:0;padding:2px 8px}.wallet-party{min-width:44px;min-height:44px}

html:not([lang="ko"]) #nav button{white-space:normal;text-overflow:clip;overflow:visible;overflow-wrap:anywhere;font-size:10px;line-height:1.15;min-width:0;padding-inline:1px}

html:not([lang="ko"]) #nav .menu-item>span:last-child{white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere;line-height:1.4;min-height:28px;font-size:10px}
/* 전투 중 소리·진동: 전장 그림 오른쪽 위에 얹는다(한 줄을 따로 쓰지 않게) */
.battle-tools{position:absolute;right:8px;top:0;z-index:3;padding:0}
#fight{position:relative}
.battle-tools button{opacity:.92;box-shadow:0 2px 8px #0006}
/* 비무 상대 이름: 말줄임 대신 두 줄까지 (문파 · 이름) */
.duel-opponents figcaption { white-space:normal; overflow:visible; text-overflow:clip; font-size:10px; line-height:1.2; word-break:keep-all; text-align:center; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; min-height:2.4em; }
