:root {
  --bg-cream: #fffdf7;
  --bg-soft: #f7f4eb;
  --surface: #ffffff;
  --ink: #1f2937;
  --ink-muted: #5b6577;
  --border-soft: #e6e2d6;

  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-soft: #eff6ff;

  --sun: #f59e0b;
  --sun-dark: #d97706;
  --sun-soft: #fffbeb;

  --success: #10b981;
  --success-dark: #059669;
  --success-soft: #ecfdf5;

  --danger: #f43f5e;
  --danger-dark: #e11d48;
  --danger-soft: #fff1f2;

  /* 低／中／高年級專屬色 */
  --low-main: #fb923c;
  --low-dark: #ea580c;
  --low-soft: #fff7ed;

  --mid-main: #10b981;
  --mid-dark: #059669;
  --mid-soft: #ecfdf5;

  --high-main: #6366f1;
  --high-dark: #4f46e5;
  --high-soft: #eef2ff;

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-card: 0 10px 28px rgba(31, 41, 55, 0.06), 0 2px 6px rgba(31, 41, 55, 0.04);
  --shadow-float: 0 16px 40px rgba(31, 41, 55, 0.14);

  --font-zh: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-en: "Fredoka", "Nunito", "Comic Sans MS", sans-serif;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-zh);
  color: var(--ink);
  background-color: var(--bg-cream);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(251, 191, 36, 0.14) 0%, transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(59, 130, 246, 0.12) 0%, transparent 34%),
    radial-gradient(circle at 80% 88%, rgba(16, 185, 129, 0.11) 0%, transparent 36%);
  background-attachment: fixed;
  overflow-x: hidden;
}

button,
input {
  font-family: inherit;
}

.en-word {
  font-family: var(--font-en);
  letter-spacing: 0.015em;
}

/* ===== 頂部導覽列 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 253, 247, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--border-soft);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 0 #1d4ed8;
}

.brand-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--ink-muted);
  font-weight: 500;
}

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

.mode-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-pill.is-cloud {
  background: #dcfce7;
  color: #166534;
}

.mode-pill.is-demo {
  background: #fef3c7;
  color: #92400e;
}

.icon-chip-btn {
  border: 2px solid var(--border-soft);
  background: var(--surface);
  color: var(--ink);
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-chip-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

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

/* ===== 主容器 ===== */
.app-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 44px;
}

.screen {
  display: none;
  animation: fadeSlideIn 0.25s ease-out;
}

.screen.is-active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 通用立體按鈕 ===== */
.btn-3d {
  border: none;
  border-radius: 18px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
  user-select: none;
}

.btn-3d:active:not(:disabled) {
  transform: translateY(3px);
}

.btn-3d:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #4f93ff 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 5px 0 var(--primary-dark), 0 10px 20px rgba(59, 130, 246, 0.25);
  padding: 16px 32px;
  font-size: 20px;
}

.btn-primary:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--primary-dark);
}

.btn-success {
  background: linear-gradient(180deg, #1cc78c 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 5px 0 var(--success-dark), 0 10px 20px rgba(16, 185, 129, 0.25);
  padding: 16px 32px;
  font-size: 20px;
}

.btn-success:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--success-dark);
}

.btn-sun {
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  color: #fff;
  box-shadow: 0 5px 0 var(--sun-dark), 0 10px 20px rgba(245, 158, 11, 0.25);
  padding: 15px 28px;
  font-size: 19px;
}

.btn-sun:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--sun-dark);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--border-soft);
  box-shadow: 0 4px 0 #d9d4c7;
  padding: 12px 22px;
  font-size: 16px;
}

.btn-ghost:active:not(:disabled) {
  box-shadow: 0 1px 0 #d9d4c7;
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger-dark);
  border: 2px solid #fecdd3;
  box-shadow: 0 3px 0 #fda4af;
  padding: 10px 18px;
  font-size: 15px;
  border-radius: 14px;
}

.btn-danger-soft:active:not(:disabled) {
  box-shadow: 0 1px 0 #fda4af;
}

