/* ============================================================================
   LONG VẬN (HANFLOW) — Neo-Ink Xuan-Jade Design System
   Dark obsidian ink base, glowing 5-tone cognitive color coding, crisp Chinese
   calligraphy typography, and tactile arcade responsiveness.
   ============================================================================ */

:root {
  --bg-deep: #060911;
  --bg-surface: rgba(14, 20, 34, 0.84);
  --bg-card: rgba(19, 27, 45, 0.86);
  --bg-card-hover: rgba(28, 39, 64, 0.94);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);

  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;

  /* 5-Tone Cognitive Color Palette */
  --t1: #38bdf8;
  --t2: #10f5a0;
  --t3: #fbbf24;
  --t4: #ff4769;
  --t5: #cbd5e1;

  --jade: #10f5a0;
  --gold: #fbbf24;
  --vermilion: #ff4769;
  --cyan: #38bdf8;
  --violet: #a78bfa;

  --font-ui: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;
  --font-zh: "Noto Serif SC", "Noto Sans SC", "Microsoft YaHei", serif;
  --font-zh-sans: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 55% at 18% 0%, rgba(16, 245, 160, 0.085), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 10%, rgba(255, 71, 105, 0.085), transparent 60%),
    radial-gradient(ellipse 65% 60% at 50% 100%, rgba(56, 189, 248, 0.07), transparent 65%);
  color: var(--text-main);
  font-family: var(--font-ui);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.fever-mode {
  background-image:
    radial-gradient(ellipse 85% 60% at 20% 0%, rgba(251, 191, 36, 0.16), transparent 60%),
    radial-gradient(ellipse 80% 55% at 85% 10%, rgba(255, 71, 105, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(251, 191, 36, 0.11), transparent 65%);
}

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

#app-shell {
  position: relative;
  z-index: 10;
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 20px 36px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Tone Coloring Classes */
.tone-t1 { color: var(--t1); }
.tone-t2 { color: var(--t2); }
.tone-t3 { color: var(--t3); }
.tone-t4 { color: var(--t4); }
.tone-t5 { color: var(--t5); }

.tone-border-1 { border-color: rgba(56, 189, 248, 0.65) !important; box-shadow: 0 0 18px rgba(56, 189, 248, 0.22); }
.tone-border-2 { border-color: rgba(16, 245, 160, 0.65) !important; box-shadow: 0 0 18px rgba(16, 245, 160, 0.22); }
.tone-border-3 { border-color: rgba(251, 191, 36, 0.65) !important; box-shadow: 0 0 18px rgba(251, 191, 36, 0.22); }
.tone-border-4 { border-color: rgba(255, 71, 105, 0.65) !important; box-shadow: 0 0 18px rgba(255, 71, 105, 0.22); }
.tone-border-5 { border-color: rgba(203, 213, 225, 0.55) !important; }

/* Micro Screen Shake */
@keyframes shakeSm {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, -1px); }
}
@keyframes shakeLg {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -4px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(5px, 2px); }
}
.shake-sm { animation: shakeSm 0.22s ease; }
.shake-lg { animation: shakeLg 0.3s ease; }

