/* =========================================================================
 * 천자문 어드벤처: 마법의 팝업 — PREMIUM 스타일
 * 밝은 라이트 테마 + 바이올렛/골드 "마법" 액센트.
 * 한자=명조, UI=산세리프. 정교한 그림자·모션·그라데이션 시스템.
 * ======================================================================= */

:root {
  --bg: #f5f6fc;
  --surface: #ffffff;
  --surface-2: #f4f5fb;
  --surface-3: #eef0f8;
  --border: #e7e9f4;
  --border-strong: #d8dbeb;
  --text: #1b2030;
  --text-soft: #6b7186;
  --text-faint: #a3a8bd;

  --primary: #6d5efc;
  --primary-dark: #5847e8;
  --primary-soft: #efeefe;
  --violet: #a855f7;
  --gold: #f59e0b;
  --gold-soft: #fff5e3;
  --ink: #1c2030;
  --ink-soft: #565d72;

  --success: #16a34a;
  --success-soft: #e7f7ee;
  --danger: #ef4444;
  --danger-soft: #fdecec;

  --grad-brand: linear-gradient(120deg, #6d5efc 0%, #a855f7 60%, #ec4899 110%);
  --grad-gold: linear-gradient(120deg, #f59e0b, #fbbf24);

  /* 정교한 그림자: 컬러 틴트(보라끼) + 다층 깊이. 위쪽에 미세한 화이트 인셋 하이라이트로 유리/카드 질감 */
  --shadow-xs: 0 1px 2px rgba(28, 25, 70, 0.05);
  --shadow-sm: 0 1px 2px rgba(28, 25, 70, 0.05), 0 3px 8px rgba(28, 25, 70, 0.055);
  --shadow-md: 0 2px 6px rgba(28, 25, 70, 0.06), 0 8px 20px rgba(28, 25, 70, 0.08), 0 16px 36px rgba(28, 25, 70, 0.05);
  --shadow-lg: 0 6px 16px rgba(24, 20, 60, 0.14), 0 20px 44px rgba(24, 20, 60, 0.16), 0 36px 80px rgba(24, 20, 60, 0.12);
  --shadow-primary: 0 6px 16px rgba(109, 94, 252, 0.32), 0 12px 28px rgba(109, 94, 252, 0.18);
  --hairline: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  --ring: 0 0 0 3px rgba(109, 94, 252, 0.35);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 접근성: 키보드 포커스에만 또렷한 링 (마우스 클릭엔 없음) */
:where(button, [tabindex], a):focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* 텍스트 선택 색 — 브랜드 톤 */
::selection { background: rgba(109, 94, 252, 0.22); color: var(--ink); }

/* 스크롤바 (Webkit) */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 3px solid var(--bg); background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #c2c6dc; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

body {
  font-family: 'Pretendard Variable', 'Pretendard', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  line-height: 1.58;
  letter-spacing: -0.018em;
  word-break: keep-all;
  min-height: 100vh;
  background:
    radial-gradient(1100px 560px at 92% -8%, #eceafe 0%, transparent 55%),
    radial-gradient(900px 520px at -8% 108%, #fdeef6 0%, transparent 52%),
    radial-gradient(700px 400px at 50% 50%, #fbfbff 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  padding: 28px 18px 64px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

/* 명조(한자) 공통 — 또렷한 획 렌더링 */
.ep-combo, .c-char, .char-box, .l-char, .combo-phrase, .w-char {
  font-feature-settings: 'palt' 1;
  -webkit-font-smoothing: auto;
}

.app { width: 100%; max-width: 1240px; position: relative; z-index: 1; }

/* 배경에 떠다니는 마법 오브 */
body::before, body::after {
  content: ''; position: fixed; border-radius: 50%;
  z-index: 0; filter: blur(70px); opacity: 0.55; pointer-events: none;
}
body::before {
  width: 360px; height: 360px; top: -90px; left: -70px;
  background: radial-gradient(circle, #cdc6ff, transparent 70%);
  animation: float1 19s ease-in-out infinite;
}
body::after {
  width: 320px; height: 320px; bottom: -80px; right: -50px;
  background: radial-gradient(circle, #ffd4ec, transparent 70%);
  animation: float2 23s ease-in-out infinite;
}
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1);} 50% { transform: translate(46px,34px) scale(1.08);} }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1);} 50% { transform: translate(-44px,-30px) scale(1.1);} }
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  * { animation-duration: 0.001ms !important; }
}

/* =========================================================================
 * 헤더 / 게임 HUD
 * ======================================================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 22px;
  box-shadow: var(--shadow-md), var(--hairline);
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 48px; height: 48px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 1.5rem;
  border-radius: 14px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-primary);
}
.brand-text h1 {
  font-size: 1.35rem; font-weight: 900; letter-spacing: -0.6px; line-height: 1.1;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text .sub { font-size: 0.74rem; color: var(--violet); font-weight: 700; letter-spacing: 1px; }

.hud { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hud-level { display: flex; align-items: center; gap: 12px; }
.rank-badge {
  background: var(--grad-brand);
  color: #fff;
  padding: 8px 16px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.3px;
  box-shadow: var(--shadow-primary);
  white-space: nowrap;
}
.level-block { min-width: 150px; }
.level-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.72rem; margin-bottom: 5px;
}
#level-label { font-weight: 800; color: var(--text); }
#exp-label { color: var(--text-faint); font-weight: 600; }
.xpbar {
  height: 8px; border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.xpbar-fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: var(--grad-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  transition: width 0.6s var(--ease);
  position: relative;
}
.xpbar-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: translateX(-100%);
  animation: shine 2.4s ease-in-out infinite;
}
@keyframes shine { 0%,60% { transform: translateX(-100%);} 100% { transform: translateX(220%);} }

.hud-stats { display: flex; gap: 8px; }
.stat {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 600; color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 13px; border-radius: 999px;
}
.stat b { color: var(--text); font-weight: 800; }

/* =========================================================================
 * 탭 네비게이션
 * ======================================================================= */
.nav { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.nav button {
  font-family: inherit; font-size: 0.9rem; font-weight: 700;
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
}
.nav button:hover { color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.nav button:active { transform: translateY(0) scale(0.97); transition-duration: 0.06s; }
.nav button.active {
  background: var(--ink); color: #fff; border-color: var(--ink);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.12);
}
.nav #btn-reset { box-shadow: none; font-weight: 600; color: var(--text-faint); }
.nav #btn-reset:hover { color: var(--danger); }

/* =========================================================================
 * 패널 공통
 * ======================================================================= */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-md), var(--hairline);
  min-height: 460px;
  animation: panelIn 0.45s var(--ease-out);
}
@keyframes panelIn { 0% { opacity: 0; transform: translateY(10px) scale(0.995);} 100% { opacity: 1; transform: none;} }
.panel.hidden { display: none; }
.panel h2 { font-size: 1.28rem; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 8px; }
.panel .hint { color: var(--text-soft); font-size: 0.88rem; line-height: 1.6; margin-bottom: 24px; max-width: 62ch; }

/* 월드맵 상단 헤더 + 전체 토글 */
.map-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; font-weight: 700; flex-shrink: 0; }

/* 전체 진행 요약 바 (월드맵 상단) */
.map-progress {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(120deg, var(--primary-soft), #fbeefb);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px; margin-bottom: 24px;
}
.map-progress .mp-label { font-size: 0.82rem; font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
.map-progress .mp-bar { flex: 1; height: 10px; border-radius: 999px; background: #fff; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.06); }
.map-progress .mp-fill { height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width 0.6s var(--ease); }
.map-progress .mp-count { font-size: 0.82rem; font-weight: 800; color: var(--text); white-space: nowrap; }

/* =========================================================================
 * 월드맵
 * ======================================================================= */
.chapter-group {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.chapter-header {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; text-align: left;
  transition: background 0.15s;
}
.chapter-header:hover { background: var(--surface-2); }
.ch-title {
  font-size: 0.96rem; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
.ch-title em {
  font-style: normal; font-size: 0.64rem; font-weight: 800; color: #fff;
  background: var(--grad-brand); padding: 3px 9px; border-radius: 999px; letter-spacing: 0.3px;
}
.ch-progress { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ch-bar { width: 130px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.ch-bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width 0.6s var(--ease); }
.ch-count { font-size: 0.78rem; font-weight: 800; color: var(--text-soft); min-width: 32px; text-align: right; }
.ch-chevron { font-size: 0.85rem; color: var(--text-faint); transition: transform 0.3s var(--ease); }
.chapter-group.collapsed .ch-chevron { transform: rotate(-90deg); }
.chapter-body { padding: 2px 18px 20px; }
.chapter-group.collapsed .chapter-body { display: none; }
.chapter-group.ch-current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }
.chapter-group.ch-locked .ch-title { color: var(--text-faint); }
.chapter-group.ch-locked .ch-bar i { background: var(--border-strong); }
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(162px, 1fr));
  gap: 13px;
}
.stage {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 16px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s;
  box-shadow: var(--shadow-sm);
  animation: stageIn 0.5s var(--ease) backwards;
  overflow: hidden;
}
.stage::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120px 70px at 50% -10%, rgba(109,94,252,0.08), transparent 70%);
  opacity: 0; transition: opacity 0.3s;
}
.stage:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stage:not(.locked):active { transform: translateY(-1px) scale(0.985); transition-duration: 0.07s; }
.stage:hover::before { opacity: 1; }
.stage .ep-no { font-size: 0.72rem; color: var(--text-faint); font-weight: 600; }
.stage .ep-combo {
  font-family: 'Noto Serif KR', serif; font-weight: 700;
  font-size: 1.72rem; letter-spacing: 2px; margin: 12px 0 8px; color: var(--ink);
  position: relative;
  white-space: nowrap;          /* 4자를 한 줄로 */
}
.stage .ep-title { font-size: 0.87rem; font-weight: 600; color: var(--text); }
.stage .ep-status {
  font-size: 0.74rem; margin-top: 14px; font-weight: 700; color: var(--text-soft);
  display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
}

.stage.locked { cursor: not-allowed; background: var(--surface-2); box-shadow: none; }
.stage.locked .ep-combo { color: #cbcfe0; filter: blur(0.4px); }
.stage.locked .ep-title, .stage.locked .ep-no { color: #bcc0d2; }
.stage.locked:hover { transform: none; box-shadow: none; border-color: var(--border); }
.stage.locked:hover::before { opacity: 0; }
.stage.locked::after {
  content: '🔒'; position: absolute; top: 13px; right: 13px; font-size: 0.95rem; opacity: 0.65;
}
.stage.cleared { border-color: #c4e9d2; background: linear-gradient(180deg, #ffffff, #f1fbf5); }
.stage.cleared .ep-status { color: var(--success); background: var(--success-soft); }
.stage.current {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--primary), var(--shadow-md);
  animation: stageIn 0.5s var(--ease) backwards, currentBreath 2.8s ease-in-out 0.6s infinite;
}
.stage.current .ep-status { color: #fff; background: var(--primary); }
.stage.current::after {
  content: 'NOW'; position: absolute; top: 11px; right: 11px;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.5px; color: #fff;
  background: var(--grad-brand); padding: 3px 7px; border-radius: 999px;
}

.progress-pips { display: flex; gap: 5px; justify-content: center; margin-top: 13px; }
.pip { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); transition: all 0.3s var(--ease); }
.pip.done { background: var(--success); border-color: var(--success); box-shadow: 0 0 6px rgba(22,163,74,0.4); }

/* =========================================================================
 * 카드 도감 — 수집 요약 헤더
 * ======================================================================= */
.collection-summary {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--primary-soft), #fbeefb);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px; margin-bottom: 24px;
  box-shadow: var(--hairline);
}
/* 원형 진행률 링 (conic-gradient) */
.cs-ring {
  --p: 0;
  width: 72px; height: 72px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(closest-side, #fff 78%, transparent 79% 100%),
    conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-3) 0);
  box-shadow: var(--shadow-sm);
}
.cs-pct { font-size: 1.18rem; font-weight: 900; color: var(--primary-dark); letter-spacing: -0.5px; }
.cs-pct small { font-size: 0.62rem; font-weight: 800; }
.cs-info { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 7px; }
.cs-count { font-size: 0.95rem; color: var(--text-soft); }
.cs-count b { font-size: 1.15rem; font-weight: 900; color: var(--text); }
.cs-bar { height: 8px; border-radius: 999px; background: #fff; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.07); }
.cs-bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width 0.7s var(--ease-out); }
.cs-rank { font-size: 0.8rem; color: var(--text-soft); }
.cs-rank b { color: var(--primary-dark); font-weight: 800; }
.cs-filter { display: inline-flex; background: rgba(255,255,255,0.7); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.cs-filter button {
  font-family: inherit; font-size: 0.8rem; font-weight: 700; color: var(--text-soft);
  border: none; background: transparent; padding: 7px 15px; border-radius: 999px; cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cs-filter button:hover { color: var(--text); }
.cs-filter button.on { background: var(--surface); color: var(--primary-dark); box-shadow: var(--shadow-xs); }

/* =========================================================================
 * 카드 도감 (홀로그래픽)
 * ======================================================================= */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 16px;
}
.card-slot {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #ffffff 0%, #f5f6ff 60%, #fdf2fb 100%);
  cursor: pointer;
  transition: transform 0.22s var(--ease), box-shadow 0.22s;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.42s var(--ease) backwards;
  overflow: hidden;
}
.card-slot::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(168,85,247,0.14) 45%, rgba(245,158,11,0.14) 55%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.7s var(--ease);
}
.card-slot:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-slot:active { transform: translateY(-2px) scale(1.0); transition-duration: 0.08s; }
.card-slot:hover::after { transform: translateX(120%); }
.card-slot.empty {
  background: var(--surface-2); border-style: dashed; box-shadow: none;
  cursor: default; font-size: 1.6rem; color: var(--text-faint);
}
.card-slot.empty::after { display: none; }
.card-slot.empty:hover { transform: none; box-shadow: none; }
.card-slot .c-char { font-family: 'Noto Serif KR', serif; font-weight: 700; font-size: 3rem; color: var(--ink); position: relative; }
.card-slot .c-read { font-size: 0.85rem; font-weight: 700; margin-top: 10px; color: var(--text-soft); position: relative; }

/* =========================================================================
 * 오답노트
 * ======================================================================= */
.wrong-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--danger-soft);
  border-left: 4px solid var(--danger);
  border-radius: var(--r-md);
  padding: 15px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.2s;
}
.wrong-item:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.wrong-item .w-char { font-family: 'Noto Serif KR', serif; font-weight: 700; font-size: 2.1rem; color: var(--danger); }
.wrong-item .w-info { flex: 1; }
.wrong-item .w-info b { font-size: 1rem; font-weight: 800; }
.wrong-item .w-info span { display: block; font-size: 0.8rem; color: var(--text-soft); margin-top: 2px; }

