/* 아기자기한 글꼴: 카페24 써라운드 (제목·버튼) + 써라운드 에어 (본문) — 무료 상업용 폰트 */
@font-face { font-family: "Cafe24Ssurround"; src: url("https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/Cafe24Ssurround.woff") format("woff"); font-weight: normal; font-style: normal; font-display: swap; ascent-override: 84%; descent-override: 28%; line-gap-override: 0%; unicode-range: U+0000-00D6, U+00D8-2013, U+2015-218F, U+2200-259F, U+2600-3007, U+3012-FFFF; }
@font-face { font-family: "Cafe24SsurroundAir"; src: url("https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/Cafe24SsurroundAir.woff") format("woff"); font-weight: normal; font-style: normal; font-display: swap; ascent-override: 84%; descent-override: 28%; line-gap-override: 0%; }

:root {
  --sea: #0b6fc2;
  --sea-dark: #08467d;
  --sea-deep: #062f57;
  --sky: #e8f6ff;
  --sun: #ffc531;
  --sun-dark: #e08a00;
  --coral: #ff6b5b;
  --wood: #8a5a2b;
  --wood-dark: #5e3b17;
  --paper: #fffaf0;
  --ink: #23303d;
  --muted: #6b7a89;
  --ok: #22a05a;
  --bad: #e2463b;
  --card: rgba(255,255,255,.94);
  --shadow: 0 10px 30px rgba(6,47,87,.25);
  --fs: 22px;             /* 고학년 기본 글자 */
  --fs-q: 30px;           /* 문제 글자 */
  --head: "Cafe24Ssurround", "Jua", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --body: "Cafe24SsurroundAir", "Gowun Dodum", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
body.low { --fs: 26px; --fs-q: 38px; }
:root { --vh: 100vh; }
@supports (height: 100dvh) { :root { --vh: 100dvh; } }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--sea);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--fs);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: var(--head); cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
button:disabled { cursor: default; }
img { display: block; }
.hidden { display: none !important; }

/* 배경 */
#bg {
  position: fixed; inset: 0; z-index: -2;
  background: var(--sea) center / cover no-repeat;
}
#bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,47,87,.05), rgba(6,47,87,.35));
}
body.on-main #bg::after { background: linear-gradient(180deg, rgba(6,47,87,0) 40%, rgba(6,47,87,.55)); }

#app { min-height: var(--vh); padding: 16px 16px 24px; max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; }

/* ---------- 버튼 ---------- */
.btn {
  border: 0; border-radius: 18px;
  padding: 14px 28px; min-height: 64px;
  font-size: calc(var(--fs) + 2px); color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.22);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.22); }

