:root {
  --ink-deep: #111613;
  --ink-panel: #1a211d;
  --ink-slot: #222b26;
  --border-ink: #34423a;
  --paper: #f5eedc;
  --paper-dim: #c2cdc6;
  --ink-text: #2a2118;
  --ink-text-dark: #1c140e;
  --jade: #5ea878;
  --jade-deep: #2f5e40;
  --gold: #f0c45c;
  --gold-glow: rgba(240, 196, 92, 0.48);
  --red: #d45242;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0d0b;
  color: var(--paper);
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-variant-numeric: tabular-nums;
}

.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--ink-deep);
  overflow: hidden;
  border-left: 1px solid #222b26;
  border-right: 1px solid #222b26;
}

.hidden {
  display: none !important;
}

/* =========================================================================
 * A. 위 줄 (topbar.png + 빚 막대 bar_frame / bar_fill)
 * ========================================================================= */
.zone-a {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: #141a17;
  border-bottom: 1px solid var(--border-ink);
  z-index: 12;
}

.top-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 5px 6px 4px;
  min-height: 46px;
  background: linear-gradient(180deg, #1b231e 0%, #141a17 100%);
}

.top-main.has-art {
  background-color: #141a17;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  min-height: 52px;
  padding: 9px 26px 5px;
}

.top-left-btns {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-stages {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 5px;
  border-radius: 6px;
  border: 1px solid rgba(212, 182, 122, 0.45);
  background: rgba(24, 20, 16, 0.78);
  color: #fffaf0;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.stage-txt-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.stage-name-mini {
  font-size: 9px;
  font-weight: 700;
  color: #ecdcb8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-gear {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border-ink);
  background: #232d27;
  color: #fffaf0;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.btn-gear.has-icon {
  padding: 0 5px;
  background: rgba(24, 20, 16, 0.72);
  border-color: rgba(212, 182, 122, 0.45);
}

.btn-gear .ui-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.stage-mid {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stage-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.stage-txt {
  font-size: 12px;
  font-weight: 800;
  color: #fffaf0;
  white-space: nowrap;
}

.pyo-txt {
  color: #ffd08a;
}

.stage-sub {
  font-size: 10px;
  font-weight: 700;
  color: #e4dcc8;
  white-space: nowrap;
}

.stage-bar-bg {
  width: 100%;
  height: 7px;
  background: #0c100e;
  border: 1px solid #48594e;
  border-radius: 4px;
  overflow: hidden;
}

.stage-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4b8f62, #7fd49a);
  transition: width 0.1s linear;
}

.pyo-fill {
  background: linear-gradient(90deg, #c95c36, #e6a84c);
}

.res-chips {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 82px;
}

.res-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #101512;
  border: 1px solid #303d35;
  font-size: 10px;
  line-height: 1.2;
}

.res-chip.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  padding: 2px 7px;
}

.chip-icon {
  width: 13px;
  height: 13px;
  object-fit: contain;
  flex: 0 0 auto;
}