/* =========================================================================
 * 버튼
 * ======================================================================= */
.btn {
  font-family: inherit; font-size: 0.92rem; font-weight: 800;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  background: var(--primary); color: #fff;
  transition: transform 0.14s var(--ease), box-shadow 0.2s, background 0.2s, filter 0.2s;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 10px 26px rgba(109,94,252,0.45), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn:active { transform: translateY(0) scale(0.97); filter: brightness(0.98); transition-duration: 0.06s; }
.btn.ghost {
  background: var(--surface); border-color: var(--border-strong); color: var(--text-soft);
  box-shadow: var(--shadow-xs);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }
.btn.crimson { background: var(--danger); box-shadow: 0 8px 22px rgba(239,68,68,0.32); }
.btn.crimson:hover { box-shadow: 0 10px 26px rgba(239,68,68,0.42); }
.empty-note { color: var(--text-soft); text-align: center; padding: 64px 0; font-size: 0.95rem; }

/* =========================================================================
 * 마법 팝업 (퀴즈 / 해설 / 콤보)
 * ======================================================================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(18, 20, 42, 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
  animation: overlayIn 0.25s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.overlay.hidden { display: none; }

.popup {
  width: 100%; max-width: 450px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), var(--hairline);
  padding: 30px 28px;
  position: relative;
  animation: popIn 0.45s var(--ease-out);
}
/* 그라데이션 글로우 보더 */
.popup::before {
  content: ''; position: absolute; inset: -2px; z-index: -1;
  border-radius: calc(var(--r-lg) + 2px);
  background: var(--grad-brand);
  opacity: 0.5; filter: blur(8px);
}
@keyframes popIn {
  0% { transform: scale(0.85) translateY(14px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.popup-head {
  text-align: center; font-size: 0.78rem; font-weight: 700;
  color: var(--text-soft); margin-bottom: 6px; letter-spacing: 0.4px;
}

/* 한자 박스 + 마법진 글로우 */
.char-stage { text-align: center; margin: 16px 0 24px; position: relative; }
.char-box {
  font-family: 'Noto Serif KR', serif; font-weight: 700;
  display: inline-block;
  font-size: 5.6rem; line-height: 1; color: var(--ink);
  padding: 24px 40px; border-radius: var(--r-md);
  background: radial-gradient(circle at 50% 35%, #ffffff, #f1f0ff 80%);
  border: 1px solid var(--primary-soft);
  position: relative; z-index: 1;
  box-shadow: 0 8px 26px rgba(109,94,252,0.14);
}
.char-box.flash { animation: flash 0.7s var(--ease); }
@keyframes flash {
  0% { transform: scale(0.65) rotate(-4deg); box-shadow: 0 0 0 0 rgba(109,94,252,0); filter: brightness(1.5); }
  45% { box-shadow: 0 0 0 16px rgba(109,94,252,0.16); }
  100% { transform: scale(1) rotate(0); box-shadow: 0 8px 26px rgba(109,94,252,0.14); filter: brightness(1); }
}

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.option {
  position: relative;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  padding: 16px 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-xs);
  animation: optionIn 0.38s var(--ease) backwards;
}
.option:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow-md); }
.option:active:not(:disabled) { transform: translateY(-1px) scale(0.98); transition-duration: 0.06s; }
.option:disabled { cursor: default; }
.option:disabled:not(.correct):not(.wrong) { opacity: 0.55; }
.option.correct { background: var(--success); color: #fff; border-color: var(--success); animation: correctPulse 0.5s; box-shadow: 0 8px 20px rgba(22,163,74,0.35); }
.option.wrong { background: var(--danger); color: #fff; border-color: var(--danger); animation: shake 0.4s; }
.opt-num {
  position: absolute; top: 7px; left: 9px;
  width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center;
  font-size: 0.66rem; font-weight: 800; color: var(--primary-dark);
  background: var(--primary-soft); border: 1px solid #ddd9fb;
}
.option.correct .opt-num, .option.wrong .opt-num { background: rgba(255,255,255,0.28); color: #fff; border-color: transparent; }
@keyframes correctPulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.07);} }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-7px); }
  40%,80% { transform: translateX(7px); }
}
.popup.shake { animation: shake 0.45s; }

