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

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #18181f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f0f5;
  --text-2: #9898b0;
  --text-3: #8b8ba7;
  --accent: #5865f2;
  --accent-h: #4752c4;
  --accent-glow: rgba(88, 101, 242, 0.25);
  --green: #3ecf8e;
  --green-bg: rgba(62, 207, 142, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --gold: #f5a524;
  --gold-bg: rgba(245, 165, 36, 0.12);
  --radius: 12px;
  --radius-lg: 18px;
}

body {
  /* 'Noto Sans SC'는 unicode-range로 CJK 한자 범위만 cover하므로,
     한자만 SC 자형으로 렌더되고 한국어/라틴은 그대로 다음 fallback이 처리한다. */
  font-family: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 40px;
}

#user-status-widget {
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

#user-track-label {
  font-weight: 800;
  color: var(--green);
}

#widget-user-email {
  color: var(--text-3);
  font-weight: 500;
}

#user-status-widget button {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

#user-status-widget button:hover {
  background: rgba(248, 113, 113, 0.25);
}

.app {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
}

/* ─── SCREEN ─────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  animation: fadeUp 0.22s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── NAVBAR ─────────────────────────────── */
.navbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.navbar.show {
  display: flex;
}

.navbar-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.navbar-back:hover {
  background: var(--surface);
  color: var(--text);
}

.navbar-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}

/* ─── TYPOGRAPHY ────────────────────────── */
h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 17px;
  font-weight: 600;
}

p.lead {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-accent {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border);
}

.badge-gold {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid rgba(245, 165, 36, 0.3);
}

.badge-green {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(62, 207, 142, 0.3);
}

/* ─── BUTTONS ───────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-btn-text, #fff);
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 14px;
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-gold {
  background: var(--gold);
  color: #000;
  font-weight: 700;
}

.btn-gold:hover {
  background: #e09810;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
  border-radius: 8px;
}

/* ─── CARD ───────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card+.card {
  margin-top: 12px;
}

/* ─── DIVIDER ───────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── HERO CARD ──────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.12), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(88, 101, 242, 0.2);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 24px;
}

/* ─── SUBJECT CARDS (main menu) ─────────── */
.subject-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  width: 100%;
}

.subject-card:hover {
  border-color: var(--border-strong);
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.subject-card+.subject-card {
  margin-top: 10px;
}

.subject-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.subject-info {
  flex: 1;
}

.subject-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 3px;
}

.subject-desc {
  font-size: 13px;
  color: var(--text-2);
}

.subject-arrow {
  color: var(--text-3);
  font-size: 18px;
}

/* ─── MODE CARDS (history hub) ─────────── */
.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.mode-card:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface2), rgba(88, 101, 242, 0.08));
  transform: translateY(-2px);
  box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.3);
}

.mode-card+.mode-card {
  margin-top: 12px;
}

/* grid-2 내부 카드는 sibling 마진 무효화 (grid gap으로 처리) */
.grid-2 .mode-card+.mode-card {
  margin-top: 0;
}

.mode-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.mode-info {
  flex: 1;
}

.mode-title {
  font-size: 15px;
  font-weight: 600;
}

.mode-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ─── PRICING ───────────────────────────── */
.pricing-box {
  background: linear-gradient(135deg, rgba(88, 101, 242, 0.08), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(88, 101, 242, 0.25);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}

.pricing-price {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.pricing-price span {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-2);
  vertical-align: middle;
  margin-left: 4px;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-2);
}

.feature-item .check {
  color: var(--green);
  font-weight: 700;
}

/* ─── PROGRESS BAR ──────────────────────── */
.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ─── HISTORY SUMMARY ───────────────────── */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255, 255, 255, 0.01);
  margin-bottom: 16px;
}

.chapter-list::-webkit-scrollbar {
  width: 6px;
}

.chapter-list::-webkit-scrollbar-track {
  background: transparent;
}

.chapter-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius);
}


.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
}

.chapter-item:hover {
  background: var(--surface2);
  border-color: var(--border-strong);
}

.chapter-item.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: #ffffff;
}

.chapter-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  min-width: 22px;
}

.summary-box {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.85;
  max-height: 50vh;
  overflow-y: auto;
  display: none;
}

.summary-box.show {
  display: block;
}

.summary-box strong {
  color: var(--text);
}

/* ─── QUIZ ──────────────────────────────── */
.quiz-q {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 20px;
  color: var(--text);
}

.quiz-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-opt {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
  text-align: left;
}

