* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #14101f;
  --panel: #1f1930;
  --panel2: #2a2342;
  --line: #3b3159;
  --text: #ece7f7;
  --dim: #9a8fc0;
  --accent: #a78bfa;
  --ember: #fb923c;
  --good: #4ade80;
  --bad: #f87171;
  --gold: #fbbf24;
}

html { touch-action: manipulation; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  display: flex; justify-content: center;
  background-image:
    radial-gradient(ellipse at 50% -10%, #2d2350 0%, var(--bg) 60%),
    radial-gradient(ellipse at 50% 115%, #241531 0%, transparent 55%);
  min-height: 100dvh;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
img { -webkit-user-drag: none; }
.ui-icon { width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; }
.ui-icon.micro { width: 17px; height: 17px; }
button .ui-icon { margin-right: 4px; }
.tut-icon { width: 54px; height: 54px; }

#app { width: 100%; max-width: 430px; min-height: 100dvh; display: flex; flex-direction: column; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }

.screen { display: none; flex: 1; flex-direction: column; animation: screenIn .3s cubic-bezier(.2, .8, .3, 1); }
.screen.active { display: flex; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; } }

button {
  font-family: inherit; cursor: pointer; border: 1px solid var(--line);
  border-bottom: 4px solid #120d20;
  background: linear-gradient(180deg, #322a4e, var(--panel2));
  color: var(--text); border-radius: 14px;
  padding: 14px 16px; font-size: 15px; text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  transition: filter .12s, transform .06s, border-bottom-width .06s;
}
button:active { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 2px; filter: brightness(1.12); }
button.primary {
  background: linear-gradient(180deg, #9d6bff, #7c3aed);
  border: none; border-bottom: 4px solid #5b21b6;
  font-weight: 800; text-align: center; color: #fff;
  box-shadow: 0 6px 20px rgba(124,58,237,.4), inset 0 1px 0 rgba(255,255,255,.3);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
button.ghost { background: transparent; border: none; text-align: center; color: var(--dim); box-shadow: none; }
button.ghost:active { transform: none; margin: 0; }

/* ── 타이틀 ── */
#screen-title { position: relative; justify-content: center; align-items: center; gap: 12px; text-align: center; }
#screen-title.active::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: url('../assets/img/title.png') center 20%/cover no-repeat;
  filter: blur(20px) brightness(.35) saturate(1.3);
  transform: scale(1.15);
}
.logo-image { width: min(64vw, 250px); aspect-ratio: 1; object-fit: cover; border-radius: 24px;
  border: 2px solid rgba(167,139,250,.4);
  box-shadow: 0 0 0 5px rgba(20,16,31,.6), 0 18px 50px rgba(0,0,0,.6), 0 0 60px rgba(167,139,250,.35); }
.logo-title { font-size: 36px; font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, #c4b5fd, #fb923c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.55)); }
.logo-sub { color: #c1b8e2; font-size: 14px; line-height: 1.6; margin-bottom: 20px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
#screen-title button { width: 80%; }
#screen-title .primary { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 6px 20px rgba(124,58,237,.4), inset 0 1px 0 rgba(255,255,255,.3); }
  50% { box-shadow: 0 6px 30px rgba(167,139,250,.75), inset 0 1px 0 rgba(255,255,255,.3); }
}
.title-foot { margin-top: 24px; color: var(--dim); font-size: 12px; letter-spacing: 1px; opacity: .8; }

/* ── 캐릭터 생성 (위저드) ── */
#screen-create.active::before, #screen-ending.active::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: url('../assets/img/title.png') center 25%/cover no-repeat;
  filter: blur(30px) brightness(.16) saturate(1.25);
  transform: scale(1.2);
}
#screen-game.active::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: var(--stage-bg, url('../assets/sprites/bg_office.png')) center 50%/cover no-repeat;
  filter: brightness(.82) saturate(1.05);
  image-rendering: pixelated;
}
#screen-game.active::after {
  content: ''; position: fixed; inset: auto 0 0 0; height: 45%; z-index: -1;
  background: linear-gradient(180deg, rgba(20,16,31,0) 0%, rgba(14,10,24,.9) 70%);
}
.stage-fade::before { animation: stageFade .4s ease-out; }
@keyframes stageFade { from { opacity: .2; } to { opacity: 1; } }
body.battle #screen-game.active::before { filter: brightness(.62) saturate(1.25) hue-rotate(-10deg); image-rendering: pixelated; }
.create-top { display: flex; justify-content: space-between; align-items: center; }
.create-top .ghost { width: 44px; padding: 8px; font-size: 18px; }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line); transition: all .25s; }
.dots i.on { width: 22px; background: var(--accent); box-shadow: 0 0 10px rgba(167,139,250,.6); }
.dots i.done { background: var(--accent); opacity: .5; }
.create-h { font-size: 22px; font-weight: 900; margin: 14px 0 16px; text-align: center; }
.create-body { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.create-body.slide { animation: slideStep .3s cubic-bezier(.2, .8, .3, 1); }
@keyframes slideStep { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; } }
.wcard { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-align: left; }
.wcard img { width: 64px; height: 64px; object-fit: cover; border-radius: 16px; flex-shrink: 0; }
.wcard .we { width: 64px; height: 64px; border-radius: 16px; background: #141024; display: flex;
  align-items: center; justify-content: center; font-size: 36px; flex-shrink: 0; }
