:root {
  --bg: #F4F1EA;
  --page: #E7E1D3;
  --ink: #2B2D42;
  --sub: #6B6860;
  --narr: #8A8578;
  --line: #E2DBCD;
  --card: #FFFFFF;
  --accent: #FF6B5B;
  --accent-soft: #FFE7E3;
  --up: #1E8E5A;
  --down: #D2442F;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--page);
  color: var(--ink);
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
}
#app {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0, 0, 0, .06);
}
.screen {
  min-height: 100dvh;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  animation: fade .35s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── 버튼 ── */
.btn {
  display: block; width: 100%;
  padding: 16px; margin-top: 10px;
  border: none; border-radius: 14px;
  font: inherit; font-weight: 700; font-size: 17px;
  cursor: pointer; transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.accent  { background: var(--accent); color: #fff; }
.btn.ghost   { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { font-size: 15px; padding: 14px 8px; }

/* ── 타이틀 ── */
.title-screen { justify-content: center; text-align: center; }
.title-badge {
  align-self: center; background: #fff; border: 1.5px solid var(--line);
  padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; color: var(--sub);
}
.logo {
  font-family: "Black Han Sans", "Noto Sans KR", sans-serif; font-weight: 400;
  font-size: 46px; line-height: 1.15; margin: 22px 0 10px; letter-spacing: -.01em;
}
.logo span { color: var(--accent); }
.title-emoji { font-size: 52px; margin: 18px 0; }
.title-desc { color: var(--sub); line-height: 1.6; margin-bottom: 28px; }

/* ── 설정 ── */
.setup h2, .dex h2 { font-size: 24px; font-weight: 900; margin: 20px 0 6px; }
.setup .lead { color: var(--sub); font-size: 14px; margin-bottom: 26px; line-height: 1.5; }
.field-label { font-weight: 700; font-size: 14px; margin: 18px 0 8px; }
.input {
  width: 100%; padding: 15px 16px; border: 2px solid var(--line); border-radius: 14px;
  font: inherit; font-size: 17px; background: #fff; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--ink); }
.field-label .sub { font-weight: 400; color: var(--narr); font-size: 12px; }
.job-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.job-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
  font: inherit; color: var(--ink); cursor: pointer; transition: border-color .15s, transform .08s;
}
.job-btn:active { transform: scale(.98); }
.job-btn .je { font-size: 24px; }
.job-btn b { font-size: 15px; margin-top: 2px; }
.job-btn small { font-size: 11.5px; color: var(--sub); line-height: 1.35; }
.job-btn .jfx { font-size: 11px; font-weight: 700; margin-top: 6px; }
.jfx .up { color: var(--up); }
.jfx .down { color: var(--down); }
.job-btn.on { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); background: #FBFAF6; }
.job-stat { font-size: 14px; color: var(--sub); }
.job-stat b { font-size: 16px; }
.mbti-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mbti-btn {
  padding: 13px 0; border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); cursor: pointer;
}
.mbti-btn small { display: block; font-size: 11px; font-weight: 400; color: var(--sub); margin-top: 2px; }
.mbti-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.mbti-btn.on small { color: rgba(255, 255, 255, .7); }
.mbti-grid.off { opacity: .3; pointer-events: none; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--sub); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.spacer { flex: 1; min-height: 24px; }
.privacy { font-size: 12px; color: var(--narr); text-align: center; margin-top: 12px; line-height: 1.5; }

/* ── 챕터 인트로 ── */
.chapter { justify-content: center; text-align: center; }
.ch-num { font-weight: 900; letter-spacing: .2em; font-size: 13px; color: var(--accent); }
.ch-emoji { font-size: 72px; margin: 18px 0 8px; }
.chapter h2 { font-size: 34px; font-weight: 900; }
.ch-sub { color: var(--sub); font-weight: 700; margin-top: 4px; }
.ch-intro { margin: 28px 0 36px; line-height: 1.75; font-size: 16px; }

/* ── 씬 ── */
.topbar { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--sub); }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 9px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.scene-title { font-size: 21px; font-weight: 900; margin: 18px 0 16px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.line { animation: pop .25s ease; }
.line.narr { color: var(--narr); font-size: 14.5px; text-align: center; padding: 4px 8px; line-height: 1.6; }
.line.narr.warn { color: var(--down); font-weight: 700; }
.line.npc { display: flex; gap: 8px; align-items: flex-start; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  background: #fff; border: 1.5px solid var(--line);
  display: grid; place-items: center; font-size: 20px;
}
.who { font-size: 12px; font-weight: 700; color: var(--sub); margin: 0 0 3px 2px; }
.bubble {
  background: #fff; border: 1.5px solid var(--line);
  padding: 10px 13px; border-radius: 4px 14px 14px 14px;
  font-size: 15.5px; line-height: 1.5; max-width: 300px;
}
.line.me { display: flex; justify-content: flex-end; }
.line.me .bubble { background: var(--ink); border-color: var(--ink); color: #fff; border-radius: 14px 4px 14px 14px; }
.picked {
  align-self: flex-end; max-width: 85%;
  background: var(--accent-soft); color: #B23A29;
  font-weight: 700; font-size: 14px; line-height: 1.45;
  padding: 8px 12px; border-radius: 12px; animation: pop .25s ease;
}
.tap-hint { text-align: center; font-size: 12px; color: var(--narr); margin-top: 14px; }
.choices { margin-top: 22px; display: flex; flex-direction: column; gap: 9px; }
.question { font-weight: 900; font-size: 16px; margin-bottom: 2px; animation: pop .25s ease; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 13px 14px; font: inherit; font-size: 15px; line-height: 1.45;
  color: var(--ink); cursor: pointer; animation: pop .25s ease both;
}
.choice:hover { border-color: var(--ink); }
.choice .num {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px;
  background: var(--bg); font-weight: 900; font-size: 12px; display: grid; place-items: center;
}
.deltas { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; animation: pop .25s ease; }
.chip { font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: #fff; border: 1.5px solid var(--line); }
.chip.up { color: var(--up); }
.chip.down { color: var(--down); }

/* ── 능력치 게이지 HUD ── */
.sticky {
  position: sticky; top: 0; z-index: 5;
  margin: -24px -20px 0; padding: 14px 20px 12px;
  background: var(--bg); border-bottom: 1.5px solid var(--line);
}
.hud { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; }
.g { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; border-radius: 8px; padding: 2px 4px; margin: -2px -4px; }
.gi { font-size: 13px; }
.gl { width: 38px; flex: none; color: var(--sub); }
.gb { flex: 1; height: 9px; background: #E4DDCF; border-radius: 9px; overflow: hidden; }
.gb i { display: block; height: 100%; border-radius: 9px; transition: width .7s cubic-bezier(.3, 1.4, .5, 1), background .3s; }
.g-mental .gb i { background: #8E7CFF; }
.g-work   .gb i { background: #3D7BFF; }
.g-rep    .gb i { background: #FFB020; }
.g-life   .gb i { background: #23BFA0; }
.g.low .gb i { background: var(--down); animation: blink 1s ease-in-out infinite; }
.g.low .gl { color: var(--down); }
.g.up   { animation: flashUp .9s ease; }
.g.down { animation: flashDown .9s ease, shake .35s ease; }
@keyframes flashUp   { 0%, 100% { background: transparent; } 30% { background: #DDF5E8; } }
@keyframes flashDown { 0%, 100% { background: transparent; } 30% { background: #FFE1DB; } }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes blink { 50% { opacity: .45; } }

/* ── 통장 / 돌발 / 호감도 ── */
.money {
  flex: none; font-size: 12.5px; font-weight: 900; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 99px; padding: 3px 9px;
}
.money.neg { color: var(--down); border-color: #F3C2B8; }
.money.up { animation: flashUp .9s ease; }
.money.down { animation: flashDown .9s ease, shake .35s ease; }
.salary {
  margin: -14px auto 28px; padding: 12px 16px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line);
  font-size: 15px; line-height: 1.5; animation: pop .4s .3s ease both;
}
.salary b { color: var(--up); }
.salary span { display: block; font-size: 12.5px; color: var(--narr); }
.event-badge {
  align-self: flex-start; margin-top: 16px; padding: 5px 11px; border-radius: 99px;
  background: #FFD84D; color: var(--ink); font-size: 12.5px; font-weight: 900;
  animation: pop .3s ease, wiggle 1.6s .4s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-4deg); } 20% { transform: rotate(4deg); } 30% { transform: rotate(0); } }
.is-event .scene-title { margin-top: 8px; }
.choice.gamble { border-color: #FFD84D; background: #FFFBEA; }
.choice.unlock { border-color: #B79CFF; background: #F6F1FF; }
.unlock-tag { display: block; font-size: 11.5px; font-weight: 700; color: #7A5AE0; margin-bottom: 3px; }
.chip.money-chip { background: #FFFBEA; }
.chip.rel { background: #FFF3F5; }
.money-final {
  text-align: center; margin: 4px 0 14px; padding: 12px; border-radius: 14px; background: #fff;
  border: 1.5px solid var(--line); font-size: 15px;
}
.money-final b { font-size: 18px; color: var(--up); }
.money-final.neg b { color: var(--down); }
.quotes { margin: 4px 0 6px; padding: 14px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.q-title { font-weight: 900; font-size: 14px; }
.quotes .bubble { background: var(--bg); border-color: transparent; font-size: 14.5px; }

/* ── 에필로그 ("N년 후…") ── */
.screen.epilogue { background: #23253A; color: #fff; justify-content: center; }
.ep-label {
  font-family: "Black Han Sans", "Noto Sans KR", sans-serif; font-size: 34px;
  margin-bottom: 26px; animation: fade 1s ease;
}
.epilogue .line.narr { color: #C8C5D8; font-size: 15px; }
.epilogue .who { color: #9F9CB5; }
.epilogue .avatar { background: #34374F; border-color: #44476A; }
.epilogue .bubble { background: #34374F; border-color: #44476A; color: #fff; }
.epilogue .line.me .bubble { background: var(--accent); border-color: var(--accent); }
.epilogue #epNext { margin-top: 28px; }

/* ── 결산 로딩: 회사생활 정산서 ── */
.loading { justify-content: center; align-items: center; }
.printer { width: 270px; height: 14px; background: var(--ink); border-radius: 8px; position: relative; z-index: 2; }
.receipt {
  position: relative; width: 240px; margin-top: -6px; padding: 22px 18px 44px;
  background: #fff; font-size: 13px; color: var(--ink);
  box-shadow: 0 6px 18px rgba(43, 45, 66, .1);
  animation: print 1.1s steps(12) both;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 16px 8px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 16px 8px repeat-x;
}
@keyframes print { from { clip-path: inset(0 0 100% 0); transform: translateY(-20px); } to { clip-path: inset(0 0 0 0); transform: none; } }
.r-head { text-align: center; font-weight: 900; font-size: 17px; letter-spacing: .08em; }
.r-sub { text-align: center; color: var(--narr); font-size: 11.5px; margin-top: 4px; }
.r-line { border-top: 2px dashed var(--line); margin: 12px 0; }
.r-row { display: flex; align-items: baseline; gap: 6px; margin: 7px 0; opacity: 0; animation: fadeIn .3s ease forwards; }
.r-row .dots { flex: 1; border-bottom: 2px dotted #D8D1C2; transform: translateY(-3px); }
.r-row b { font-weight: 900; font-family: Consolas, monospace; font-size: 14px; }
@keyframes fadeIn { to { opacity: 1; } }
.r-total { text-align: center; font-weight: 900; font-size: 14px; opacity: 0; animation: fadeIn .3s 1.5s ease forwards; }
.ell { display: inline-block; animation: blink .8s infinite; }
.stamp {
  position: absolute; right: 8px; bottom: 6px;
  width: 64px; height: 64px; border: 4px solid var(--accent); border-radius: 50%;
  color: var(--accent); font-weight: 900; font-size: 13px; line-height: 1.15;
  display: grid; place-items: center; text-align: center;
  opacity: 0; transform: rotate(-16deg) scale(2.2);
  animation: stamp .35s 2.1s cubic-bezier(.2, 1.6, .4, 1) forwards;
  mix-blend-mode: multiply;
}
@keyframes stamp { to { opacity: .9; transform: rotate(-16deg) scale(1); } }
.loading .ad-slot { width: 100%; height: 120px; margin-top: 34px; }

/* ── 결과 ── */
.result-head { text-align: center; font-weight: 700; color: var(--sub); margin: 6px 0 14px; }
.card-wrap { border-radius: 18px; overflow: hidden; box-shadow: 0 8px 30px rgba(43, 45, 66, .12); }
.card-wrap canvas { display: block; width: 100%; height: auto; }
.result-comment { margin: 18px 4px 6px; line-height: 1.7; font-size: 15px; }
.share-stat {
  margin: 12px 0 8px; padding: 14px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line);
  text-align: center; font-size: 15px; line-height: 1.6;
}
.share-stat b { color: var(--accent); font-size: 20px; }
.share-stat .note { display: block; font-size: 11px; color: var(--narr); margin-top: 4px; }

/* ── 도감 ── */
.dex .lead { color: var(--sub); font-size: 14px; margin-bottom: 18px; }
.dex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dex-item { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; }
.dex-item .e { font-size: 34px; }
.dex-item .t { font-weight: 700; font-size: 13.5px; margin-top: 6px; line-height: 1.35; }
.dex-item .h { font-size: 12px; color: var(--narr); margin-top: 4px; }
.dex-item.locked { background: transparent; border-style: dashed; }
.dex-item.locked .e { filter: grayscale(1); opacity: .5; }

/* ── 광고 자리 (개발용 표시) ── */
.ad-slot {
  margin-top: 22px; height: 100px; border: 2px dashed #CFC8B8; border-radius: 12px;
  display: grid; place-items: center; color: #B0AA9C; font-size: 12px; font-weight: 700; letter-spacing: .05em;
}

/* ── 사이트 하단 링크 ── */
.site-footer {
  margin-top: 26px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px;
  font-size: 12px; color: var(--narr);
}
.site-footer a { color: var(--sub); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ── 토스트 / 디버그 ── */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 10;
  max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#debug {
  position: fixed; right: 8px; top: 8px; z-index: 20;
  background: rgba(20, 20, 30, .88); color: #fff; font: 12px/1.5 Consolas, monospace;
  padding: 10px 12px; border-radius: 10px; min-width: 150px;
}
#debug button { margin-top: 6px; font: inherit; padding: 2px 6px; cursor: pointer; }