.quiz-opt:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.quiz-opt.correct {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

.quiz-opt.wrong {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

.quiz-opt.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: #ffffff;
  transform: scale(1.02);
}

.quiz-feedback {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  display: none;
}

.quiz-feedback.correct {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(62, 207, 142, 0.2);
}

.quiz-feedback.wrong {
  background: var(--red-bg);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.quiz-select-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.quiz-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-filter-chip {
  width: auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.quiz-filter-chip:hover,
.quiz-filter-chip.active {
  border-color: rgba(88, 101, 242, 0.45);
  background: var(--accent-glow);
  color: #c7d2fe;
}

.quiz-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-card+.stat-card {
  margin-top: 8px;
}

.stat-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

.stat-mini {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.stat-bar {
  height: 7px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
}

.wrong-item-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 8px;
}

.flashcard-recommend-box {
  border-color: rgba(245, 165, 36, 0.35);
  background: linear-gradient(135deg, rgba(245, 165, 36, 0.08), rgba(88, 101, 242, 0.08));
}

/* fallback label/main/sub inside non-flip context */
.flashcard-label-plain {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
}

.flashcard-main-plain {
  color: var(--text);
  font-size: 36px;
  font-weight: 800;
  line-height: 1.45;
}

.flashcard-sub-plain {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
}

/* ─── MATCH GAME ────────────────────────── */
/* (styles consolidated above in CHINESE MODULE section) */

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  25% {
    transform: translateX(-5px)
  }

  75% {
    transform: translateX(5px)
  }
}

/* ─── CHINESE PRACTICE ──────────────────── */
#s-cn-practice.active {
  display: flex;
}
#s-cn-practice {
  gap: 16px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
}

.timer-val {
  font-variant-numeric: tabular-nums;
}

.timer-val.over {
  color: var(--red);
}

.instruction {
  font-size: 14px;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 16px;
  min-height: 20px;
}

.instruction.good {
  color: var(--green);
}

.instruction.bad {
  color: var(--red);
}

.word-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  margin-bottom: 10px;
}

.word-area.selected-area {
  border-style: dashed;
  border-color: rgba(88, 101, 242, 0.3);
}

.word-chip-cn {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
  position: relative;
}

.word-chip-cn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.word-chip-cn.placeholder {
  visibility: hidden;
  pointer-events: none;
}

.answer-box {
  background: var(--green-bg);
  border: 1px solid rgba(62, 207, 142, 0.2);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: none;
  margin-bottom: 16px;
}

.answer-box.show {
  display: block;
}

.pinyin {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}

.korean {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}

.btn-tts {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(62, 207, 142, 0.15);
  border: 1px solid rgba(62, 207, 142, 0.25);
  color: var(--green);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
  font-weight: 600;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ─── RESULTS ───────────────────────────── */
.result-time {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
}

/* ─── LEADERBOARD ───────────────────────── */
.lb-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lb-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.lb-input:focus {
  border-color: var(--accent);
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 14px;
}

.lb-rank {
  font-size: 18px;
  width: 28px;
  flex-shrink: 0;
  text-align: center;
}

.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.lb-score {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.lb-score.good {
  color: var(--green);
}

.lb-score.bad {
  color: var(--red);
}

/* ─── LOADER ────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── BLANK BOX (Active Recall) ─────────── */
.blank-box {
  display: inline-block;
  background: rgba(88, 101, 242, 0.1);
  border: 1px dashed var(--accent);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  margin: 0 2px;
  transition: all 0.15s ease;
  user-select: none;
  font-size: 0.95em;
}

.blank-box:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.blank-box.revealed {
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid var(--green);
  color: var(--green);
}

.hidden {
  display: none !important;
}

.mt-4 {
  margin-top: 4px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.mt-32 {
  margin-top: 32px;
}

.mb-4 {
  margin-bottom: 4px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-10 {
  margin-bottom: 10px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

.mb-24 {
  margin-bottom: 24px;
}

/* screen 내부 하단 여백 */
.screen.active {
  padding-bottom: 40px;
}

.mode-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  margin: 20px 0 8px 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card-sm {
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.mode-card-sm:hover {
  background: linear-gradient(135deg, var(--surface2), rgba(88, 101, 242, 0.08));
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 16px -6px rgba(0, 0, 0, 0.25);
}

.mode-card-sm .mode-icon {
  font-size: 18px;
  margin-bottom: 4px;
}

.mode-card-sm .mode-title {
  font-size: 14px;
  font-weight: 700;
}

/* ─── CHINESE MODULE: PREMIUM UI OVERHAUL ──────────────────── */

/* 1. 플립 카드 - 더 세련되게 */
.flashcard {
  perspective: 1200px;
  cursor: pointer;
  height: 280px;
  width: 100%;
  position: relative;
  margin: 20px 0;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  transform-origin: center;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface2), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard-label {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.flashcard-main {
  font-size: 48px;
  font-weight: 900;
  color: var(--text);
}

.flashcard-sub {
  color: var(--text-3);
  font-size: 14px;
  margin-top: 16px;
  font-weight: 500;
}

/* 2. 매칭 게임 & 테스트 UI */
.match-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.match-chip {
  padding: 14px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  line-height: 1.4;
}

.match-chip:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-2px);
}

.match-chip.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(1.02);
}

.match-chip.matched {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
  opacity: 0.7;
}

.match-chip.error {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
  animation: shake 0.3s;
}

/* 3. 버튼들 - 플랫폼 통일 */
#s-pinyin-test button,
#s-pinyin-study button,
#s-perf-test button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 12px;
  font-size: 15px;
}

#s-pinyin-test button:hover,
#s-pinyin-study button:hover,
#s-perf-test button:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

#btn-check-test {
  background: var(--accent) !important;
  color: white !important;
  border: none !important;
}

#btn-check-test:hover {
  background: var(--accent-h) !important;
}

.star-active {
  color: var(--accent);
}

/* ─── PERFORMANCE TEST (EXAM) ──────────────── */
.exam-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
  margin-bottom: 20px;
}