.wcard .wtxt { display: flex; flex-direction: column; gap: 3px; }
.wcard .wtxt b { font-size: 16px; }
.wcard .wtxt small { font-size: 12px; color: var(--dim); line-height: 1.5; word-break: keep-all; }
.idcard { background: linear-gradient(180deg, #241c3c, #1a1430); border: 1px solid #4c4178; border-radius: 20px;
  padding: 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 16px 40px rgba(0,0,0,.45);
  animation: cardDrop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes cardDrop { from { opacity: 0; transform: translateY(-24px) rotate(-2deg) scale(.94); } to { opacity: 1; } }
.idcard-h { font-size: 11px; font-weight: 800; letter-spacing: 5px; color: var(--dim); }
.idcard img { width: 108px; height: 108px; object-fit: cover; border-radius: 22px; border: 2px solid var(--accent);
  box-shadow: 0 0 24px rgba(167,139,250,.35); }
.idcard b { font-size: 18px; }
.idcard small { color: var(--dim); font-size: 13px; }
.idcard-stats { margin-top: 6px; font-size: 13px; color: var(--dim); padding: 8px 16px;
  border-radius: 99px; background: #141024; font-variant-numeric: tabular-nums; }

/* ── 게임 ── */
.hud { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 13px; font-weight: 700; padding: 4px 2px 10px; }
.hud .who { color: var(--text); display: inline-flex; align-items: center; gap: 7px; }
.hud .who img { width: 34px; height: 34px; object-fit: cover; border-radius: 11px;
  border: 1px solid var(--line); box-shadow: 0 0 0 2px rgba(167,139,250,.25); }
.hud-week-chip { padding: 5px 12px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: #c4b5fd; font-size: 12px; }

.stats {
  background: linear-gradient(180deg, rgba(36,28,60,.9), rgba(26,20,48,.9));
  border: 1px solid #4c4178; border-radius: 16px; padding: 13px 14px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 8px 24px rgba(0,0,0,.35);
}
.stat { position: relative; display: grid; grid-template-columns: 64px 44px 1fr; gap: 8px; align-items: center; font-size: 13px; }
.stat .sname { color: var(--dim); }
.stat .sval { font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; transition: color .3s; }
.stat.low .sval { color: var(--bad); }
.bar { height: 10px; background: #141024; border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .45s ease;
  background-image: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 55%); }
.bar.mp i { background-color: #a78bfa; }
.bar.trust i { background-color: #fb7185; }
.bar.gold i { background-color: #fbbf24; }
.stat.low .bar i { animation: dangerPulse .7s ease-in-out infinite alternate; }
@keyframes dangerPulse { from { filter: brightness(.8) saturate(1.4); } to { filter: brightness(1.5) saturate(1.6); } }
.float-delta {
  position: absolute; right: 2px; top: -4px; z-index: 2;
  font-size: 13px; font-weight: 900; pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  animation: floatUp .9s ease-out forwards;
}
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-24px); } }

/* ── 가방 & 버프 바 ── */
.inv-bar { display: flex; align-items: center; gap: 6px; padding: 8px 2px 2px; min-height: 44px; }
.inv-slot { width: 38px; height: 38px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 19px; padding: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05); transition: all .15s; }
.inv-slot img { width: 31px; height: 31px; object-fit: contain; image-rendering: pixelated; }
.inv-slot.empty { border-style: dashed; opacity: .35; }
.inv-slot.sel { transform: scale(1.18); border-color: var(--gold); box-shadow: 0 0 14px rgba(251,191,36,.5); }
.inv-slot.pop { animation: lootIn .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes lootIn { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1); } }
.inv-hint { font-size: 10px; color: var(--gold); font-weight: 800; margin-left: 2px; min-width: 70px; }
.buff-chips { display: flex; gap: 5px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.buff-chip { font-size: 10px; font-weight: 800; padding: 4px 9px; border-radius: 99px;
  background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.45); color: var(--good); white-space: nowrap; }
.buff-chip.bad { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.45); color: var(--bad); }
.buff-chip.build { background: rgba(167,139,250,.08); border-color: rgba(167,139,250,.4); color: var(--accent); }
.buff-chip.rel { background: rgba(251,146,60,.08); border-color: rgba(251,146,60,.4); color: var(--ember); }
.buff-chip.maxed { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 8px rgba(251,191,36,.4); }
.buff-chip.armed { background: rgba(251,191,36,.1); border-color: var(--gold); color: var(--gold);
  animation: armedPulse 1.4s ease-in-out infinite; }