.chip-tag { color: #d8e2dc; font-weight: 700; }
.chip-nyang .chip-val { color: var(--gold); font-weight: 800; }
.chip-jade .chip-val { color: #8ff0d2; font-weight: 800; }

/* 밝은 한지 chip.png 위에서는 먹색 글자 (#2a2118, 명암비 13.6:1) */
.res-chip.has-art .chip-tag { color: #3a2d20; font-weight: 800; }
.res-chip.has-art .chip-val { color: var(--ink-text-dark); font-weight: 900; }

.res-chip.chip-pop {
  animation: chipBounce 0.16s cubic-bezier(0.22, 1.4, 0.36, 1);
}

@keyframes chipBounce {
  0% { transform: scale(1); }
  45% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* 빚 3,000냥 가는 막대 */
.debt-strip {
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: none;
  border-top: 1px solid #352722;
  background: #1c1411;
  color: #fffaf0;
  font-size: 10px;
  cursor: pointer;
}

.debt-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex: 0 0 auto;
}

.debt-strip-label {
  font-weight: 700;
  color: #f5d4c8;
  white-space: nowrap;
}

.debt-bar-bg {
  position: relative;
  flex: 1;
  height: 8px;
  background: #0e0a09;
  border-radius: 4px;
  overflow: hidden;
}

.debt-bar-bg.has-art {
  height: 11px;
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 0;
  padding: 2px 3px;
}

.debt-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c94e3f, #e4b454);
  transition: width 0.2s ease;
}

.debt-bar-fill.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.debt-strip-pct {
  font-weight: 800;
  color: var(--gold);
  min-width: 28px;
  text-align: right;
}

/* =========================================================================
 * B. 무대 (높이 49% 이상 유지)
 * ========================================================================= */
.zone-b {
  position: relative;
  flex: 1 1 49%;
  min-height: 48%;
  width: 100%;
  overflow: hidden;
  background: #101613;
  border-bottom: 1px solid var(--border-ink);
}

#stageCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.boss-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(110, 24, 18, 0.92);
  border: 1px solid #e08252;
  font-size: 11px;
  font-weight: 800;
  color: #fff5e6;
  pointer-events: none;
  z-index: 10;
}

.boss-retry-bar {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 8px;
  border-radius: 6px;
  background: rgba(20, 26, 22, 0.92);
  border: 1px solid var(--gold);
  font-size: 11px;
  font-weight: 700;
  color: #fffaf0;
  z-index: 14;
}

.btn-retry-now {
  padding: 2px 8px;
  border-radius: 4px;
  border: none;
  background: var(--gold);
  color: var(--ink-text-dark);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.offline-bar {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 8px;
  background: rgba(20, 28, 23, 0.96);
  border: 1px solid var(--gold);
  border-radius: 6px;
  z-index: 25;
  font-size: 11px;
}

.offline-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff7e0;
}

.btn-claim {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 4px;
  border: none;
  background: var(--gold);
  color: var(--ink-text-dark);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.toast-line {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 82%;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(14, 18, 16, 0.95);
  border: 1px solid #6b7d72;
  color: #fffaf0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 32;
  pointer-events: none;
}

/* 절초 단추 (무대 아래쪽 가운데, 지름 64px) */
.btn-ult {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}

.ult-btn-canvas {
  width: 86px;
  height: 86px;
  pointer-events: none;
  flex: 0 0 auto;
}

.ult-btn-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 900;
  color: #fff7df;
  text-shadow: 0 1px 3px #000, 0 0 2px #000;
  white-space: nowrap;
  pointer-events: none;
}

.btn-ult.ult-ready {
  animation: ultBreathe 0.95s ease-in-out infinite;
}

@keyframes ultBreathe {
  0%, 100% { transform: translateX(-50%) scale(1.0); }
  50%      { transform: translateX(-50%) scale(1.08); }
}

/* B-왼 / B-오른 세로 단추 열 */
.side-col {
  position: absolute;
  bottom: 8px;
  width: 56px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 12;
}

.side-left { left: 6px; }
.side-right { right: 6px; }

.side-btn {
  position: relative;
  width: 100%;
  min-height: 44px;
  padding: 3px 2px;
  border-radius: 7px;
  border: 1.5px solid #4c6154;
  background: rgba(22, 30, 26, 0.92);
  color: #fffaf0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.side-btn.has-art {
  min-height: 54px;
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  border-radius: 50%;
  box-shadow: none;
  padding: 5px 3px 4px;
}

.side-icon {
  position: relative;
  z-index: 2;
  width: 26px;
  height: 26px;
  object-fit: contain;
  pointer-events: none;
}

.side-btn.locked {
  border-color: #3a423d;
  background-color: rgba(18, 22, 20, 0.86);
  color: #e2dcd0;
}

.side-btn.locked.has-art {
  background-color: transparent;
}

.side-btn.active-buff {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(240, 196, 92, 0.7);
}

.side-btn.auto-on {
  border-color: #7ee3a2;
  background: rgba(28, 66, 44, 0.94);
  box-shadow: 0 0 8px rgba(126, 227, 162, 0.55);
}

.side-atk { border-color: #b55446; }
.side-inc { border-color: #549e6b; }
.side-pyo { border-color: #c9943e; }

.side-name {
  position: relative;
  z-index: 2;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.05;
  color: #fffaf0;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.side-sub {
  position: relative;
  z-index: 2;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.05;
  color: #ffe08a;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.side-btn.locked .side-sub { color: #d8d2c6; }

/* 첫 표행 안내 포인터 (CSS 도형, 이모지 금지) */
.pyo-pointer {
  position: absolute;
  left: -14px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 10px solid var(--gold);
  transform: translateY(-50%);
  animation: ptrBounce 0.7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ptrBounce {
  0%, 100% { transform: translate(0, -50%); }
  50% { transform: translate(-4px, -50%); }
}

.btn-exit-pyo {
  position: absolute;
  left: 6px;
  bottom: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1.5px solid #c96d5c;
  background: rgba(58, 24, 20, 0.94);
  color: #fff4ee;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  z-index: 15;
}

.unlock-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 9, 0.62);
  pointer-events: auto;
  cursor: pointer;
  z-index: 28;
  animation: unlockDimIn 0.5s ease-out forwards;
}

@keyframes unlockDimIn {
  0% { background: rgba(8, 10, 9, 0); }
  100% { background: rgba(8, 10, 9, 0.62); }
}

.unlock-fx {
  position: absolute;
  width: 240px;
  height: 240px;
  object-fit: contain;
  animation: fxNewTierSpin 1.1s linear forwards;
  pointer-events: none;
}

@keyframes fxNewTierSpin {
  0% { transform: rotate(0deg) scale(0.5); opacity: 0.95; }
  70% { transform: rotate(220deg) scale(1.15); opacity: 0.88; }
  100% { transform: rotate(300deg) scale(1.3); opacity: 0; }
}

.unlock-wpn {
  position: relative;
  z-index: 2;
  height: 48%;
  max-height: 148px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(240, 196, 92, 0.98));
  animation: unlockSpinPop 1.05s cubic-bezier(0.22, 1.28, 0.36, 1) forwards;
}

@keyframes unlockSpinPop {
  0%   { transform: scale(0.4) rotate(0deg); opacity: 0; }
  45%  { transform: scale(2.0) rotate(360deg); opacity: 1; }
  75%  { transform: scale(1.65) rotate(360deg); opacity: 1; }
  100% { transform: scale(1.5) rotate(360deg); opacity: 0.95; }
}

.unlock-name {
  position: relative;
  z-index: 2;
  margin-top: 4px;
  font-size: 19px;
  font-weight: 900;
  color: #fff8e6;
  text-shadow: 0 2px 8px #000;
}

.unlock-sub {
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  color: #f2e5c8;
  text-shadow: 0 1px 4px #000;
}

@keyframes unlockPop {
  0% { transform: scale(2.2); opacity: 0; }
  35% { transform: scale(0.95); opacity: 1; }
  75% { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(1.0); opacity: 0; }
}

.debt-clear-banner {
  position: absolute;
  inset: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(18, 22, 19, 0.95);
  border: 2px solid var(--gold);
  border-radius: 10px;
  z-index: 30;
  text-align: center;
}

.debt-clear-title { font-size: 18px; font-weight: 900; color: var(--gold); }
.debt-clear-sub { font-size: 12px; color: #fffaf0; }
.btn-small {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--gold);
  background: #2f2a1d;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* =========================================================================
 * 무대 위 종이 패널 (sheet.png 적용 시 먹색 글자 + 회색 격자 제거)
 * ========================================================================= */
.scroll-sheet {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 6px;
  bottom: 6px;
  display: flex;
  flex-direction: column;
  background: rgba(24, 30, 26, 0.96);
  border: 1.5px solid #6b7d6e;
  border-radius: 10px;
  padding: 8px 10px;
  z-index: 22;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.scroll-sheet.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 44px 32px 38px;
  color: var(--ink-text);
}

.sheet-head {
  position: relative;
  z-index: 2;
  flex: 0 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-ink);
  padding-bottom: 3px;
  margin-bottom: 4px;
}

.scroll-sheet.has-art .sheet-head {
  border-bottom-color: rgba(42, 33, 24, 0.28);
}

.sheet-title { font-size: 13px; font-weight: 900; color: var(--gold); }
.scroll-sheet.has-art .sheet-title { color: var(--ink-text-dark); }

.btn-sheet-close {
  padding: 2px 9px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--border-ink);
  background: #242f29;
  color: #fffaf0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.scroll-sheet.has-art .btn-sheet-close {
  background: #3b2d21;
  border-color: #2a2118;
  color: #fffaf0;
}

.sheet-body {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  overflow: hidden;
}

.stage-wipe {
  position: absolute;
  inset: 0;
  background: #0a0d0b;
  pointer-events: none;
  z-index: 26;
  animation: stageWipeAnim 0.3s ease-in-out forwards;
}

.stage-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 250, 0.92);
  pointer-events: none;
  z-index: 29;
  animation: stageFlashAnim 0.12s ease-out forwards;
}

