/* 냥도사 퇴마록
   보름달 밤 게임이라 밝기 설정과 상관없이 남색 밤 톤 하나로 간다. 포인트는 부적 노랑과 도장 빨강. */
:root {
  --bg: #16122e;
  --surface: #241e48;
  --surface-2: #2f2860;
  --ink: #f3f0ff;
  --sub: #aaa3d6;
  --line: #3a3270;
  --accent: #ffcf3f;
  --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); } }

/* ---- 살아 있는 골목(시작·결과) */
.alley { position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 24px; overflow: hidden; background: #1b1640; box-shadow: var(--shadow); isolation: isolate; flex: none; }
.alley .bg { position: absolute; inset: 0; background: url("sprites/bg-start.webp") center / cover no-repeat, linear-gradient(#1b1640, #3a2a78); }
.alley.dawn .bg { background-image: url("sprites/bg-dawn.webp"), linear-gradient(#ffb27a, #5b4aa8); }
.alley.night .bg { filter: saturate(.8) brightness(.85); }
.moonglow { position: absolute; left: 52%; top: -9%; width: 26%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(rgba(255, 244, 200, .55), rgba(255, 244, 200, 0) 65%); animation: breathe 5s ease-in-out infinite; mix-blend-mode: screen; }
@keyframes breathe { 50% { opacity: .45; transform: scale(1.08); } }
.eyes { position: absolute; display: flex; gap: 6px; animation: blink 4.2s infinite; }
.eyes i { width: 7px; height: 5px; border-radius: 50%; background: #ffe36a; box-shadow: 0 0 8px #ffd43a; }
.eyes.e1 { left: 4%; top: 76%; animation-delay: .4s; }
.eyes.e2 { left: 88%; top: 84%; animation-delay: 1.7s; }
.eyes.e2 i { background: #ff7ad9; box-shadow: 0 0 8px #ff4ccf; }
.eyes.e3 { left: 33%; top: 47%; animation-delay: 2.9s; transform: scale(.7); }
@keyframes blink { 0%, 44%, 52%, 100% { opacity: 1; } 48% { opacity: 0; } 70%, 76% { opacity: 0; } }
.wisp { position: absolute; width: 13%; animation: drift 7s ease-in-out infinite; filter: drop-shadow(0 0 10px rgba(110, 200, 255, .8)); opacity: .9; }
.wisp.w1 { left: 22%; top: 30%; width: 10%; }
.wisp.w2 { right: 26%; top: 36%; width: 8%; animation-duration: 9s; animation-delay: -3s; }
@keyframes drift { 25% { transform: translate(14px, -10px); } 50% { transform: translate(4px, -20px) rotate(6deg); } 75% { transform: translate(-10px, -6px); } }
.peek { position: absolute; bottom: -4%; width: 20%; animation: peek 6s ease-in-out infinite; }
.peek.p1 { left: -3%; }
.peek.p2 { right: -2%; width: 17%; animation-delay: -3s; transform: scaleX(-1); }
@keyframes peek { 0%, 30%, 100% { translate: 0 60%; } 40%, 70% { translate: 0 0; } }
.sulwin { position: absolute; right: 4%; top: 25%; width: 15%; animation: lean 5s ease-in-out infinite; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .4)); }
@keyframes lean { 50% { transform: rotate(-4deg) translateY(2px); } }
.hero-btn { position: absolute; left: 50%; bottom: 2%; width: 34%; transform: translateX(-50%); border: 0; background: none; padding: 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%; }
.hero-pose.pop { animation: hop .45s ease-out, idle 2.4s ease-in-out .45s infinite; }
@keyframes idle { 50% { transform: scaleY(.97) scaleX(1.02); } }
@keyframes hop { 40% { transform: translateY(-12%) scaleY(1.05); } 70% { transform: scaleY(.94); } }
.bubble { position: absolute; left: 4%; top: 5%; max-width: 50%; 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; }
.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; }

/* 결과 장면 */
.result .hero-pose.big { position: absolute; left: 50%; bottom: 2%; width: 46%; transform: translateX(-50%); animation: none; }
.result .hero-pose.cheer { animation: cheer 1s ease-in-out infinite; }
.result .hero-pose.down { width: 50%; bottom: 0; }
@keyframes cheer { 50% { transform: translateX(-50%) translateY(-6%); } }
.result .sulwin.tea { top: auto; bottom: 6%; right: 2%; width: 26%; }
.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; }
@keyframes stamp { from { transform: rotate(-10deg) scale(2.4); opacity: 0; } }
.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(4, 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, .sk-list { 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-card { 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 .cnt { font-size: 12px; color: var(--accent); font-weight: 700; }
.sk { display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; align-items: center; background: var(--surface); border-radius: 14px; padding: 8px 10px; }
.sk .ico { width: 40px; height: 40px; grid-row: span 2; }
.sk.locked .ico { filter: grayscale(1) brightness(.6); }
.sk.evo { background: linear-gradient(90deg, #3d2f12, var(--surface)); }

/* ---- 판 */
.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; }
.xpbar { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .5); overflow: hidden; border: 1px solid rgba(255, 255, 255, .15); }
.xpbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #5ec8ff, #b9f0ff); transition: width .15s; }
.xpbar span { position: absolute; inset: 0; font: 11px/14px var(--game); text-align: center; color: #fff; text-shadow: 0 1px 2px #000; }
.hud-row { display: grid; grid-template-columns: 44px 1fr 74px; 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; }
.clock { text-align: center; font: 30px/1 var(--game); color: #fff; text-shadow: 0 2px 0 #000a; font-variant-numeric: tabular-nums; }
.clock.late { color: #ff7a6e; }
.tally { text-align: right; font: 13px/1.25 var(--game); color: #fff; text-shadow: 0 1px 2px #000; }
.owned { display: flex; gap: 4px; flex-wrap: wrap; }
.own { position: relative; width: 30px; height: 30px; border-radius: 8px; background: rgba(0, 0, 0, .45); display: grid; place-items: center; }
.own .ico { width: 24px; height: 24px; }
.own b { position: absolute; right: -2px; bottom: -3px; font: 11px/1 var(--game); color: #fff; background: #000a; border-radius: 6px; padding: 1px 3px; }
.own.pas { background: rgba(60, 40, 120, .55); }
.own.evo { background: rgba(160, 110, 10, .7); box-shadow: 0 0 8px #ffcf3f; }
.owned.res { justify-content: center; }
.owned.res .own { width: 36px; height: 36px; background: var(--surface); }
.owned.res .own .ico { width: 28px; height: 28px; }
.bossbar { position: relative; margin: 2px 16px 0; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, .6); border: 2px solid #ff7a6e; overflow: hidden; }
.bossbar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #ff4e3a, #ff9a5a); transition: width .2s; }
.bossbar span { position: absolute; inset: 0; z-index: 1; font: 11px/12px var(--game); text-align: center; color: #fff; text-shadow: 0 1px 2px #000; }
.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); }
.cards { display: grid; gap: 8px; }
.pick { display: grid; grid-template-columns: 52px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; text-align: left; align-items: center; border: 2px solid var(--line); background: var(--surface-2); border-radius: 16px; padding: 10px 12px; color: var(--ink); animation: pop .3s ease-out both; }
.pick:nth-child(2) { animation-delay: .06s; }
.pick:nth-child(3) { animation-delay: .12s; }
.pick:active { border-color: var(--accent); transform: scale(.98); }
.pick .ico { width: 52px; height: 52px; grid-row: span 2; }
.pick b { font: 19px var(--game); }
.pick .tag { grid-column: 3; grid-row: 1; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 99px; padding: 2px 8px; }
.pick .desc { grid-column: 2 / 4; font-size: 13px; color: var(--sub); }
.chest > .ico { width: 96px; height: 96px; align-self: center; animation: pop .5s ease-out; }
.chest.evo { background: linear-gradient(#4a3810, var(--surface)); }
.chest .desc { color: var(--sub); font-size: 14px; word-break: keep-all; }

.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 .alley { width: 82%; 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 .alley { width: 62%; }
.stage.fit2 .hero-title .lede, .stage.fit2 .screen > .fine { display: none; }
.stage.fit2 .bubble { font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .moonglow, .eyes, .wisp, .peek, .sulwin, .hero-pose, .runaway { animation: none !important; }
}