@keyframes armedPulse { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 10px rgba(251,191,36,.55); } }

.loot-pop { position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%); z-index: 8;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 30px; border-radius: 20px;
  background: rgba(20,16,31,.95); border: 1px solid var(--gold); color: var(--gold);
  font-weight: 900; font-size: 15px; opacity: 0; pointer-events: none;
  box-shadow: 0 0 40px rgba(251,191,36,.3), 0 14px 44px rgba(0,0,0,.55); }
.loot-pop .li { font-size: 42px; line-height: 1; }
.loot-pop .li img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.loot-pop.show { animation: lootPop 1.4s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes lootPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  30% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%); } }

/* ── 용사 침공전 ── */
.battle-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-top: 6px;
  border-radius: 14px; background: linear-gradient(180deg, #3a1420, #2a0f18); border: 1px solid #7f1d1d;
  box-shadow: 0 0 24px rgba(248,113,113,.2), inset 0 1px 0 rgba(255,255,255,.05);
  animation: battleBarIn .5s cubic-bezier(.2, .8, .3, 1); }
@keyframes battleBarIn { from { opacity: 0; transform: scaleY(.6); } to { opacity: 1; } }
.battle-bar .bb-name { font-size: 12px; font-weight: 800; color: #fda4af; white-space: nowrap; }
.battle-bar .bar { flex: 1; height: 12px; }
.bar.bb i { background-color: #f87171; }
.battle-bar b { font-size: 14px; color: #fda4af; font-variant-numeric: tabular-nums; min-width: 20px; text-align: right; }
body.shakefx { animation: screenShake .4s ease; }
@keyframes screenShake {
  0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

.event-box {
  position: relative;
  background: rgba(18,13,32,.94);
  border: 2px solid #4c4178; border-radius: 14px;
  box-shadow: 0 0 0 3px rgba(18,13,32,.94), 0 0 0 4px #2c2350, 0 10px 30px rgba(0,0,0,.5);
  padding: 22px 18px 18px; margin: 14px 2px 10px; min-height: 118px;
  font-size: 16px; line-height: 1.75; word-break: keep-all;
}
.speaker { position: absolute; top: -16px; left: 12px; display: flex; align-items: center; gap: 7px;
  padding: 5px 16px 5px 7px; border-radius: 10px 10px 10px 2px;
  background: linear-gradient(180deg, #4a3b7d, #33285c);
  border: 1.5px solid var(--accent); font-size: 12.5px; font-weight: 900; color: #e9e2ff;
  box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.type-ind { position: absolute; right: 16px; bottom: 8px; color: var(--accent); font-size: 13px;
  animation: indBlink .8s ease-in-out infinite; display: none; }
.type-ind.on { display: block; }
@keyframes indBlink { 0%, 100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(2px); } }
.speaker .se { width: 24px; height: 24px; border-radius: 50%; background: #141024; display: flex;
  align-items: center; justify-content: center; font-size: 14px; overflow: hidden; }
.speaker .se.chip-sprite { background-color: #141024; background-position: 0 0; background-repeat: no-repeat; image-rendering: pixelated; }
.speaker .se img { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; }
.event-box.animate { animation: cardIn .35s cubic-bezier(.2, .8, .3, 1); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; } }

/* ── 12주 진행 맵 ── */
.week-map { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px 10px; }
.week-map i { width: 9px; height: 9px; border-radius: 3px; background: var(--line); transform: rotate(45deg);
  font-style: normal; font-size: 0; transition: background .3s; }
.week-map i.done { background: var(--accent); box-shadow: 0 0 6px rgba(167,139,250,.5); }
.week-map i.cur { width: 24px; height: 24px; transform: none; background: transparent; font-size: 16px;
  display: flex; align-items: center; justify-content: center; animation: curBob 1.6s ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.7)); }
.week-map i.cur img { width: 24px; height: 24px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--accent); box-shadow: 0 0 8px rgba(167,139,250,.6); }
.week-map i.goal { width: auto; height: auto; transform: none; background: transparent; font-size: 13px; opacity: .8; }
.week-map i.goal .ui-icon { width: 25px; height: 25px; }
@keyframes curBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ── 주사위 판정 ── */
.dice-pop { position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%); z-index: 8;
  font-size: 22px; font-weight: 900; opacity: 0; pointer-events: none; text-align: center;
  padding: 14px 26px; border-radius: 18px; background: rgba(20,16,31,.94); border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(0,0,0,.55); }
.dice-pop.show { opacity: 1; }
.dice-pop.spin { font-size: 44px; padding: 12px 22px; animation: diceSpin .9s ease-in-out; }
@keyframes diceSpin {
  0% { transform: translate(-50%, -50%) rotate(0) scale(.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(720deg) scale(1); opacity: 1; }
}
.dice-pop.ok { color: var(--good); border-color: var(--good); box-shadow: 0 0 30px rgba(74,222,128,.35); animation: rollStamp .5s cubic-bezier(.2, 1.6, .4, 1); }
.dice-pop.no { color: var(--bad); border-color: var(--bad); box-shadow: 0 0 30px rgba(248,113,113,.35); animation: rollStamp .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes rollStamp { from { transform: translate(-50%, -50%) scale(1.7); } to { transform: translate(-50%, -50%) scale(1); } }
.cost.riskc { color: var(--ember); font-weight: 800; }

/* ── 캐릭터 리액션 ── */
/* ── RPG 무대: PC(좌) vs NPC(우) ── */
.scene { flex: 1; min-height: 0; position: relative; display: flex; align-items: flex-end;
  justify-content: space-between; padding: 10px 26px 22px; }
.scene .pc, .scene .npc { position: relative; display: flex; flex-direction: column; align-items: center; }
.scene .pc::after, .scene .npc::after {
  content: ''; position: absolute; bottom: -12px; width: 76%; height: 16px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 70%); z-index: -1; }
.npc .sprite { font-size: min(20vw, 80px); line-height: 1.1; filter: drop-shadow(0 10px 22px rgba(0,0,0,.6));
  animation: npcIn .45s cubic-bezier(.2, 1.2, .4, 1), idleBob 3.4s ease-in-out .45s infinite; }
/* 도트 스프라이트 (128px 프레임, CSS steps() 애니메이션) */
.dot-sprite { width: 128px; height: 128px; background-repeat: no-repeat; background-position: 0 0;
  image-rendering: pixelated; filter: drop-shadow(0 10px 22px rgba(0,0,0,.6)); }
@keyframes spriteFrames { to { background-position-x: var(--sprite-end); } }
.npc .dot-sprite { animation: npcIn .45s cubic-bezier(.2, 1.2, .4, 1); }
.npc.foe .dot-sprite { filter: drop-shadow(0 10px 22px rgba(0,0,0,.6)) drop-shadow(0 0 18px rgba(248,113,113,.55)); }
@media (max-width: 400px) { .dot-sprite { transform: scale(.82); transform-origin: bottom center; } }
.npc .nlabel { font-size: 11px; font-weight: 800; color: var(--dim); margin-top: 8px;
  padding: 2px 10px; border-radius: 99px; background: rgba(20,16,31,.7); border: 1px solid var(--line); }
@keyframes npcIn { from { opacity: 0; transform: translateX(46px) scale(.7); } to { opacity: 1; } }
.npc.talk .sprite { animation: talkPulse .32s ease-in-out infinite alternate; }
@keyframes talkPulse { from { transform: translateY(0) scale(1); } to { transform: translateY(-3px) scale(1.05); } }
.npc.foe .sprite { filter: drop-shadow(0 10px 22px rgba(0,0,0,.6)) drop-shadow(0 0 18px rgba(248,113,113,.55)); }
.npc.foe .nlabel { color: #fda4af; border-color: #7f1d1d; }
.lungeL { animation: lungeLeft .45s cubic-bezier(.3, 0, .4, 1) !important; }
@keyframes lungeLeft { 0% { transform: translateX(0); } 35% { transform: translateX(calc(-38vw + 60px)); } 60% { transform: translateX(calc(-38vw + 60px)); } 100% { transform: translateX(0); } }
.lungeR { animation: lungeRight .45s cubic-bezier(.3, 0, .4, 1) !important; }
@keyframes lungeRight { 0% { transform: translateX(0); } 35% { transform: translateX(calc(38vw - 60px)); } 60% { transform: translateX(calc(38vw - 60px)); } 100% { transform: translateX(0); } }
.flash { animation: hitFlash .4s ease !important; }
@keyframes hitFlash { 0%, 100% { filter: none; } 30% { filter: brightness(2.6) saturate(0); } 60% { filter: brightness(.7) sepia(.5) hue-rotate(-30deg); } }
.dmg-num { position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 27px; font-weight: 900; pointer-events: none; z-index: 4; white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0,0,0,.7), 0 0 14px rgba(0,0,0,.5);
  animation: dmgFloat 1s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes dmgFloat {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.6); }
  18% { opacity: 1; transform: translateX(-50%) translateY(-4px) scale(1.25); }
  38% { transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-34px); } }
