/* 汉字乐园 · Hanzi Play — Warm Storybook Theme for Kindergarten & Grade 1 */

:root {
  --bg: #FFF9F0;
  --bg-soft: #FFF2DF;
  --card: #FFFFFF;
  --ink: #2B2D42;
  --ink-soft: #646B82;
  --coral: #FF6B6B;
  --coral-dark: #D94848;
  --sunny: #FFB703;
  --sunny-dark: #D99300;
  --mint: #2EC4B6;
  --mint-dark: #1E998D;
  --sky: #4EA8DE;
  --sky-dark: #2C7EB3;
  --purple: #9B5DE5;
  --purple-dark: #7539BE;
  --green: #38B000;
  --green-dark: #257D00;
  --border: #EFE5D5;
  --shadow: 0 10px 28px rgba(74, 58, 35, 0.08);
  --radius: 22px;
  --font-ui: "Nunito", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-hanzi: "KaiTi", "STKaiti", "Kaiti SC", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at top right, #FFF2DA 0%, var(--bg) 48%, #F4FBFF 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* Confetti Layer */
#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  font-size: 22px;
  animation: confetti-fall 1.4s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  user-select: none;
}

@keyframes confetti-fall {
  0% {
    transform: translate(0, 0) scale(0.6) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx, 0px), var(--dy, 180px)) scale(1.15) rotate(var(--rot, 240deg));
    opacity: 0;
  }
}

/* Shell */
.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

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

.home-back-btn {
  border: 2px solid var(--border);
  background: #FFF9EE;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.home-back-btn:hover {
  background: #FFECC8;
}

.mascot-badge {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FFF0C2, #FFD6A5);
  border: 2px solid #F6C36E;
  display: grid;
  place-items: center;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.mascot-badge:hover {
  transform: scale(1.08) rotate(-5deg);
}

.mascot-badge.cheer {
  animation: bounce-cheer 0.55s ease;
}

@keyframes bounce-cheer {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.24) rotate(-8deg); }
  70% { transform: scale(1.12) rotate(8deg); }
}

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--ink);
}

.brand-en {
  color: var(--coral);
  font-size: 18px;
  margin-left: 4px;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
}

.stat-stars {
  background: #FFF4D2;
  color: #A66A00;
  border: 2px solid #FFE08A;
}

.stat-streak {
  background: #FFE8E8;
  color: #C93636;
  border: 2px solid #FFC4C4;
}

.level-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid #B7E8D8;
  background: #E8FBF5;
  color: #14776B;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.level-header-btn:hover {
  background: #D5F6EC;
  transform: translateY(-1px);
}

.icon-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #F8F5F0;
  color: var(--ink-soft);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-toggle.active {
  background: #E8F7FF;
  border-color: #9AD3F5;
  color: #1A6FA3;
}

.icon-toggle:active {
  transform: scale(0.95);
}

.icon-toggle.settings-btn {
  background: #FFF6E3;
  border-color: #F2D28B;
  color: #825300;
}

.icon-toggle.settings-btn:hover {
  background: #FFEDC7;
}

.header-sound-seg {
  padding: 3px;
}

.ask-prompt-emoji {
  font-size: 56px;
  line-height: 1;
  margin-right: 12px;
  align-self: center;
}

/* Mode Nav */
.mode-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 18px;
  border: 2px solid var(--border);
  border-bottom: 5px solid #E3D6C3;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.mode-btn:hover {
  transform: translateY(-2px);
}

.mode-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.mode-btn.active {
  background: linear-gradient(180deg, #FF7B7B 0%, var(--coral) 100%);
  border-color: var(--coral-dark);
  border-bottom-color: #BA3333;
  color: #FFFFFF;
}

.mode-btn.active small {
  color: rgba(255, 255, 255, 0.92);
}

.mode-emoji {
  font-size: 26px;
  line-height: 1;
}

.mode-titles {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.mode-titles strong {
  font-size: 15px;
  font-weight: 800;
}

.mode-titles small {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* Collapsible Filter Bar */
.filter-bar {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.collapsible-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s ease;
}

.collapsible-trigger:hover {
  background: #FFFBF4;
}

.collapsible-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.collapsible-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}

.collapsible-caret {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink-soft);
  transition: transform 0.18s ease;
}

.filter-bar:not(.collapsed) .collapsible-caret {
  transform: rotate(180deg);
}

.filter-bar-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 10px 14px 12px;
  border-top: 2px solid #F3ECE0;
  flex-wrap: wrap;
}

