/* ============================================================
 * 点点小练习 · 英文记单词 —— 共用样式
 * 视觉语言复用 数学练习2：粉紫蓝渐变 / 浮动泡泡 / 玻璃卡片
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  -webkit-font-smoothing: antialiased;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ---------- 背景 ---------- */
.bg-stage {
  min-height: 100vh;
  background: linear-gradient(135deg, #fbcfe8 0%, #ddd6fe 45%, #bfdbfe 100%);
  position: relative;
  overflow-x: hidden;
}

/* 浮动泡泡装饰 */
.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0.3;
  filter: blur(40px);
  animation: float 8s ease-in-out infinite;
  pointer-events: none;
}
.bubble-1 { width: 200px; height: 200px; background: radial-gradient(circle, #f9a8d4, transparent); top: 8%;  left: 4%;  animation-delay: 0s; }
.bubble-2 { width: 150px; height: 150px; background: radial-gradient(circle, #c084fc, transparent); top: 55%; right: 8%; animation-delay: 2s; }
.bubble-3 { width: 180px; height: 180px; background: radial-gradient(circle, #93c5fd, transparent); bottom: 8%; left: 28%; animation-delay: 4s; }
.bubble-4 { width: 120px; height: 120px; background: radial-gradient(circle, #fde047, transparent); top: 18%; right: 22%; animation-delay: 1s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-30px) scale(1.1); }
}

/* ---------- 标题 ---------- */
.app-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  background: linear-gradient(90deg, #ec4899, #a855f7, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-title i { -webkit-text-fill-color: initial; }

/* ---------- 玻璃卡片 / 通用 ---------- */
.glass {
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 1.5rem;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.12);
}

.main-card {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.6);
  padding: 1.5rem;
  position: relative;
}
.main-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #ec4899, #a855f7, #3b82f6, #10b981);
  border-radius: 3px 3px 0 0;
}

/* ---------- 按钮组 / 导航 ---------- */
.nav-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.nav-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.9rem; border-radius: 0.75rem;
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
  background: rgba(255,255,255,0.75); border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08); transition: all 0.2s ease;
  color: #6b7280; cursor: pointer;
}
.nav-link:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.12); color: #7c3aed; }
.nav-link.active {
  background: linear-gradient(135deg, #ede9fe, #fce7f3);
  border-color: #c084fc; color: #7c3aed;
  box-shadow: 0 4px 12px rgba(168,85,247,0.3);
}

/* 通用按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem; border-radius: 0.85rem;
  font-size: 0.9rem; font-weight: 700; border: none; cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary { background: linear-gradient(135deg, #a855f7, #ec4899); color: #fff; box-shadow: 0 6px 14px rgba(168,85,247,0.35); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(168,85,247,0.45); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: rgba(255,255,255,0.8); color: #6b7280; border: 1px solid rgba(0,0,0,0.06); }
.btn-ghost:hover { color: #7c3aed; transform: translateY(-2px); }
.btn-danger { background: linear-gradient(135deg, #fb7185, #ef4444); color: #fff; }

/* ---------- 表单 ---------- */
.field {
  width: 100%; padding: 0.5rem 0.8rem; border-radius: 0.6rem;
  border: 1px solid #e5e7eb; background: #fff; font-size: 0.9rem;
  outline: none; transition: all 0.2s ease;
}
.field:focus { border-color: #a855f7; box-shadow: 0 0 0 3px rgba(168,85,247,0.18); }

/* ============================================================
 * 练习页 —— 连线配对
 * ============================================================ */
.match-stage {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem 0;
  align-items: stretch;
  min-height: 360px;
}

/* 左右两列 */
.word-col {
  display: flex; flex-direction: column; gap: 0.6rem;
  position: relative; z-index: 2;
}
.word-col.left  { align-items: flex-start; }
.word-col.right { align-items: flex-end; }

/* 单个词条卡 */
.word-card {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1rem; border-radius: 1rem;
  background: #fff; border: 2px solid #ede9fe;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  font-size: 1.1rem; font-weight: 700; color: #374151;
  cursor: pointer; user-select: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  max-width: 100%;
}
.word-card:hover:not(.matched):not(.disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 16px rgba(168,85,247,0.18);
}
.word-card.selected {
  border-color: #a855f7;
  background: linear-gradient(135deg, #f5f3ff, #fdf2f8);
  box-shadow: 0 0 0 4px rgba(168,85,247,0.2), 0 8px 16px rgba(168,85,247,0.25);
  transform: scale(1.03);
}
.word-card.wrong {
  border-color: #f87171;
  background: #fef2f2;
  animation: shake 0.5s ease-in-out;
}
.word-card.matched {
  border-color: #86efac;
  background: #f0fdf4;
  color: #9ca3af;
  cursor: default;
  opacity: 0.65;
}
.word-card .text { line-height: 1.2; }

/* 喇叭按钮 */
.speaker {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: none; cursor: pointer; flex-shrink: 0;
  background: linear-gradient(135deg, #ddd6fe, #fbcfe8);
  color: #7c3aed; font-size: 0.8rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.speaker:hover { transform: scale(1.15); box-shadow: 0 4px 10px rgba(168,85,247,0.3); }
.speaker:active { transform: scale(0.95); }
.speaker.speaking { animation: spk-pulse 0.6s ease-in-out infinite; }
@keyframes spk-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,85,247,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(168,85,247,0); }
}

/* 中间 SVG 连线层 */
.lines-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 1;
}
.lines-svg path {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

/* 连线绘制动画 */
@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}

/* ============================================================
 * 动画
 * ============================================================ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes pop-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes number-flash {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* 进度条 */
.progress-bar-container {
  width: 100%; height: 0.6rem; background: #f3f4f6; border-radius: 9999px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #a855f7, #ec4899);
  border-radius: 9999px; transition: width 0.5s ease; position: relative;
}
.progress-bar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 2s infinite;
}

/* 统计卡片（复用数学练习） */
.stat-card {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.8); border-radius: 1rem; padding: 0.5rem 1rem;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.5);
}
.stat-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 0.75rem;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.stat-label { font-size: 0.7rem; color: #9ca3af; font-weight: 500; }
.stat-value { font-size: 1.25rem; font-weight: 800; color: #374151; line-height: 1.2; }

/* ============================================================
 * 撒星星 / 庆祝
 * ============================================================ */
.star-fall {
  position: fixed; font-size: 1.6rem; pointer-events: none; z-index: 50;
  animation: confetti-bounce-fall 2.8s ease-in forwards;
}
@keyframes confetti-bounce-fall {
  0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  60%  { transform: translateY(60vh) rotate(360deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
.mega-pop-text {
  position: fixed; font-size: clamp(2.5rem, 8vw, 4.5rem); font-weight: 900;
  pointer-events: none; z-index: 60;
  background: linear-gradient(90deg, #ec4899, #a855f7, #3b82f6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: mega-pop 1.8s ease-out forwards;
}
@keyframes mega-pop {
  0%   { transform: scale(0) translateY(0); opacity: 0; }
  30%  { transform: scale(1.3) translateY(-30px); opacity: 1; }
  70%  { transform: scale(1) translateY(-50px); opacity: 1; }
  100% { transform: scale(1) translateY(-90px); opacity: 0; }
}

/* ============================================================
 * 后台表格
 * ============================================================ */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.88rem; }
.tbl th {
  text-align: left; padding: 0.6rem 0.75rem; font-weight: 700; color: #6b7280;
  background: #faf5ff; position: sticky; top: 0;
}
.tbl td { padding: 0.5rem 0.75rem; border-top: 1px solid #f3f4f6; color: #374151; }
.tbl tr:hover td { background: #fdf4ff; }
.tag {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 9999px;
  font-size: 0.72rem; font-weight: 600; background: #ede9fe; color: #6d28d9;
}
.tag-grey { background: #f3f4f6; color: #6b7280; }

/* 滚动容器 */
.scroll-area { max-height: 60vh; overflow: auto; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  padding: 0.7rem 1.4rem; border-radius: 1rem; font-weight: 600; z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15); animation: pop-in 0.3s ease-out;
}
.toast-ok    { background: linear-gradient(135deg, #86efac, #4ade80); color: #14532d; }
.toast-err   { background: linear-gradient(135deg, #fda4af, #f87171); color: #7f1d1d; }
.toast-info  { background: linear-gradient(135deg, #c4b5fd, #a78bfa); color: #3b0764; }

/* loading 蒙层 */
.loading-mask {
  position: fixed; inset: 0; background: rgba(255,255,255,0.6);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  z-index: 200; flex-direction: column; gap: 1rem;
}
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid #ede9fe; border-top-color: #a855f7;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
 * 模式切换按钮组
 * ============================================================ */
.mode-toggle-group {
  display: inline-flex; gap: 0;
  background: rgba(255,255,255,0.6); border-radius: 1rem;
  padding: 0.35rem; border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.mode-btn {
  padding: 0.5rem 1.2rem; border: none; border-radius: 0.75rem;
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
  background: transparent; color: #9ca3af;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.mode-btn:hover { color: #7c3aed; }
.mode-btn.active {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  box-shadow: 0 4px 12px rgba(168,85,247,0.35);
}
.mode-btn i { margin-right: 0.3rem; }

/* ============================================================
 * 记单词模式 —— 闪卡
 * ============================================================ */
.spell-stage {
  display: flex; flex-direction: column;
  align-items: center; gap: 1.2rem;
  min-height: 320px;
  padding: 1rem 0;
}

/* 闪卡容器 */
.spell-card {
  background: #fff;
  border-radius: 1.5rem;
  padding: 2rem 2.5rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
  border: 2px solid #ede9fe;
  display: flex; flex-direction: column;
  align-items: center; gap: 1.8rem;
  min-width: 280px;
  max-width: 90vw;
  transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
  animation: pop-in 0.35s ease-out;
}
.spell-card.correct {
  border-color: #86efac;
  box-shadow: 0 0 0 6px rgba(134,239,172,0.25), 0 16px 40px rgba(0,0,0,0.12);
  background: #f0fdf4;
}
.spell-card.wrong {
  border-color: #f87171;
  box-shadow: 0 0 0 6px rgba(248,113,113,0.2), 0 16px 40px rgba(0,0,0,0.12);
  background: #fef2f2;
  animation: shake 0.5s ease-in-out;
}

/* 词号 + 中文提示 */
.spell-header {
  display: flex; align-items: center; gap: 1rem;
  font-size: 1.05rem; color: #6b7280;
}
.spell-header .chinese-hint {
  background: linear-gradient(135deg, #ede9fe, #fce7f3);
  color: #7c3aed; font-weight: 700;
  padding: 0.3rem 0.9rem; border-radius: 0.6rem;
  font-size: 1.1rem;
}
.spell-header .word-num {
  font-weight: 600; color: #9ca3af;
}

/* 单词展示行 —— 字母和空格混合 */
.spell-word-row {
  display: flex; align-items: center; justify-content: center;
  gap: 0.35rem; flex-wrap: wrap;
  font-size: 2.2rem; font-weight: 800;
}
.spell-word-row .letter-shown {
  color: #374151;
  min-width: 0.55em; text-align: center;
  transition: color 0.3s ease;
}
.spell-word-row .letter-space {
  color: transparent;
  min-width: 0.35em;
}
.spell-card.correct .letter-shown { color: #16a34a; }
.spell-card.wrong .letter-shown { color: #dc2626; }

/* 空白格输入框 */
.spell-input {
  width: 1.3em; height: 1.5em;
  border: none;
  border-bottom: 3px solid #c4b5fd;
  background: #f5f3ff;
  border-radius: 0.25rem 0.25rem 0 0;
  text-align: center;
  font-size: inherit; font-weight: 800;
  color: #7c3aed;
  outline: none;
  padding: 0; margin: 0;
  font-family: 'SF Mono', 'Cascadia Code', 'Courier New', monospace;
  transition: border-color 0.2s ease, background 0.2s ease;
  caret-color: #a855f7;
}
.spell-input:focus {
  border-bottom-color: #a855f7;
  background: #ede9fe;
  box-shadow: 0 2px 6px rgba(168,85,247,0.2);
}
.spell-card.correct .spell-input {
  border-bottom-color: #4ade80;
  background: #dcfce7;
  color: #16a34a;
}
.spell-card.wrong .spell-input {
  border-bottom-color: #f87171;
  background: #fee2e2;
  color: #dc2626;
}

/* 反馈文字 */
.spell-feedback {
  font-size: 1.1rem; font-weight: 700;
  min-height: 1.8rem;
  text-align: center;
  transition: all 0.3s ease;
}
.spell-feedback.correct-msg { color: #16a34a; }
.spell-feedback.wrong-msg { color: #dc2626; }
.correct-answer-reveal {
  color: #7c3aed; font-size: 1.3rem; font-weight: 800;
}

/* 喇叭按钮（闪卡中） */
.spell-speaker {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.8rem; height: 2.8rem; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, #ddd6fe, #fbcfe8);
  color: #7c3aed; font-size: 1.2rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 10px rgba(168,85,247,0.2);
}
.spell-speaker:hover { transform: scale(1.12); box-shadow: 0 6px 16px rgba(168,85,247,0.35); }
.spell-speaker:active { transform: scale(0.95); }
.spell-speaker.speaking { animation: spk-pulse 0.6s ease-in-out infinite; }

/* 跳过按钮 */
.spell-skip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.4rem 1rem; border-radius: 0.6rem;
  border: 1px solid #e5e7eb; background: rgba(255,255,255,0.8);
  color: #9ca3af; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease;
}
.spell-skip:hover { color: #7c3aed; border-color: #c4b5fd; }

/* 响应式 */
@media (max-width: 640px) {
  .word-card { font-size: 1rem; padding: 0.55rem 0.8rem; }
  .match-stage { min-height: 300px; }
  .spell-word-row { font-size: 1.6rem; gap: 0.25rem; }
  .spell-card { padding: 1.4rem 1.2rem; min-width: 240px; }
  .spell-input { width: 1.1em; height: 1.3em; }
  .spell-speaker { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
}