.scene .joy { animation: joyBounce .6s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes joyBounce { 0% { transform: translateY(0); } 35% { transform: translateY(-16px) scale(1.04); } 70% { transform: translateY(0) scale(.98); } 100% { transform: translateY(0); } }
.scene .hit { animation: hitShake .5s ease; filter: sepia(.4) hue-rotate(-30deg) saturate(2); }
@keyframes hitShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px) rotate(-2deg); } 40% { transform: translateX(7px) rotate(2deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(4px); } }
.emote { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); font-size: 34px;
  pointer-events: none; animation: emotePop 1.1s cubic-bezier(.2, .8, .3, 1) forwards; z-index: 3;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.6)); }
.reaction-icon { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
@keyframes emotePop {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.4); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
  45% { transform: translateX(-50%) translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px); } }
.particle { position: absolute; bottom: 40%; left: 50%; font-size: 18px; pointer-events: none;
  animation: partFly .9s ease-out forwards; z-index: 2; }
.particle-icon { width: 22px; height: 22px; object-fit: contain; image-rendering: pixelated; }
@keyframes partFly { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.6); } }
.battle-fx { position: absolute; width: 128px; height: 128px; left: 50%; bottom: 0; transform: translateX(-50%);
  z-index: 5; pointer-events: none; background-size: 512px 128px; background-repeat: no-repeat;
  image-rendering: pixelated; animation: spriteFrames .56s steps(4) 1 both; }