/* ===== 首頁 Hero ===== */
.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f4f9ff 60%, #fffbeb 100%);
  border: 2px solid #e2ecff;
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 1.3fr auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 26px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1.5px solid #bfdbfe;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-title {
  margin: 0 0 10px;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.25;
  color: var(--ink);
}

.hero-title span {
  color: var(--primary);
}

.hero-desc {
  margin: 0 0 22px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-muted);
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.hero-mascot {
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: gentleBob 3.2s ease-in-out infinite;
}

@keyframes gentleBob {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-7px);
  }
}

/* ===== 排行榜區 ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-note {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 600;
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.lb-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lb-card-head {
  padding: 14px 18px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lb-card.is-low .lb-card-head {
  background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
}

.lb-card.is-mid .lb-card-head {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.lb-card.is-high .lb-card-head {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.lb-card-title {
  font-size: 17px;
  font-weight: 800;
}

.lb-card-scope {
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.22);
  padding: 3px 10px;
  border-radius: 999px;
}

.lb-list {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1.5px solid transparent;
}

.lb-row.rank-1 {
  background: #fffbeb;
  border-color: #fde68a;
}

.lb-row.rank-2 {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.lb-row.rank-3 {
  background: #fff7ed;
  border-color: #fed7aa;
}

.lb-medal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  flex-shrink: 0;
}

.rank-1 .lb-medal {
  background: #fef08a;
  color: #a16207;
}

.rank-2 .lb-medal {
  background: #e2e8f0;
  color: #475569;
}

.rank-3 .lb-medal {
  background: #fed7aa;
  color: #9a3412;
}

.lb-student {
  flex: 1;
  min-width: 0;
}

.lb-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-grade {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.lb-score {
  text-align: right;
  flex-shrink: 0;
}

.lb-score-num {
  font-family: var(--font-en);
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
}

.lb-score-unit {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
}

.lb-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--ink-muted);
  font-size: 14.5px;
  font-weight: 600;
}

/* ===== 步驟卡片容器（選年級 / 選姓名 / 選時間） ===== */
.panel-card {
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 26px 28px;
  box-shadow: var(--shadow-card);
}

.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.step-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 6px 14px;
  border-radius: 999px;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 900;
}

.panel-subtitle {
  margin: 0 0 22px;
  font-size: 15.5px;
  color: var(--ink-muted);
}

/* 年級選擇網格 */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grade-btn {
  border: 2.5px solid transparent;
  border-radius: 20px;
  padding: 22px 16px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

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

.grade-btn.is-low {
  background: var(--low-soft);
  border-color: #fdba74;
  box-shadow: 0 5px 0 #fb923c;
  color: #9a3412;
}

.grade-btn.is-mid {
  background: var(--mid-soft);
  border-color: #6ee7b7;
  box-shadow: 0 5px 0 #10b981;
  color: #065f46;
}

.grade-btn.is-high {
  background: var(--high-soft);
  border-color: #a5b4fc;
  box-shadow: 0 5px 0 #6366f1;
  color: #3730a3;
}

.grade-btn-emoji {
  font-size: 32px;
}

.grade-btn-label {
  font-size: 23px;
  font-weight: 900;
}

.grade-btn-meta {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
}

/* 學生姓名網格 */
.student-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.search-input {
  flex: 1;
  min-width: 220px;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--border-soft);
  font-size: 16px;
  background: var(--bg-cream);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px 10px;
}

.student-btn {
  background: #fff;
  border: 2px solid #dbe4f3;
  border-radius: 16px;
  padding: 16px 10px;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  text-align: center;
}

.student-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.student-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

/* 限時選擇網格 */
.selected-student-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--primary-soft);
  border: 2px solid #bfdbfe;
  border-radius: 18px;
  padding: 14px 20px;
  margin-bottom: 22px;
}

.selected-student-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 900;
  color: #1e3a8a;
}