@keyframes stageFlashAnim {
  0% { opacity: 0.92; }
  100% { opacity: 0; }
}

.boss-in-band {
  position: absolute;
  left: 0;
  top: 26%;
  width: 100%;
  height: auto;
  max-height: 92px;
  object-fit: contain;
  pointer-events: none;
  z-index: 27;
  animation: bossBandSlide 0.8s ease-out forwards;
}

@keyframes bossBandSlide {
  0% { transform: translateX(40%) scaleY(0.7); opacity: 0; }
  20% { transform: translateX(0) scaleY(1); opacity: 1; }
  80% { transform: translateX(0) scaleY(1); opacity: 1; }
  100% { transform: translateX(-30%) scaleY(0.85); opacity: 0; }
}

.stage-banner-name.has-band {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  padding: 14px 36px;
}

.stage-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 27;
  animation: stageBannerFade 0.9s ease-out forwards;
}

.stage-banner-name {
  font-family: 'Batang', 'Gungsuh', 'Nanum Myeongjo', serif;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fffaf0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 3px #1a120d;
  padding: 6px 20px;
  border-top: 2px solid rgba(240, 196, 92, 0.85);
  border-bottom: 2px solid rgba(240, 196, 92, 0.85);
  background: rgba(14, 12, 10, 0.62);
}