/* ==================== TOP NAVIGATION ==================== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-seal {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, #d91c43, #ff4769);
  border: 2px solid rgba(251, 191, 36, 0.7);
  box-shadow: 0 0 18px rgba(255, 71, 105, 0.35);
  display: grid;
  place-items: center;
  font-family: var(--font-zh);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 1px;
  color: #fff;
  line-height: 1;
}

.brand-name {
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.6px;
}
.brand-sub {
  font-weight: 700;
  font-size: 12px;
  color: var(--jade);
  margin-left: 5px;
  letter-spacing: 1.5px;
}
.brand-tagline {
  font-size: 11.5px;
  color: var(--text-dim);
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-btn {
  position: relative;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  padding: 8px 15px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.nav-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}
.nav-btn.active {
  color: #061018;
  background: linear-gradient(135deg, var(--jade), #38bdf8);
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(16, 245, 160, 0.28);
}

.due-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--vermilion);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Bilingual VI / EN Switcher Pill */
.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.lang-btn:hover {
  color: var(--text-main);
}
.lang-btn.active {
  background: linear-gradient(135deg, var(--gold), #fb923c);
  color: #0b0f19;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.xp-pill { color: var(--gold); border-color: rgba(251, 191, 36, 0.32); }
.streak-pill { color: #fb923c; border-color: rgba(251, 146, 60, 0.32); }

/* ==================== BUTTONS & SHARED CONTROLS ==================== */
.btn {
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--jade), #22d3ee);
  color: #05131a;
  box-shadow: 0 4px 20px rgba(16, 245, 160, 0.28);
}
.btn-primary:hover {
  box-shadow: 0 6px 26px rgba(16, 245, 160, 0.45);
  transform: translateY(-1px);
}

.btn-hero {
  width: 100%;
  padding: 13px 18px;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  background: linear-gradient(135deg, #fbbf24, #ff4769);
  color: #fff;
  box-shadow: 0 6px 28px rgba(255, 71, 105, 0.36);
}
.btn-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 34px rgba(255, 71, 105, 0.5);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.icon-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.icon-pill:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: var(--border-strong);
}
.danger-pill:hover {
  border-color: rgba(255, 71, 105, 0.65);
  color: var(--vermilion);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: #e2e8f0;
}

.mini-select, .search-input {
  background: rgba(10, 15, 27, 0.9);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 9px;
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
}
.mini-select:focus, .search-input:focus {
  border-color: var(--cyan);
}

/* ==================== HUB VIEW ==================== */
.hero-panel {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(16, 24, 42, 0.92), rgba(22, 18, 36, 0.88));
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  margin-bottom: 22px;
}

.hero-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--jade);
  margin-bottom: 6px;
}
.hero-title {
  margin: 0 0 10px;
  font-size: 25px;
  font-weight: 900;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-zh {
  font-family: var(--font-zh);
  font-size: 22px;
  color: var(--gold);
  opacity: 0.9;
}

.hero-xp-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 6px;
}
.hero-xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--jade), var(--gold));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.hero-xp-caption {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.tone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  font-weight: 700;
}

.hero-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpi-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 8px;
  text-align: center;
}
.kpi-val {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}
.kpi-lbl {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.hub-section {
  margin-bottom: 22px;
}
.section-head h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.sec-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

/* 7 Realms Grid */
.realms-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.realm-card {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 11px 10px;
  color: var(--text-main);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.realm-card:hover {
  transform: translateY(-2px);
  border-color: var(--realm-color);
  background: var(--bg-card-hover);
}
.realm-card.active {
  border-color: var(--realm-color);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(15, 22, 38, 0.95));
  box-shadow: 0 0 0 1px var(--realm-color), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.realm-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.realm-zh {
  font-family: var(--font-zh);
  font-size: 20px;
  font-weight: 900;
  color: var(--realm-color);
  white-space: nowrap;
}
.realm-lvl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.realm-code {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  margin-top: 2px;
}
.realm-name {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.3;
  min-height: 30px;
}
.realm-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.realm-bar-fill {
  height: 100%;
  background: var(--realm-color);
  border-radius: 999px;
}
.realm-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.active-realm-banner {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.arb-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  flex-shrink: 0;
}
.arb-desc {
  color: var(--text-dim);
  margin-left: auto;
}

/* 5 Mode Cards */
.modes-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.mode-card {
  position: relative;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  color: var(--text-main);
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.mode-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--mode-accent);
  opacity: 0.85;
}
.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--mode-accent);
  background: var(--bg-card-hover);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
}

.mode-card-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.mode-name {
  font-size: 15.5px;
  font-weight: 800;
}
.mode-zh {
  font-family: var(--font-zh);
  font-size: 13px;
  color: var(--mode-accent);
  margin-left: 4px;
}
.mode-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--mode-accent);
  margin-top: 2px;
}
.mode-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.48;
  flex: 1;
}
.mode-cta {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--mode-accent);
}
.mode-alert {
  align-self: flex-start;
  background: rgba(255, 71, 105, 0.2);
  border: 1px solid rgba(255, 71, 105, 0.55);
  color: #fda4af;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Bottom Quests & Seals */
.hub-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 16px;
}

