/* 냥냥대군
   밤길 행진 게임. 퇴마록과 같은 남보라 밤 톤에, 포인트는 숫자 문 파랑과 츄르 분홍. */
:root {
  --bg: #15122f;
  --surface: #241e48;
  --surface-2: #2f2860;
  --ink: #f3f0ff;
  --sub: #aaa3d6;
  --line: #3a3270;
  --accent: #ffd23f;
  --accent-ink: #2a1d00;
  --red: #ff5a4e;
  --jade: #6fe3c8;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  --game: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --body: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; }
h1, h2, h3 { font-family: var(--game); font-weight: 400; margin: 0; text-wrap: balance; }
p { margin: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.stage { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 6px; }
.logo { font-family: var(--game); font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: 0.04em; }
.logo b { color: #ff4867; font-weight: 400; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.screen.measuring > * { flex-shrink: 0; }
.sub { color: var(--sub); }
.small { font-size: 13px; }
.center { text-align: center; }
.fine { font-size: 12px; color: var(--sub); text-align: center; }

.btn { min-height: 52px; border-radius: 16px; border: 0; padding: 10px 16px; font-size: 16px; font-weight: 700; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); transition: transform .08s ease; text-decoration: none; display: grid; place-items: center; text-align: center; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-family: var(--game); font-weight: 400; font-size: 22px; box-shadow: 0 6px 0 #b8860b, var(--shadow); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #b8860b, var(--shadow); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--sub); font-weight: 400; min-height: 44px; }
.actions { display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 99px; background: var(--surface); border: 0; color: var(--ink); font-size: 13px; font-weight: 700; box-shadow: var(--shadow); }
.chip .ico { width: 18px; height: 18px; }
.chip.new { background: var(--accent); color: var(--accent-ink); animation: pop .5s ease-out both .9s; }
.ico { width: 28px; height: 28px; object-fit: contain; flex: none; }
.seg { display: flex; align-items: center; justify-content: center; gap: 2px; background: var(--surface); border-radius: 99px; padding: 4px; box-shadow: var(--shadow); align-self: center; }
.seg-lbl { font-size: 12px; color: var(--sub); padding: 0 6px 0 8px; }
.seg button { border: 0; background: transparent; border-radius: 99px; min-width: 38px; min-height: 34px; font-weight: 700; font-size: 14px; color: var(--sub); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

/* ---- 살아 있는 행진(시작·결과) */
.parade { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 24px; overflow: hidden; background: #1b1440; box-shadow: var(--shadow); isolation: isolate; flex: none; }
.parade .bg { position: absolute; inset: 0; background: url("sprites/bg-start.webp") center 70% / cover no-repeat, linear-gradient(#1b1440, #563067); }
.parade.lose .bg { filter: saturate(.7) brightness(.75); }
.gate-deco { position: absolute; left: 66%; top: 5%; width: 46%; translate: -50% 0; filter: drop-shadow(0 0 14px rgba(110, 190, 255, .6)); }
.gate-num { position: absolute; left: 66%; top: 20%; translate: -50% 0; font: 34px/1 var(--game); color: #fff; -webkit-text-stroke: 6px #1b1440; paint-order: stroke; }
.gate-num.bad { color: #ffd7d3; }
.gate-deco.pass, .gate-num.pass { animation: gatepass 2.2s ease-in both; }
@keyframes gatepass { 0% { opacity: 0; transform: scale(.55); } 15% { opacity: 1; transform: scale(.8); } 40% { transform: scale(1.05); opacity: 1; } 55% { transform: scale(1.6); opacity: 0; } 100% { opacity: 0; transform: scale(.55); } }
.march { position: absolute; left: 50%; bottom: 3%; width: 78%; translate: -50% 0; display: grid; grid-template-columns: repeat(5, 1fr); justify-items: center; align-items: end; gap: 0 2px; }
.mc { width: 100%; max-width: 56px; margin-top: -42%; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); animation: bob .26s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.07s); }
.march .mc:nth-child(5n+1), .march .mc:nth-child(5n) { translate: 0 -8%; }
@keyframes bob { to { transform: translateY(-5%); } }
.parade .hero-btn { position: absolute; left: 50%; bottom: 13%; width: 26%; transform: translateX(-50%); border: 0; background: none; padding: 0; z-index: 2; }
.count-badge { position: absolute; left: 50%; top: 47%; translate: -50% 0; background: #2f80ff; color: #fff; font: 26px/1 var(--game); padding: 7px 14px; border-radius: 14px; border: 3px solid #fff; box-shadow: var(--shadow); z-index: 3; font-variant-numeric: tabular-nums; }
.count-badge.pop { animation: pop .35s ease-out; }
.invite { background: #3b2a7a; border: 2px solid var(--accent); border-radius: 16px; padding: 10px 14px; text-align: center; font-size: 15px; word-break: keep-all; }
.invite b { color: var(--accent); }
.btn.daily { background: #2f80ff; color: #fff; display: flex; flex-direction: column; gap: 0; line-height: 1.2; }
.btn.daily .sub { color: #dbe9ff; font-weight: 400; }
.btn.daily.hot { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px var(--accent), var(--shadow); } }
b.hot { color: var(--accent); }
.result .march { width: 92%; }
.result .hero-pose.big { position: absolute; left: 50%; bottom: 4%; width: 36%; transform: translateX(-50%); animation: none; z-index: 2; }
.result .hero-pose.cheer { animation: cheer 1s ease-in-out infinite; }
.result .hero-pose.down { width: 40%; bottom: 0; }
@keyframes cheer { 50% { transform: translateX(-50%) translateY(-6%); } }
.runaway { position: absolute; bottom: 4%; width: 20%; animation: run 1.6s linear infinite; }
.runaway.r1 { left: 2%; }
.runaway.r2 { right: 2%; transform: scaleX(-1); animation-delay: -.8s; }
@keyframes run { 50% { translate: 0 -10%; } }
.result .bubble { animation: pop .4s ease-out .3s both; }
.stamp { position: absolute; right: 5%; top: 8%; border: 4px solid var(--red); color: var(--red); font-family: "Gowun Batang", serif; font-weight: 700; font-size: 20px; padding: 2px 10px; border-radius: 6px; transform: rotate(-10deg); background: rgba(255, 255, 255, .85); animation: stamp .5s cubic-bezier(.2, 1.6, .4, 1) .5s both; z-index: 3; }
@keyframes stamp { from { transform: rotate(-10deg) scale(2.4); opacity: 0; } }
.hero-pose { width: 100%; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); animation: idle 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes idle { 50% { transform: scaleY(.97) scaleX(1.02); } }
.bubble { position: absolute; left: 4%; top: 5%; max-width: 44%; background: #fff; color: #1d1838; border-radius: 16px 16px 16px 4px; padding: 7px 12px; font-family: var(--game); font-size: 15px; line-height: 1.35; box-shadow: var(--shadow); word-break: keep-all; z-index: 4; }
.bubble.sul { background: #efe6ff; }
.bubble.pop { animation: pop .3s ease-out; }
.hero-title { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.hero-title h1 { font-size: 44px; line-height: 1.05; letter-spacing: -0.01em; text-shadow: 0 3px 0 #000a; }
.hero-title h1 em { font-style: normal; color: var(--accent); }
.hero-title .lede { color: var(--sub); font-size: 15px; word-break: keep-all; }

.res-title { text-align: center; }
.res-title h2 { font-size: 30px; color: var(--accent); animation: pop .5s ease-out .6s both; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats div { background: var(--surface); border-radius: 14px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; }
.stats b { font-family: var(--game); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--sub); }
.earn { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; flex-wrap: wrap; }
.earn b { font-family: var(--game); font-weight: 400; font-size: 22px; color: var(--accent); }
.unlocks { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ---- 상점 */
.shop-head { display: flex; align-items: flex-end; gap: 8px; }
.shop-sul { width: 84px; height: 84px; object-fit: contain; flex: none; }
.say { flex: 1; background: var(--surface); border-radius: 18px 18px 18px 6px; padding: 10px 14px; margin-bottom: 12px; font-size: 15px; word-break: keep-all; }
.say .who { display: block; font-size: 11px; color: var(--sub); }
.purse { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; }
.purse b { font-family: var(--game); font-weight: 400; font-size: 26px; color: var(--accent); }
.shop-list, .dex-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.shop-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 16px; padding: 8px 10px; }
.shop-row > .ico { width: 44px; height: 44px; }
.shop-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--accent); }
.btn.buy { min-height: 42px; min-width: 76px; padding: 4px 10px; font-family: var(--game); font-weight: 400; font-size: 17px; display: flex; gap: 2px; background: var(--surface-2); }
.btn.buy .ico { width: 20px; height: 20px; }

/* ---- 도감 */
.screen-title { font-size: 26px; text-align: center; }
.dex-grid { grid-template-columns: 1fr 1fr; }
.dex-grid li { display: contents; }
.dex-card { width: 100%; border: 2px solid transparent; color: var(--ink); font: inherit; background: var(--surface); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.dex-card img { width: 72px; height: 72px; object-fit: contain; }
.dex-card.unseen img { filter: brightness(0) opacity(.5); }
.dex-card.on { border-color: var(--accent); }
.dex-grid { grid-template-columns: 1fr 1fr 1fr; }
.dex-card b { font: 15px var(--game); }
.dex-card .cnt { font-size: 12px; color: var(--accent); font-weight: 700; }

/* ---- 판 */
.stage.playing .topbar { display: none; }
.stage.playing .screen { padding: 0; }
.play { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #221c40; touch-action: none; }
.play canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 0; pointer-events: none; display: flex; flex-direction: column; gap: 6px; }
.hud-row { display: grid; grid-template-columns: 44px 1fr 92px; align-items: center; }
.hud .pause { pointer-events: auto; width: 40px; height: 40px; background: rgba(0, 0, 0, .45); box-shadow: none; }
.hud .pause svg { width: 18px; height: 18px; }
.where { text-align: center; font: 18px/1.1 var(--game); color: #fff; text-shadow: 0 2px 0 #000a; }
.peak { text-align: right; font: 14px/1.2 var(--game); color: #ffe14a; text-shadow: 0 1px 2px #000; }
.prog { height: 8px; margin: 0 6px; border-radius: 4px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7cc8ff, #ffe14a); }
.banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); white-space: nowrap; font: 24px/1.2 var(--game); color: #fff; text-shadow: 0 3px 0 #000, 0 0 12px #000; pointer-events: none; opacity: 0; }
.banner.on { animation: banner 1s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 1; } }
.overlay { position: absolute; inset: 0; background: rgba(10, 8, 30, .72); display: grid; place-items: center; padding: 16px; z-index: 5; backdrop-filter: blur(2px); }
.panel { width: 100%; max-width: 400px; background: var(--surface); border-radius: 22px; padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; box-shadow: var(--shadow); animation: pop .3s ease-out; }
.panel h2 { font-size: 24px; }
.kicker { font: 16px var(--game); color: var(--accent); }

.cardimg { width: 100%; border-radius: 18px; box-shadow: var(--shadow); -webkit-touch-callout: default; user-select: auto; }

/* ---- 아래 설명 글 */
.guide { max-width: 480px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 28px; }
.guide section { display: flex; flex-direction: column; gap: 10px; }
.guide h2 { font-size: 24px; }
.guide p, .guide li { font-size: 15px; max-width: 65ch; }
.guide a { color: var(--accent); }
.guide ul, .guide ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.arcana { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; list-style: none; padding: 0 !important; }
.arcana li { background: var(--surface); border-radius: 14px; padding: 8px 12px; font-size: 13px; }
.arcana b { display: block; font-family: var(--game); font-weight: 400; font-size: 16px; }
.log { font-size: 14px; }
.site-foot { border-top: 1px solid var(--line); padding-top: 16px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.site-foot a { color: var(--sub); }

/* ---- 작은 화면 */
.stage.fit1 .parade { width: 86%; align-self: center; }
.stage.fit1 .hero-title h1 { font-size: 36px; }
.stage.fit1 .btn { min-height: 46px; }
.stage.fit1 .shop-sul { width: 60px; height: 60px; }
.stage.fit2 .parade { width: 66%; }
.stage.fit2 .hero-title .lede, .stage.fit2 .screen > .fine { display: none; }
.stage.fit2 .bubble { font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .mc, .hero-pose, .runaway, .gate-deco, .gate-num { animation: none !important; }
}

/* ---- 냥도사 스킬 버튼: 게이지가 아래에서 차오르고, 다 차면 빛난다 */
.skill { position: absolute; right: 14px; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff; background: #2a2160; overflow: hidden; padding: 0; z-index: 4; box-shadow: var(--shadow); color: #fff; touch-action: manipulation; }
.skill img { position: absolute; inset: 4px 6px 14px; width: calc(100% - 12px); height: calc(100% - 18px); object-fit: contain; z-index: 2; filter: grayscale(.6) brightness(.8); }
.skill i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(#ffe14a, #ff9f1c); z-index: 1; transition: height .2s; }
.skill b { position: absolute; left: 0; right: 0; bottom: 6px; z-index: 3; font: 12px/1 var(--game); font-weight: 400; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.skill:disabled { opacity: .85; }
.skill.ready { animation: skillglow .8s ease-in-out infinite alternate; }
.skill.ready img { filter: none; }
@keyframes skillglow { from { box-shadow: 0 0 0 0 rgba(255, 225, 74, .9), var(--shadow); transform: scale(1); } to { box-shadow: 0 0 0 10px rgba(255, 225, 74, 0), var(--shadow); transform: scale(1.06); } }
/* ---- 디펜스 바리케이드 체력 */
.wallbar { display: flex; align-items: center; gap: 8px; margin-top: 6px; font: 13px/1 var(--game); color: #fff; text-shadow: 0 1px 2px #000; }
.wallbar[hidden] { display: none; }
.wallbar div { flex: 1; height: 10px; border-radius: 99px; background: rgba(0, 0, 0, .45); overflow: hidden; border: 1.5px solid rgba(255, 255, 255, .7); }
.wallbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #6fe38a, #b8f36a); transition: width .2s; }
.wallbar i.low { background: linear-gradient(90deg, #ff5a4e, #ff9f6a); }
/* ---- 마을 지도 */
.vmap { background: var(--surface); border-radius: 18px; padding: 10px 12px; box-shadow: var(--shadow); }
.vmap ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; position: relative; }
.vmap li { text-align: center; font-size: 11px; color: var(--sub); line-height: 1.25; word-break: keep-all; }
.vmap li::before { content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 4px; border-radius: 50%; background: #3a3270; border: 2px solid #4b4290; }
.vmap li.won { color: var(--ink); }
.vmap li.won::before { background: radial-gradient(circle, #ffe9a8, #ffb03a); border-color: #ffd23f; box-shadow: 0 0 10px rgba(255, 200, 80, .7); }
.vmap li.now { color: var(--accent); font-weight: 700; }
.vmap li.now::before { background: #2f80ff; border-color: #fff; animation: pop 1s ease-in-out infinite alternate; }
.vstep { margin: 8px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.vstep .dots { display: inline-flex; gap: 3px; }
.vstep .dots i { width: 10px; height: 10px; border-radius: 3px; background: #3a3270; }
.vstep .dots i.defense { background: #5a2f4e; }
.vstep .dots i.boss { width: 14px; background: #6a2a2a; }
.vstep .dots i.done { background: #6fe3c8; }
.vstep .dots i.now { background: var(--accent); box-shadow: 0 0 0 2px #fff; }
.village-won { text-align: center; background: linear-gradient(90deg, #4a2a10, #7a4a14); border: 2px solid var(--accent); border-radius: 16px; padding: 10px 14px; margin: 0; word-break: keep-all; animation: pop .5s ease-out both .6s; }
.village-won b { color: var(--accent); }
b.stars { color: var(--accent); letter-spacing: 2px; }
