:root {
  --ink: #14141f;
  --bg: #eef1fb;
  --bg2: #dfe4fb;
  --bg-accent2: #ffe7c2;
  --card: #ffffff;
  --muted: #4b4b63;
  --red: #ff4655;
  --blue: #3d8bfd;
  --yellow: #ffc93c;
  --green: #35d07f;
  --purple: #8c6bff;
  --track-bg: #eceefb;
  --choice-bg: #f5f6fd;
  --choice-hover-bg: #eceeff;
  --weak-bg: #fff0f1;
  --weak-text: #7a1a24;
  --ok-bg: #e3fff0;
  --bad-bg: #ffe9ea;
  --speech-bg: #fff9e8;
  --dashed: #d8dcf3;
  --border-w: 3px;
  --shadow-ink: 6px 6px 0 var(--ink);
  --shadow-ink-sm: 4px 4px 0 var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef0ff;
    --bg: #12131c;
    --bg2: #1b1f33;
    --bg-accent2: #3a2a1c;
    --card: #1c2036;
    --muted: #a6acc9;
    --red: #ff7b86;
    --blue: #7ab2ff;
    --yellow: #ffd875;
    --green: #57e3a0;
    --purple: #b09bff;
    --track-bg: #252a45;
    --choice-bg: #232842;
    --choice-hover-bg: #2b3152;
    --weak-bg: #3a1e22;
    --weak-text: #ffb3bb;
    --ok-bg: #173325;
    --bad-bg: #3a1f22;
    --speech-bg: #332a17;
    --dashed: #3a4066;
  }
}

:root[data-theme="dark"] {
  --ink: #eef0ff; --bg: #12131c; --bg2: #1b1f33; --bg-accent2: #3a2a1c; --card: #1c2036;
  --muted: #a6acc9; --red: #ff7b86; --blue: #7ab2ff; --yellow: #ffd875; --green: #57e3a0;
  --purple: #b09bff; --track-bg: #252a45; --choice-bg: #232842; --choice-hover-bg: #2b3152;
  --weak-bg: #3a1e22; --weak-text: #ffb3bb; --ok-bg: #173325; --bad-bg: #3a1f22;
  --speech-bg: #332a17; --dashed: #3a4066;
}
:root[data-theme="light"] {
  --ink: #14141f; --bg: #eef1fb; --bg2: #dfe4fb; --bg-accent2: #ffe7c2; --card: #ffffff;
  --muted: #4b4b63; --red: #ff4655; --blue: #3d8bfd; --yellow: #ffc93c; --green: #35d07f;
  --purple: #8c6bff; --track-bg: #eceefb; --choice-bg: #f5f6fd; --choice-hover-bg: #eceeff;
  --weak-bg: #fff0f1; --weak-text: #7a1a24; --ok-bg: #e3fff0; --bad-bg: #ffe9ea;
  --speech-bg: #fff9e8; --dashed: #d8dcf3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, var(--bg2) 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, var(--bg-accent2) 0%, transparent 40%),
    var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.mono { font-variant-numeric: tabular-nums; }

a { color: var(--blue); }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
}

/* ---------- Disclaimer bar ---------- */
.disclaimer-bar {
  background: var(--weak-bg);
  color: var(--weak-text);
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
}

/* ---------- Hero / header ---------- */
.hero {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-ink);
  padding: 18px 20px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hero h1 {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
  font-weight: 500;
}

.icon-btn {
  flex-shrink: 0;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.icon-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* ---------- Mascot ---------- */
.mascot-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
}