.stage-banner-sub {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #ffe28a;
  text-shadow: 0 1px 4px #000;
}

@keyframes stageBannerFade {
  0%   { opacity: 0; transform: scale(1.12); }
  18%  { opacity: 1; transform: scale(1.0); }
  78%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(0.98); }
}

/* 지나온 곳 24칸 도감 격자 */
.stage-gallery-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(44px, 1fr);
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
}

.stage-tile {
  position: relative;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(42, 33, 24, 0.35);
  background: #231e18;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 44px;
}

.stage-tile-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.stage-tile.unvisited .stage-tile-bg {
  filter: brightness(0.12) contrast(1.4) grayscale(1);
}

.stage-tile-name {
  position: relative;
  z-index: 2;
  background: rgba(16, 13, 10, 0.78);
  color: #fffaf0;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  padding: 1px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-tile.unvisited .stage-tile-name {
  color: #a8a096;
}

@keyframes stageWipeAnim {
  0% { opacity: 0; }
  45% { opacity: 0.92; }
  100% { opacity: 0; }
}

/* =========================================================================
 * C. 무기 받침대 (slot.png / slot_equipped.png + 72% 무기 + 밝은 테두리 + 먹 원)
 * ========================================================================= */
.zone-c {
  flex: 0 0 auto;
  padding: 5px 6px;
  background: #141a16;
  border-bottom: 1px solid #26312a;
}

.rack-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(2, 58px);
  gap: 4px;
  touch-action: none;
}

.rack-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-slot);
  border: 1.5px solid var(--border-ink);
  border-radius: 7px;
  overflow: hidden;
  min-width: 56px;
  min-height: 56px;
}

.rack-slot.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  border-radius: 6px;
}

.rack-slot.equipped {
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 9px var(--gold-glow);
}

.rack-slot.equipped.has-art {
  border: none;
  box-shadow: none;
}

/* 13~24단 푸른 기운 / 25~30단 금빛 기운 */
.rack-slot.tier-blue {
  box-shadow: inset 0 0 0 2px #58b4ff, inset 0 0 11px rgba(88, 180, 255, 0.72);
}

.rack-slot.tier-gold {
  box-shadow: inset 0 0 0 2px #ffd24d, inset 0 0 12px rgba(255, 210, 77, 0.85);
}

