:root {
  --bg: #eef4ff;
  --bg2: #e3ecff;
  --card: #fff;
  --ink: #1e2a44;
  --ink-soft: #6a7796;
  --line: #d7e0f2;
  --me: #3d7bfd;
  --me-ink: #fff;
  --good: #16a34a;
  --bad: #e0413c;
  --warm: #ffb020;
  --shadow: 0 6px 0 rgba(30,50,90,.06), 0 12px 24px rgba(40,70,140,.10);
  --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--ink);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 17px; line-height: 1.5; -webkit-text-size-adjust: 100%;
}
#app { max-width: 560px; margin: 0 auto; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; }
.screen { padding: 18px 16px 28px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#home, #result { overflow-y: auto; }
#play { overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; font-weight: 700; cursor: pointer; border: 0; color: inherit; }

/* ── 시작 화면 ───────────────────────────────────────────────────── */
.hero { text-align: center; margin: 6px 0 14px; }
.hero h1 { font-size: 2.3rem; margin: 0; letter-spacing: -1px; line-height: 1.1; }
.hero-who { display: block; font-size: 1.1rem; letter-spacing: -.5px; color: var(--ink-soft); }
.hero-emoji { display: inline-block; margin-right: 6px; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-7px) rotate(4deg); } }
.hero-sub { color: var(--ink-soft); font-size: .95rem; margin: 6px 0 0; }

.streak-row { display: flex; gap: 8px; margin: 4px 0 16px; }
.pill { flex: 1; background: var(--card); border-radius: 16px; padding: 10px 4px; text-align: center;
  box-shadow: var(--shadow); }
.pill b { display: block; font-size: 1.3rem; color: var(--me); }
.pill span { font-size: .68rem; color: var(--ink-soft); font-weight: 700; }