.filter-bar.collapsed .filter-bar-body {
  display: none;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #F5EFE6;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 800;
}

.options-toggle-btn .opt-caret {
  display: inline-block;
  margin-left: 2px;
  transition: transform 0.18s ease;
}

.options-toggle-btn[aria-expanded="true"] {
  background: #EAF6FF;
  border-color: #A8D8F7;
  color: #166FA6;
}

.options-toggle-btn[aria-expanded="true"] .opt-caret {
  transform: rotate(180deg);
}

.options-drawer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  background: #FFFBF4;
  border: 2px solid #F0E6D6;
  border-radius: 16px;
  padding: 10px 12px;
  margin: -6px 0 14px;
}

.options-drawer.collapsed {
  display: none;
}

/* Home Screen Grid (4 Big Game Cards) */
.home-welcome {
  text-align: center;
  margin: 4px 0 20px;
}

.home-welcome h2 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
}

.home-welcome p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 760px;
  margin: 0 auto 20px;
}

.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 26px 18px 22px;
  border-radius: 26px;
  border: 3px solid var(--border);
  border-bottom: 7px solid #E1D4C0;
  background: #FFFDF9;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.14s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.home-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 26px rgba(74, 58, 35, 0.12);
}

.home-card:active {
  transform: translateY(2px);
}

.home-card.card-ask {
  background: linear-gradient(180deg, #FFF9F5 0%, #FFECE8 100%);
  border-color: #F8C4BC;
  border-bottom-color: #E89D92;
}

.home-card.card-quiz {
  background: linear-gradient(180deg, #F5FBFF 0%, #E5F4FF 100%);
  border-color: #B4DCF7;
  border-bottom-color: #82C2ED;
}

.home-card.card-flow {
  background: linear-gradient(180deg, #F4FDFA 0%, #DFF8F1 100%);
  border-color: #A2E6D8;
  border-bottom-color: #6CCFB9;
}

.home-card.card-wall {
  background: linear-gradient(180deg, #FFFBF2 0%, #FFF0D1 100%);
  border-color: #F4D58D;
  border-bottom-color: #DFB55B;
}

.home-card-emoji {
  font-size: 54px;
  line-height: 1;
  margin-bottom: 4px;
}

.home-card-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
}

.home-card-zh {
  font-size: 14px;
  font-weight: 800;
  color: var(--coral-dark);
}

.home-card-desc {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  max-width: 240px;
  line-height: 1.35;
}

.home-card-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--mint);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
}

.home-footer-actions {
  display: flex;
  justify-content: center;
}

/* Compact Status Bar + Gear Icon + Unified Expandable Menu Drawer */
.compact-status-bar {
  margin-bottom: 12px;
}

.icon-gear-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #FFF9EE;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-gear-btn:hover {
  background: #FFECC8;
}

.icon-gear-btn[aria-expanded="true"] {
  background: #EAF6FF;
  border-color: #9ED4F7;
  transform: rotate(45deg);
}

.unified-menu-drawer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FFFBF4;
  border: 2px solid #EDE1CE;
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 14px;
  animation: pop-in 0.18s ease;
}

.unified-menu-drawer.collapsed {
  display: none;
}

.menu-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-drawer-topics {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.menu-drawer-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.menu-drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1.5px dashed #E9DCC8;
}

.menu-drawer-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-drawer-game-opts {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1.5px dashed #E9DCC8;
}

@media (max-width: 640px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  flex: 1 1 560px;
}

.cat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: #F6F1E9;
  color: var(--ink);
  white-space: nowrap;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill:hover {
  background: #EFE7DA;
}