.mascot-avatar {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  border-radius: 18px;
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-ink-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  animation: bob 2.4s ease-in-out infinite;
}
.mascot-avatar.lv1 { background: linear-gradient(160deg, #b6ffd8, var(--green)); }
.mascot-avatar.lv2 { background: linear-gradient(160deg, #bfe0ff, var(--blue)); }
.mascot-avatar.lv3 { background: linear-gradient(160deg, #ffe08a, #ff9f43); }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

.speech-bubble {
  position: relative;
  background: var(--speech-bg);
  border: var(--border-w) solid var(--ink);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: var(--shadow-ink-sm);
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 12px 8px 0;
  border-style: solid;
  border-color: transparent var(--ink) transparent transparent;
}
.speech-bubble::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 7px 10px 7px 0;
  border-style: solid;
  border-color: transparent var(--speech-bg) transparent transparent;
}

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  border: var(--border-w) solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-ink-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
}
.stat-card.tile-level { background: linear-gradient(160deg, #e4f1ff, var(--blue)); }
.stat-card.tile-streak { background: linear-gradient(160deg, #ffe4c2, #ff9f43); }
.stat-card.tile-coins { background: linear-gradient(160deg, #f1e6ff, var(--purple)); color: #fff; }
.stat-card.tile-acc { background: linear-gradient(160deg, #d5ffe9, var(--green)); }

.stat-icon { font-size: 1.3rem; }
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.75;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
}

/* ---------- Weak note badge ---------- */
.weak-note {
  background: var(--weak-bg);
  border: var(--border-w) dashed var(--red);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--weak-text);
  margin-bottom: 6px;
}
.weak-note.intro { color: var(--ink); border-color: var(--blue); background: var(--choice-bg); }

/* ---------- Buttons (chunky press) ---------- */
.btn-primary, .btn-secondary {
  border: var(--border-w) solid var(--ink);
  border-radius: 14px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-ink-sm);
  transform: translate(0, 0);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-primary:active, .btn-secondary:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}
.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary { background: var(--yellow); color: var(--ink); }
.btn-secondary { background: var(--card); color: var(--ink); }

.cta-row {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  flex-wrap: wrap;
}

/* ---------- Settings row ---------- */
.settings-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}
.ghost-btn {
  background: transparent;
  border: 2px dashed var(--dashed);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.ghost-btn.danger { color: var(--red); border-color: var(--red); }
.ghost-btn.file-label { position: relative; }

/* ---------- Panel / stats ---------- */
.panel {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-ink);
  padding: 18px;
  margin-top: 8px;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 800;
  margin: 4px 0 12px;
}

.bar-list { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 100px;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.bar-label { color: var(--muted); }
.mini-lv { font-size: 0.68rem; opacity: 0.7; }

.bar-track {
  height: 12px;
  background: var(--track-bg);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  border-radius: 999px;
}

.bar-pct { color: var(--muted); text-align: right; }

.session-list { display: flex; flex-direction: column; gap: 6px; }
.session-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px dashed var(--dashed);
  padding: 6px 0;
}

.empty { color: var(--muted); font-size: 0.85rem; }

/* ---------- Quiz top row / progress ---------- */
.quiz-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.mode-badge {
  background: var(--choice-bg);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}
.mode-badge.timer { background: var(--yellow); }
.quit-btn { margin-left: auto; color: var(--red); border-color: var(--red); }

.progress-track {
  height: 16px;
  background: var(--track-bg);
  border: var(--border-w) solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: repeating-linear-gradient(45deg, var(--green), var(--green) 10px, #2fc074 10px, #2fc074 20px);
  transition: width 0.25s ease;
}
.progress-text {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin: 0 0 16px;
}

/* ---------- Question card ---------- */
.question-card {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-ink);
  padding: 22px;
}

.question-sentence {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.7;
  margin: 0 0 20px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  text-align: left;
  background: var(--choice-bg);
  border: var(--border-w) solid var(--ink);
  color: var(--ink);
  padding: 13px 16px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-ink-sm);
  transform: translate(0, 0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}
.choice-btn:hover:not(:disabled) { background: var(--choice-hover-bg); }
.choice-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.choice-btn:disabled { cursor: default; }
.choice-btn.correct {
  background: var(--green);
  color: #063a20;
  animation: pop 0.35s ease;
}
.choice-btn.incorrect {
  background: var(--red);
  color: #390509;
  animation: shake 0.4s ease;
}
.chk-icon { font-weight: 900; margin-right: 2px; }

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.feedback {
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: 14px;
  border: var(--border-w) solid var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
}
.feedback.ok, .feedback.bad { display: block; }
.feedback.ok { background: var(--ok-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback-title { font-weight: 800; margin: 0 0 4px; font-size: 0.98rem; }
.feedback-explain { margin: 0; color: var(--muted); font-weight: 500; }

#nextBtn { margin-top: 16px; width: 100%; justify-content: center; }

/* ---------- Result screen ---------- */
.result-card {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-ink);
  padding: 26px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.trophy {
  font-size: 3rem;
  animation: bob 1.8s ease-in-out infinite;
}
.result-card h1 { font-weight: 800; margin: 6px 0; text-wrap: balance; }
.result-score {
  font-size: 1.9rem;
  font-weight: 800;
  margin: 8px 0;
  color: var(--purple);
}
.result-time { color: var(--muted); font-size: 0.85rem; font-weight: 700; margin: 0 0 8px; }
.disclaimer-box {
  background: var(--track-bg);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 10px 0 18px;
}
.result-estimate {
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 4px;
}
.disclaimer { font-size: 0.72rem; color: var(--muted); margin: 0; font-weight: 500; }
.result-card .bar-list { text-align: left; margin-top: 12px; }
.result-card .cta-row { justify-content: center; }
.nudge {
  background: var(--speech-bg);
  border: 2px dashed var(--yellow);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 16px;
  text-align: left;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  animation: fall linear forwards;
  pointer-events: none;
}
.confetti-c1 { color: var(--yellow); }
.confetti-c2 { color: var(--purple); }
.confetti-c3 { color: var(--blue); }
.confetti-c4 { color: var(--green); }
.confetti-c5 { color: var(--red); }
@keyframes fall {
  to { transform: translateY(340px) rotate(360deg); opacity: 0; }
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 2px dashed var(--dashed);
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}
.footer-links a { color: var(--muted); text-decoration: underline; margin: 0 4px; }

/* ---------- Legal pages ---------- */
.legal-card {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-ink);
  padding: 22px;
}
.legal-card h1 { font-size: 1.3rem; margin: 8px 0 14px; }
.legal-card ul { padding-left: 20px; color: var(--muted); font-size: 0.88rem; line-height: 1.7; }
.legal-card li { margin-bottom: 8px; }
.back-link { font-size: 0.82rem; font-weight: 700; text-decoration: none; }

/* ---------- Onboarding overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-ink);
  padding: 24px;
  max-width: 380px;
  width: 100%;
}
.modal h2 { margin: 0 0 10px; }
.onb-list { padding-left: 18px; font-size: 0.85rem; color: var(--muted); line-height: 1.7; margin: 0 0 18px; }
.modal .btn-primary { width: 100%; justify-content: center; }

@media (min-width: 480px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Drill mode ---------- */
.drill-intro {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.6;
}
.cat-pick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.cat-pick-btn {
  background: var(--choice-bg);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
}
.cat-pick-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

.streak-dots {
  letter-spacing: 2px;
  color: var(--purple);
  font-weight: 700;
}

@media (min-width: 480px) {
  .cat-pick-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Custom icon set ---------- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}
.icon svg { display: block; }

.icon-sm { font-size: 0.85em; }
.icon-lg { font-size: 1.5em; }
.icon-xl { font-size: 2.2em; }
.icon-2xl { font-size: 3rem; }

.mascot-avatar .icon { font-size: 2.3rem; color: var(--ink); }
.trophy .icon { color: var(--yellow); }
.brand-logo { font-size: 1.6rem; margin-right: 2px; }

.confetti-piece svg { display: block; }