.btn:disabled { opacity: .45; }
.btn.small { min-height: 46px; padding: 8px 16px; font-size: 18px; border-radius: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.btn.blue { background: linear-gradient(#3aa0f0, #1665c1); }
.btn.orange { background: linear-gradient(#ffb43b, #f07d00); }
.btn.brown { background: linear-gradient(#a8743f, var(--wood-dark)); }
.btn.ghost { background: var(--card); color: var(--sea-dark); }
.btn.big { min-height: 76px; padding: 16px 40px; font-size: calc(var(--fs) + 6px); border-radius: 22px; }
.btn.pulse { animation: btnPulse 1.4s ease-in-out infinite; }
@keyframes btnPulse { 50% { transform: scale(1.05); filter: brightness(1.1); } }

.bottom { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 18px; }

/* ---------- 머리줄 ---------- */
.bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding-right: 80px; flex-wrap: wrap; }
.bar h1 {
  font-family: var(--head); font-weight: 400; margin: 0;
  font-size: clamp(26px, 3.6vw, 40px); color: #fff;
  text-shadow: 0 3px 0 var(--sea-dark), 0 0 14px rgba(0,0,0,.35);
  flex: 1; min-width: 0;
}
.h-num { display: inline-block; background: var(--sun); color: var(--wood-dark); text-shadow: none; border-radius: 12px; padding: 0 12px; margin-right: 6px; font-size: .8em; vertical-align: 3px; box-shadow: 0 3px 0 var(--sun-dark); }
.steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 4px; background: rgba(255,255,255,.25); border-radius: 999px; }
.steps li { font-family: var(--head); font-size: 17px; padding: 6px 14px; border-radius: 999px; color: rgba(255,255,255,.85); }
.steps li.on { background: #fff; color: var(--sea-dark); box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.steps li.done { color: #fff; }
.steps li.done::after { content: " ✔"; color: #b9ffcf; }

/* ---------- 🎵 노래 버튼 ---------- */
.bgm-btn {
  position: fixed; top: 14px; right: 14px; z-index: 50;
  width: 64px; height: 64px; border-radius: 50%;
  border: 4px solid #fff;
  background: radial-gradient(circle at 35% 30%, #ffe27a, var(--sun-dark));
  box-shadow: 0 5px 0 rgba(0,0,0,.25), 0 0 0 0 rgba(255,197,49,.6);
  font-size: 30px; line-height: 1; padding: 0;
}
.bgm-btn .note { display: inline-block; }
.bgm-btn.playing .note { animation: bounce .6s ease-in-out infinite alternate; }
.bgm-btn.playing { animation: pulse 1.6s infinite; }
.bgm-btn.off { background: radial-gradient(circle at 35% 30%, #eee, #9aa3ad); }
.bgm-btn.off::after {
  content: ""; position: absolute; left: 10px; right: 10px; top: 50%;
  height: 5px; background: #e2463b; border-radius: 3px; transform: rotate(-40deg);
}
@keyframes bounce { from { transform: translateY(2px) rotate(-8deg); } to { transform: translateY(-4px) rotate(8deg); } }
@keyframes pulse { 0% { box-shadow: 0 5px 0 rgba(0,0,0,.25), 0 0 0 0 rgba(255,197,49,.7); } 100% { box-shadow: 0 5px 0 rgba(0,0,0,.25), 0 0 0 18px rgba(255,197,49,0); } }

/* ---------- 메인 ---------- */
.is-main { justify-content: space-between; }
.main { position: relative; display: flex; flex-direction: column; align-items: center; flex: 1; justify-content: space-between; gap: 18px; padding: 2vh 0 1vh; }
.title { text-align: center; animation: drop .7s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes drop { from { transform: translateY(-60px) scale(.8); opacity: 0; } }
.logo-text { font-family: var(--head); font-weight: 400; margin: 0; font-size: clamp(64px, 11vw, 140px); line-height: 1; letter-spacing: 2px; }
.logo-text span {
  display: inline-block;
  text-shadow: 5px 0px 0 var(--sea-deep), -5px 0px 0 var(--sea-deep), 0px 5px 0 var(--sea-deep), 0px -5px 0 var(--sea-deep), 4px 4px 0 var(--sea-deep), -4px 4px 0 var(--sea-deep), 4px -4px 0 var(--sea-deep), -4px -4px 0 var(--sea-deep), 2px 5px 0 var(--sea-deep), -2px 5px 0 var(--sea-deep), 5px 2px 0 var(--sea-deep), -5px 2px 0 var(--sea-deep), 2px -5px 0 var(--sea-deep), -2px -5px 0 var(--sea-deep), 5px -2px 0 var(--sea-deep), -5px -2px 0 var(--sea-deep), 0 11px 0 var(--sea-deep), 0 16px 22px rgba(0,0,0,.35);
}
.logo-text .t1 { color: #ffcc2e; transform: rotate(-3deg); }
.logo-text .t2 { color: #84dcff; transform: rotate(2deg); }
.ribbon {
  display: inline-block; margin: 14px 0 0; padding: 8px 30px;
  font-family: var(--head); font-size: clamp(22px, 2.6vw, 32px); color: var(--wood-dark);
  background: linear-gradient(#fff8e1, #f3dfb4); border: 4px solid var(--wood); border-radius: 14px;
  box-shadow: 0 6px 0 rgba(0,0,0,.2); transform: rotate(-1deg);
}
.ribbon b { color: #d63b2f; font-weight: 400; }

.mascot { display: flex; align-items: center; gap: 14px; animation: rise2 .6s .3s both; }
@keyframes rise2 { from { transform: translateY(30px); opacity: 0; } }
.mascot img { width: 96px; height: 96px; border-radius: 50%; border: 5px solid #fff; box-shadow: var(--shadow); object-fit: cover; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(-6deg) translateY(-4px); } }
.m-bubble { position: relative; margin: 0; background: #fff; border-radius: 20px; padding: 12px 20px; font-size: 21px; line-height: 1.45; box-shadow: var(--shadow); }
.m-bubble::before { content: ""; position: absolute; left: -12px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }

.entry { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; animation: rise2 .6s .45s both; }
.entry-btn {
  position: relative; width: 320px; min-height: 160px; border-radius: 30px;
  border: 5px solid #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; box-shadow: 0 10px 0 rgba(0,0,0,.25), var(--shadow);
  transition: transform .12s;
}

.entry-btn:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.entry-btn .e-ic { font-size: 40px; line-height: 1; }
.entry-btn b { font-weight: 400; font-size: 44px; text-shadow: 0 3px 0 rgba(0,0,0,.22); }
.entry-btn small { font-size: 20px; background: rgba(255,255,255,.95); color: var(--wood-dark); padding: 4px 16px; border-radius: 999px; }
.entry-btn em { position: absolute; top: -14px; right: -10px; font-style: normal; font-family: var(--head); font-size: 18px; background: #fff; color: var(--sun-dark); padding: 4px 12px; border-radius: 999px; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.entry-btn.low { background: linear-gradient(#ffd25a, #f39a10); }
.entry-btn.high { background: linear-gradient(#5cb6ff, #1a62c6); }

.lock {
  position: fixed; right: 14px; bottom: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.5); font-size: 18px; opacity: .6;
}
.lock:hover { opacity: 1; }

/* ---------- 챕터 지도 ---------- */
.rank-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--card); border-radius: 24px; padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.rank-ic { font-size: 46px; width: 70px; height: 70px; display: grid; place-items: center; background: linear-gradient(#fff3c4, #ffd75e); border-radius: 50%; border: 4px solid #fff; box-shadow: 0 4px 0 var(--sun-dark); }
.rank-info { flex: 1; min-width: 200px; }
.rank-info b { font-family: var(--head); font-weight: 400; font-size: 26px; color: var(--sea-dark); }
.rank-bar { height: 16px; background: #e3edf6; border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd34d, #ff9d1c); border-radius: 999px; transition: width .8s; position: relative; }
.rank-bar i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); animation: shine 2s infinite; }
@keyframes shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.rank-info small { font-size: 16px; color: var(--muted); }

.map-board {
  position: relative; width: min(100%, calc((var(--vh) - 232px) * 16 / 9)); aspect-ratio: 16 / 9;
  margin: 0 auto; border-radius: 28px; border: 6px solid #fff; box-shadow: var(--shadow);
  background: url(assets/img/bg/map.jpg) center / cover;
}
.route { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.route line { stroke: rgba(255,255,255,.85); stroke-width: 5; stroke-dasharray: 2 12; stroke-linecap: round; }
.route line.done { stroke: #ffd34d; stroke-dasharray: none; stroke-width: 7; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }

.node {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 0; color: var(--ink);
  transition: transform .15s;
}

.node:active { transform: translate(-50%, -48%) scale(.97); }
.map-board { container-type: size; }
.n-pic { width: clamp(52px, 15cqh, 118px); aspect-ratio: 1; border-radius: 50%; background: center / cover; border: 5px solid #fff; box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 8px 18px rgba(0,0,0,.25); }
.node.done .n-pic { border-color: #ffd34d; }
.node.perfect .n-pic { box-shadow: 0 0 0 5px rgba(255,211,77,.6), 0 6px 0 rgba(0,0,0,.25), 0 0 24px #ffd34d; }
.node.next .n-pic { animation: nodePulse 1.3s ease-in-out infinite; }
@keyframes nodePulse { 0%,100% { box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 0 0 0 rgba(255,255,255,.9); } 50% { box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 0 0 14px rgba(255,255,255,0); } }
.n-num { position: absolute; top: -4px; left: -4px; width: clamp(26px, 6cqh, 38px); height: clamp(26px, 6cqh, 38px); font-size: clamp(14px, 3.4cqh, 20px) !important; border-radius: 50%; background: var(--sea-dark); color: #fff; border: 3px solid #fff; display: grid; place-items: center; font-size: 20px; }
.node.done .n-num { background: var(--ok); }
.n-flag { position: absolute; top: -26px; right: -18px; background: var(--coral); color: #fff; font-size: 16px; padding: 2px 10px; border-radius: 10px; border: 3px solid #fff; animation: bounce .5s ease-in-out infinite alternate; }
.n-label { font-family: var(--head); font-size: clamp(12px, 3.2cqh, 20px); background: #fff; padding: 3px 12px; border-radius: 999px; box-shadow: 0 3px 0 rgba(0,0,0,.18); white-space: nowrap; margin-top: 4px; }
.node .stars { font-size: clamp(10px, 2.4cqh, 15px); line-height: 1; background: rgba(6,47,87,.55); padding: 2px 8px; border-radius: 999px; }
.stars { letter-spacing: 2px; white-space: nowrap; }
.star { color: #cfd6dd; font-size: 1.4em; text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.star.on { color: var(--sun); text-shadow: 0 1px 0 var(--sun-dark); }

/* ---------- 이야기 ---------- */
.story { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.story-pic { position: relative; width: min(860px, 100%, calc((var(--vh) - 380px) * 2)); min-width: min(100%, 480px); }
.story-pic img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 26px; border: 6px solid #fff; box-shadow: var(--shadow); animation: kenburns 12s ease-in-out infinite alternate; }
@keyframes kenburns { to { transform: scale(1.015); } }
.story-pic .dots { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(6,47,87,.5); padding: 6px 10px; border-radius: 999px; }
.dots { display: flex; gap: 8px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.5); }
.dots i.on { background: #fff; transform: scale(1.3); }
.dots i.seen { background: rgba(255,255,255,.85); }
.talk { display: flex; align-items: flex-start; gap: 14px; width: min(860px, 100%); margin-top: -46px; position: relative; z-index: 2; }
.avatar { width: 108px; height: 108px; flex: none; border-radius: 50%; border: 5px solid #fff; object-fit: cover; box-shadow: var(--shadow); background: #fff; animation: pop .35s; }
.bubble {
  position: relative; flex: 1; margin-top: 46px;
  background: var(--paper); border: 4px solid #fff; border-radius: 24px;
  padding: 24px 26px; box-shadow: var(--shadow); min-height: 110px; cursor: pointer;
}
.who {
  position: absolute; top: -20px; left: 18px;
  background: var(--sea-dark); color: #fff; font-family: var(--head);
  padding: 4px 16px; border-radius: 999px; font-size: 20px; border: 3px solid #fff;
}
.say { margin: 0; font-size: calc(var(--fs) + 4px); line-height: 1.55; word-break: keep-all; }
.say.typing::after { content: "▍"; color: var(--sea); animation: blink .6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }


/* ---------- 퀴즈 ---------- */
.quiz { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qtop { display: flex; align-items: center; gap: 12px; width: min(960px, 100%); }
.qnum { font-family: var(--head); background: var(--card); color: var(--sea-dark); padding: 6px 16px; border-radius: 999px; white-space: nowrap; }
.qprog { flex: 1; display: flex; gap: 6px; }
.qprog i { flex: 1; height: 14px; border-radius: 999px; background: rgba(255,255,255,.45); transition: background .3s; }
.qprog i.cur { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.4); }
.qprog i.ok { background: #5ed68f; }
.qprog i.retry { background: #ffb43b; }
.qbox {
  position: relative; width: min(960px, 100%);
  background: var(--paper); border: 4px solid #fff; border-radius: 24px;
  padding: 28px 30px; box-shadow: var(--shadow); text-align: center; animation: pop .3s;
}
.q { margin: 0; font-family: var(--head); font-size: var(--fs-q); line-height: 1.4; word-break: keep-all; }
.lyric { margin: 0; font-family: var(--head); font-size: var(--fs-q); line-height: 1.5; word-break: keep-all; }
.cue { margin: 10px 0 0; color: var(--wood); }
.hole {
  display: inline-block; min-width: 3em; padding: 0 10px; margin: 0 4px;
  border-bottom: 5px solid var(--sun-dark); color: var(--sun-dark); background: #fff1c7; border-radius: 8px;
}
.hole.filled { color: var(--ok); border-color: var(--ok); background: #dcf6e6; animation: pop .35s; }
.src { margin: -4px 0 0; font-size: 18px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: min(960px, 100%); }
body.low .opts { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.opts.ox { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; }
.opt {
  min-height: 84px; padding: 14px 18px; border-radius: 20px;
  border: 4px solid #fff; background: linear-gradient(#ffffff, #e3f1ff);
  color: var(--sea-dark); font-size: calc(var(--fs) + 4px); line-height: 1.3; word-break: keep-all;
  box-shadow: 0 6px 0 rgba(8,70,125,.35); transition: transform .08s;
  animation: optIn .35s backwards;
}
.opt:nth-child(2) { animation-delay: .06s; } .opt:nth-child(3) { animation-delay: .12s; } .opt:nth-child(4) { animation-delay: .18s; } .opt:nth-child(5) { animation-delay: .24s; }
@keyframes optIn { from { transform: translateY(16px); opacity: 0; } }
.opts.ox .opt { font-size: 64px; min-height: 140px; }

.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(8,70,125,.35); }
.opt.right { background: linear-gradient(#5ed68f, var(--ok)); color: #fff; animation: pop .35s; }
.opt.wrong { background: linear-gradient(#ff8a7e, var(--bad)); color: #fff; animation: shake .4s; opacity: .8; }
.opt.gone { opacity: .2; filter: grayscale(1); }
.opt.used { opacity: .35; }
.opt.glow { animation: glow 0.5s 3; }
.opt:disabled:not(.right):not(.wrong):not(.gone):not(.used) { opacity: .6; }

.order-picked { list-style: none; counter-reset: n; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 0; padding: 0; min-height: 44px; }
.order-picked li { counter-increment: n; background: var(--sea); color: #fff; border-radius: 12px; padding: 6px 12px; font-size: 18px; animation: pop .25s; }
.order-picked li::before { content: counter(n) ". "; }

.feedback { min-height: 0; width: min(960px, 100%); text-align: center; font-size: calc(var(--fs) + 2px); }
.feedback:empty { display: none; }
.feedback b { display: block; font-family: var(--head); font-weight: 400; font-size: 1.3em; }
.feedback span { display: block; margin-top: 4px; }
.feedback.good, .feedback.bad { padding: 14px 18px; border-radius: 18px; border: 4px solid #fff; box-shadow: var(--shadow); animation: pop .3s; }
.feedback.good { background: #dcf6e6; color: #145c33; }
.feedback.bad { background: #ffe3e0; color: #9b1f16; font-family: var(--head); }

@keyframes pop { 0% { transform: scale(.85); } 70% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes glow { 50% { box-shadow: 0 0 0 8px var(--sun), 0 6px 0 rgba(8,70,125,.35); transform: scale(1.04); } }

/* ---------- 결과 ---------- */
.result {
  position: relative; margin: 10px auto 0; width: min(620px, 100%); text-align: center;
  background: var(--paper); border: 6px solid #fff; border-radius: 32px; padding: 0 24px 26px;
  box-shadow: var(--shadow); animation: pop .4s; overflow: hidden;
}
.r-pic { width: calc(100% + 48px); margin: 0 -24px 8px; aspect-ratio: 3.4 / 1; object-fit: cover; }
.result h1 { font-family: var(--head); font-weight: 400; font-size: 50px; margin: 0; color: var(--sea-dark); }
.big-stars { font-size: 76px; margin: 4px 0; }
.r-stars .star { display: inline-block; transform: scale(0); animation: starIn .5s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes starIn { 0% { transform: scale(0) rotate(-120deg); } 100% { transform: scale(1) rotate(0); } }
.new-best { display: inline-block; font-family: var(--head); color: #fff; background: var(--coral); padding: 4px 14px; border-radius: 999px; font-size: 20px; animation: comboPop .5s 1.4s backwards; }
.msg { font-family: var(--head); font-size: 28px; color: var(--wood-dark); margin: 10px 0; }
.badge-get { display: inline-block; background: var(--sun); color: var(--wood-dark); font-family: var(--head); padding: 10px 24px; border-radius: 999px; font-size: 26px; box-shadow: 0 4px 0 var(--sun-dark); animation: badgeSpin .8s 1.2s backwards; }
@keyframes badgeSpin { from { transform: rotateY(540deg) scale(.3); opacity: 0; } }
.rank-up {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 150;
  background: linear-gradient(#fff6cf, #ffd34d); border: 6px solid #fff; border-radius: 32px; padding: 26px 46px;
  text-align: center; box-shadow: 0 0 0 100vmax rgba(6,47,87,.55), var(--shadow); cursor: pointer;
  animation: rankIn .6s cubic-bezier(.2,1.5,.4,1) both;
}
.rank-up span { display: block; font-size: 90px; line-height: 1; }
.rank-up b { display: block; font-family: var(--head); font-weight: 400; font-size: 48px; color: var(--coral); text-shadow: 0 3px 0 #fff; }
.rank-up em { display: block; font-style: normal; font-family: var(--head); font-size: 32px; color: var(--wood-dark); }
@keyframes rankIn { from { transform: translate(-50%, -50%) scale(0) rotate(-20deg); } }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,30,60,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal-box { background: var(--paper); border: 5px solid #fff; border-radius: 26px; padding: 26px; width: min(380px, 100%); text-align: center; box-shadow: var(--shadow); }
.modal-box h2 { font-family: var(--head); font-weight: 400; margin: 0 0 4px; font-size: 32px; }
.modal-box p { margin: 6px 0; font-size: 20px; }
.modal-box input { width: 100%; font-size: 36px; text-align: center; letter-spacing: 12px; padding: 10px; border-radius: 14px; border: 3px solid var(--sea); font-family: var(--head); }
.modal-box .row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.pw-msg { color: var(--bad); min-height: 1.2em; font-family: var(--head); }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -160%);
  background: rgba(20,30,40,.92); color: #fff; padding: 12px 20px; border-radius: 14px; font-size: 18px;
  transition: transform .25s, opacity .25s; z-index: 120; opacity: 0; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- 답지 ---------- */
.tabs { display: flex; gap: 10px; margin-bottom: 12px; }
.tab { flex: 1; max-width: 220px; border: 4px solid #fff; border-radius: 16px; padding: 10px; font-size: 24px; background: rgba(255,255,255,.7); color: var(--sea-dark); }
.tab.on { background: var(--sun); color: var(--wood-dark); }
.k-tools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.print-title { display: none; }
.k-ch { background: var(--paper); border: 3px solid #fff; border-radius: 18px; margin-bottom: 10px; font-size: 18px; box-shadow: 0 4px 12px rgba(6,47,87,.15); }
.k-ch summary { font-family: var(--head); font-size: 24px; padding: 14px 18px; cursor: pointer; }
.k-ch summary small { font-family: var(--body); font-size: 16px; color: var(--wood); }
.k-list { margin: 0; padding: 0 18px 14px 50px; }
.k-list li { padding: 10px 0; border-top: 1px dashed #d8c7a3; }
.k-q { font-weight: 700; }
.tag { font-family: var(--head); font-weight: 400; font-size: 14px; background: var(--sea); color: #fff; border-radius: 6px; padding: 1px 7px; vertical-align: 2px; }
.k-opts { color: #6b5b45; font-size: 16px; margin-top: 2px; }
.k-a { color: var(--ok); font-family: var(--head); font-size: 22px; margin-top: 2px; }
.k-e { font-size: 16px; color: #4a3f33; }
.k-s { font-size: 15px; color: var(--wood); }
.reset-zone { text-align: center; margin-top: 18px; }
.link-btn { background: none; border: 0; color: #fff; text-decoration: underline; font-family: var(--body); font-size: 16px; opacity: .85; }

/* ---------- 그림 화살표 (글꼴과 상관없이 똑같이 보임) ---------- */
.ar { display: inline-block; width: 0; height: 0; border-top: .38em solid transparent; border-bottom: .38em solid transparent; vertical-align: -.02em; }
.ar.l { border-right: .55em solid currentColor; margin-right: .4em; }
.ar.r { border-left: .55em solid currentColor; margin-left: .4em; }
.ar.big { border-top-width: .5em; border-bottom-width: .5em; margin: 0; }
.ar.l.big { border-right-width: .75em; }
.ar.r.big { border-left-width: .75em; }

/* ---------- 처음 화면: 눌러서 시작 (브라우저가 자동 재생을 막을 때만) ---------- */
.tap-start { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.25), rgba(6,47,87,.75)), url(assets/img/bg/main.jpg) center / cover; transition: opacity .45s; }
.tap-start.bye { opacity: 0; pointer-events: none; }
.ts-in { text-align: center; color: #fff; }
.ts-logo { font-family: var(--head); font-size: clamp(56px, 10vw, 120px); line-height: 1.1; }
.ts-logo .t1 { color: #ffcc2e; } .ts-logo .t2 { color: #84dcff; }
.ts-logo span { text-shadow: 0 6px 0 var(--sea-deep), 0 0 24px rgba(0,0,0,.4); }
.ts-hand { font-size: 80px; margin-top: 16px; animation: tapHand 1s ease-in-out infinite; }
@keyframes tapHand { 50% { transform: translateY(-16px) scale(1.1); } }
.ts-in p { display: inline-block; background: rgba(6,47,87,.6); padding: 10px 28px; border-radius: 999px; border: 4px solid #fff; font-family: var(--head); font-size: clamp(26px, 3.6vw, 40px); margin: 8px 0 0; text-shadow: 0 3px 0 var(--sea-deep); animation: feverBlinkSoft 1s ease-in-out infinite alternate; }
@keyframes feverBlinkSoft { to { opacity: .6; } }

/* ---------- 🏆 피날레 ---------- */
.finale { position: fixed; inset: 0; z-index: 300; overflow: hidden; overflow: clip; background: #062f57; display: grid; place-items: center; }
.fin-scene { position: absolute; inset: 0; }
.fin-dokdo { position: absolute; inset: 0; background: center / cover; transform: scale(1.15); filter: brightness(.6); transition: transform 3.5s ease-out, filter 1.4s; }
.finale.open .fin-dokdo { transform: scale(1); filter: brightness(1.05) saturate(1.2); }
.fin-rays { position: absolute; left: 50%; top: 45%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax; z-index: 1; opacity: 0; transition: opacity 1s .4s;
  background: repeating-conic-gradient(from 0deg, rgba(255,240,170,.28) 0deg 8deg, transparent 8deg 22deg); animation: spin 18s linear infinite; mix-blend-mode: screen; }
.finale.open .fin-rays { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.fin-spark { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 1s .6s; }
.finale.open .fin-spark { opacity: 1; }
.fin-spark i { position: absolute; font-style: normal; color: #fff6b0; text-shadow: 0 0 12px #ffd34d, 0 0 26px #fff; animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(.3) rotate(0); opacity: .2; } 50% { transform: scale(1.3) rotate(45deg); opacity: 1; } }
.fin-door { position: absolute; top: 0; bottom: 0; width: 50.5%; z-index: 5; display: grid; place-items: center;
  background: repeating-linear-gradient(90deg, #7a4a20 0 34px, #8e5a2a 34px 68px); box-shadow: inset 0 0 0 14px #5e3b17, inset 0 0 0 20px #e0a800;
  transition: transform 1.3s cubic-bezier(.7,0,.3,1); }
.fin-door.l { left: 0; } .fin-door.r { right: 0; }
.fin-door b { font-family: var(--head); font-weight: 400; font-size: clamp(80px, 14vw, 180px); color: #ffd34d; text-shadow: 0 6px 0 #5e3b17, 0 0 30px rgba(255,211,77,.7); }
.fin-knob { position: absolute; top: 50%; width: 34px; height: 34px; margin-top: -17px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #e0a800); box-shadow: 0 4px 0 #8a5a2b; }
.fin-door.l .fin-knob { right: 34px; } .fin-door.r .fin-knob { left: 34px; }
.finale.open .fin-door.l { transform: translateX(-102%); }
.finale.open .fin-door.r { transform: translateX(102%); }
.fin-lock { position: absolute; z-index: 6; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: var(--head); font-size: clamp(24px, 3.4vw, 40px); color: #5e3b17;
  background: linear-gradient(#fff6cf, #ffd34d); border: 5px solid #fff; border-radius: 999px; padding: 12px 34px; box-shadow: 0 0 30px rgba(255,211,77,.9); animation: feverBlink .5s ease-in-out infinite alternate; transition: opacity .3s; white-space: nowrap; }
.finale.open .fin-lock { opacity: 0; }
.fin-text { position: relative; z-index: 7; text-align: center; color: #fff; transform: scale(.4); opacity: 0; transition: transform .6s cubic-bezier(.2,1.6,.4,1), opacity .4s; padding: 0 16px; }
.finale.title .fin-text { transform: scale(1); opacity: 1; }
.fin-text h1 { margin: 0; font-family: var(--head); font-weight: 400; font-size: clamp(56px, 9vw, 120px); color: #ffd34d; text-shadow: 0 6px 0 var(--sea-deep), 0 0 30px rgba(255,180,0,.8); animation: btnPulse 1.2s ease-in-out infinite; }
.fin-text h2 { margin: 6px 0 0; font-family: var(--head); font-weight: 400; font-size: clamp(26px, 4vw, 48px); text-shadow: 0 4px 0 var(--sea-deep), 0 0 16px rgba(0,0,0,.5); }
.fin-text h2 em { font-style: normal; color: #84dcff; }
.fin-stat { display: inline-block; margin: 14px 0 0; font-family: var(--head); font-size: clamp(20px, 2.6vw, 30px); background: rgba(6,47,87,.6); border-radius: 999px; padding: 6px 22px; }
.finale.ask .fin-text { transform: translateY(-24vh) scale(.72); }
.fin-card { position: absolute; z-index: 8; left: 50%; bottom: 6vh; width: min(520px, calc(100% - 32px)); transform: translate(-50%, 140%); transition: transform .6s cubic-bezier(.2,1.4,.4,1);
  background: var(--paper); border: 6px solid #fff; border-radius: 28px; padding: 20px 22px; text-align: center; box-shadow: var(--shadow); }
.finale.ask .fin-card { transform: translate(-50%, 0); }
.fin-card h3 { margin: 0 0 10px; font-family: var(--head); font-weight: 400; font-size: 28px; color: var(--sea-dark); }
.fin-card input { width: 100%; font-family: var(--head); font-size: 34px; text-align: center; padding: 10px 14px; border: 4px solid var(--sea); border-radius: 18px; outline: none; }
.fin-card input:focus { border-color: var(--sun-dark); box-shadow: 0 0 0 5px rgba(255,197,49,.4); }
.fin-card .row, .cert-box .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.finale.quick .fin-door, .finale.quick .fin-lock { display: none; }
.finale.cert .fin-text, .finale.cert .fin-card { display: none; }
.cert-box { position: absolute; inset: 0; margin: auto; height: fit-content; z-index: 9; width: min(980px, calc(100vw - 32px)); text-align: center; animation: pop .5s; }
.cert-img { width: 100%; max-height: calc(var(--vh) - 150px); object-fit: contain; border-radius: 12px; box-shadow: 0 0 0 6px #fff, 0 20px 50px rgba(0,0,0,.5); background: #fff; }

/* ---------- 💯 결과 점수 ---------- */
.r-score { font-family: var(--head); color: var(--sea-dark); font-size: 26px; margin: 0 0 2px; }
.r-score b { font-weight: 400; font-size: 56px; color: var(--sun-dark); text-shadow: 0 3px 0 #fff, 0 4px 0 rgba(0,0,0,.12); }
.r-score small { font-family: var(--body); font-size: 18px; color: var(--muted); }
.r-break { font-size: 18px; color: var(--muted); margin-bottom: 4px; }
.r-best { display: inline-block; font-size: 17px; color: var(--muted); background: #fff; border-radius: 999px; padding: 2px 12px; }
.qp { display: inline-block; font-size: .8em; color: #fff; background: var(--sun-dark); border-radius: 999px; padding: 0 10px; margin-right: 4px; animation: comboPop .45s; }

/* ---------- 🏆 전국 순위 ---------- */
.lb { text-align: left; }
.lb-me { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.lb-me span { font-family: var(--head); font-size: 20px; background: linear-gradient(#fff6cf, #ffe08a); border: 3px solid #fff; border-radius: 999px; padding: 6px 16px; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.lb-me em { font-style: normal; color: var(--coral); font-size: 1.25em; }
.lb-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.lb-tabs button { flex: 1; border: 3px solid #fff; border-radius: 14px; padding: 8px; font-size: 19px; background: #e3edf6; color: var(--sea-dark); }
.lb-tabs button.on { background: var(--sea); color: #fff; }
.lb-list { list-style: none; margin: 0; padding: 0; max-height: min(42vh, 360px); overflow: auto; border-radius: 14px; background: #fff; }
.lb-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #eef2f6; font-size: 18px; }
.lb-list li.me { background: #fff1c7; font-weight: 700; }
.lb-list li.empty { justify-content: center; color: var(--muted); padding: 20px; }
.lb-n { width: 34px; text-align: center; font-family: var(--head); font-size: 20px; color: var(--sea-dark); flex: none; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--head); }
.lb-sub { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.lb-list b { font-family: var(--head); font-weight: 400; color: var(--sun-dark); white-space: nowrap; }
.lb-foot { margin: 8px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.lb-box { width: min(560px, 100%); max-height: calc(var(--vh) - 32px); overflow: auto; }
.lb-box h2 small, .fin-rank h3 small { font-family: var(--body); font-size: 17px; color: var(--muted); }
.lb-wait { text-align: center; padding: 24px 0; color: var(--muted); }

/* 피날레 안의 입력 칸과 순위 */
.fin-fields { display: flex; gap: 8px; margin-bottom: 8px; }
.fin-fields select { flex: none; width: 34%; font-family: var(--head); font-size: 22px; padding: 8px; border: 4px solid var(--sea); border-radius: 18px; background: #fff; color: var(--ink); }
.fin-fields input { flex: 1; min-width: 0; }
.fin-card input#finSchool { font-size: 26px; }
.fin-note { margin: 8px 0 0; font-size: 15px; color: var(--muted); }
.finale.ranked .fin-text, .finale.ranked .fin-card { display: none; }
.fin-rank { position: absolute; inset: 0; margin: auto; height: fit-content; max-height: calc(var(--vh) - 24px); overflow: auto; z-index: 9;
  width: min(600px, calc(100vw - 32px)); background: var(--paper); border: 6px solid #fff; border-radius: 28px; padding: 18px 20px; box-shadow: var(--shadow); text-align: center; animation: pop .5s; }
.fin-rank h3 { margin: 0 0 10px; font-family: var(--head); font-weight: 400; font-size: 30px; color: var(--sea-dark); }
.fin-rank .row { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- 마우스가 있을 때만 hover ---------- */
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { filter: brightness(1.07); }
  .entry-btn:hover { transform: translateY(-5px) rotate(-1deg); }
  .node:hover { transform: translate(-50%, -54%) scale(1.06); }
  .opt:hover:not(:disabled) { transform: translateY(-2px); }
}

/* ---------- 화면 크기 ---------- */
@media (max-width: 980px) {
  .steps { display: none; }
}
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  /* 좁거나 세로인 화면: 지도를 카드 목록으로 */
  .map-board { width: 100%; aspect-ratio: auto; background: rgba(255,255,255,.2); padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 42vw), 1fr)); gap: 14px; background-image: none; }
  .route { display: none; }
  .node { position: relative; left: auto !important; top: auto !important; transform: none; background: var(--card); border-radius: 20px; padding: 12px 6px; }
  .n-flag { top: 4px; right: 6px; }
  .node:hover, .node:active { transform: none; }
  .n-num { top: 4px; left: 4px; }
  .map-board { container-type: normal; }
  .n-pic { width: clamp(84px, 17vw, 150px); }
  .n-num { width: 38px; height: 38px; font-size: 20px !important; }
  .n-label { font-size: clamp(16px, 2.6vw, 22px); white-space: normal; }
  .node .stars { font-size: clamp(14px, 2.2vw, 20px); }
}
@media (max-width: 680px) {
  :root { --fs: 19px; --fs-q: 25px; }
  body.low { --fs: 21px; --fs-q: 29px; }
  .entry-btn { width: 100%; min-height: 130px; }
  .entry-btn b { font-size: 36px; }
  .entry { width: 100%; }
  .opts { grid-template-columns: 1fr; }
  .bgm-btn { width: 52px; height: 52px; font-size: 24px; }
  .btn { padding: 12px 18px; }
  .avatar { width: 76px; height: 76px; }
  .talk { margin-top: -30px; }
  .bubble { margin-top: 30px; }
}

/* ---------- 높이가 낮은 화면 (가로 태블릿·크롬북) ---------- */
@media (max-height: 820px) {
  .result { padding-bottom: 16px; }
  .r-pic { aspect-ratio: 4.2 / 1; }
  .result h1 { font-size: 38px; }
  .big-stars { font-size: 56px; margin: 0; }
  .split { margin: 0 0 4px; }
  .msg { font-size: 23px; margin: 6px 0; }
  .badge-get { font-size: 22px; padding: 6px 20px; }
  .bottom { padding-top: 12px; }
  .qbox { padding-top: 20px; padding-bottom: 20px; }
}

/* ---------- 인쇄 (답지) ---------- */
@media print {
  #bg, .bgm-btn, .tabs, .k-tools, .bottom, .reset-zone, .bar, .toast, .lock { display: none !important; }
  body { background: #fff; }
  #app { padding: 0; max-width: none; }
  .print-title { display: block; font-family: var(--head); font-size: 26px; margin: 0 0 10px; }
  .k-ch { border: 1px solid #999; break-inside: avoid-page; box-shadow: none; }
  .k-ch summary { list-style: none; }
  .k-list li { break-inside: avoid; }
}