.scope-tag {
  background: #fff;
  color: var(--primary-dark);
  border: 1.5px solid #93c5fd;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.time-btn {
  background: #fff;
  border: 2.5px solid var(--border-soft);
  border-radius: 18px;
  padding: 18px 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 #d9d4c7;
  transition: all 0.12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.time-btn-num {
  font-family: var(--font-en);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.time-btn-unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
}

.time-btn.is-selected {
  background: #fffbeb;
  border-color: var(--sun);
  box-shadow: 0 5px 0 var(--sun-dark);
}

.time-btn.is-selected .time-btn-num {
  color: var(--sun-dark);
}

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

.center-action {
  display: flex;
  justify-content: center;
}

/* ===== 測驗主畫面（平板免捲動精簡佈局） ===== */
.quiz-hud {
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

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

.hud-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.hud-name {
  font-size: 16px;
  font-weight: 900;
}

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

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

.stat-pill.is-correct {
  background: var(--success-soft);
  color: var(--success-dark);
}

.stat-pill.is-wrong {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

.stat-pill.is-combo {
  background: var(--sun-soft);
  color: var(--sun-dark);
}

.timer-box {
  font-family: var(--font-en);
  font-size: 24px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 14px;
  background: #f1f5f9;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.timer-box.is-urgent {
  background: var(--danger-soft);
  color: var(--danger-dark);
  animation: pulseUrgent 1s ease-in-out infinite;
}

@keyframes pulseUrgent {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

/* 題目區 */
.quiz-stage {
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 22px 26px;
  box-shadow: var(--shadow-card);
}

.question-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.q-type-badge {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.q-number {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
}

.question-prompt {
  min-height: 112px;
  background: linear-gradient(180deg, #fafcff 0%, #f4f7fc 100%);
  border: 2px dashed #cbd5e1;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  text-align: center;
}

.prompt-word-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.prompt-en {
  font-family: var(--font-en);
  font-size: 46px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}

.prompt-zh {
  font-size: 32px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.3;
}

.prompt-hint {
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 600;
}

/* 發音喇叭按鈕（獨立防誤觸） */
.speaker-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid #93c5fd;
  background: #eff6ff;
  color: var(--primary-dark);
  font-size: 24px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 3px 0 #93c5fd;
  transition: transform 0.12s ease, background 0.15s ease;
}

.speaker-btn:hover {
  background: #dbeafe;
}

.speaker-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #93c5fd;
}

.speaker-btn.is-large {
  width: 82px;
  height: 82px;
  font-size: 38px;
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  color: #fff;
  border-color: var(--primary-dark);
  box-shadow: 0 6px 0 var(--primary-dark), 0 12px 24px rgba(59, 130, 246, 0.25);
}

.speaker-btn.is-playing {
  animation: speakerPulse 0.55s ease-in-out infinite;
}

@keyframes speakerPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
  }
}

/* 4 選 1 選項網格 */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.option-card {
  position: relative;
  min-height: 76px;
  background: #fff;
  border: 2.5px solid #dbe4f0;
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  text-align: left;
}

.option-card:hover:not(.is-locked) {
  border-color: var(--primary);
  background: #f8fbff;
}

.option-card:active:not(.is-locked) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.option-card.is-locked {
  cursor: default;
}

.option-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink-muted);
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.option-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  word-break: break-word;
}

.option-text.is-en {
  font-family: var(--font-en);
  font-size: 26px;
  font-weight: 600;
}

.option-card.is-correct {
  background: var(--success-soft);
  border-color: var(--success);
  box-shadow: 0 4px 0 var(--success-dark);
}

.option-card.is-correct .option-letter {
  background: var(--success);
  color: #fff;
}

.option-card.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  box-shadow: 0 4px 0 var(--danger-dark);
  animation: gentleShake 0.32s ease;
}

.option-card.is-wrong .option-letter {
  background: var(--danger);
  color: #fff;
}

@keyframes gentleShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* 趣味填空題樣式 */
.fill-slots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}

.fill-char {
  width: 48px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--font-en);
  font-size: 32px;
  font-weight: 700;
}

.fill-char.is-fixed {
  background: #fff;
  border: 2px solid #dbe4f0;
  color: var(--ink);
}

