:root {
  --hanji: #EAD7AE;
  --paper: #F6EBD2;
  --ink: #1F2333;
  --juhong: #C8402A;
  --navy: #2B3A67;
  --ok: #2E6B3F;
  --body: 'Noto Sans KR', system-ui, sans-serif;
  --title: 'Song Myung', serif;
  --brush: 'Nanum Brush Script', cursive;
  --rough: 'East Sea Dokdo', cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--hanji) url('/img/hanji_bg.webp') repeat;
  background-size: 512px;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
.app { max-width: 440px; margin: 0 auto; padding: 16px 18px 40px; position: relative; min-height: 100dvh; }
.screen { display: none; flex-direction: column; align-items: center; text-align: center; }
.screen.active { display: flex; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
[hidden] { display: none !important; }

.sound-toggle { position: absolute; top: 12px; right: 12px; z-index: 5; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--paper); font-size: 20px; cursor: pointer; }

/* 버튼 — B급 두꺼운 외곽선 + 먹 그림자 */
.btn { font-family: var(--body); font-weight: 700; font-size: 18px; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 14px; padding: 14px 18px; min-height: 52px; width: 100%;
  box-shadow: 4px 4px 0 var(--ink); cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary { background: var(--juhong); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-style: dashed; }
.link { background: none; border: 0; color: var(--navy); text-decoration: underline; font-size: 15px; padding: 8px; cursor: pointer; font-family: var(--body); }

/* 표지 */
.banner { margin: 28px 0 0; font-family: var(--brush); font-size: 30px; color: var(--juhong); letter-spacing: 2px; }
.title { font-family: var(--title); font-weight: 400; font-size: 40px; line-height: 1.15; margin: 4px 0 8px; }
.title span { font-size: 50px; display: inline-block; border-bottom: 6px double var(--juhong); }
.cover-king { width: 72%; max-width: 300px; height: auto; margin: 4px 0 10px; }
.lead { font-size: 17px; line-height: 1.6; margin: 0 0 18px; }
.count { font-size: 15px; color: var(--navy); margin: 14px 0 0; min-height: 1.4em; }
.foot { font-size: 13px; color: var(--navy); opacity: .8; margin-top: 18px; }

/* 풀이 */
.quiz-head { width: 100%; display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 8px; padding-right: 52px; }
.qno { font-family: var(--brush); font-size: 34px; }
.qtype { font-size: 14px; font-weight: 700; color: #fff; background: var(--navy); padding: 4px 10px; border-radius: 999px; }
.ticks { width: 100%; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-bottom: 14px; }
.ticks i { height: 8px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); }
.ticks i.ok { background: var(--ok); } .ticks i.ng { background: var(--juhong); } .ticks i.now { background: var(--ink); }
.paper { width: 100%; background: var(--paper); border: 3px solid var(--ink); border-radius: 6px; padding: 20px 16px;
  box-shadow: 0 0 0 6px var(--paper), 0 0 0 9px var(--juhong); margin: 8px 0 22px; }
.prompt { font-size: 20px; font-weight: 700; line-height: 1.5; margin: 0; word-break: keep-all; }
.listen { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 14px; }
.ai-voice { font-size: 12px; color: var(--navy); opacity: .75; }
.btn-listen { width: auto; padding: 10px 26px; background: var(--navy); color: #fff; }
.dictation { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.dictation input { font: 700 20px var(--body); padding: 14px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; width: 100%; }
.dictation input:disabled { background: var(--paper); }
.dict-rule { font-size: 13px; color: var(--navy); }
.fb-answer { font-size: 16px; margin: 0 0 12px; } .fb-answer b { color: var(--ok); }
.ticks i.half { background: #E0A43A; }
.choices { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.choice { font-size: 18px; font-weight: 700; text-align: left; position: relative; padding-left: 52px; word-break: keep-all; }
.choice::before { content: attr(data-n); position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--brush); font-size: 26px; color: var(--juhong); }
.choice.correct { background: #DCEBD9; border-color: var(--ok); box-shadow: 4px 4px 0 var(--ok); }
.choice.wrong { background: #F4D3CB; border-color: var(--juhong); box-shadow: 4px 4px 0 var(--juhong); text-decoration: line-through; }
.choice.correct::after { content: '정답'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--ok); }
.choice:disabled { cursor: default; color: var(--ink); opacity: 1; }
.feedback { width: 100%; margin-top: 16px; }
.fb-line { font-family: var(--rough); font-size: 34px; margin: 0 0 12px; line-height: 1.1; }
.fb-line.ok { color: var(--ok); } .fb-line.ng { color: var(--juhong); }
.btn-next { background: var(--ink); color: var(--paper); }

/* 채점 연출 */
#reveal { min-height: 80dvh; justify-content: center; }
.scroll { background: var(--paper); border: 4px solid var(--ink); border-left-width: 14px; border-right-width: 14px; border-radius: 6px;
  padding: 40px 24px; width: 90%; animation: unroll 1.4s ease forwards; transform-origin: center; }
.scroll p { font-family: var(--title); font-size: 52px; margin: 0; color: var(--juhong); }
.scroll small { font-size: 15px; }
@keyframes unroll { from { transform: scaleX(.05); } to { transform: scaleX(1); } }

/* 판정 */
.result-card { width: 100%; background: var(--hanji); border: 3px solid var(--ink); padding: 18px 14px 20px; margin-top: 46px;
  box-shadow: 0 0 0 6px var(--hanji), 0 0 0 10px var(--juhong); position: relative; }
.rc-top { font-family: var(--title); font-size: 18px; margin: 0 0 6px; }
.seal { display: inline-block; font-family: var(--brush); font-size: 50px; color: var(--juhong); border: 5px solid var(--juhong);
  border-radius: 10px; padding: 0 16px; transform: rotate(-6deg); margin: 6px 0; line-height: 1.2; }
.score { font-size: 22px; margin: 6px 0 0; } .score b { font-family: var(--title); font-size: 64px; font-weight: 400; }
.rank { font-size: 18px; font-weight: 900; color: var(--navy); margin: 2px 0 6px; min-height: 1.4em; }
.result-king { width: 70%; max-width: 280px; height: auto; }
.speech { font-family: var(--rough); font-size: 34px; line-height: 1.15; margin: 8px 6px 0; word-break: keep-all; }
.speech::before { content: '“'; } .speech::after { content: '”'; }
.result-rage .speech { color: var(--juhong); animation: shake .4s 2; }
@keyframes shake { 25% { transform: translateX(-4px) rotate(-1deg); } 75% { transform: translateX(4px) rotate(1deg); } }
.actions { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* 오답노트 */
.review-title { font-family: var(--title); font-weight: 400; font-size: 40px; margin: 40px 0 10px; }
.review-list { list-style: none; padding: 0; margin: 0; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 14px; }
.review-list li { background: var(--paper); border: 3px solid var(--ink); border-left-width: 10px; border-radius: 8px; padding: 14px; }
.review-list li.ng { border-left-color: var(--juhong); } .review-list li.half { border-left-color: #E0A43A; } .review-list li.ok { border-left-color: var(--ok); }
.rv-head { font-size: 13px; font-weight: 700; color: var(--navy); margin: 0 0 4px; }
.rv-q { font-weight: 700; margin: 0 0 8px; word-break: keep-all; }
.rv-a { margin: 2px 0; font-size: 15px; } .rv-a.my { color: var(--juhong); } .rv-a.ans { color: var(--ok); font-weight: 700; }
.rv-ex { font-size: 14px; margin: 8px 0 0; line-height: 1.5; } .rv-ref { font-size: 12px; color: var(--navy); margin: 4px 0 0; }

/* 모달·토스트 */
.modal { position: fixed; inset: 0; background: rgba(31, 35, 51, .8); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-body { background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 14px; max-width: 420px; width: 100%;
  display: flex; flex-direction: column; gap: 10px; max-height: 94dvh; overflow: auto; }
.modal-body img { width: 100%; height: auto; border: 2px solid var(--ink); }
.hint { margin: 0; text-align: center; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: 999px; font-size: 15px; z-index: 30; max-width: 90%; }
@media (min-width: 700px) { .app { padding-top: 32px; } }