/* 공격 연출 */
.attack-flash {
  position: absolute; inset: 0; border-radius: var(--r-lg);
  background: radial-gradient(circle, rgba(109,94,252,0.45), transparent 70%);
  pointer-events: none; opacity: 0;
}
.attack-flash.go { animation: attack 0.5s ease-out; }
@keyframes attack { 0% { opacity: 0; transform: scale(0.6);} 50% { opacity: 1;} 100% { opacity: 0; transform: scale(1.3);} }

/* ---------- 해설 탭 ---------- */
.lore { animation: fadeUp 0.45s var(--ease); }
@keyframes fadeUp { 0% { opacity: 0; transform: translateY(14px);} 100% { opacity: 1; transform: translateY(0);} }
.lore-head { text-align: center; margin-bottom: 14px; }
.lore-head .l-char {
  font-family: 'Noto Serif KR', serif; font-weight: 700; font-size: 3.6rem;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lore-head .l-read { font-size: 1.3rem; font-weight: 800; margin-top: 4px; letter-spacing: 1px; }
.lore-meta { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 0.78rem; color: var(--text-soft); margin-bottom: 20px; }
.lore-meta span { background: var(--surface-2); padding: 5px 11px; border-radius: 999px; font-weight: 600; }
.lore-section { margin-bottom: 16px; }
.lore-section h4 { font-size: 0.8rem; font-weight: 800; color: var(--primary-dark); margin-bottom: 8px; letter-spacing: 0.3px; }
.lore-section p { font-size: 0.93rem; line-height: 1.7; color: var(--text); }
.vocab { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.vocab li { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 14px; font-size: 0.9rem; border: 1px solid var(--border); }
.vocab li b { color: var(--text); font-weight: 800; }
.vocab li span { color: var(--text-soft); }
.lore-actions { display: flex; gap: 10px; margin-top: 22px; }
.lore-actions .btn { flex: 1; }

.card-earned {
  text-align: center; font-size: 0.84rem; font-weight: 700; color: var(--success);
  background: var(--success-soft); padding: 11px; border-radius: var(--r-sm);
  margin: 12px 0 4px; animation: fadeUp 0.5s 0.15s both;
}

/* ---------- 콤보 연출 ---------- */
.combo { text-align: center; animation: fadeUp 0.5s; padding: 8px 0; }
.combo .combo-banner { font-size: 0.82rem; font-weight: 800; color: var(--gold); letter-spacing: 3px; margin-bottom: 12px; }
.combo .combo-phrase {
  font-family: 'Noto Serif KR', serif; font-weight: 700;
  font-size: 3.1rem; letter-spacing: 9px; margin: 14px 0;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: comboGlow 1s var(--ease);
}
@keyframes comboGlow {
  0% { transform: scale(0.55); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.combo .combo-read {
  display: flex; justify-content: center; gap: 1.05rem;
  font-weight: 700; font-size: 1.12rem; letter-spacing: 0.5px;
  color: var(--violet); margin: -4px 0 16px;
}
.combo .combo-trans { font-size: 1.08rem; font-weight: 500; margin-bottom: 22px; color: var(--text); }
.combo .combo-reward { display: flex; justify-content: center; gap: 12px; margin-bottom: 24px; }
.combo .combo-reward span {
  background: var(--gold-soft); border: 1px solid #f6e2bd;
  padding: 11px 20px; border-radius: var(--r-sm);
  font-size: 0.95rem; font-weight: 700;
}
.combo .combo-reward b { color: var(--gold); }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff;
  padding: 14px 26px; border-radius: 999px; font-size: 0.9rem; font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s var(--ease); z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================================
 * 동적 등장 / 강조 애니메이션
 * ======================================================================= */
@keyframes stageIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes optionIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes currentBreath {
  0%, 100% { box-shadow: 0 0 0 2px var(--primary), var(--shadow-md); }
  50% { box-shadow: 0 0 0 6px rgba(109, 94, 252, 0.22), var(--shadow-md); }
}
.stat.bump { animation: bump 0.45s var(--ease); }
@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.16); } }
.rank-badge.bump { animation: bump 0.5s var(--ease); }

/* =========================================================================
 * 반응형 — 태블릿 / 모바일
 * ======================================================================= */
@media (max-width: 720px) {
  .stage-grid { grid-template-columns: repeat(auto-fill, minmax(162px, 1fr)); }
}

@media (max-width: 560px) {
  body { padding: 16px 12px 44px; overflow-x: hidden; }

  /* 헤더 / HUD: 두 줄로 자연스럽게 */
  .topbar { gap: 14px; padding: 14px 16px; }
  .brand { gap: 11px; }
  .logo { width: 42px; height: 42px; font-size: 1.3rem; }
  .brand-text h1 { font-size: 1.18rem; }
  .hud { width: 100%; gap: 12px; }
  .hud-level { flex: 1; }
  .level-block { flex: 1; min-width: 0; }
  .hud-stats { flex-shrink: 0; }

  /* 탭: 가로 스크롤로 한 줄 유지 */
  .nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { flex-shrink: 0; padding: 9px 15px; font-size: 0.86rem; }
  .nav #btn-reset { margin-left: 0 !important; }

  .panel { padding: 20px 16px; min-height: 0; }
  .panel h2 { font-size: 1.12rem; }

  /* 월드맵: 2열 고정 + 콤보 한자 축소 */
  .stage-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .stage { padding: 16px 10px 14px; }
  .stage .ep-combo { font-size: 1.55rem; letter-spacing: 2px; }
  .stage .ep-title { font-size: 0.8rem; }
  .stage .ep-status { font-size: 0.68rem; }

  .map-progress { padding: 12px 14px; gap: 10px; }
  .map-progress .mp-label { font-size: 0.74rem; }
  .map-progress .mp-count { font-size: 0.76rem; }

  /* 장 아코디언 헤더 압축 */
  .chapter-header { padding: 14px 14px; gap: 10px; }
  .ch-title { font-size: 0.86rem; gap: 7px; }
  .ch-title em { font-size: 0.58rem; padding: 2px 7px; }
  .ch-bar { width: 64px; }
  .ch-count { font-size: 0.72rem; min-width: 26px; }
  .chapter-body { padding: 2px 12px 14px; }

  /* 도감 */
  .collection-summary { gap: 14px; padding: 15px 16px; }
  .cs-ring { width: 60px; height: 60px; }
  .cs-pct { font-size: 1rem; }
  .cs-filter { width: 100%; justify-content: center; order: 3; }
  .cs-info { min-width: 0; }
  .collection-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 11px; }
  .card-slot .c-char { font-size: 2.3rem; }
  .card-slot .c-read { font-size: 0.78rem; }

  /* 팝업 */
  .popup { padding: 24px 18px; }
  .char-box { font-size: 4.2rem; padding: 18px 26px; }
  .options { gap: 9px; }
  .option { padding: 14px 6px; font-size: 0.95rem; }
  .lore-head .l-char { font-size: 3.1rem; }
  .combo .combo-phrase { font-size: 2.3rem; letter-spacing: 5px; }
  .combo .combo-reward { flex-wrap: wrap; }
}

@media (max-width: 360px) {
  .stage .ep-combo { font-size: 1.35rem; letter-spacing: 1px; }
  .option { font-size: 0.88rem; }
}