.glass-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  backdrop-filter: blur(12px);
}
.panel-title {
  margin: 0 0 12px;
  font-size: 15.5px;
  font-weight: 800;
}
.panel-note {
  margin: -6px 0 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quest-item {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
}
.quest-item.quest-done {
  border-color: rgba(16, 245, 160, 0.45);
  background: rgba(16, 245, 160, 0.07);
}
.quest-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.quest-reward {
  color: var(--gold);
  font-weight: 800;
  font-family: var(--font-mono);
}
.quest-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.quest-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.quest-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--jade), var(--cyan));
}
.quest-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.seals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.seal-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}
.seal-chip.locked {
  opacity: 0.45;
  filter: grayscale(0.8);
}
.seal-chip.unlocked {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.07);
}
.seal-stamp {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: linear-gradient(135deg, #be123c, #ff4769);
  border: 1.5px solid rgba(251, 191, 36, 0.7);
  display: grid;
  place-items: center;
  font-family: var(--font-zh);
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.seal-name { font-size: 12.5px; font-weight: 700; }
.seal-desc { font-size: 11px; color: var(--text-dim); line-height: 1.3; }

/* ==================== PLAY VIEW & HUD ==================== */
.play-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hud-title {
  font-weight: 800;
  font-size: 16px;
}
.hud-zh {
  font-family: var(--font-zh);
  color: var(--gold);
  font-size: 14px;
  margin-left: 4px;
}
.hud-realm-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  border: 1px solid var(--pill-accent, var(--cyan));
  color: var(--pill-accent, var(--cyan));
  background: rgba(255, 255, 255, 0.04);
}
.hud-center {
  flex: 1;
  max-width: 280px;
  min-width: 140px;
}
.hud-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  overflow: hidden;
}
.hud-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--jade));
  transition: width 0.25s ease;
}
.hud-progress-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.hud-lives {
  display: flex;
  gap: 5px;
  font-size: 18px;
}
.heart.alive {
  color: var(--vermilion);
  text-shadow: 0 0 12px rgba(255, 71, 105, 0.65);
}
.heart.lost {
  color: rgba(148, 163, 184, 0.25);
}