.chain-tag { position: absolute; top: -15px; right: 14px; padding: 4px 12px; border-radius: 99px;
  background: rgba(167,139,250,.12); border: 1px solid var(--accent); font-size: 11px; font-weight: 800; color: var(--accent); }
.pc img, .pc .stage-emoji {
  width: min(34vw, 132px); aspect-ratio: 1; object-fit: cover; border-radius: 26px;
  border: 2px solid rgba(167,139,250,.35);
  box-shadow: 0 18px 40px rgba(0,0,0,.5), 0 0 36px rgba(167,139,250,.15);
  animation: idleBob 3s ease-in-out infinite; }
.pc .stage-emoji { display: flex; align-items: center; justify-content: center; font-size: 72px; background: #1a1430; }
@keyframes idleBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.choices { display: flex; flex-direction: column; gap: 7px; }
.choices button { background: rgba(42,35,66,.9); }
.choices button > span:first-child::before { content: '\276F '; color: var(--accent); font-weight: 900; }
.choices button.chosen > span:first-child::before { color: var(--gold); }
.choices button { display: flex; justify-content: space-between; align-items: center; gap: 8px; line-height: 1.45; word-break: keep-all;
  animation: riseIn .3s cubic-bezier(.2, .8, .3, 1) backwards; transition: opacity .3s, box-shadow .2s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }
.choices .cost { color: var(--dim); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.choices button:disabled { cursor: default; }
.choices button.chosen { border-color: var(--accent); background: linear-gradient(180deg, #4a3b7d, #3b2f63);
  box-shadow: 0 0 0 1px var(--accent), 0 0 22px rgba(167,139,250,.5); }
.choices button.faded { opacity: .22; }
.d-up { color: var(--good); } .d-down { color: var(--bad); }

.result-pop { position: fixed; top: 42%; left: 50%; transform: translate(-50%, -50%); z-index: 7;
  display: flex; gap: 16px; padding: 15px 24px; border-radius: 18px;
  background: rgba(20,16,31,.94); border: 1px solid var(--line);
  font-weight: 900; font-size: 16px; white-space: nowrap;
  opacity: 0; pointer-events: none; box-shadow: 0 14px 44px rgba(0,0,0,.55); }
.result-pop.show { animation: resultPop 1s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes resultPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -46%); }
}

.week-stamp {
  position: fixed; top: 38%; left: 50%; z-index: 8;
  transform: translate(-50%, -50%);
  font-size: 42px; font-weight: 900; letter-spacing: 6px; color: var(--ember);
  text-shadow: 0 0 30px rgba(251,146,60,.5), 0 4px 18px rgba(0,0,0,.8);
  opacity: 0; pointer-events: none;
}
.week-stamp.show { animation: stampIn 1s cubic-bezier(.2, .8, .3, 1); }
@keyframes stampIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
}