.rack-slot.drop-merge { box-shadow: inset 0 0 0 2px #7ee3a2, inset 0 0 10px rgba(126, 227, 162, 0.6); }
.rack-slot.drop-swap  { box-shadow: inset 0 0 0 2px #b6c8be; }
.rack-slot.dragging-src img { opacity: 0.25; }

.rack-slot img.slot-wpn {
  width: 72%;
  height: 72%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 0 1px #fff8e0) drop-shadow(0 0 1.5px rgba(255, 248, 224, 0.85));
}

.rack-slot.tier-blue img.slot-wpn {
  filter: drop-shadow(0 0 1.5px #d9f2ff) drop-shadow(0 0 4px rgba(76, 174, 255, 0.95));
}

.rack-slot.tier-gold img.slot-wpn {
  filter: drop-shadow(0 0 1.5px #fff5c4) drop-shadow(0 0 5px rgba(255, 206, 64, 0.98));
}

.slot-tier {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(16, 13, 10, 0.9);
  border: 1px solid rgba(255, 244, 214, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  color: #fffaf0;
  pointer-events: none;
  z-index: 2;
}

.rack-slot.equipped .slot-tier {
  border-color: var(--gold);
  color: #ffe28a;
}

.slot-stamp {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

.slot-stamp.stamp-blue {
  background: #144980;
  border: 1px solid #8ad0ff;
  color: #f0f9ff;
}

.slot-stamp.stamp-gold {
  background: #7a4b00;
  border: 1px solid #ffe070;
  color: #fff9db;
}

/* fx_merge.png 6칸 0.3초 연출 (v0.2.4: 1.5배 크기) */
.fx-merge-layer {
  position: absolute;
  inset: -16px;
  background-repeat: no-repeat;
  background-size: 600% 100%;
  pointer-events: none;
  z-index: 4;
  animation: fxMergeAnim 0.3s steps(6) forwards;
}

@keyframes fxMergeAnim {
  0% { background-position: 0% 0%; opacity: 1; }
  100% { background-position: 100% 0%; opacity: 0; }
}

.rack-slot.anim-buy img.slot-wpn { animation: slotBounce 0.2s cubic-bezier(0.22, 1.4, 0.36, 1); }
.rack-slot.anim-merge { animation: mergeSlotPop 0.26s cubic-bezier(0.22, 1.4, 0.36, 1); }
.rack-slot.anim-merge img.slot-wpn { animation: mergePop 0.3s cubic-bezier(0.22, 1.4, 0.36, 1); }
.rack-slot.anim-ripple { animation: rippleSlotPop 0.22s ease-out; }

@keyframes mergeSlotPop {
  0% { transform: scale(1); box-shadow: inset 0 0 24px rgba(255, 240, 175, 0.95); }
  40% { transform: scale(1.3); box-shadow: inset 0 0 14px rgba(255, 240, 175, 0.8); }
  100% { transform: scale(1); box-shadow: inset 0 0 0 rgba(255, 240, 175, 0); }
}

@keyframes rippleSlotPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.upg-btn.upg-bounce {
  animation: upgBtnBounce 0.16s cubic-bezier(0.22, 1.4, 0.36, 1);
}

@keyframes upgBtnBounce {
  0% { transform: scale(0.93); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes slotBounce {
  0% { transform: scale(0.3) translateY(-14px); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes mergePop {
  0% { transform: scale(0.5); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes mergeFlash {
  0% { box-shadow: inset 0 0 22px rgba(255, 240, 175, 0.95); }
  100% { box-shadow: inset 0 0 0 rgba(255, 240, 175, 0); }
}

.drag-ghost {
  position: fixed;
  width: 60px;
  height: 60px;
  pointer-events: none;
  z-index: 60;
  transform: translate(-50%, -50%) scale(1.12);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.75));
}

.drag-ghost img { width: 100%; height: 100%; object-fit: contain; }

/* =========================================================================
 * D. 사기 줄 (btn_wide_gold.png / btn_wide.png + 안쪽 여백 + 명암비 ≥ 4.5:1)
 * ========================================================================= */
.zone-d {
  flex: 0 0 auto;
  min-height: 46px;
  display: grid;
  grid-template-columns: 1.32fr 1fr 1fr;
  gap: 5px;
  padding: 4px 6px;
  background: #141a17;
  border-bottom: 1px solid #26312a;
}

.act-btn {
  position: relative;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  border: 1.5px solid transparent;
  overflow: hidden;
  padding: 4px 10px;
}

.act-btn.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  border-radius: 0;
  padding: 5px 12px;
}

.act-buy {
  background: linear-gradient(180deg, #437c57 0%, #2d573c 100%);
  border-color: #6cc28a;
  color: #fffaf0;
}

/* 금빛 바탕(btn_wide_gold.png) 위 먹색 글자 (#2a2118, 10.1:1) */
.act-buy.has-art {
  color: var(--ink-text-dark);
}

.act-merge {
  background: linear-gradient(180deg, #3c4e44 0%, #27342d 100%);
  border-color: #637a6c;
  color: #fffaf0;
}

.act-jade {
  background: linear-gradient(180deg, #2b6654 0%, #1d473b 100%);
  border-color: #72d6b6;
  color: #fffaf0;
}

.act-btn.disabled {
  background-color: #1f2622;
  border-color: #35403a;
  color: #b4c0b8;
}

.act-btn.has-art.disabled {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  filter: saturate(0.5) brightness(0.9);
}

.act-buy.has-art.disabled {
  color: var(--ink-text-dark);
}

.act-merge.has-art.disabled,
.act-jade.has-art.disabled {
  color: #e6dfd2;
}

.act-main-row {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.act-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.act-main {
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.act-sub {
  position: relative;
  z-index: 2;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

/* =========================================================================
 * E. 강화 단추 3개 고정 (btn_upg_atk/spd/inc + ic_atk/spd/inc 28px + 명암비 ≥ 4.5:1)
 * ========================================================================= */
.zone-e {
  flex: 0 0 auto;
  min-height: 82px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px 6px;
  background: #121714;
  z-index: 20;
}

.upg-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px;
  border-radius: 8px;
  border: 1.5px solid #5ea878;
  background: linear-gradient(180deg, #2d5940 0%, #1d3b2a 100%);
  color: #fffaf0;
  cursor: pointer;
  overflow: hidden;
}

.upg-btn.has-art {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  border-radius: 0;
  padding: 7px 11px 6px;
}

.upg-btn.cant-afford {
  border-color: #3a4740;
  background: linear-gradient(180deg, #222b26 0%, #19201c 100%);
  color: #dbe3de;
}

.upg-btn.has-art.cant-afford {
  background-color: transparent;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  filter: saturate(0.6) brightness(0.9);
}

.upg-top {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  font-size: 10px;
  font-weight: 800;
}

.upg-btn.has-art.upg-atk .upg-top,
.upg-btn.has-art.upg-spd .upg-top {
  background: rgba(18, 13, 10, 0.72);
  border-radius: 4px;
  padding: 1px 4px;
  color: #fffaf0;
}

.upg-btn.has-art.upg-inc .upg-top {
  color: var(--ink-text-dark);
}

.upg-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
  margin-right: 1px;
}

.upg-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upg-lv {
  font-size: 9px;
  font-weight: 800;
  color: #d6f5df;
  white-space: nowrap;
}

.upg-btn.has-art.upg-atk .upg-lv,
.upg-btn.has-art.upg-spd .upg-lv {
  color: #ffe6a6;
}

.upg-btn.has-art.upg-inc .upg-lv {
  color: var(--ink-text-dark);
}

.upg-val {
  position: relative;
  z-index: 2;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.05;
  color: #fffaf0;
  -webkit-text-stroke: 1px #1a120d;
  text-shadow: -1px -1px 0 #1a120d, 1px -1px 0 #1a120d, -1px 1px 0 #1a120d, 1px 1px 0 #1a120d;
  padding: 0 6px;
  border-radius: 5px;
}

.upg-btn.has-art .upg-val {
  background: rgba(18, 13, 10, 0.62);
}

.upg-val.pop { animation: valPop 0.12s ease-out; }
@keyframes valPop { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

.upg-cost {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(16, 12, 9, 0.84);
  font-size: 10px;
  font-weight: 800;
  color: #ffe28a;
  text-align: center;
  white-space: nowrap;
}

.shake-red {
  color: #ff7b6b !important;
  animation: shakeRed 0.22s ease;
}

@keyframes shakeRed {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* =========================================================================
 * 종이 내부 공용 스타일 (sheet.png 위 먹색 글자 + 깔끔한 한지 배치)
 * ========================================================================= */
.sheet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  background: #1e2621;
  border: 1px solid #303d35;
  border-radius: 6px;
}

.scroll-sheet.has-art .sheet-card {
  background: rgba(250, 244, 228, 0.45);
  border: 1px solid rgba(42, 33, 24, 0.22);
  border-radius: 5px;
}

.sheet-big { font-size: 14px; font-weight: 900; color: #8ee3b0; }
.sheet-line { font-size: 11px; font-weight: 700; color: #fffaf0; line-height: 1.3; }
.sheet-dim { font-size: 10px; font-weight: 600; color: #c8d2cc; }

.scroll-sheet.has-art .sheet-big { color: #1b4d2e; }
.scroll-sheet.has-art .sheet-line { color: var(--ink-text-dark); }
.scroll-sheet.has-art .sheet-dim { color: #4a3a2a; }

.ki-icon {
  width: 15px;
  height: 15px;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 3px;
}

.btn-act {
  flex: 0 0 auto;
  min-width: 66px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--jade);
  background: var(--jade-deep);
  color: #fffaf0;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.scroll-sheet.has-art .btn-act {
  background: #2e4f3a;
  border-color: #1f3828;
  color: #fffaf0;
}

.btn-act.disabled {
  border-color: #36423b;
  background: #27302b;
  color: #c0cbc4;
}

.scroll-sheet.has-art .btn-act.disabled {
  background: #5a5046;
  border-color: #463d34;
  color: #f0e8dc;
}

.btn-danger { border-color: var(--red); background: #782b22; color: #fffaf0; }
.scroll-sheet.has-art .btn-danger { border-color: #6b1d15; background: #8a2c22; color: #fffaf0; }

.btn-row { display: flex; gap: 6px; }
.btn-row .btn-act { flex: 1; height: 32px; font-size: 12px; }

.seal-stamp {
  position: absolute;
  right: 26px;
  top: 48px;
  padding: 3px 10px;
  border: 2.5px solid #c43025;
  border-radius: 4px;
  color: #c43025;
  font-size: 14px;
  font-weight: 900;
  transform: rotate(-12deg);
  pointer-events: none;
  z-index: 10;
  animation: stampSlam 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}

@keyframes stampSlam {
  0% { transform: scale(2.1) rotate(-18deg); opacity: 0; }
  40% { transform: scale(0.95) rotate(-12deg); opacity: 1; }
  100% { transform: scale(1) rotate(-12deg); opacity: 0; }
}

.mundo-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
}

.mundo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1e2621;
  border: 1px solid #2f3d35;
  border-radius: 6px;
  padding: 2px;
}

.scroll-sheet.has-art .mundo-card {
  background: transparent;
  border: 1px solid rgba(42, 33, 24, 0.2);
}

.mundo-card.locked { opacity: 0.4; }
.mundo-card.active { border-color: var(--gold); }
.scroll-sheet.has-art .mundo-card.active {
  border-color: #9e6b1e;
  background: rgba(235, 206, 134, 0.25);
}

.mundo-portrait {
  width: 32px;
  height: 32px;
  background-repeat: no-repeat;
  background-size: 384px 32px;
  background-position: 0 0;
}

.mundo-label { font-size: 9px; font-weight: 800; color: #fffaf0; white-space: nowrap; }
.scroll-sheet.has-art .mundo-label { color: var(--ink-text-dark); }

/* 단추 눌림 0.97배 + 밝기 1.15, 95ms */
button { transition: transform 95ms ease, filter 95ms ease; }
button:active { transform: scale(0.97); filter: brightness(1.15); }

.ink-wipe {
  position: fixed;
  inset: 0;
  background: #090b0a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: inkFade 1.2s ease-in-out forwards;
}

.ink-wipe-txt { font-size: 26px; font-weight: 900; letter-spacing: 6px; color: #ebe3d3; }
@keyframes inkFade { 0% { opacity: 0; } 35% { opacity: 1; } 65% { opacity: 1; } 100% { opacity: 0; } }

/* 360x640 대응: 받침대 칸 56px 유지 + 무대 48% 이상 + 여백 압축 */
@media (max-width: 370px) {
  .zone-c { padding: 3px 3px; }
  .rack-grid { gap: 3px; grid-template-rows: repeat(2, 56px); }
  .top-main.has-art { padding: 7px 20px 4px; }
  .btn-gear { padding: 0 4px; font-size: 10px; }
  .btn-stages { padding: 0 4px; font-size: 9px; }
  .stage-name-mini { display: none; }
  .upg-btn.has-art { padding: 5px 8px 5px; }
  .upg-icon { width: 18px; height: 18px; }
  .scroll-sheet.has-art { padding: 34px 24px 28px; }
}

@media (max-height: 680px) {
  .top-main, .top-main.has-art { min-height: 40px; padding-top: 4px; padding-bottom: 3px; }
  .debt-strip { height: 18px; }
  .zone-d { min-height: 38px; padding: 3px 5px; }
  .zone-e { min-height: 68px; padding: 3px 5px; }
  .upg-val { font-size: 14px; }
  .upg-icon { width: 18px; height: 18px; }
  .side-btn { min-height: 36px; }
  .side-btn.has-art { min-height: 44px; }
  .side-icon { width: 20px; height: 20px; }
  .scroll-sheet.has-art { padding: 32px 24px 26px; }
}