.hud-combo-box, .hud-score-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.hud-lbl {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.hud-combo {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 800;
  color: var(--cyan);
}
.hud-combo.combo-hot { color: var(--gold); }
.hud-combo.combo-fever {
  color: var(--vermilion);
  text-shadow: 0 0 16px rgba(255, 71, 105, 0.8);
}
.hud-score {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 800;
  color: var(--text-main);
}

.play-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mode-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 7px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn.active {
  background: rgba(56, 189, 248, 0.22);
  color: var(--cyan);
}

.pill-tag {
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ==================== MODE 1: HÁN TỰ TRẢM ==================== */
.echo-ribbon {
  min-height: 38px;
  padding: 8px 14px;
  background: rgba(16, 245, 160, 0.06);
  border: 1px solid rgba(16, 245, 160, 0.22);
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.echo-hint { color: var(--text-dim); }
.echo-hanzi { font-family: var(--font-zh); font-size: 18px; font-weight: 900; color: #fff; }
.echo-py { font-weight: 700; }
.echo-hv { color: var(--gold); font-weight: 700; font-size: 12px; }
.echo-vi { color: var(--text-main); font-weight: 600; }
.echo-parts { color: var(--text-dim); font-size: 12px; }
.echo-bonus {
  margin-left: auto;
  background: rgba(251, 191, 36, 0.18);
  color: var(--gold);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
}

.slash-arena {
  position: relative;
  height: 345px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 25%, rgba(56, 189, 248, 0.08), transparent 65%),
    rgba(9, 14, 26, 0.92);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
body.fever-mode .slash-arena {
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: 0 0 36px rgba(251, 191, 36, 0.22) inset;
}

.arena-lane {
  border-right: 1px dashed rgba(148, 163, 184, 0.08);
}
.arena-lane:last-of-type { border-right: none; }

.fever-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 5px;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.28), rgba(255, 71, 105, 0.35), transparent);
  color: var(--gold);
  opacity: 0;
  transform: translateY(-100%);
  transition: all 0.3s ease;
  z-index: 6;
}
.fever-banner.active {
  opacity: 1;
  transform: translateY(0);
}

.orb-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.hanzi-orb {
  position: absolute;
  top: 0;
  min-width: 190px;
  max-width: 310px;
  padding: 16px 26px;
  border-radius: 20px;
  background: radial-gradient(circle at 30% 20%, rgba(30, 41, 66, 0.96), rgba(11, 17, 30, 0.96));
  border: 2px solid var(--orb-color, var(--cyan));
  box-shadow: 0 0 28px color-mix(in srgb, var(--orb-color, #38bdf8) 38%, transparent), 0 12px 30px rgba(0, 0, 0, 0.55);
  text-align: center;
  will-change: transform;
  transition: opacity 0.16s ease, filter 0.16s ease;
}
.hanzi-orb.orb-danger {
  border-color: var(--vermilion);
  box-shadow: 0 0 36px rgba(255, 71, 105, 0.65);
}
.hanzi-orb.orb-slashed {
  opacity: 0;
  filter: brightness(2.5) blur(4px);
}

.orb-main-zh {
  font-family: var(--font-zh);
  font-size: clamp(2.4rem, 4.4vw, 3.5rem);
  font-weight: 900;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 0 20px color-mix(in srgb, var(--orb-color, #38bdf8) 45%, transparent);
}
.orb-main-vi {
  font-size: 21px;
  font-weight: 800;
  color: #fff;
}
.orb-sub-py {
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}
.orb-sub-vi {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 4px;
}
.orb-sub-hv {
  font-size: 12.5px;
  color: var(--gold);
  margin-top: 4px;
  font-weight: 600;
}
.orb-audio-pulse {
  font-size: 40px;
  animation: pulseGlow 1.2s infinite ease-in-out;
}
@keyframes pulseGlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.defense-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 44px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--vermilion), var(--gold), var(--vermilion), transparent);
  box-shadow: 0 0 14px rgba(255, 71, 105, 0.7);
  z-index: 3;
}
.defense-tag {
  position: absolute;
  right: 16px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: rgba(255, 71, 105, 0.85);
}

/* Memory Lock Overlay on Mistake */
.memory-lock {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(6, 9, 17, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 6px;
}
.ml-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 1px;
}
.ml-hanzi {
  font-family: var(--font-zh);
  font-size: 56px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
}
.ml-pinyin { font-size: 21px; font-weight: 800; }
.ml-meaning { font-size: 18px; font-weight: 700; color: var(--jade); }
.ml-meta { font-size: 13.5px; color: var(--text-dim); max-width: 580px; margin-top: 4px; }

/* Choice Cards Grid (Shared by Slash & Boss) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 76px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  color: var(--text-main);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.14s ease;
}
.choice-card:hover {
  border-color: var(--cyan);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}
.choice-card .choice-key {
  position: absolute;
  top: 8px;
  left: 10px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-dim);
  display: grid;
  place-items: center;
}
.choice-main {
  font-size: 17px;
  font-weight: 700;
}
.choice-zh .choice-main {
  font-family: var(--font-zh);
  font-size: 30px;
  font-weight: 900;
}
.choice-sub {
  font-size: 12.5px;
  color: var(--text-dim);
}
.choice-card.choice-correct {
  border-color: var(--jade) !important;
  background: rgba(16, 245, 160, 0.18) !important;
  box-shadow: 0 0 22px rgba(16, 245, 160, 0.3);
}
.choice-card.choice-wrong {
  border-color: var(--vermilion) !important;
  background: rgba(255, 71, 105, 0.2) !important;
}

/* Pro Typing Deck */
.typing-deck {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 18px;
}
.typing-prompt {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.typing-row {
  display: flex;
  gap: 10px;
}
.typing-input {
  flex: 1;
  background: rgba(6, 9, 17, 0.9);
  border: 2px solid var(--border-strong);
  border-radius: 11px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  outline: none;
}
.typing-input:focus { border-color: var(--cyan); }
.typing-input.input-ok { border-color: var(--jade); box-shadow: 0 0 18px rgba(16, 245, 160, 0.35); }
.typing-input.input-wrong { border-color: var(--vermilion); }

/* ==================== MODE 2: THANH ĐIỆU ĐẠO ==================== */
.tone-stage {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
}
.tone-word-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.tone-meaning {
  font-size: 19px;
  font-weight: 800;
}
.badge-hv {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.14);
  color: var(--gold);
}
.tone-syllables {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.syl-box {
  min-width: 84px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 2px solid var(--border);
  transition: all 0.18s ease;
}
.syl-box.syl-active {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.08);
  transform: translateY(-3px);
}
.syl-zh {
  font-family: var(--font-zh);
  font-size: 40px;
  font-weight: 900;
  line-height: 1.1;
}
.syl-py {
  font-size: 17px;
  font-weight: 700;
  margin-top: 4px;
}
.syl-badge {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  font-weight: 700;
}
.tone-tip {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 22px;
}
.tone-complete-msg { color: var(--jade); font-weight: 700; }
.tone-hint-miss { color: #fda4af; }

.tone-canvas-wrap {
  position: relative;
  background: rgba(8, 13, 24, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  min-height: 210px;
  overflow: hidden;
}
#tone-pitch-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.pitch-axis {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
  pointer-events: none;
}

.tone-pads {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.tone-pad {
  position: relative;
  padding: 14px 10px;
  border-radius: 15px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  color: var(--text-main);
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.14s ease;
}
.tone-pad:hover {
  border-color: var(--pad-color);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.tone-pad .choice-key {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.tone-svg { width: 74px; height: 36px; }
.tone-pad-title { font-size: 14.5px; font-weight: 800; color: var(--pad-color); }
.tone-mark { font-size: 17px; }
.tone-pad-desc { font-size: 11.5px; color: var(--text-dim); }
.tone-pad.pad-dim { opacity: 0.48; }
.tone-pad.pad-ok { background: rgba(16, 245, 160, 0.18); border-color: var(--jade); }
.tone-pad.pad-wrong { background: rgba(255, 71, 105, 0.2); border-color: var(--vermilion); }

/* ==================== MODE 3: BỘ THỦ HỢP NHẤT ==================== */
.forge-stage {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
}
.forge-target-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.forge-family-tag {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  background: rgba(251, 191, 36, 0.14);
  color: var(--gold);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.forge-meaning { font-size: 22px; font-weight: 900; }
.forge-story { font-size: 14.5px; color: var(--text-dim); line-height: 1.55; }

.forge-crucible {
  position: relative;
  min-height: 205px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.1), rgba(8, 12, 22, 0.94) 68%);
  border: 1.5px solid rgba(251, 191, 36, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}
.forge-crucible.forge-lit {
  border-color: var(--jade);
  box-shadow: 0 0 36px rgba(16, 245, 160, 0.28);
}
.forge-crucible.forge-error {
  border-color: var(--vermilion);
}
.crucible-ring {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1.5px dashed rgba(251, 191, 36, 0.22);
  animation: slowSpin 26s linear infinite;
  pointer-events: none;
}
@keyframes slowSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.forge-equation {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
}
.rune-slot {
  width: 74px;
  height: 74px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px dashed rgba(251, 191, 36, 0.45);
  display: grid;
  place-items: center;
  font-family: var(--font-zh);
  font-size: 36px;
  font-weight: 900;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.rune-slot.filled {
  border-style: solid;
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
  transform: scale(1.06);
}
.forge-op {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dim);
}
.forge-result-box {
  width: 112px;
  height: 112px;
  border-radius: 22px;
  background: rgba(6, 10, 20, 0.9);
  border: 2px solid rgba(56, 189, 248, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.result-placeholder {
  font-family: var(--font-zh);
  font-size: 38px;
  color: rgba(148, 163, 184, 0.25);
}
.forged-hanzi {
  font-family: var(--font-zh);
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
}
.forged-py {
  font-size: 14px;
  font-weight: 800;
  margin-top: 2px;
}

.forge-stamp {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 2px solid var(--vermilion);
  color: var(--vermilion);
  font-family: var(--font-zh);
  font-size: 18px;
  font-weight: 900;
  transform: rotate(-10deg);
  background: rgba(255, 71, 105, 0.12);
  animation: stampPop 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes stampPop {
  from { transform: scale(2.1) rotate(-18deg); opacity: 0; }
  to { transform: scale(1) rotate(-10deg); opacity: 1; }
}

.radical-tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.rune-tile {
  position: relative;
  padding: 14px 10px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  color: var(--text-main);
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.rune-tile:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.rune-tile.selected {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.18);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.28);
}
.rune-tile.rune-wrong {
  border-color: var(--vermilion);
  background: rgba(255, 71, 105, 0.2);
}
.rune-tile .choice-key {
  position: absolute;
  top: 7px;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.rune-char {
  font-family: var(--font-zh);
  font-size: 36px;
  font-weight: 900;
  line-height: 1.1;
}
.rune-name {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
}

/* ==================== MODE 4: LONG MẠCH CÂU ==================== */
.sentence-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sent-prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  text-align: center;
}
.sent-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--violet);
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.35);
  margin-bottom: 10px;
}
.sent-vi {
  font-size: 21px;
  font-weight: 800;
  color: #fff;
}

.sent-track {
  min-height: 92px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: rgba(8, 13, 24, 0.92);
  border: 2px dashed rgba(167, 139, 250, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  transition: all 0.2s ease;
}
.sent-track.track-ok {
  border-style: solid;
  border-color: var(--jade);
  background: rgba(16, 245, 160, 0.08);
}
.sent-track.track-wrong {
  border-style: solid;
  border-color: var(--vermilion);
  background: rgba(255, 71, 105, 0.09);
}
.track-placeholder {
  color: var(--text-muted);
  font-size: 14px;
}
.track-chip {
  padding: 10px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.24), rgba(56, 189, 248, 0.22));
  border: 1.5px solid rgba(167, 139, 250, 0.65);
  color: #fff;
  font-family: var(--font-zh);
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
}

.sent-insight {
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(16, 245, 160, 0.09);
  border: 1px solid rgba(16, 245, 160, 0.32);
  text-align: center;
}
.insight-py { font-size: 16px; font-weight: 700; margin-bottom: 4px; color: var(--cyan); }
.insight-rule { font-size: 13.5px; color: var(--text-main); }
.insight-miss { font-size: 13.5px; color: var(--gold); }

.sent-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 12px 0;
}
.chunk-tile {
  position: relative;
  padding: 14px 22px 14px 36px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  color: #fff;
  font-family: var(--font-zh);
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chunk-chengyu {
  font-size: 34px;
  min-width: 96px;
}
.chunk-tile:hover:not(.used) {
  border-color: var(--violet);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.chunk-tile.used {
  opacity: 0.22;
  pointer-events: none;
  transform: scale(0.95);
}
.chunk-tile .choice-key {
  position: absolute;
  top: 8px;
  left: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== MODE 5: BOSS TÂM MA ==================== */
.boss-arena {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(25, 13, 28, 0.92), rgba(14, 20, 36, 0.92));
  border: 1.5px solid color-mix(in srgb, var(--boss-color, #ff4769) 55%, transparent);
}
.boss-emblem {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 20px;
  background: radial-gradient(circle, color-mix(in srgb, var(--boss-color, #ff4769) 35%, #120816), #090b13);
  border: 2px solid var(--boss-color, var(--vermilion));
  box-shadow: 0 0 28px color-mix(in srgb, var(--boss-color, #ff4769) 45%, transparent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.boss-emblem.boss-hit {
  transform: scale(0.86) rotate(-7deg);
  filter: brightness(2.2);
}
.boss-zh-sigil {
  font-family: var(--font-zh);
  font-size: 28px;
  font-weight: 900;
  color: #fff;
}
.boss-info { flex: 1; }
.boss-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.boss-title { font-size: 19px; font-weight: 900; color: #fff; }
.boss-subtitle { font-size: 13px; color: var(--boss-color); font-weight: 700; }

.boss-hp-bar {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin-bottom: 6px;
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #be123c, #ff4769, #fb923c);
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.boss-hp-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}
.boss-status { font-size: 12.5px; color: var(--text-dim); }

.boss-prompt-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 12px;
}
.boss-attack-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.14);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.boss-zh-big {
  font-family: var(--font-zh);
  font-size: clamp(3rem, 6vw, 4.4rem);
  font-weight: 900;
  line-height: 1.12;
  color: #fff;
}
.boss-audio-big { font-size: 56px; line-height: 1.1; }
.boss-vi-big { font-size: 28px; font-weight: 900; color: #fff; }
.boss-prompt-sub { font-size: 14px; color: var(--text-dim); margin-top: 6px; }
.boss-replay-btn { position: absolute; top: 14px; right: 14px; }

.boss-feedback {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 71, 105, 0.14);
  border: 1px solid rgba(255, 71, 105, 0.45);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.fb-zh { font-family: var(--font-zh); font-size: 24px; font-weight: 900; color: #fff; }

/* Memory Echo Pairs Phase */
.pairs-header { text-align: center; margin-bottom: 12px; }
.pairs-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}
.pairs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.pair-card {
  min-height: 92px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  color: #fff;
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.pair-zh .pair-main { font-family: var(--font-zh); font-size: 30px; font-weight: 900; }
.pair-vi .pair-main { font-size: 15px; font-weight: 700; text-align: center; }
.pair-sub { font-size: 11.5px; color: var(--gold); }
.pair-card:hover:not(.matched) { border-color: var(--cyan); transform: translateY(-2px); }
.pair-card.selected { border-color: var(--gold); background: rgba(251, 191, 36, 0.16); }
.pair-card.matched { border-color: var(--jade); background: rgba(16, 245, 160, 0.14); opacity: 0.45; pointer-events: none; }
.pair-card.pair-wrong { border-color: var(--vermilion); background: rgba(255, 71, 105, 0.22); }

/* ==================== MEMORY VAULT & SETTINGS ==================== */
.vault-top-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
  margin-bottom: 18px;
}

.tone-analytics {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tone-stat-row {
  display: grid;
  grid-template-columns: 145px 1fr 98px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
}
.ts-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.ts-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.ts-val { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); text-align: right; }

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  padding: 4px 0;
}
.set-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--jade);
  cursor: pointer;
}
.settings-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.voice-info { font-size: 12px; color: var(--text-dim); }
.settings-actions { display: flex; gap: 8px; }

.codex-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.codex-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.search-input { min-width: 295px; }

.vault-realm-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  padding: 6px 11px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chip-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--cyan);
  color: var(--cyan);
}

.vault-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}
.vocab-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.vocab-card:hover {
  border-color: var(--cyan);
  background: rgba(255, 255, 255, 0.06);
}
.vc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.vc-hanzi {
  font-family: var(--font-zh);
  font-size: 24px;
  font-weight: 900;
  margin-right: 8px;
}
.vc-py { font-size: 14px; font-weight: 700; }
.vc-badges { display: flex; align-items: center; gap: 6px; }
.vc-realm { font-size: 10.5px; font-weight: 800; }
.vc-lvl {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}
.vc-lvl.lvl-3, .vc-lvl.lvl-4, .vc-lvl.lvl-5 {
  background: rgba(16, 245, 160, 0.16);
  color: var(--jade);
}
.vc-speak {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 13px;
}
.vc-vi { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.vc-hv { font-size: 12.5px; color: var(--gold); font-weight: 600; }
.vc-parts { font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.vc-ex {
  padding-top: 5px;
  border-top: 1px dashed rgba(148, 163, 184, 0.14);
  font-size: 12px;
  display: flex;
  flex-direction: column;
}
.vc-ex-zh { font-family: var(--font-zh-sans); color: #e2e8f0; }
.vc-ex-vi { color: var(--text-muted); }
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 34px;
  color: var(--text-dim);
}

/* ==================== RESULT MODAL ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 7, 14, 0.82);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.result-card {
  width: 100%;
  max-width: 510px;
  background: linear-gradient(160deg, #131c31, #0c1120);
  border: 1.5px solid rgba(251, 191, 36, 0.45);
  border-radius: 22px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}
.res-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}
.res-win { background: rgba(16, 245, 160, 0.18); color: var(--jade); border: 1px solid rgba(16, 245, 160, 0.45); }
.res-retry { background: rgba(251, 191, 36, 0.18); color: var(--gold); border: 1px solid rgba(251, 191, 36, 0.45); }
.res-title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.res-subtitle { margin: 0 0 18px; font-size: 13.5px; color: var(--text-dim); }

.res-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-bottom: 18px;
}
.res-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 6px;
}
.rm-val { font-family: var(--font-mono); font-size: 20px; font-weight: 800; }
.rm-val.gold { color: var(--gold); }
.rm-val.cyan { color: var(--cyan); }
.rm-val.jade { color: var(--jade); }
.rm-lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.res-rank-box {
  background: rgba(255, 255, 255, 0.035);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.res-rank-line { font-size: 13px; margin-bottom: 8px; }

.res-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.res-actions .btn { flex: 1; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1080px) {
  .realms-grid { grid-template-columns: repeat(4, 1fr); }
  .modes-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-panel { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .realms-grid { grid-template-columns: repeat(2, 1fr); }
  .modes-grid { grid-template-columns: 1fr; }
  .hub-bottom-grid, .vault-top-grid, .tone-stage, .forge-stage, .vault-list { grid-template-columns: 1fr; }
  .tone-pads { grid-template-columns: repeat(2, 1fr); }
  .radical-tray, .pairs-grid { grid-template-columns: repeat(2, 1fr); }
  .choice-grid { grid-template-columns: 1fr; }
  .res-metrics { grid-template-columns: repeat(2, 1fr); }
}
