:root {
  /* 一年级快乐拼音王 · 阳光护眼绘本色系（明快、温暖、不刺眼） */
  --song-celadon: #2563EB;       /* 主色：晴空蓝 */
  --song-celadon-deep: #1D4ED8;  /* 深晴空蓝 */
  --song-celadon-soft: #DBEAFE;  /* 浅晴空蓝底 */

  --song-cinnabar: #E11D48;      /* 辅色一：草莓红 / 小红花色 */
  --song-cinnabar-soft: #FFE4E6; /* 浅草莓粉底 */

  --song-ochre: #D97706;         /* 辅色二：向日葵暖橙黄 */
  --song-ochre-soft: #FEF3C7;    /* 浅暖黄底 */

  --song-bamboo: #059669;        /* 辅色三：青苹果护眼绿 */
  --song-bamboo-soft: #D1FAE5;   /* 浅果绿底 */

  /* 护眼奶油绘本纸色阶 */
  --bg-page: #FFF8EB;            /* 全域底衬：暖阳奶油米色 */
  --surface: #FFFFFF;            /* 卡片洁白底色 */
  --surface-variant: #FDE68A;    /* 暖黄焦点槽底色 */
  --surface-warm: #FEF9EE;       /* 浅奶黄次级块面 */
  --bone-cream: #FFFFFF;         /* 拼音卡片纯白底 */

  /* 清晰易读深色字阶 */
  --text-primary: #1E293B;       /* 黑板深蓝灰 */
  --text-secondary: #475569;     /* 柔和中灰蓝 */
  --text-muted: #64748B;         /* 辅助浅灰蓝 */

  /* 轻快柔和投影与圆润大圆角 */
  --shadow-sm: 0 6px 20px rgba(30, 41, 59, 0.06);
  --shadow-md: 0 10px 28px rgba(30, 41, 59, 0.09);
  --shadow-lg: 0 24px 52px rgba(30, 41, 59, 0.18);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Rounded Mplus 1c", sans-serif;
  background-color: var(--bg-page);
  background-image:
    radial-gradient(circle at 10% 12%, rgba(225, 29, 72, 0.06) 0%, transparent 36%),
    radial-gradient(circle at 88% 14%, rgba(37, 99, 235, 0.07) 0%, transparent 38%),
    radial-gradient(circle at 82% 86%, rgba(5, 150, 105, 0.07) 0%, transparent 36%),
    radial-gradient(circle at 18% 84%, rgba(217, 119, 6, 0.08) 0%, transparent 38%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tone-primary, .icon-celadon { color: var(--song-celadon); }
.tone-cinnabar, .icon-cinnabar { color: var(--song-cinnabar); }
.tone-ochre, .icon-ochre { color: var(--song-ochre); }
.tone-bamboo, .icon-bamboo { color: var(--song-bamboo); }
.icon-muted { color: var(--text-muted); }

.mono-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mono-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.mono-icon-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.mono-icon-lg {
  width: 54px;
  height: 54px;
  display: inline-block;
}

/* ==================== Top App Bar ==================== */
.top-bar {
  min-height: 60px;
  background: linear-gradient(90deg, #FFFDF9 0%, #FFFFFF 50%, #FFFDF9 100%);
  border-bottom: 2px solid rgba(217, 119, 6, 0.14);
  box-shadow: 0 4px 16px rgba(30, 41, 59, 0.05);
  padding: 8px clamp(18px, 2.8vw, 38px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.song-seal {
  background: linear-gradient(135deg, #FB7185 0%, #E11D48 100%);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 5px 11px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(225, 29, 72, 0.25);
}

.logo-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.logo-sub {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--song-ochre);
  background: var(--song-ochre-soft);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 顶部显眼 1~6 年级选择胶囊栏 */
.top-grade-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  background: #FEF3C7;
  padding: 3px;
  border-radius: 999px;
  gap: 2px;
  max-width: 100%;
  border: 1.5px solid rgba(217, 119, 6, 0.25);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.08);
}

.grade-pill {
  border: none;
  background: transparent;
  color: #92400E;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.grade-pill:hover {
  background: rgba(255, 255, 255, 0.75);
  color: #B45309;
}

.grade-pill.active {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.28);
}

/* 左栏顶部显眼 1~6 年级选择网格卡 */
.grade-selector-box {
  background: rgba(255, 255, 255, 0.86);
  border-radius: 14px;
  padding: 8px 9px;
  margin-bottom: 8px;
  border: 1.5px solid rgba(245, 158, 11, 0.28);
  box-shadow: 0 3px 10px rgba(217, 119, 6, 0.06);
}

.grade-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.grade-focus-tag {
  font-size: 11px;
  font-weight: 800;
  color: #D97706;
  background: #FEF3C7;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.side-grade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.side-grade-btn {
  border: 1.5px solid #E2E8F0;
  background: #FFFFFF;
  border-radius: 9px;
  padding: 4px 3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: inherit;
  transition: all 0.16s ease;
}

.side-grade-btn:hover {
  border-color: #F59E0B;
  background: #FFFBEB;
  transform: translateY(-1px);
}

.side-grade-btn.active {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border-color: #F59E0B;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.18);
}

.sg-name {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.side-grade-btn.active .sg-name {
  color: #92400E;
}

.sg-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.side-grade-btn.active .sg-sub {
  color: #B45309;
}

/* Mode Switcher Chips */
.mode-switcher {
  display: flex;
  background: #F1F5F9;
  padding: 4px;
  border-radius: var(--radius-pill);
  gap: 4px;
  flex-shrink: 0;
}

.mode-chip {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 6px 15px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.mode-chip:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.6);
}

.mode-chip.active {
  background: var(--song-celadon);
  color: #FFFFFF;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}

.mode-chip.active .mode-svg-icon {
  color: #FFFFFF;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pill-btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 7px 15px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn.primary {
  background: linear-gradient(135deg, #FB7185 0%, #E11D48 100%);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(225, 29, 72, 0.24);
}

.pill-btn.primary:hover {
  background: linear-gradient(135deg, #F43F5E 0%, #BE123C 100%);
  transform: translateY(-1px);
}

.pill-btn.secondary {
  background: #F1F5F9;
  color: var(--text-primary);
}

.pill-btn.secondary:hover {
  background: #E2E8F0;
}

.badge-count {
  background: var(--song-celadon-soft);
  color: var(--song-celadon);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #F1F5F9;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--song-celadon-soft);
  transform: scale(1.05);
}

/* ==================== Full-Screen Responsive 3-Column Classroom Layout ==================== */
@media (min-width: 760px) {
  body {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }
  .top-bar {
    flex-wrap: wrap;
    padding: 6px clamp(12px, 1.8vw, 26px);
    min-height: 50px;
    gap: 8px;
  }
  .logo-sub {
    display: none;
  }
}

@media (min-width: 1360px) {
  .logo-sub {
    display: inline-block;
  }
}

.app-container {
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: clamp(6px, 0.9vh, 12px) clamp(10px, 1.5vw, 24px) clamp(8px, 1.1vh, 14px);
  display: grid;
  grid-template-columns: minmax(185px, 1fr) minmax(310px, min(43vw, calc(100vh - 140px))) minmax(195px, 1fr);
  gap: clamp(8px, 1.2vw, 20px);
  align-items: stretch;
}

.side-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(12px, 1.6vh, 18px);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  border-radius: 20px;
  padding: clamp(16px, 1.8vh, 22px) clamp(16px, 1.6vw, 22px);
  box-shadow: var(--shadow-sm);
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.left-panel {
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.96) 0%, rgba(254, 245, 224, 0.92) 100%);
}

.right-panel {
  background: linear-gradient(180deg, rgba(247, 252, 255, 0.96) 0%, rgba(235, 245, 255, 0.92) 100%);
}

.m3-card {
  background: transparent;
  border-radius: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.stats-card { flex: 0 0 auto; }
.tools-card { flex: 0 0 auto; padding-top: 2px; }
.knowledge-card { flex: 0 0 auto; }
.feed-card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-top: 4px;
}

.eyebrow {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--song-ochre);
}

/* Left Panel Header */
.level-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.level-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.level-header h2 {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mini-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(37, 99, 235, 0.08);
  color: var(--song-celadon);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.mini-nav-btn:hover {
  background: var(--song-celadon);
  color: #FFFFFF;
}

.level-badge {
  color: var(--song-celadon);
  font-weight: 800;
  font-size: 12.5px;
  padding: 2px 6px;
  white-space: nowrap;
}

.score-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.04);
}

.metric-box {
  padding: 2px 0;
  text-align: left;
  min-width: 0;
}

.metric-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
}

.metric-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.progress-section {
  margin-bottom: 16px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.g-progress-bar {
  height: 8px;
  background: rgba(30, 41, 59, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.g-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3B82F6 0%, #10B981 55%, #F59E0B 100%);
  border-radius: var(--radius-pill);
  transition: width 0.35s cubic-bezier(0.2, 0, 0, 1);
}

.section-subtitle {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-subtitle::before {
  content: "";
  width: 4px;
  height: 12px;
  border-radius: 99px;
  background: var(--song-celadon);
}

.goal-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.goal-chip {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 12px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(30, 41, 59, 0.04);
}

.goal-chip:hover {
  background: #FFFFFF;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.08);
}

.goal-chip.completed {
  background: var(--song-bamboo-soft);
}

.goal-chip svg {
  width: 38px;
  height: 38px;
}

.goal-count {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-secondary);
  white-space: nowrap;
}

.goal-chip.completed .goal-count {
  color: var(--song-bamboo);
}

/* Power-up Tools */
.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.72);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.tool-btn:hover:not(:disabled) {
  background: #FFFFFF;
  transform: translateX(3px);
  box-shadow: 0 3px 10px rgba(30, 41, 59, 0.06);
}

.tool-btn.active-tool {
  background: var(--song-cinnabar-soft);
  box-shadow: 0 0 0 2px var(--song-cinnabar);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.blue-bg { background: var(--song-celadon-soft); }
.ochre-bg { background: var(--song-ochre-soft); }
.red-bg { background: var(--song-cinnabar-soft); }
.green-bg { background: var(--song-bamboo-soft); }

.tool-meta {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tool-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.tool-stock {
  background: rgba(30, 41, 59, 0.06);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.tool-status-tip {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ==================== Center Board Stage ==================== */
.board-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: clamp(8px, 1.1vh, 12px);
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFDF7 100%);
  border-radius: 22px;
  padding: clamp(12px, 1.4vh, 18px) clamp(12px, 1.3vw, 18px);
  box-shadow: var(--shadow-md);
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.search-omni-bar {
  width: 100%;
  background: #FEF3C7;
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  flex-shrink: 0;
}

.search-g-icon {
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 11.5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.omni-text {
  flex: 1;
  font-size: 13px;
  color: #92400E;
  font-weight: 700;
  line-height: 1.35;
}

.combo-pill {
  background: linear-gradient(135deg, #FB7185 0%, #E11D48 100%);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  animation: pulsePop 0.35s ease;
}

.hidden {
  display: none !important;
}

/* 8x8 阳光黑板报棋盘 */
.board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100vh - 190px);
  margin: 0 auto;
  background: linear-gradient(145deg, #FDE68A 0%, #FCD34D 100%);
  border-radius: 18px;
  padding: clamp(10px, 1vw, 14px);
  box-shadow: inset 0 2px 8px rgba(180, 83, 9, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-board {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  gap: clamp(5px, 0.55vw, 8px);
  background: transparent;
}

/* Individual Pinyin Tile */
.tile {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 6px rgba(30, 41, 59, 0.08);
  cursor: grab;
  touch-action: none;
  will-change: transform;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease, background 0.18s ease;
  overflow: hidden;
}

.tile.dragging {
  cursor: grabbing;
  z-index: 12;
  transition: none !important;
  box-shadow: 0 12px 26px rgba(30, 41, 59, 0.22);
}

.tile.drag-neighbor {
  z-index: 8;
  transition: transform 0.06s linear !important;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(30, 41, 59, 0.13);
}

.tile[data-color="blue"] {
  background: linear-gradient(145deg, #FFFFFF 0%, #EFF6FF 100%);
}
.tile[data-color="red"] {
  background: linear-gradient(145deg, #FFFFFF 0%, #FFF1F2 100%);
}
.tile[data-color="yellow"] {
  background: linear-gradient(145deg, #FFFFFF 0%, #FFFBEB 100%);
}
.tile[data-color="green"] {
  background: linear-gradient(145deg, #FFFFFF 0%, #ECFDF5 100%);
}

.tile.selected {
  background: #FEF9C3;
  box-shadow: 0 0 0 3px #F59E0B, 0 8px 16px rgba(217, 119, 6, 0.24);
  transform: scale(1.07);
  z-index: 4;
}

.tile.hint-glow {
  animation: hintPulse 0.9s infinite alternate ease-in-out;
}

.tile.special-line::after {
  content: "⚡";
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 11px;
}

.tile.special-bomb {
  background: linear-gradient(135deg, #FEF08A 0%, #FDE047 100%);
}

.tile.special-bomb::after {
  content: "🌟";
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 11px;
}

.tile-svg-wrap {
  width: 90%;
  height: 90%;
  display: grid;
  place-items: center;
}

.tile-svg-wrap svg {
  width: 100%;
  height: 100%;
}

/* 拼字找朋友模式：大汉字 + 底部小提示 */
.tile.modern-variant .modern-primary-glyph {
  font-size: clamp(20px, 2.3vw, 31px);
  font-weight: 900;
  font-family: "KaiTi", "STKaiti", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.05;
}

.tile-mini-sub {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.72;
  margin-top: 1px;
}

/* Tile Animations */
.tile.swapping {
  z-index: 10;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease !important;
  box-shadow: 0 8px 18px rgba(30, 41, 59, 0.18);
}

.tile.match-highlight {
  z-index: 5;
  background: #FEF08A !important;
  box-shadow: 0 0 0 3px #F59E0B, 0 6px 16px rgba(217, 119, 6, 0.25);
  transform: scale(1.09);
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.25s ease, background 0.25s ease;
}

.tile.matching {
  animation: matchClear 0.42s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.tile.dropping {
  animation: tileDrop 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.tile.invalid-shake {
  animation: shakeTile 0.4s ease;
}

@keyframes matchClear {
  0% { transform: scale(1.08); opacity: 1; }
  40% { transform: scale(1.2); background: #FDE047; opacity: 0.95; }
  100% { transform: scale(0.15); opacity: 0; }
}

@keyframes tileDrop {
  0% { transform: translateY(-38px) scale(0.94); opacity: 0.3; }
  75% { transform: translateY(2px) scale(1.01); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes shakeTile {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  85% { transform: translateX(4px); }
}

@keyframes hintPulse {
  0% { box-shadow: 0 0 0 2px #F59E0B; background-color: #FFFBEB; }
  100% { box-shadow: 0 0 0 5px #E11D48; background-color: #FEF08A; transform: scale(1.05); }
}

@keyframes pulsePop {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.fx-layer {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.floating-toast {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 66px;
  height: 66px;
  padding: 6px;
  display: grid;
  place-items: center;
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(30, 41, 59, 0.22);
  animation: floatUpFade 1.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.floating-toast svg {
  width: 100%;
  height: 100%;
}

@keyframes floatUpFade {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(0.65); }
  22% { opacity: 1; transform: translate(-50%, -55%) scale(1.15); }
  75% { opacity: 1; transform: translate(-50%, -95%) scale(1.02); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.95); }
}

/* Bottom Legend Bar */
.quick-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.legend-pill {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.legend-pill:hover {
  background: var(--song-celadon-soft);
  color: var(--song-celadon);
  transform: translateY(-1px);
}

.legend-pill svg {
  width: 20px;
  height: 20px;
}

/* ==================== Right Panel: 1st-Grade Pinyin Classroom ==================== */
.card-tag-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}

.g-pill-tag {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 2px 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.g-pill-tag::before {
  content: "";
  width: 4px;
  height: 12px;
  border-radius: 99px;
  background: var(--song-cinnabar);
}

.phonetic-badges {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.pinyin-tag {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 10px;
  border: none;
  white-space: nowrap;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
}

.pill-prefix {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pinyin-tag strong {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archaic-pill {
  background: var(--song-ochre-soft);
  color: #B45309;
}

.archaic-pill strong {
  color: #92400E;
}

.modern-pill {
  background: var(--song-celadon-soft);
  color: var(--song-celadon);
}

.modern-pill strong {
  color: var(--song-celadon-deep);
}

.pronounce-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.pronounce-btn:hover {
  transform: scale(1.03);
  filter: brightness(0.97);
}

.pronounce-btn:active {
  transform: scale(0.96);
}

.char-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 4px 0 10px;
}

.oracle-glyph-box {
  width: 78px;
  height: 78px;
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12), inset 0 0 0 2.5px rgba(37, 99, 235, 0.18);
  display: grid;
  place-items: center;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.18s ease;
}

.oracle-glyph-box:hover {
  transform: scale(1.06);
}

.pic-glyph-box {
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.12), inset 0 0 0 2.5px rgba(217, 119, 6, 0.22);
}

.oracle-glyph-box svg {
  width: 100%;
  height: 100%;
}

.char-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-primary);
  text-align: center;
}

.rhyme-callout {
  background: linear-gradient(90deg, #FEF3C7 0%, #FFFBEB 100%);
  color: #92400E;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.45;
  padding: 7px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
  border-left: 3.5px solid #F59E0B;
}

.char-desc {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Interactive 4-Tones Train */
.tones-practice-wrap {
  margin-bottom: 10px;
}

.tone-pills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 4px;
}

.tone-practice-btn {
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tone-practice-btn:hover {
  background: var(--song-celadon-soft);
  color: var(--song-celadon-deep);
  transform: translateY(-1px);
}

.char-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px 0;
}

.mini-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.mini-val {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Match Log Feed */
.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.log-item:hover {
  background: #FFFFFF;
}

.log-item-badge {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.log-item-badge svg {
  width: 100%;
  height: 100%;
}

.log-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 4px;
  text-align: center;
}

/* ==================== Modals ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.m3-dialog {
  background: var(--surface);
  border-radius: 24px;
  padding: 24px 28px;
  max-width: 1060px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.archaeology-stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  background: var(--surface-warm);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.arch-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.arch-num {
  font-size: 18px;
  font-weight: 800;
}

.arch-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.dict-controls-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}

.dict-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-top: 14px;
  padding-right: 4px;
}

.dict-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
}

.dict-search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  border-radius: var(--radius-pill);
  border: 1.5px solid #E2E8F0;
  background: #F8FAFC;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.dict-search-input:focus {
  background: #FFFFFF;
  border-color: var(--song-celadon);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.dict-tab {
  border: none;
  background: #F1F5F9;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.dict-tab:hover {
  background: var(--song-celadon-soft);
  color: var(--song-celadon);
}

.dict-tab.active {
  background: var(--song-celadon);
  color: #FFFFFF;
}

.dict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.dict-pagination {
  margin-top: 18px;
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.dict-page-info {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.dict-item {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  border: 1.5px solid #E2E8F0;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.04);
  transition: all 0.16s ease;
}

.dict-item:hover {
  border-color: var(--song-celadon);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.dict-item-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dict-svg {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 4px;
  box-shadow: inset 0 0 0 1.5px rgba(37, 99, 235, 0.18);
  display: grid;
  place-items: center;
}

.dict-svg svg {
  width: 100%;
  height: 100%;
}

.dict-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.dict-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.dict-hanzi-group {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.dict-hanzi {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
  flex-shrink: 0;
}

.dict-trad-glyph {
  font-size: 12px;
  font-weight: 800;
  color: var(--song-cinnabar);
  background: var(--song-cinnabar-soft);
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

.dict-phonetic {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dict-status-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.dict-status-badge.unlocked {
  background: var(--song-bamboo-soft);
  color: var(--song-bamboo);
}

.dict-status-badge.try {
  background: var(--song-ochre-soft);
  color: var(--song-ochre);
}

.dict-tags-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dict-chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  background: #F1F5F9;
  padding: 2px 8px;
  border-radius: 6px;
}

.dict-chip.method {
  color: var(--song-celadon);
  background: var(--song-celadon-soft);
}

.dict-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  border-top: 1px dashed #E2E8F0;
  padding-top: 8px;
}

/* Result Dialog */
.result-dialog {
  max-width: 420px;
  text-align: center;
}

.result-confetti {
  font-size: 52px;
  margin-bottom: 8px;
}

.result-dialog h2 {
  font-size: 26px;
  margin-bottom: 6px;
}

.result-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.res-box {
  background: var(--surface-warm);
  padding: 14px;
  border-radius: 16px;
}

.res-box span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.res-box strong {
  font-size: 24px;
  color: var(--song-celadon);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ==================== Multi-Device Responsive Breakpoints ==================== */
@media (min-width: 1600px) {
  .top-bar { padding: 10px 36px; }
  .logo-title { font-size: 24px; }
  .app-container {
    grid-template-columns: minmax(260px, 1fr) minmax(480px, min(45vw, calc(100vh - 156px))) minmax(260px, 1fr);
    padding: 12px 32px 16px;
    gap: 24px;
  }
  .oracle-glyph-box { width: 92px; height: 92px; }
  .goal-chip svg { width: 44px; height: 44px; }
  .char-title { font-size: 19px; }
  .char-desc { font-size: 13.5px; }
  .floating-toast { width: 76px; height: 76px; }
}

@media (max-width: 759px) {
  .top-bar {
    padding: 8px 12px;
    justify-content: center;
    gap: 8px;
  }
  .brand {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  .logo-sub { display: none; }
  .top-grade-bar {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: 100%;
    border-radius: 14px;
    padding: 4px;
    gap: 4px;
  }
  .grade-pill {
    padding: 5px 2px;
    font-size: 11.5px;
    text-align: center;
    border-radius: 9px;
  }
  .app-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    padding: 12px 12px 24px;
    gap: 14px;
  }
  .side-panel { height: auto; }
  .board-stage {
    grid-column: 1 / -1;
    order: -1;
    height: auto;
  }
  .board-frame {
    width: min(90vw, 520px);
    height: min(90vw, 520px);
  }
  .log-list { max-height: 220px; }
}

@media (max-width: 680px) {
  .top-bar {
    flex-wrap: wrap;
    justify-content: center;
    padding: 8px 10px;
    gap: 6px;
  }
  .brand {
    width: 100%;
    justify-content: center;
    gap: 6px;
  }
  .logo-title { font-size: 18px; }
  .top-grade-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
  }
  .grade-pill {
    font-size: 12px;
    padding: 5px 4px;
    text-align: center;
    border-radius: 8px;
  }
  .grade-selector-box {
    display: none;
  }
  .mode-switcher {
    width: 100%;
    justify-content: center;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mode-chip {
    font-size: 12px;
    padding: 5px 4px;
    justify-content: center;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 5px;
  }
  .pill-btn {
    padding: 5px 8px;
    font-size: 11.5px;
    gap: 4px;
    flex: 1 1 auto;
    justify-content: center;
  }
  .badge-count {
    padding: 1px 5px;
    font-size: 10.5px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }
  .app-container {
    grid-template-columns: 1fr;
    padding: 8px 10px 24px;
    gap: 12px;
  }
  .board-stage {
    grid-column: 1;
    order: -1;
    gap: 10px;
  }
  .board-frame {
    width: min(92vw, 440px);
    height: min(92vw, 440px);
    padding: 8px;
    border-radius: 18px;
  }
  .game-board { gap: 4px; }
  .tile { border-radius: 9px; }
  .tools-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .tool-btn {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px 6px;
    gap: 6px;
  }
  .tool-meta { flex-direction: column; gap: 4px; }
  .tool-name { font-size: 12px; }
  .m3-dialog { padding: 16px; border-radius: 18px; max-height: 92vh; }
  .dict-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