.section-title { font-size: .84rem; color: var(--ink-soft); margin: 14px 2px 8px; font-weight: 800; }
.modes, .levels { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.modes { grid-template-columns: 1fr; }
.levels { grid-template-columns: repeat(5, 1fr); }
.mode-btn, .level-btn { width: 100%; background: var(--card); border-radius: 16px; text-align: left;
  box-shadow: var(--shadow); border: 3px solid transparent; }
.mode-btn { padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.mode-btn .icon { font-size: 1.7rem; }
.mode-btn b { display: block; font-size: 1rem; }
.mode-btn span { font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.level-btn { padding: 10px 2px; text-align: center; }
.level-btn b { display: block; font-size: 1.15rem; }
.level-btn span { font-size: .6rem; color: var(--ink-soft); font-weight: 700; }
.mode-btn.on, .level-btn.on { border-color: var(--me); background: #f2f6ff; }

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.home-actions > .big-btn { grid-column: 1 / -1; }
.big-btn { background: var(--me); color: var(--me-ink); border-radius: 18px; padding: 16px 14px;
  font-size: 1.15rem; box-shadow: 0 5px 0 #2b5fd0; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #2b5fd0; }
.ghost-btn { background: var(--card); border-radius: 18px; padding: 14px 10px; font-size: .95rem;
  box-shadow: 0 3px 0 var(--line); }
.ghost-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.tiny { font-size: .74rem; color: var(--ink-soft); text-align: center; margin-top: 14px; line-height: 1.6; }

/* ── 문제 화면 ───────────────────────────────────────────────────── */
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--card); font-size: 1.2rem;
  box-shadow: var(--shadow); }
.progress { flex: 1; height: 12px; background: var(--card); border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(30,50,90,.08); }
#progressBar { height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #7bd389, #3d7bfd); transition: width .3s ease; }
.bar-score { font-size: .82rem; color: var(--ink-soft); font-weight: 800; }
.bar-score b { font-size: 1.15rem; color: var(--me); }

.boss-banner { background: #2b1b4d; color: #fff; border-radius: 16px; padding: 10px 14px;
  text-align: center; font-size: .88rem; margin-bottom: 10px; animation: bossin .4s ease-out both; }
@keyframes bossin { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.stage { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.q-card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow);
  animation: pop .22s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.q-label { font-size: .7rem; font-weight: 800; color: var(--me); margin-bottom: 6px; }
.q-ask { font-size: 1.35rem; font-weight: 800; line-height: 1.45; }
.q-ask .gap { display: inline-block; min-width: 76px; border-bottom: 4px solid var(--warm);
  margin: 0 4px; vertical-align: -2px; }
.q-hint { font-size: .85rem; color: var(--ink-soft); margin-top: 8px; }

.choices { display: grid; gap: 8px; }
.choice { background: var(--card); border-radius: 16px; padding: 15px 14px; text-align: left;
  box-shadow: var(--shadow); border: 3px solid transparent; font-size: 1.05rem; }
.choice:active { transform: translateY(2px); }
.choice.right { border-color: var(--good); background: #eafaf0; }
.choice.wrong { border-color: var(--bad); background: #fdeceb; }
.choice.dim { opacity: .45; }

/* 조합 — 동사 카드 × 방향 카드 */
.combo { display: grid; gap: 10px; }
.combo-slots { display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.slot { min-width: 108px; min-height: 52px; border-radius: 14px; border: 3px dashed var(--line);
  display: grid; place-items: center; font-size: 1.1rem; font-weight: 800; color: var(--ink-soft); }
.slot.filled { border-style: solid; border-color: var(--me); color: var(--ink); background: #f2f6ff; }
.slot-plus { font-size: 1.3rem; color: var(--ink-soft); font-weight: 900; }
.card-row { display: flex; flex-wrap: wrap; gap: 7px; }
.card-row .row-label { width: 100%; font-size: .7rem; font-weight: 800; color: var(--ink-soft); }
.wcard { background: var(--card); border-radius: 13px; padding: 10px 13px; box-shadow: var(--shadow);
  font-size: 1rem; border: 3px solid transparent; }
.wcard.on { border-color: var(--me); background: #f2f6ff; }
.wcard .ico { margin-right: 4px; }
.wcard:active { transform: translateY(2px); }

/* ── 채점 ────────────────────────────────────────────────────────── */
.verdict { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 16px 16px 22px;
  border-radius: 24px 24px 0 0; box-shadow: 0 -10px 30px rgba(30,50,90,.18);
  animation: slideup .25s cubic-bezier(.2,1.4,.4,1) both; max-width: 560px; margin: 0 auto; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.verdict.ok { background: #eafaf0; }
.verdict.no { background: #fdeceb; }
.v-head { font-size: 1.2rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.verdict.ok .v-head { color: var(--good); }
.verdict.no .v-head { color: var(--bad); }
.v-body { font-size: .95rem; margin-top: 8px; line-height: 1.55; }
.v-ex { margin-top: 10px; padding: 10px 12px; background: rgba(255,255,255,.75); border-radius: 12px;
  font-size: .92rem; }
.v-ex i { display: block; font-style: normal; color: var(--ink-soft); font-size: .82rem; margin-top: 3px; }
.v-family { margin-top: 10px; font-size: .82rem; color: var(--ink-soft); }
.v-family b { color: var(--ink); }
.v-sibs { margin-top: 10px; display: grid; gap: 6px; }
.v-sib { font-size: .86rem; background: rgba(255,255,255,.75); border-radius: 10px; padding: 8px 10px; }
.v-sib b { color: var(--me); }
.v-next { width: 100%; margin-top: 14px; }

/* ── 결과 ────────────────────────────────────────────────────────── */
.result-card { background: var(--card); border-radius: 26px; padding: 22px 18px; box-shadow: var(--shadow);
  text-align: center; }
.result-emoji { font-size: 4rem; }
.result-card h2 { margin: 6px 0 4px; font-size: 1.7rem; }
.result-why { color: var(--ink-soft); margin: 0 0 14px; font-size: .92rem; }
.result-nums { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.result-nums div { flex: 1; background: #f2f6ff; border-radius: 16px; padding: 10px 4px; }
.result-nums b { display: block; font-size: 1.35rem; color: var(--me); }
.result-nums span { font-size: .68rem; color: var(--ink-soft); font-weight: 700; }
.learned { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; max-height: 240px; overflow-y: auto; }
.learned li { border-bottom: 1px dashed var(--line); padding: 8px 4px; }
.learned b { font-size: 1rem; }
.learned span { display: block; font-size: .8rem; color: var(--ink-soft); }
.learned .miss { color: var(--bad); font-size: .62rem; font-weight: 800; }
.result-actions { display: grid; gap: 8px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -24px; width: 10px; height: 16px; border-radius: 2px;
  animation: fall linear forwards; }
@keyframes fall { 0% { transform: translateY(-10vh) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .9; } }

/* ── 대화상자 ────────────────────────────────────────────────────── */
dialog { border: 0; border-radius: 22px; padding: 22px; max-width: 480px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(20,40,80,.3); background: var(--card); color: var(--ink);
  max-height: 84dvh; }
dialog::backdrop { background: rgba(20,35,70,.45); }
.rules { padding-left: 20px; margin: 0 0 12px; }
.rules li { margin-bottom: 10px; font-size: .92rem; }
.rules i { font-style: normal; color: var(--me); font-weight: 700; }
.part-list { display: grid; gap: 10px; margin: 12px 0; }
.part-group b { font-size: 1.1rem; color: var(--me); }
.part-sense { display: flex; gap: 8px; align-items: baseline; font-size: .86rem; padding: 4px 0 4px 8px; }
.part-sense .ico { font-size: 1.1rem; }
.part-sense em { font-style: normal; font-weight: 800; }
.part-sense span { color: var(--ink-soft); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  background: #1e2a44; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .88rem;
  font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

@media (min-width: 520px) { body { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}