.game-foot { display: flex; justify-content: space-between; padding-top: 8px; }
.game-foot button { padding: 8px 12px; font-size: 12px; }

/* ── 엔딩 ── */
#screen-ending { justify-content: center; align-items: center; text-align: center; gap: 10px; }
.end-week { color: var(--dim); font-size: 13px; font-weight: 700; letter-spacing: 2px; }
.end-emoji { font-size: 80px; margin: 6px 0; line-height: 1;
  animation: endPop .6s cubic-bezier(.2, 1.6, .4, 1);
  filter: drop-shadow(0 0 24px rgba(167,139,250,.45)); }
.ending-icon { width: 104px; height: 104px; object-fit: contain; image-rendering: pixelated; }
@keyframes endPop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.end-title { font-size: 30px; font-weight: 900; animation: fadeUp .5s .12s cubic-bezier(.2, .8, .3, 1) backwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }
.rarity { display: inline-block; font-size: 11px; font-weight: 800; padding: 4px 12px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  animation: fadeUp .5s .2s cubic-bezier(.2, .8, .3, 1) backwards; }
.rarity.r희귀 { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px rgba(167,139,250,.35); }
.rarity.r전설 { color: var(--gold); border-color: var(--gold); background: rgba(251,191,36,.08); box-shadow: 0 0 18px rgba(251,191,36,.4); }
.end-desc { color: #c9c0e8; font-size: 15px; line-height: 1.8; word-break: keep-all; padding: 6px 8px;
  animation: fadeUp .5s .28s cubic-bezier(.2, .8, .3, 1) backwards; }