.fill-char.is-blank {
  background: #fffbeb;
  border: 3px dashed var(--sun);
  color: var(--primary-dark);
  cursor: pointer;
}

.fill-char.is-blank.is-filled {
  background: #eff6ff;
  border: 3px solid var(--primary);
}

.fill-char.is-blank.is-correct {
  background: var(--success-soft);
  border: 3px solid var(--success);
  color: var(--success-dark);
}

.fill-char.is-blank.is-wrong {
  background: var(--danger-soft);
  border: 3px solid var(--danger);
  color: var(--danger-dark);
}

.fill-tiles-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 0;
}

.letter-tile {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  border: 2.5px solid #bfdbfe;
  background: #fff;
  font-family: var(--font-en);
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  box-shadow: 0 5px 0 #93c5fd;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.letter-tile:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #93c5fd;
}

.letter-tile.is-used {
  opacity: 0.3;
  cursor: default;
}

/* 回饋與下一題列 */
.feedback-bar {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  background: var(--bg-soft);
  border: 2px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.feedback-bar.is-correct {
  background: var(--success-soft);
  border-color: #6ee7b7;
}

.feedback-bar.is-wrong {
  background: var(--danger-soft);
  border-color: #fda4af;
}

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

.feedback-owl {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.feedback-title {
  font-size: 18px;
  font-weight: 900;
}

.feedback-detail {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* ===== 結算頁面 ===== */
.summary-hero {
  text-align: center;
  padding: 24px 20px;
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 55%, #ecfdf5 100%);
  border: 2px solid #fde68a;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  margin-bottom: 22px;
}

.summary-title {
  margin: 8px 0 6px;
  font-size: 30px;
  font-weight: 900;
}

.summary-badge-new {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}

.summary-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 22px;
}

.summary-stat-card {
  background: #fff;
  border: 2px solid var(--border-soft);
  border-radius: 18px;
  padding: 16px 12px;
}

.summary-stat-val {
  font-family: var(--font-en);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
}

.summary-stat-val.is-green {
  color: var(--success-dark);
}

.summary-stat-val.is-red {
  color: var(--danger-dark);
}

.summary-stat-val.is-blue {
  color: var(--primary-dark);
}

.summary-stat-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-top: 4px;
}

.wrong-review-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.wrong-word-chip {
  background: #fff;
  border: 2px solid #fecdd3;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wrong-word-en {
  font-family: var(--font-en);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
}

.wrong-word-zh {
  font-size: 14px;
  color: var(--ink-muted);
  font-weight: 600;
}

/* ===== 彈窗 Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 26px;
  padding: 28px 26px;
  box-shadow: var(--shadow-float);
  text-align: center;
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-emoji {
  font-size: 46px;
  margin-bottom: 8px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 900;
}

.modal-desc {
  margin: 0 0 20px;
  font-size: 16px;
  color: var(--ink-muted);
  line-height: 1.55;
}

.modal-highlight {
  display: inline-block;
  background: var(--primary-soft);
  color: #1e3a8a;
  border: 2px solid #93c5fd;
  padding: 10px 22px;
  border-radius: 16px;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 22px;
}

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

.modal-actions .btn-3d {
  flex: 1;
  padding: 14px 18px;
  font-size: 17px;
}

.settings-field {
  text-align: left;
  margin-bottom: 16px;
}

.settings-label {
  display: block;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 6px;
}

.settings-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 2px solid var(--border-soft);
  font-size: 14px;
}

/* ===== 響應式平板與手機微調 ===== */
@media (max-width: 900px) {
  .leaderboard-grid {
    grid-template-columns: 1fr;
  }
  .hero-card {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 22px;
  }
  .hero-mascot {
    margin: 0 auto;
    width: 130px;
    height: 130px;
  }
  .hero-cta-row {
    justify-content: center;
  }
  .summary-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .grade-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .time-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .prompt-en {
    font-size: 36px;
  }
  .prompt-zh {
    font-size: 26px;
  }
  .feedback-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .brand-sub {
    display: none;
  }
}