.cat-pill.active {
  background: var(--cat-color, var(--sky));
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.level-group {
  display: inline-flex;
  background: #F4EDE2;
  padding: 3px;
  border-radius: 999px;
  gap: 2px;
  flex-shrink: 0;
}

.level-pill {
  border: none;
  background: transparent;
  padding: 6px 11px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.level-pill.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Stage Container */
.stage {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 26px;
  padding: 18px 20px 24px;
  box-shadow: var(--shadow);
  min-height: 500px;
}

.game-view {
  display: none;
}

.game-view.active {
  display: block;
}

/* Subbar */
.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.subbar-left, .subbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-badge {
  background: #F3ECFF;
  color: #6B36B8;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}

.score-badge {
  background: #E6FAF0;
  color: #167C49;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 999px;
}

.session-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #F2EAE0;
  overflow: hidden;
  margin: -6px 0 16px;
}

.session-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint) 0%, var(--sky) 60%, var(--sunny) 100%);
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.level-tag {
  background: #E2F8F5;
  color: #147E73;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}

.switch-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F7F2EA;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.switch-chip input {
  accent-color: var(--coral);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.chip-btn {
  border: 2px solid var(--border);
  background: #FFFBF4;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.chip-btn:hover {
  background: #FFF0D9;
}

.chip-btn:active {
  transform: scale(0.95);
}

.seg-group {
  display: inline-flex;
  background: #F4EDE2;
  padding: 4px;
  border-radius: 14px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-group.compact .seg-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.seg-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Tactile 3D Kid Buttons */
.btn {
  border: none;
  border-radius: 18px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  filter: brightness(1.03);
}

.btn:active {
  transform: translateY(3px);
}

.btn-lg {
  padding: 15px 28px;
  font-size: 18px;
}

.btn-primary {
  background: var(--sky);
  color: #FFFFFF;
  border-bottom: 5px solid var(--sky-dark);
}

.btn-secondary {
  background: #FFF3D1;
  color: #8F5A00;
  border-bottom: 5px solid #E5C165;
}

.btn-success {
  background: var(--mint);
  color: #FFFFFF;
  border-bottom: 5px solid var(--mint-dark);
}

.btn-warm {
  background: #FFE5D9;
  color: #B5432A;
  border-bottom: 5px solid #EAB59F;
}

.btn-danger {
  background: #FFE0E0;
  color: #C42B2B;
  border-bottom: 4px solid #E8A5A5;
}

.btn-sm {
  padding: 9px 15px;
  font-size: 14px;
  border-radius: 14px;
  border-bottom-width: 4px;
}

.mode-count-pill {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: #E8F8F5;
  color: #137C71;
  vertical-align: middle;
}

.mode-btn.active .mode-count-pill {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

/* Empty Active Words Banner */
.empty-active-banner {
  text-align: center;
  padding: 46px 20px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF6E5 100%);
  border: 3px dashed #EBD2A7;
  border-radius: 24px;
  margin: 8px 0;
}

.empty-emoji {
  font-size: 62px;
  line-height: 1;
}

.empty-active-banner h3 {
  margin: 12px 0 6px;
  font-size: 22px;
  color: var(--ink);
}

.empty-active-banner p {
  margin: 0 auto 20px;
  max-width: 460px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 15px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 田字格 (Tian-zi-ge) Traditional Chinese Character Box */
.tianzige-box {
  position: relative;
  width: 196px;
  height: 196px;
  border-radius: 26px;
  border: 4px solid #F29E8E;
  background: #FFFDF9;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(242, 158, 142, 0.22);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}

.tianzige-box::before,
.tianzige-box::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* Horizontal dashed center line */
.tianzige-box::before {
  left: 10px;
  right: 10px;
  top: 50%;
  border-top: 2px dashed rgba(242, 158, 142, 0.45);
}

/* Vertical dashed center line */
.tianzige-box::after {
  top: 10px;
  bottom: 10px;
  left: 50%;
  border-left: 2px dashed rgba(242, 158, 142, 0.45);
}

.tianzige-box:hover {
  transform: scale(1.04);
}

.tianzige-box:active {
  transform: scale(0.97);
}

.tianzige-char {
  position: relative;
  z-index: 2;
  font-family: var(--font-hanzi);
  font-size: 122px;
  line-height: 1;
  color: #242638;
  user-select: none;
}

.speak-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #FFF1D0;
  border: 2px solid #F7C96A;
  display: grid;
  place-items: center;
  font-size: 16px;
}

/* MODE 1: ASK & TELL */
.ask-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.ask-card {
  width: 100%;
  max-width: 560px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF7EB 100%);
  border: 3px solid #F3E3CA;
  border-radius: 28px;
  padding: 22px 24px 26px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(154, 118, 66, 0.08);
  transition: transform 0.25s ease;
}

.ask-prompt-hint {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.ask-hero-row {
  display: flex;
  justify-content: center;
}

.ask-pinyin-slot {
  min-height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

.pinyin-pill {
  display: inline-block;
  background: #E8F6FF;
  color: #1672AD;
  border: 2px solid #A4DAFA;
  border-radius: 999px;
  padding: 5px 20px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  animation: pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from { transform: scale(0.75); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.ask-answer {
  margin-top: 14px;
  animation: pop-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.answer-divider {
  height: 2px;
  background: repeating-linear-gradient(90deg, #E8D5B7 0 8px, transparent 8px 16px);
  margin: 0 12px 16px;
}

.answer-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.answer-emoji {
  font-size: 64px;
  line-height: 1;
}

.answer-words {
  text-align: left;
}

.answer-en {
  font-size: 38px;
  font-weight: 900;
  color: var(--coral);
  line-height: 1.1;
}

.answer-pinyin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.answer-pinyin {
  font-size: 22px;
  font-weight: 800;
  color: #1C7BB8;
}

.mini-speak-btn {
  border: 2px solid #DCEAF7;
  background: #FFFFFF;
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-speak-btn:hover {
  background: #EAF6FF;
}

.answer-phrase {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #FFFFFF;
  border: 2px solid #EFE2CE;
  border-radius: 16px;
  padding: 8px 16px;
  font-size: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.phrase-zh {
  font-family: var(--font-hanzi);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.phrase-py {
  color: #2181BC;
  font-weight: 700;
}

.phrase-en {
  color: var(--ink-soft);
  font-weight: 700;
}

.ask-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* MODE 2: OPTION QUIZ */
.quiz-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.quiz-prompt-card {
  width: 100%;
  max-width: 520px;
  background: linear-gradient(180deg, #FFFDF9 0%, #F4FAFF 100%);
  border: 3px solid #D9ECF9;
  border-radius: 26px;
  padding: 18px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.quiz-prompt-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
}

.quiz-prompt-main {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.quiz-prompt-en-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #FFFFFF;
  border: 3px solid #BCE0FA;
  border-radius: 22px;
  padding: 16px 28px;
  box-shadow: 0 6px 16px rgba(78, 168, 222, 0.14);
}

.quiz-prompt-en-box .big-emoji {
  font-size: 56px;
  line-height: 1;
}

.quiz-prompt-en-box .big-word {
  font-size: 36px;
  font-weight: 900;
  color: var(--ink);
}

.quiz-prompt-sub {
  min-height: 28px;
  font-size: 20px;
  font-weight: 800;
  color: #1D7AB6;
}

.quiz-feedback {
  min-height: 36px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.quiz-feedback.oops {
  color: #D9534F;
}

.quiz-feedback.learn {
  color: #1A6FA3;
  background: #EDF7FF;
  border: 2px solid #C2E2FA;
  border-radius: 16px;
  padding: 8px 16px;
}

.quiz-footer-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.quiz-options {
  width: 100%;
  max-width: 680px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.quiz-opt-btn {
  position: relative;
  background: #FFFFFF;
  border: 3px solid #E8DFD2;
  border-bottom: 6px solid #D9CCB8;
  border-radius: 22px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  min-height: 126px;
}

.quiz-key-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #F4EDE2;
  border: 1.5px solid #E2D5C2;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 900;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.quiz-opt-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--sky);
  background: #F6FBFF;
}

.quiz-opt-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.quiz-opt-emoji {
  font-size: 44px;
  line-height: 1;
}

.quiz-opt-main {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
}

.quiz-opt-main.hanzi {
  font-family: var(--font-hanzi);
  font-size: 62px;
  font-weight: 700;
}

.quiz-opt-main.pinyin {
  font-size: 28px;
  color: #1971AB;
}

.quiz-opt-sub {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.quiz-opt-btn.correct {
  background: #E4FAEE;
  border-color: var(--mint);
  border-bottom-color: var(--mint-dark);
  animation: pop-in 0.25s ease;
}

.quiz-opt-btn.wrong {
  background: #FFEBEB;
  border-color: #F49797;
  border-bottom-color: #D96C6C;
  animation: gentle-shake 0.35s ease;
}

@keyframes gentle-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* MODE 3: HANZI FLOW */
.flow-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flow-arena {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: 26px;
  overflow: hidden;
  border: 3px solid #BCE2F7;
  background: linear-gradient(180deg, #CBEFFF 0%, #EBF8FF 58%, #B4E7FF 82%, #7CCFF5 100%);
  user-select: none;
}

.sky-cloud {
  position: absolute;
  font-size: 46px;
  opacity: 0.55;
  pointer-events: none;
  animation: cloud-drift 28s linear infinite;
}

.cloud-1 { top: 14px; left: -60px; animation-duration: 32s; }
.cloud-2 { top: 58px; left: -60px; font-size: 34px; animation-duration: 24s; animation-delay: -10s; }
.cloud-3 { top: 24px; left: -60px; font-size: 40px; animation-duration: 38s; animation-delay: -20s; }

@keyframes cloud-drift {
  from { transform: translateX(0); }
  to { transform: translateX(1060px); }
}

.flow-hud {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #CBE7F9;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(32, 92, 130, 0.1);
}

.hud-toast {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hud-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.flow-bubbles-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

/* Flowing Lantern / Bubble */
.flow-bubble {
  position: absolute;
  top: 0;
  left: 0;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  padding: 10px 16px;
  min-width: 98px;
  min-height: 98px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(32, 85, 120, 0.18), inset 0 4px 10px rgba(255, 255, 255, 0.55);
  transition: filter 0.12s ease;
  will-change: transform;
  font-family: inherit;
}

.flow-bubble:hover {
  filter: brightness(1.06);
}

.flow-bubble .bubble-char {
  font-family: var(--font-hanzi);
  font-size: 54px;
  line-height: 1.05;
  color: #FFFFFF;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.flow-bubble .bubble-py {
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.96);
  margin-top: 2px;
}

.flow-bubble.en-bubble {
  min-width: 132px;
  min-height: 92px;
  padding: 10px 16px;
}

.flow-bubble .bubble-emoji {
  font-size: 32px;
  line-height: 1;
}

.flow-bubble .bubble-en {
  font-size: 18px;
  font-weight: 900;
  color: #FFFFFF;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  margin-top: 3px;
}

.flow-bubble.popping {
  pointer-events: none;
  animation: bubble-pop-burst 0.34s ease forwards;
}

@keyframes bubble-pop-burst {
  0% { opacity: 1; filter: brightness(1.25); }
  100% { opacity: 0; filter: brightness(1.5); }
}

.flow-bubble.wobble {
  filter: saturate(0.75) brightness(0.92);
}

.flow-waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52px;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.wave {
  position: absolute;
  bottom: -14px;
  left: -50%;
  width: 200%;
  height: 52px;
  border-radius: 45%;
  background: rgba(255, 255, 255, 0.28);
  animation: wave-sway 7s ease-in-out infinite alternate;
}

.wave-2 {
  bottom: -22px;
  background: rgba(78, 168, 222, 0.25);
  animation-duration: 9s;
  animation-direction: alternate-reverse;
}

@keyframes wave-sway {
  from { transform: translateX(-3%); }
  to { transform: translateX(3%); }
}

/* Flow Overlay */
.flow-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(255, 249, 240, 0.84);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
}

.overlay-card {
  background: #FFFFFF;
  border: 3px solid #F7D488;
  border-radius: 26px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.overlay-emoji {
  font-size: 54px;
  line-height: 1;
}

.overlay-card h2 {
  margin: 8px 0 4px;
  font-size: 24px;
}

.overlay-card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-weight: 700;
}

/* Target Bar below Flow Arena */
.flow-target-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(90deg, #FFF7E2 0%, #FFF1D0 100%);
  border: 3px solid #F6CF79;
  border-radius: 22px;
  padding: 12px 18px;
  flex-wrap: wrap;
}

.flow-target-label {
  font-size: 15px;
  font-weight: 800;
  color: #825300;
}

.flow-target-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #FFFFFF;
  border: 3px solid #F3BD4F;
  border-bottom-width: 5px;
  border-radius: 18px;
  padding: 8px 18px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease;
}

.flow-target-card:active {
  transform: scale(0.96);
}

.target-emoji {
  font-size: 38px;
  line-height: 1;
}

.target-text-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.target-main {
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
}

.target-main.hanzi {
  font-family: var(--font-hanzi);
  font-size: 40px;
}

.target-py {
  font-size: 15px;
  font-weight: 800;
  color: #1D7AB6;
}

.target-speaker {
  font-size: 22px;
}

/* MODE 4: WORD BANK (PARENT DB MANAGER) */
.bank-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.bank-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.db-badge {
  background: #E8F9EE;
  color: #1D7A43;
  border: 1.5px solid #B7E8C9;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
}

.db-badge.local-only {
  background: #FFF4DC;
  color: #8F5C00;
  border-color: #F4D58D;
}

.bank-tip {
  margin: 0;
  background: #F6FAFF;
  border: 1.5px solid #D5E8FA;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

.search-input {
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: #FFFDF9;
  width: 210px;
  outline: none;
}

.search-input:focus {
  border-color: var(--sky);
}

.wall-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.level-group-section {
  background: #FFFDF8;
  border: 2px solid #EFE4D4;
  border-radius: 22px;
  overflow: hidden;
}

.level-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(90deg, #FFF9EE 0%, #F7FBFF 100%);
  border-bottom: 2px solid #EFE4D4;
  flex-wrap: wrap;
}

.level-group-section.collapsed .level-group-header {
  border-bottom: none;
}

.level-group-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}

.level-group-chevron {
  font-size: 16px;
  color: var(--ink-soft);
  width: 18px;
  display: inline-block;
  transition: transform 0.18s ease;
}

.level-group-section.collapsed .level-group-chevron {
  transform: rotate(-90deg);
}

.level-group-badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--lvl-color, var(--sky));
  color: #FFFFFF;
  flex-shrink: 0;
}

.level-group-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.level-group-titles strong {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
}

.level-group-titles small {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.level-group-count {
  background: #EFE7DA;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.level-group-count.all-on {
  background: #E2F8F0;
  color: #137A65;
}

.level-group-count.all-off {
  background: #EFEBE6;
  color: #7A736A;
}

.level-group-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.group-toggle-btn {
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  background: #FFFFFF;
  color: var(--ink);
  transition: all 0.15s ease;
}

.group-toggle-btn.enable:hover,
.group-toggle-btn.enable.active {
  background: var(--mint);
  border-color: var(--mint-dark);
  color: #FFFFFF;
}

.group-toggle-btn.disable:hover,
.group-toggle-btn.disable.active {
  background: #E7DFD4;
  border-color: #C7BCB0;
  color: #544D44;
}

.level-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 12px;
  padding: 14px;
}

.level-group-section.collapsed .level-cards-grid {
  display: none;
}

/* Onboarding Level Picker Modal */
.onboarding-card {
  position: relative;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 26px 24px;
  border-color: #9ED8F5;
}

.onboarding-hero {
  font-size: 56px;
  line-height: 1;
}

.onboarding-sub {
  margin: 0 auto 16px;
  max-width: 500px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
  font-weight: 700;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
  margin-bottom: 18px;
}

.onboarding-option {
  border: 3px solid #E9DFD1;
  border-bottom: 5px solid #DBCEBC;
  border-radius: 20px;
  background: #FFFDF9;
  padding: 14px 15px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.onboarding-option:hover {
  transform: translateY(-2px);
  border-color: var(--sky);
}

.onboarding-option.selected {
  background: #EDF8FF;
  border-color: var(--sky);
  border-bottom-color: var(--sky-dark);
  box-shadow: 0 6px 18px rgba(78, 168, 222, 0.2);
}

.onboarding-opt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.onboarding-opt-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
}

.onboarding-opt-zh {
  font-size: 12px;
  font-weight: 800;
  color: #1A76B0;
  background: #E2F3FF;
  padding: 2px 8px;
  border-radius: 999px;
}

.onboarding-opt-desc {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.35;
}

.onboarding-opt-samples {
  font-family: var(--font-hanzi);
  font-size: 16px;
  color: var(--ink);
  background: #FFFFFF;
  border: 1.5px solid #EAE0D2;
  border-radius: 10px;
  padding: 5px 8px;
}

.onboarding-opt-count {
  font-size: 11px;
  font-weight: 800;
  color: #147E6B;
}

.onboarding-footer {
  display: flex;
  justify-content: center;
}

/* Settings Modal */
.settings-modal-card {
  max-width: 600px;
  text-align: left;
  padding: 22px 24px 20px;
  border-color: #F2D28B;
  max-height: 90vh;
  overflow-y: auto;
}

.settings-intro {
  margin: -6px 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-box {
  background: #FFFDF8;
  border: 2px solid #EFE4D4;
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-box-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 2px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.settings-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--sky);
  cursor: pointer;
}

@media (max-width: 600px) {
  .onboarding-grid {
    grid-template-columns: 1fr;
  }
}

.wall-card {
  position: relative;
  background: #FFFDF9;
  border: 2px solid #C8EBDD;
  border-bottom: 4px solid #A4DEC8;
  border-radius: 20px;
  padding: 10px 10px 11px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.wall-card.is-off {
  opacity: 0.56;
  background: #F8F5F0;
  border-color: #E3DAD0;
  border-bottom-color: #D2C7B9;
}

.wall-card.is-off:hover {
  opacity: 0.85;
}

.wall-card:hover {
  transform: translateY(-2px);
  border-color: var(--sky);
}

.wall-card.speaking {
  border-color: var(--coral);
  background: #FFF3F3;
  transform: scale(1.03);
}

.wall-card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.wall-card-body {
  width: 100%;
  border: none;
  background: transparent;
  padding: 2px 0;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.wall-toggle-btn {
  border: none;
  border-radius: 999px;
  padding: 3px 9px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wall-toggle-btn.on {
  background: var(--mint);
  color: #FFFFFF;
}

.wall-toggle-btn.off {
  background: #DDD5CA;
  color: #5C554C;
}

.wall-card-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wall-level-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: #EFE7DA;
  color: var(--ink-soft);
}

.wall-edit-btn {
  border: none;
  background: #F4EDE2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.wall-edit-btn:hover {
  background: #FFE5B4;
  transform: scale(1.1);
}

.wall-char {
  font-family: var(--font-hanzi);
  font-size: 46px;
  line-height: 1.1;
  color: var(--ink);
  margin: 2px 0;
}

.wall-py {
  font-size: 14px;
  font-weight: 800;
  color: #1A77B3;
}

.wall-meaning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}

.wall-phrase {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-top: 2px;
}

.wall-stars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #C48200;
  min-height: 18px;
  margin-top: 2px;
}

.wall-err-badge {
  background: #FFE5E5;
  color: #C93030;
  border: 1px solid #F7BABA;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
}

.wf-error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #FFF2F2;
  border: 1.5px solid #F7CACA;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  color: #B33030;
}

/* Add / Edit Character Modal */
.word-modal-card {
  max-width: 520px;
  text-align: left;
  padding: 22px 24px 24px;
  border-color: #BCE0FA;
  max-height: 92vh;
  overflow-y: auto;
}

.word-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.word-modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}

.icon-close-btn {
  border: none;
  background: #F3ECE2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
}

.icon-close-btn:hover {
  background: #FFE3E3;
  color: var(--coral-dark);
}

.word-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 10px;
}

.form-row.two-col {
  grid-template-columns: 1fr 1fr;
}

.form-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.field-hint {
  font-weight: 600;
  color: var(--ink-soft);
}

.form-field input,
.form-field select {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: #FFFDF9;
  outline: none;
  width: 100%;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--sky);
  background: #FFFFFF;
}

.tone-helpers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.tone-helpers button {
  border: 1.5px solid #D9E9F7;
  background: #F3F9FF;
  color: #196BA3;
  border-radius: 8px;
  padding: 3px 7px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.tone-helpers button:hover {
  background: #DDF0FF;
}

.emoji-quick-picks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.emoji-quick-picks button {
  border: 1.5px solid var(--border);
  background: #FFFBF4;
  border-radius: 8px;
  padding: 3px 6px;
  font-size: 16px;
  cursor: pointer;
}

.emoji-quick-picks button:hover {
  background: #FFF0D1;
  transform: scale(1.1);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ECFBF7;
  border: 1.5px solid #B5EAE0;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #136B62;
  cursor: pointer;
}

.form-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--mint);
}

.word-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 2px solid #F2EAE0;
}

.word-modal-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

@media (max-width: 600px) {
  .form-row.two-col,
  .form-row.three-col {
    grid-template-columns: 1fr;
  }
}

/* Milestone Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 42, 66, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  background: #FFFFFF;
  border: 4px solid #FFD166;
  border-radius: 30px;
  padding: 30px 34px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.2);
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-trophy {
  font-size: 68px;
  line-height: 1;
}

.modal-card h2 {
  margin: 10px 0 6px;
  font-size: 26px;
  color: var(--coral);
}

.modal-card p {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
}

.modal-stars {
  font-size: 32px;
  margin-bottom: 18px;
  letter-spacing: 6px;
}

/* End-of-Session Result Modal */
.result-modal-card {
  position: relative;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px 26px 24px;
  border-color: #FFD166;
}

.modal-close-corner {
  position: absolute;
  top: 14px;
  right: 14px;
}

.result-trophy {
  font-size: 66px;
  line-height: 1;
}

.result-subtitle {
  margin: 0 0 14px;
}

.result-score-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #FFF7DF 0%, #FFECC0 100%);
  border: 3px solid #F7C96A;
  border-radius: 22px;
  padding: 12px 30px;
  margin-bottom: 14px;
}

.result-score-big {
  font-size: 38px;
  font-weight: 900;
  color: var(--coral);
  line-height: 1.1;
}

.result-score-pct {
  font-size: 14px;
  font-weight: 800;
  color: #8F5C00;
  margin-top: 2px;
}

.result-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.result-stat {
  border-radius: 16px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  font-weight: 800;
}

.result-stat strong {
  font-size: 22px;
  line-height: 1.1;
}

.result-stat.good {
  background: #E8FAF1;
  color: #167A48;
}

.result-stat.warn {
  background: #FFF0E8;
  color: #C44A29;
}

.result-stat.star {
  background: #FFF5DA;
  color: #A66A00;
}

.result-review-section {
  text-align: left;
  background: #FFFDF8;
  border: 2px solid #F0E6D8;
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.result-review-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}

.result-word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.result-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid #E2ECE8;
  background: #FFFFFF;
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.result-chip:hover {
  transform: scale(1.04);
  background: #EFF8FF;
  border-color: var(--sky);
}

.result-chip.missed {
  border-color: #F6C5B8;
  background: #FFF7F4;
}

.result-chip .chip-char {
  font-family: var(--font-hanzi);
  font-size: 18px;
}

.result-chip .chip-py {
  color: #1A77B3;
  font-size: 12px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Responsive */
@media (max-width: 720px) {
  .app-shell {
    padding: 10px 10px 24px;
  }

  .mode-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .toggle-label {
    display: none;
  }

  .tianzige-box {
    width: 166px;
    height: 166px;
  }

  .tianzige-char {
    font-size: 102px;
  }

  .flow-arena {
    height: 320px;
  }

  .stage {
    padding: 14px 12px 20px;
  }
}