.end-stat { font-size: 13px; color: var(--dim); padding: 8px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.end-pct { font-size: 13px; color: var(--ember); font-weight: 700; min-height: 18px; }
#screen-ending button { width: 82%; }

.lockbox { background: var(--panel); border: 1px dashed var(--gold); border-radius: 16px; padding: 20px; width: 90%;
  box-shadow: 0 0 30px rgba(251,191,36,.15); }
.lockbox h3 { color: var(--gold); margin-bottom: 8px; }
.lockbox p { color: var(--dim); font-size: 13px; line-height: 1.7; margin-bottom: 14px; word-break: keep-all; }
.lockbox button { width: 100%; }

/* ── 도감 ── */
.dex-h { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 14px; }
.dex-h h2 { font-size: 20px; }
.dex-h span { color: var(--accent); font-weight: 800; font-size: 14px; }
.dex-goals { margin-bottom: 10px; }
.dex-goal-h { font-size: 12px; font-weight: 800; color: var(--gold); margin-bottom: 6px; letter-spacing: 1px; }
.dex-goal { font-size: 12px; color: var(--dim); line-height: 1.6; word-break: keep-all; padding: 8px 12px;
  border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 5px; }
.dex-goal b { color: var(--accent); margin-right: 4px; }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow-y: auto; align-content: start; }
.dex-cell { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 13px 6px 11px; text-align: center; font-size: 11px; color: var(--dim); line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.dex-cell .de { font-size: 28px; display: block; margin-bottom: 4px; }
.dex-cell .de img { width: 46px; height: 46px; object-fit: contain; image-rendering: pixelated; }
.dex-cell.got { color: var(--text); border-color: #4c4178; background: linear-gradient(180deg, #2a2148, #241c3c); }
.dex-cell.locked { border-style: dashed; border-color: #7a6524; }
.dex-cell .pct { display: block; font-size: 10px; color: var(--ember); font-weight: 700; }
#screen-dex .ghost { margin-top: 12px; }

/* ── 상점 ── */
.shop-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 7px; background: rgba(20,16,31,.5); }
.shop-row.owned { border-color: var(--gold); }
.shop-row .si { font-size: 24px; width: 32px; text-align: center; flex-shrink: 0; }
.shop-row .si img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.shop-cart { width: 52px; height: 52px; }
.shop-row .st { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.shop-row .st b { font-size: 13px; }
.shop-row .st b em { font-style: normal; font-size: 10px; color: var(--gold); border: 1px solid var(--gold);
  border-radius: 99px; padding: 1px 6px; margin-left: 4px; }
.shop-row .st small { font-size: 11px; color: var(--dim); line-height: 1.4; word-break: keep-all; }
.shop-buy { flex-shrink: 0; padding: 8px 12px; font-size: 12px; font-weight: 800; text-align: center;
  color: var(--gold); border-color: #7a6524; min-width: 68px; }
.shop-buy:disabled { opacity: .4; cursor: default; }
.inv-slot.gear { border-color: #7a6524; background: rgba(251,191,36,.08); margin-right: 6px; }
.inv-slot.gear.empty { border-style: dashed; opacity: .3; }

/* ── P1: 예고·능력·비교 ── */
.forecast { text-align: center; font-size: 11px; font-weight: 700; color: var(--dim); padding: 0 0 8px; letter-spacing: .5px; }
#btn-ability.armed { color: var(--gold); text-shadow: 0 0 10px rgba(251,191,36,.5); }
.game-foot { flex-wrap: wrap; gap: 2px; }
.game-foot button { padding: 8px 8px; font-size: 11px; }
.cmp-event { font-size: 13px; color: #c9c0e8; line-height: 1.7; word-break: keep-all; text-align: center;
  background: rgba(18,13,32,.9); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.cmp-badge { display: inline-block; font-size: 13px; font-weight: 900; padding: 6px 16px; border-radius: 99px; margin: 4px 0; }
.cmp-badge.same { color: var(--good); border: 1.5px solid var(--good); background: rgba(74,222,128,.08); }
.cmp-badge.diff { color: var(--ember); border: 1.5px solid var(--ember); background: rgba(251,146,60,.08); }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.cmp-col { background: rgba(31,25,48,.9); border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 5px; text-align: center; }
.cmp-col.me { border-color: var(--accent); box-shadow: 0 0 14px rgba(167,139,250,.25); }
.cmp-col small { font-size: 10px; color: var(--dim); font-weight: 800; letter-spacing: 1px; }
.cmp-col b { font-size: 13px; line-height: 1.4; word-break: keep-all; }
.cmp-col span { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.cmp-copy { font-size: 14px; font-weight: 800; color: var(--ember); text-align: center; word-break: keep-all;
  line-height: 1.6; padding: 2px 8px; }

/* ── 모달 (도감 상세 / 온보딩) ── */
.modal { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  background: rgba(10,7,18,.72); backdrop-filter: blur(3px); padding: 24px; }
.modal.show { display: flex; animation: screenIn .25s cubic-bezier(.2,.8,.3,1); }
.modal-card { width: 100%; max-width: 340px; background: linear-gradient(180deg, #241c3c, #1a1430);
  border: 1px solid #4c4178; border-radius: 20px; padding: 22px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06); }
.tut-row { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--dim); line-height: 1.6;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; word-break: keep-all; }
.tut-row b { color: var(--text); white-space: nowrap; }
.dexd-emoji { font-size: 56px; text-align: center; }
.dexd-emoji .ending-icon { width: 88px; height: 88px; }
.dexd-title { font-size: 22px; font-weight: 900; text-align: center; margin: 6px 0 8px; }
.dexd-desc { font-size: 14px; line-height: 1.8; color: #c9c0e8; word-break: keep-all; margin: 12px 0; }
.dexd-meta { font-size: 12px; color: var(--dim); text-align: center; line-height: 1.8; }
.dex-cell.got { cursor: pointer; }

.toast { position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: rgba(20,16,31,.92); border: 1px solid var(--line); color: #fff; padding: 11px 20px; border-radius: 99px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 12; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }


/* ── 짧은 화면 압축 (iPhone SE 등 667px) — 한 화면 수용 ── */
@media (max-height: 720px) {
  #app { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .stats { padding: 8px 12px; gap: 6px; }
  .week-map { padding: 0 8px 6px; }
  .forecast { padding: 0 0 5px; font-size: 10px; }
  .inv-bar { min-height: 36px; padding: 4px 2px 2px; }
  .inv-slot { width: 32px; height: 32px; font-size: 16px; }
  .scene { padding: 4px 22px 14px; }
  .pc img, .pc .stage-emoji, .dot-sprite { transform: scale(.78); transform-origin: bottom center; }
  .npc .sprite { font-size: min(16vw, 62px); }
  .event-box { padding: 18px 16px 14px; min-height: 96px; font-size: 15px; line-height: 1.65; margin: 12px 2px 8px; }
  .choices button { padding: 10px 14px; font-size: 14px; }
  .game-foot { padding-top: 5px; padding-bottom: env(safe-area-inset-bottom); }
}
