:root {
  --navy: #17223B; --navy2: #22325A; --ink: #17223B; --muted: #6B7489;
  --bg: #F3F5FA; --card: #FFFFFF; --line: #E3E7F0;
  --yellow: #FFC93C; --coral: #FF6B6B; --mint: #2EC4B6; --sky: #5AA9E6; --purple: #B892FF;
  --session: #FFC93C; --r: 20px;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.55; word-break: keep-all; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.3; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px 80px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }
.big { font-size: 64px; line-height: 1.1; }

/* 상단 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--navy); color: #fff; }
.me { display: flex; align-items: center; gap: 8px; background: var(--navy2); border: 0; border-radius: 999px; padding: 6px 14px 6px 8px; cursor: pointer; color: #fff; max-width: 55%; }
.me span { font-size: 24px; }
.me b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stamps { display: flex; gap: 5px; }
.stamp { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--navy2); color: #5d6b8f; }
.stamp.on { background: var(--c); color: var(--navy); }
.announce { background: var(--yellow); color: var(--navy); font-weight: 700; padding: 10px 16px; text-align: center; animation: pulse 2s ease-in-out 3; }
@keyframes pulse { 50% { filter: brightness(1.12); } }

/* 히어로 */
.hero { background: var(--navy); color: #fff; border-radius: var(--r); padding: 28px 24px; margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, #FFC93C55, transparent 70%); }
.hero h1 { font-size: clamp(26px, 5vw, 38px); font-weight: 800; }
.hero p { margin: 0; color: #C9D6EE; }
.hero.small h1 { font-size: clamp(22px, 4.2vw, 30px); }
.kicker { font-size: 13px; font-weight: 800; letter-spacing: .08em; color: #9FB3D9; margin-bottom: 8px; }
.y { color: var(--yellow); }

/* 카드·버튼 */
.card { background: var(--card); border-radius: var(--r); padding: 20px; margin-bottom: 14px; box-shadow: 0 2px 10px #17223B12; display: block; text-decoration: none; }
.card h3 { font-size: 19px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 16px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 48px; }
.btn:active { transform: scale(.97); }
.btn.big { min-height: 58px; font-size: 18px; padding: 12px 20px; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.link { background: var(--yellow); border-color: var(--yellow); color: var(--navy); width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.right { background: var(--mint); border-color: var(--mint); color: #fff; opacity: 1; }
.btn.wrong { background: var(--coral); border-color: var(--coral); color: #fff; opacity: 1; }
main > .btn.big { width: 100%; margin: 6px 0 14px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.links { display: grid; gap: 10px; }
input { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 52px; background: #fff; }
input:focus { outline: none; border-color: var(--sky); }
form.card input { margin-bottom: 10px; }
.tip { background: #FFF8DC; border-radius: 14px; padding: 12px 14px; }
.card.tip { background: #FFF8DC; }
.done-msg { text-align: center; font-weight: 800; color: #12907F; background: #DDF7F3; border-radius: 14px; padding: 14px; }
.lesson { font-size: 19px; }

/* 회차 고르기 */
.pick { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.pick-card { display: grid; gap: 4px; border: 3px solid var(--c); }
.pick-card b { font-size: 22px; }

/* 입장 */
.lbl { display: block; font-weight: 800; margin: 6px 0 8px; }
.warn { font-weight: 600; font-size: 14px; color: var(--coral); margin-left: 6px; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.av { font-size: 30px; aspect-ratio: 1; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.av.on { border-color: var(--navy); background: #FFF3CF; transform: scale(1.08); }
.join .btn.big { width: 100%; margin-top: 16px; }

/* 탐험 지도 */
.map { list-style: none; padding: 0; margin: 0 0 14px; position: relative; }
.map::before { content: ""; position: absolute; left: 39px; top: 20px; bottom: 20px; border-left: 3px dashed #C3CBDA; }
.map li { margin-bottom: 12px; position: relative; }
.mcard { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--r); padding: 14px 16px; text-decoration: none; box-shadow: 0 2px 10px #17223B12; border: 3px solid transparent; }
.mcard .badge, .mhead .badge { flex: none; width: 50px; height: 50px; border-radius: 50%; background: var(--c); display: grid; place-items: center; font-weight: 800; font-size: 22px; color: var(--navy); border: 4px solid var(--navy); }
.mt { flex: 1; display: grid; }
.mt small { color: var(--muted); font-weight: 700; font-size: 13px; }
.mt b { font-size: 19px; }
.mt span { color: var(--muted); font-size: 15px; }
.state { font-weight: 800; font-size: 20px; color: var(--muted); }
.mcard.now { border-color: var(--c); box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 30%, transparent); animation: glow 1.6s ease-in-out infinite; }
.mcard.now .state { color: var(--navy); background: var(--c); border-radius: 999px; padding: 2px 12px; font-size: 15px; }
@keyframes glow { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--c) 18%, transparent); } }
.mcard.done { background: #FBFCFE; }
.mcard.rest { background: transparent; box-shadow: none; padding-top: 4px; padding-bottom: 4px; }
.mcard.rest .badge { width: 40px; height: 40px; font-size: 18px; margin-left: 5px; background: #E3E7F0; border-width: 3px; }
.gallery-link { font-size: 18px; }

/* 미션 머리 */
.crumb { margin: 2px 0 10px; font-weight: 700; }
.crumb a { text-decoration: none; color: var(--muted); }
.mhead { display: flex; gap: 14px; align-items: flex-start; background: var(--navy); color: #fff; border-radius: var(--r); padding: 20px; margin-bottom: 14px; }
.mhead small { color: var(--c); font-weight: 800; letter-spacing: .06em; }
.mhead h1 { font-size: clamp(24px, 4.6vw, 32px); margin: 2px 0 6px; }
.mhead p { margin: 0; color: #C9D6EE; }
.mhead b { color: #fff; }
.mhead .badge { border-color: #fff; }

/* 퀴즈 카드 */
.qcard small { color: var(--muted); }
.q { font-size: 21px; font-weight: 800; margin: 6px 0 12px; }
.why p { background: #F3F5FA; border-radius: 14px; padding: 12px 14px; margin: 12px 0 10px; }
.why .btn { width: 100%; }
.result { font-size: 19px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* 미션2 채팅 */
.chat { display: grid; gap: 10px; }
.bubble { border-radius: 18px; padding: 12px 16px; max-width: 92%; }
.bubble.user { justify-self: end; background: var(--navy); color: #fff; font-weight: 700; border-bottom-right-radius: 4px; }
.bubble.ai { background: #F3F5FA; border-bottom-left-radius: 4px; display: grid; gap: 6px; }
.who { font-weight: 800; font-size: 14px; color: var(--muted); }
.sent { text-align: left; border: 2px dashed #C3CBDA; background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: 18px; }
.sent:disabled { cursor: default; }
.sent.bad { border: 3px solid var(--coral); background: #FFE8E8; text-decoration: line-through wavy var(--coral); }
.sent.right { box-shadow: 0 0 0 3px var(--mint); }
.sent.wrong { box-shadow: 0 0 0 3px #8A94A8; }

/* 미션3 */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vs { border-radius: 16px; padding: 14px; }
.vs small { font-weight: 800; }
.vs p { font-weight: 800; margin: 6px 0; }
.vs span { font-size: 14px; color: var(--muted); }
.vs.bad { background: #F1F2F5; }
.vs.good { background: #E3F8F5; }
.formula { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; font-weight: 800; }
.formula span { background: var(--c); color: var(--navy); border-radius: 10px; padding: 6px 12px; }
.formula i { font-style: normal; color: var(--muted); }
.block { border-left: 0; }
.tag { background: var(--c); color: var(--navy); border-radius: 10px; padding: 3px 12px; }
.block h3 small { color: var(--muted); font-weight: 600; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 15px; cursor: pointer; font-weight: 600; min-height: 44px; }
.chip.on { background: var(--c, var(--navy)); border-color: var(--c, var(--navy)); color: var(--navy); font-weight: 800; }
#cats .chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-in { flex: 1 1 180px; min-height: 44px; border-radius: 999px; padding: 8px 15px; width: auto; }
.result-prompt { position: sticky; bottom: 10px; border: 3px solid var(--navy); }
.level { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.meter { flex: 1; height: 14px; background: #EEF1F6; border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--yellow), var(--mint), var(--sky), var(--purple)); transition: width .3s; }
.prompt-out { background: #F3F5FA; border-radius: 14px; padding: 14px; font-size: 18px; font-weight: 700; min-height: 56px; margin: 10px 0 0; }
.prompt-out.small { font-size: 15px; }

/* 미션4 */
.vbtn.on { background: var(--c); border-color: var(--c); color: var(--navy); }
.bars { display: grid; gap: 6px; margin-top: 12px; }
.bar { display: grid; grid-template-columns: 90px 1fr 46px; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.bar i { height: 14px; border-radius: 999px; min-width: 4px; transition: width .4s; }
.vote .why { background: #F3F5FA; border-radius: 14px; padding: 10px 14px; margin: 10px 0 0; }
.sec { margin: 22px 4px 10px; }
.sec small { color: var(--muted); }
.board { columns: 2 260px; column-gap: 12px; margin-bottom: 14px; }
.note { break-inside: avoid; background: #FFF8DC; border-radius: 16px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 8px #17223B10; }
.note.cat-check { background: #E3F8F5; }
.note.cat-respect { background: #EDE4FF; }
.note.cat-think { background: #E2EFFC; }
.note .nt { font-size: 13px; font-weight: 800; color: var(--muted); }
.note p { margin: 4px 0 8px; font-size: 18px; font-weight: 700; }
.nf { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); gap: 6px; }
.heart, .x { border: 0; background: #ffffffb0; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-weight: 700; }
.heart.on { background: #FFD9D9; }

/* 미션5 */
.steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.steps label { display: grid; grid-template-columns: 28px 1fr; gap: 2px 10px; background: #F3F5FA; border-radius: 14px; padding: 12px; cursor: pointer; }
.steps input { width: 24px; height: 24px; min-height: 0; grid-row: span 2; margin: 2px 0 0; accent-color: var(--mint); }
.steps span { color: var(--muted); font-size: 15px; }
.steps li.ok label { background: #E3F8F5; }
.steps li.ok b { text-decoration: line-through; }

/* 갤러리 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.gcard { background: #fff; border-radius: var(--r); overflow: hidden; box-shadow: 0 2px 10px #17223B12; }
.gopen { display: block; width: 100%; aspect-ratio: 4/3; border: 0; padding: 0; background: #EEF1F6; cursor: pointer; position: relative; }
.gopen iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.noimg { font-size: 60px; display: grid; place-items: center; height: 100%; }
.gbody { padding: 12px 14px; display: grid; gap: 4px; }
.gbody p { margin: 0; }
.gbody .muted { font-size: 14px; }
.cheers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.cheer { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 9px; cursor: pointer; font-size: 15px; }
.cheer.on { border-color: var(--navy); background: #FFF3CF; }
.embed { aspect-ratio: 4/3; margin: 10px 0; border-radius: 14px; overflow: hidden; background: #EEF1F6; }
.embed iframe { width: 100%; height: 100%; border: 0; }

/* 배지·모달·토스트 */
#badge { width: min(100%, 420px); height: auto; border-radius: 20px; margin: 10px auto; display: block; box-shadow: 0 8px 30px #17223B33; }
.rest-card { padding: 40px 20px; }
.modal { position: fixed; inset: 0; background: #17223BAA; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: var(--r); padding: 20px; width: min(720px, 100%); max-height: 90vh; overflow: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; opacity: 0; transition: .25s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .avatars { grid-template-columns: repeat(4, 1fr); }
  .compare, .row2 { grid-template-columns: 1fr; }
  .stamp { width: 24px; height: 24px; font-size: 12px; }
  .row3 .btn { font-size: 14px; padding: 8px 4px; }
  .bar { grid-template-columns: 76px 1fr 40px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
[hidden] { display: none !important; }