.exam-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.exam-label-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
  margin-top: -4px;
}

.exam-q-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.exam-q-row:last-child {
  margin-bottom: 0;
}

.exam-q-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.exam-input {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.exam-input:focus {
  border-color: var(--accent);
}

.word-pool-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  min-height: 50px;
}

.exam-word-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}

.exam-word-chip:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.exam-word-chip.used {
  opacity: 0.3;
  pointer-events: none;
  border-style: dashed;
}

.exam-answer-slot {
  background: var(--surface2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.exam-answer-slot:hover {
  border-color: var(--accent);
}

/* ─── LEADERBOARD RANK STYLES ──────────────── */
.lb-item.rank-gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 215, 0, 0.05));
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.15);
}
.lb-item.rank-gold .lb-name {
  color: #ffd700;
  font-weight: 800;
}
.lb-item.rank-silver {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05));
  border: 1px solid rgba(192, 192, 192, 0.3);
}
.lb-item.rank-silver .lb-name {
  color: #e2e8f0;
  font-weight: 750;
}
.lb-item.rank-bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05));
  border: 1px solid rgba(205, 127, 50, 0.3);
}
.lb-item.rank-bronze .lb-name {
  color: #fca5a5;
  font-weight: 700;
}

/* Hanzi Slide Study Styles */
.hanzi-slide-card-container {
  display: flex;
  flex-direction: column;
  height: 340px;
  width: 100%;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface2), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  position: relative;
  margin: 20px 0;
}

.hanzi-slide-top {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
  padding: 20px;
}

#hanzi-slide-char {
  font-size: 72px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* 중국어 한자 자형(간체) — 한국어 시스템 폰트가 한자를 한국 자형으로 그리는 문제 회피.
   !important로 weight mismatch 시 fallback이 한국어 폰트로 새지 않도록 강제. */
.hanzi,
:lang(zh-Hans),
:lang(zh-CN) {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', sans-serif !important;
}

.hanzi-slide-bottom {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
}

.hanzi-slide-answer-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: rgba(62, 207, 142, 0.03);
}

.hanzi-slide-pinyin {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  text-align: center;
  width: 100%;
  /* 병음(라틴+성조 결합 글리프) 전용 폰트 강제 — Noto Sans SC fallback이
     combining diacritical mark를 잘못된 위치에 그리지 않게 차단. */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: none;
}

.hanzi-slide-meaning {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hanzi-slide-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #2d2d3d, #1f1f2e);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.15s ease-out, background-color 0.3s;
  z-index: 10;
}

.hanzi-slide-cover:active {
  cursor: grabbing;
}

.hanzi-slide-cover.sliding-down {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hanzi-slide-cover-handle {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  position: absolute;
  top: 12px;
}

.hanzi-slide-cover-text {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 600;
  text-align: center;
  padding: 0 20px;
  animation: pulseGhost 2s infinite ease-in-out;
}

@keyframes pulseGhost {
  0%, 100% { opacity: 0.7; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(2px); }
}


body.light-mode {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface2: #f1f3f5;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #212529;
  --text-2: #495057;
  --text-3: #868e96;
  --accent: #4c6ef5;
  --accent-h: #3b5bdb;
  --accent-glow: rgba(76, 110, 245, 0.25);
  --green: #2b8a3e;
  --green-bg: rgba(43, 138, 62, 0.1);
  --red: #e03131;
  --red-bg: rgba(224, 49, 49, 0.1);
  --gold: #f08c00;
  --gold-bg: rgba(240, 140, 0, 0.12);
}


.light-mode {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f0f0f5;
  --surface3: #e5e5f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-2: #48484a;
  --text-3: #86868b;
  --accent: #007aff;
  --accent-h: #0056b3;
  --accent-glow: rgba(0, 122, 255, 0.15);
  --green: #28a745;
  --green-bg: rgba(40, 167, 69, 0.1);
  --red: #dc3545;
  --red-bg: rgba(220, 53, 69, 0.1);
  --gold: #f5a623;
  --gold-bg: rgba(245, 166, 35, 0.1);
}
