:root {
  --bg: #f6f5fb;
  --card: #ffffff;
  --ink: #16182b;
  --muted: #6b6f86;
  --line: #e4e3ef;
  --soft: #efeefe;
  --accent: #5b5bf0;
  --accent-ink: #ffffff;
  --band: rgba(91, 91, 240, 0.12);
  --income: #5b5bf0;
  --security: #1fae8c;
  --satisfaction: #f0a03a;
  --skill: #c656e0;
  --st-orig: #5b5bf0;
  --st-ai: #1fae8c;
  --st-other: #f0a03a;
  --st-founder: #e0569b;
  --st-unemployed: #b9bbcc;
  --shadow: 0 1px 2px rgba(22, 24, 43, 0.04), 0 6px 24px rgba(22, 24, 43, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020;
    --card: #181a2e;
    --ink: #ecebfa;
    --muted: #9a9cb8;
    --line: #2a2c45;
    --soft: #23254a;
    --accent: #8b8cff;
    --accent-ink: #0f1020;
    --band: rgba(139, 140, 255, 0.16);
    --income: #8b8cff;
    --security: #3dd6b5;
    --satisfaction: #ffb35c;
    --skill: #df86f5;
    --st-orig: #8b8cff;
    --st-ai: #3dd6b5;
    --st-other: #ffb35c;
    --st-founder: #ff7ab6;
    --st-unemployed: #4a4d68;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  word-break: keep-all;
}
button, input { font: inherit; color: inherit; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

.topbar {
  max-width: 720px; margin: 0 auto; padding: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand { font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 0; }
.link:hover { color: var(--accent); }

.screen { display: none; }
.screen.active { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { padding: 24px 0 20px; }
.hero.compact { padding-top: 8px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-weight: 700; font-size: 14px; }
h1 { margin: 0; font-size: clamp(26px, 6vw, 38px); line-height: 1.3; letter-spacing: -0.03em; }
h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.02em; }
h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.02em; }
.lead { color: var(--muted); margin: 12px 0 0; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; text-align: center; margin: 10px 0 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow);
}

/* 시작 폼 */
.field { display: block; margin-bottom: 22px; }
.field > span { display: block; font-weight: 700; margin-bottom: 8px; }
.field b { color: var(--accent); }
input:not([type]) {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.nav { display: flex; gap: 16px; }
.cat-label { margin: 14px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.cat-label:first-child { margin-top: 0; }
.job-hint { margin-top: 14px; padding: 14px 16px; background: var(--soft); border-radius: 12px; font-size: 14px; }
.job-hint:empty { display: none; }
.job-hint p { margin: 8px 0 0; }
.job-hint.flat { margin: 0 0 10px; }
.meters { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); font-size: 13px; }
.meters b { color: var(--accent); letter-spacing: 1px; font-weight: 400; }
.prose h2 { margin-top: 18px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--ink); font-size: 15px; }
.prose ul { padding-left: 20px; }
.refs li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.table-wrap { overflow-x: auto; }
.job-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.job-table th, .job-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.job-table th:first-child, .job-table td:first-child { text-align: left; }
.job-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.foot .link { font-size: 12px; text-decoration: underline; }
.job-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.job {
  display: inline-flex; align-items: center; gap: 5px; font-size: 14px;
  padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); cursor: pointer;
}
.job span { font-size: 15px; }
.job.on { border-color: var(--accent); background: var(--soft); font-weight: 700; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 16px;
  cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; font-weight: 800; }
.btn.small { padding: 6px 12px; font-size: 14px; }

/* 플레이 */
.play-head .when { display: flex; align-items: baseline; gap: 10px; }
.year { font-size: 40px; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.job-now { font-weight: 700; margin: 2px 0 14px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; background: var(--soft); color: var(--accent); }
.badge.unemployed { color: var(--muted); }
.badge.founder { color: var(--st-founder); }
.ai-meter { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.6s ease; }
.ai-meter .bar i { background: linear-gradient(90deg, var(--accent), var(--skill)); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.stat-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.stat-top b { font-variant-numeric: tabular-nums; }
.bar i.income { background: var(--income); }
.bar i.security { background: var(--security); }
.bar i.satisfaction { background: var(--satisfaction); }
.bar i.skill { background: var(--skill); }

.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
.ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; }
.seg { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 12px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }

.log { list-style: none; padding: 8px 20px; max-height: 360px; overflow-y: auto; }
.log li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; animation: fade 0.3s ease; }
.log li:last-child { border-bottom: 0; }
.log .y { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 13px; padding-top: 2px; }
.log li.news { color: var(--muted); }
.log li.choice { font-weight: 600; }

/* 사건 모달 */
.modal {
  position: fixed; inset: 0; background: rgba(10, 10, 25, 0.5); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10; backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); border-radius: 20px; padding: 24px; max-width: 460px; width: 100%;
  border: 1px solid var(--line); animation: pop 0.25s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.modal-card p:not(.eyebrow) { color: var(--muted); margin: 0 0 18px; }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; padding: 14px 16px; }
.share-text {
  width: 100%; padding: 12px; margin-bottom: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 14px;
}
#shareClose, #cardClose, #requestClose { justify-self: center; }
.card-img { display: block; width: 100%; border-radius: 12px; margin-bottom: 12px; }
#cardModal .modal-card { max-height: 92vh; overflow-y: auto; }
#cardExternal { text-align: center; text-decoration: none; color: var(--ink); }
.request-link { margin-top: 10px; font-size: 14px; }
.friend-banner { margin: 0 0 14px; padding: 14px 16px; border-radius: 14px; background: var(--soft); border: 1px solid var(--accent); font-size: 15px; }
.friend-banner b { color: var(--accent); }

/* 결과 */
.result-hero { padding: 28px 22px; background: linear-gradient(135deg, var(--soft), var(--card)); }
.result-hero h1 { font-size: clamp(24px, 5.5vw, 32px); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { margin: 0; padding: 14px; text-align: center; }
.kpi span { display: block; font-size: 13px; color: var(--muted); }
.kpi b { display: block; font-size: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.compare { font-size: 20px; margin: 4px 0 4px; }
.compare b { color: var(--accent); font-size: 30px; }
canvas.chart { width: 100%; display: block; margin-top: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lifemap { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; margin: 6px 0 4px; }
.lifemap span { aspect-ratio: 1; border-radius: 5px; }
.st-orig { background: var(--st-orig); }
.st-ai { background: var(--st-ai); }
.st-other { background: var(--st-other); }
.st-founder { background: var(--st-founder); }
.st-unemployed { background: var(--st-unemployed); }
.moments { margin: 0; padding-left: 0; list-style: none; }
.moments li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.moments li:last-child { border-bottom: 0; }
.moments .y { color: var(--muted); font-size: 13px; margin-right: 8px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }

/* 랭킹 */
.ranking { padding: 8px 12px; }
.rank-row {
  display: grid; grid-template-columns: 28px 1fr 90px 48px; gap: 10px; align-items: center; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 6px; cursor: pointer; text-align: left;
}
.rank-row:last-child { border-bottom: 0; }
.rank-row:hover { background: var(--soft); border-radius: 10px; }
.rank-row .rk { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row .nm small { display: block; color: var(--muted); font-size: 12px; }
.rank-row b { text-align: right; font-variant-numeric: tabular-nums; }
.pad { padding: 16px 8px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 20;
}
.toast[hidden] { display: none; }
.foot { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .rank-row { grid-template-columns: 24px 1fr 60px 44px; }
}
