/* ========================================================
   南一版三年級上學期數學 資源班備課與教學平台
   特教無障礙、低刺激（ASD友善）、高對比、大觸控視覺系統
   ======================================================== */

@import url("https://cdn.jsdelivr.net/npm/@fontsource/bpmf-zihi-kai-std@latest/index.css");

:root {
  --primary: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-dark: #3730a3;
  --secondary: #0284c7;
  --secondary-light: #e0f2fe;
  --accent: #d97706;
  --accent-light: #fef3c7;
  --success: #059669;
  --success-light: #d1fae5;
  --danger: #dc2626;
  --danger-light: #fee2e2;

  /* 背景與文字色 */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #cbd5e1;

  /* 位值標準特教專用色碼 (千紅/百藍/十綠/個橘) */
  --pv-thousand: #dc2626;
  --pv-hundred: #2563eb;
  --pv-ten: #16a34a;
  --pv-one: #ea580c;

  /* 幾何與排版 */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  /* 專為特教學童閱讀設計之字嗨注音標楷與標準國字字型系統 */
  --font-zihi: "Bpmf Zihi Kai Std", "Zihi Kai Std", "BpmfZihiKaiStd", "字嗨注音標楷", "DFKai-SB", "BiauKai", "標楷體", "TW-Kai", "STKaiti", "KaiTi", serif;
  --font-size-base: 18px;
}

/* 高對比模式 (給視知覺弱或學障學童) */
body.high-contrast-mode {
  --bg-main: #000000;
  --bg-card: #18181b;
  --bg-subtle: #27272a;
  --text-main: #ffffff;
  --text-muted: #e4e4e7;
  --border-color: #facc15;
  --primary: #818cf8;
  --primary-light: #312e81;
}

/* 專注/低刺激模式 (自閉症友善，減少所有陰影與跳躍元素) */
body.calm-focus-mode {
  --bg-main: #f0fdf4;
  --bg-card: #ffffff;
  --primary: #059669;
  --secondary: #0d9488;
}

body.calm-focus-mode .banner,
body.calm-focus-mode .decorative-item {
  display: none !important;
}

/* 全域重設 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 無障礙跳至主內容 */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: #ffffff;
  padding: 8px 16px;
  z-index: 1000;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: top 0.2s;
}
.skip-link:focus {
  top: 10px;
}

/* 頁首 Header 導覽列 */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: block;
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 12px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 特教友善工具按鈕 */
.tool-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  min-height: 44px;
}
.tool-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.tool-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary-dark);
}

@keyframes pulseHighlight {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.pulse-highlight {
  animation: pulseHighlight 1.5s infinite ease-in-out !important;
  border: 2px solid #f59e0b !important;
  font-weight: 900 !important;
  background: #fef3c7 !important;
  color: #92400e !important;
}

/* ========================================================
   特教專業功能直式選單 (Vertical Dropdown Menu)
   ======================================================== */
.tools-dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-trigger-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  border: 1.5px solid #818cf8 !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.dropdown-trigger-btn:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.dropdown-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.85rem;
}

.tools-dropdown-container.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* 直式選單主體面板 */
.vertical-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  width: 330px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: #ffffff;
  border: 2px solid #6366f1;
  border-radius: 16px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(99, 102, 241, 0.1);
  padding: 8px;
  z-index: 10000;
  display: none;
  flex-direction: column;
  animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.vertical-dropdown-menu::-webkit-scrollbar {
  width: 6px;
}
.vertical-dropdown-menu::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.tools-dropdown-container.open .vertical-dropdown-menu {
  display: flex;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-header {
  padding: 10px 12px 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 6px;
}

.dropdown-header-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #1e1b4b;
  display: block;
}

.dropdown-header-sub {
  font-size: 0.75rem;
  color: #64748b;
  display: block;
  margin-top: 2px;
}

.dropdown-items-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
  font-family: inherit;
}

.dropdown-menu-item:hover,
.dropdown-menu-item:focus {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateX(3px);
}

.dropdown-menu-item.active {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
}

.dropdown-menu-item.active .menu-item-title {
  color: #1d4ed8 !important;
}

.menu-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.menu-item-content {
  flex: 1;
  min-width: 0;
}

.menu-item-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.2;
}

.menu-item-desc {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 高對比模式相容 */
body.high-contrast .vertical-dropdown-menu {
  background: #000000 !important;
  border-color: #ffff00 !important;
  box-shadow: 0 0 20px #ffff00 !important;
}
body.high-contrast .dropdown-header-title,
body.high-contrast .menu-item-title {
  color: #ffff00 !important;
}
body.high-contrast .dropdown-header-sub,
body.high-contrast .menu-item-desc {
  color: #ffffff !important;
}
body.high-contrast .dropdown-menu-item:hover {
  background: #222222 !important;
  border-color: #ffff00 !important;
}

/* 代幣集星箱 (Token Economy) */
.token-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  color: #92400e;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 1.05rem;
}

/* 主導覽標籤列 (Tabs) */
.main-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}
.nav-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-tab {
  background: none;
  border: none;
  border-bottom: 4px solid transparent;
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}
.nav-tab:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 主畫面容器 */
.main-content {
  flex: 1;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* 頁面區塊切換 */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* 單元選擇格線 (Unit Grid) */
.unit-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.unit-card-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.unit-card-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.unit-card-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

.unit-num-badge {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
}
.unit-title-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}
.unit-curriculum-code {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 單元教學與詳情主面板 */
.unit-detail-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}
@media (max-width: 1024px) {
  .unit-detail-layout {
    grid-template-columns: 1fr;
  }
}

/* 特教鷹架側邊欄 (C-R-A & 障別提示) */
.special-ed-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

/* C-R-A 階段指示籤 */
.cra-stage-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  border-left: 5px solid var(--primary);
}
.cra-stage-box.c-stage { border-left-color: #10b981; }
.cra-stage-box.r-stage { border-left-color: #3b82f6; }
.cra-stage-box.a-stage { border-left-color: #8b5cf6; }

.cra-tag {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.cra-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* 障別提示摺疊/清單 */
.need-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.tag-sld { background: #fee2e2; color: #b91c1c; } /* 學障-紅 */
.tag-asd { background: #e0e7ff; color: #4338ca; } /* 自閉-藍紫 */
.tag-id  { background: #fef3c7; color: #b45309; } /* 智障-琥珀 */

.disability-guide-item {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-color);
}
.disability-guide-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* ========================================================
   🎚️ 提示階層三段消褪控制列 (Prompt Hierarchy Fading System)
   ======================================================== */
.fading-control-panel {
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.fading-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fading-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.fading-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-muted);
  transition: all 0.2s;
}
.fading-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.fading-btn.active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}

/* Level 2: 半鷹架消褪樣式 (去鮮豔色、留灰色骨架) */
.prompt-level-2 .pv-cell.pv-thousand,
.prompt-level-2 .pv-cell.pv-hundred,
.prompt-level-2 .pv-cell.pv-ten,
.prompt-level-2 .pv-cell.pv-one {
  border-top-color: #64748b !important;
}
.prompt-level-2 .carry-bubble {
  background: #64748b !important;
  border: 1px solid #475569 !important;
}
.prompt-level-2 .block-tens { background: #f1f5f9 !important; border-color: #94a3b8 !important; }
.prompt-level-2 .block-ones { background: #f8fafc !important; border-color: #cbd5e1 !important; }

/* Level 3: 無鷹架獨立模式 (完全黑白、隱藏進位圈與高亮框) */
.prompt-level-3 .pv-cell {
  border-top-color: #0f172a !important;
  background: #ffffff !important;
}
.prompt-level-3 .carry-bubble,
.prompt-level-3 .borrow-bubble {
  visibility: hidden !important;
}
.prompt-level-3 .scaffold-wizard-box,
.prompt-level-3 .scaffold-tip {
  display: none !important;
}
.prompt-level-3 .vertical-math-board {
  background: #ffffff !important;
  border: 2px solid #000000 !important;
}

/* ========================================================
   🔄 先備能力診斷與回溯卡 (Prerequisite Backtracking Card)
   ======================================================== */
.prerequisite-card {
  background: #f0fdf4;
  border: 2px solid #22c55e;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.prereq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.prereq-badge {
  background: #dcfce7;
  color: #15803d;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 12px;
}
.prereq-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #166534;
}
.prereq-body {
  font-size: 0.92rem;
  color: #14532d;
  line-height: 1.6;
}
.prereq-check {
  font-family: var(--font-zihi);
  background: #ffffff;
  border: 1px dashed #4ade80;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 1.15rem;
  line-height: 1.75;
  letter-spacing: 0.04em;
  color: #14532d;
}

/* ========================================================
   🚨 迷思概念除錯專區 (Misconception Clinic Card)
   ======================================================== */
.misconception-clinic-card {
  background: #fff1f2;
  border: 2px solid #f43f5e;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.clinic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.clinic-badge {
  background: #fecdd3;
  color: #9f1239;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 12px;
}
.clinic-bad-example {
  background: #ffffff;
  border-left: 4px solid #e11d48;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
  color: #881337;
  margin-bottom: 8px;
}
.clinic-root-cause {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 8px;
}
.clinic-buster-solution {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.92rem;
  color: #166534;
  font-weight: 600;
}

/* ========================================================
   🚀 特教微步驟教學引導精靈 (Step-by-Step Scaffolding Wizard)
   ======================================================== */
.scaffold-wizard-box {
  background: var(--bg-card);
  border: 3px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.wizard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.wizard-mode-pill {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 步驟指示條 */
.wizard-steps-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin: 16px 0 24px 0;
  padding: 0 10px;
}
.wizard-steps-track::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 20px;
  right: 20px;
  height: 4px;
  background: var(--border-color);
  z-index: 1;
  transform: translateY(-50%);
}

.wizard-step-node {
  position: relative;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s;
}
.wizard-step-node.completed {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}
.wizard-step-node.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.25);
}

/* 當前步驟卡片 */
.wizard-current-card {
  background: #fdf4ff;
  border: 2px solid #d946ef;
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
}
.wizard-step-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #86198f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.wizard-step-instruction {
  font-family: var(--font-zihi);
  font-size: 1.35rem;
  font-weight: 600;
  color: #701a75;
  line-height: 1.8;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.wizard-step-check {
  font-family: var(--font-zihi);
  background: #ffffff;
  border: 1px dashed #c026d3;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 1.15rem;
  color: #4a044e;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.03em;
}

/* 步驟導引按鈕控制列 */
.wizard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 逐步解題鷹架階梯 (Practice Scaffolds) */
.step-ladder-box {
  background: #ffffff;
  border: 3px solid #3b82f6;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 18px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.12);
}
.ladder-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 12px;
}
.ladder-header-title {
  font-weight: 800;
  color: #1e40af;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ladder-progress-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ladder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-family: var(--font-zihi);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.75;
  transition: all 0.25s ease;
}
.ladder-item.ladder-step-revealed {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  animation: ladderSlideIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.ladder-item.ladder-step-active {
  background: #eff6ff;
  border: 2px solid #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.ladder-item.ladder-step-final {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 3px solid #10b981;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2);
}
.ladder-item.ladder-step-locked {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  color: #94a3b8;
  user-select: none;
  font-size: 1.05rem;
}
@keyframes ladderSlideIn {
  0% { transform: translateY(-8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.ladder-dot {
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
  font-family: var(--font-base);
}
.ladder-item.ladder-step-final .ladder-dot {
  background: #10b981;
}
.ladder-item.ladder-step-locked .ladder-dot {
  background: #cbd5e1;
  color: #64748b;
}
.ladder-text {
  font-family: var(--font-zihi);
  font-size: 1.25rem;
  line-height: 1.75;
  letter-spacing: 0.04em;
  flex: 1;
}
.ladder-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid #e2e8f0;
  flex-wrap: wrap;
}

/* 互動教具容器樣式 */
.manipulative-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.manipulative-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.manipulative-header h4 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.scaffold-tip {
  background: var(--accent-light);
  border-left: 5px solid var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: #78350f;
  margin-bottom: 20px;
}

/* 彩色位值格 (千紅 百藍 十綠 個橘) */
.place-value-display-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.pv-cell {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  border-top: 6px solid #cbd5e1;
}
.pv-cell.pv-thousand { border-top-color: var(--pv-thousand); }
.pv-cell.pv-hundred  { border-top-color: var(--pv-hundred); }
.pv-cell.pv-ten      { border-top-color: var(--pv-ten); }
.pv-cell.pv-one      { border-top-color: var(--pv-one); }

.pv-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}
.pv-val {
  display: block;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.2;
}
.pv-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 總數顯示與朗讀列 */
.pv-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-light);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.highlight-number {
  color: var(--primary-dark);
  font-size: 1.6rem;
  font-weight: 900;
}

/* 大觸控按鈕 */
.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  min-height: 48px;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.9rem;
  min-height: 38px;
}
.btn-xs {
  padding: 4px 8px;
  font-size: 0.85rem;
  min-height: 32px;
}
.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
}
.btn-accent {
  background: var(--accent);
  color: #ffffff;
}
.btn-accent:hover {
  background: #b45309;
}
.btn-speech {
  background: #fdf2f8;
  color: #db2777;
  border-color: #f472b6;
}
.btn-speech:hover {
  background: #fce7f3;
}

/* 觸控增減按鈕群 */
.manipulative-control-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.coin-control-column {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item-preview {
  font-weight: 800;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}
.money-1000 { background: #fee2e2; color: #b91c1c; border: 2px solid #ef4444; }
.money-100  { background: #fee2e2; color: #991b1b; border: 2px solid #f87171; }
.money-10   { background: #dcfce7; color: #166534; border: 2px solid #4ade80; }
.money-1    { background: #ffedd5; color: #9a3412; border: 2px solid #fb923c; }

.block-1000 { background: #fee2e2; color: #b91c1c; }
.block-100  { background: #dbeafe; color: #1e40af; }
.block-10   { background: #dcfce7; color: #166534; }
.block-1    { background: #ffedd5; color: #9a3412; }

.btn-group-touch {
  display: flex;
  gap: 6px;
}
.btn-action-touch {
  flex: 1;
  min-height: 44px;
  font-weight: 800;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-color);
  cursor: pointer;
}
.btn-action-touch:hover {
  background: var(--primary-light);
}

.regroup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 四位數直式輔助樣式 */
.vertical-math-board {
  max-width: 440px;
  margin: 0 auto;
  background: var(--bg-subtle);
  border: 3px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.vm-row {
  display: grid;
  grid-template-columns: 50px repeat(4, 1fr);
  align-items: center;
  text-align: center;
  min-height: 48px;
}
.vm-col {
  font-size: 1.8rem;
  font-weight: 900;
}
.vm-header .vm-col {
  font-size: 1.1rem;
  font-weight: 800;
  padding-bottom: 6px;
}
.vm-operator {
  color: var(--primary);
  font-size: 2rem;
}
.vm-bottom-border {
  border-bottom: 4px solid var(--text-main);
  padding-bottom: 8px;
}
.vm-result {
  padding-top: 10px;
  color: var(--primary-dark);
}
.carry-bubble, .borrow-bubble {
  display: inline-block;
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  line-height: 32px;
}
.borrow-bubble {
  background: #dc2626;
  border-radius: 6px;
  width: auto;
  padding: 2px 6px;
  height: auto;
  line-height: 1.4;
}

/* 逐步引導算式與邊講邊顯示動態揭示樣式 */
.step-progress-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.step-pill {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  border: 2px solid #cbd5e1;
  transition: all 0.2s;
}
.step-pill.current {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  border-color: #312e81;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
  transform: scale(1.06);
}
.step-pill.completed {
  background: #ecfdf5;
  color: #047857;
  border-color: #10b981;
}

.step-guide-card {
  background: linear-gradient(135deg, #ffffff, #fffbeb);
  border: 3px solid #f59e0b;
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.12);
}
.step-guide-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: #92400e;
  margin-bottom: 6px;
}
.step-guide-instruction {
  font-size: 1.15rem;
  color: #1f2937;
  line-height: 1.6;
}

.vm-col.active-column {
  background: rgba(245, 158, 11, 0.15) !important;
  border-radius: 12px;
  box-shadow: 0 0 0 2px #f59e0b;
  animation: columnPulse 1.8s infinite alternate;
}
@keyframes columnPulse {
  from { background: rgba(245, 158, 11, 0.12); }
  to { background: rgba(245, 158, 11, 0.25); }
}

.vm-res-placeholder {
  color: #cbd5e1;
  font-size: 1.8rem;
  font-weight: 700;
  display: inline-block;
  user-select: none;
}
.vm-res-revealed {
  display: inline-block;
  font-size: 2.1rem;
  font-weight: 900;
  animation: digitPop 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes digitPop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); opacity: 1; }
}

.carry-bubble.revealed,
.borrow-bubble.revealed {
  animation: bubbleDrop 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes bubbleDrop {
  0% { transform: translateY(-12px) scale(0.5); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 乘法面積模型樣式 */
.multiplication-area-box {
  display: flex;
  gap: 6px;
  background: #ffffff;
  border: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  min-height: 120px;
}
.area-block {
  padding: 14px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.block-tens { background: #dbeafe; border: 2px solid #3b82f6; }
.block-ones { background: #fef3c7; border: 2px solid #f59e0b; }
.multiplication-sum-bar {
  background: var(--success-light);
  color: #065f46;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 800;
  text-align: center;
  font-size: 1.2rem;
}

/* 直尺與放大鏡 */
.ruler-workspace {
  background: #ffffff;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.measure-target-item {
  height: 50px;
  background: #e2e8f0;
  border: 2px solid #64748b;
  border-radius: 6px;
  margin-left: 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
}
.magnifier-readout-card {
  background: var(--bg-subtle);
  border: 2px solid var(--secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* 動態角樣式 */
.angle-interactive-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  flex-wrap: wrap;
}
.badge-tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 1.1rem;
  background: var(--bg-subtle);
}
.badge-tag.angle-right { background: #dcfce7; color: #15803d; }
.badge-tag.angle-acute { background: #dbeafe; color: #1d4ed8; }
.badge-tag.angle-obtuse { background: #fef3c7; color: #b45309; }

/* 除法分物盤 */
.division-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.baskets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.basket-plate {
  background: #ffffff;
  border: 3px solid #cbd5e1;
  border-radius: 50%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: var(--shadow-sm);
}
.apple-item {
  font-size: 1.5rem;
}
.remainder-box {
  background: #fee2e2;
  border: 2px dashed #ef4444;
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

/* 容量量筒 */
.beaker-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  flex-wrap: wrap;
}
.drink-comparisons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.drink-item {
  background: #ffffff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
}

/* 分數切盤與符號卡 */
.fraction-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  flex-wrap: wrap;
}
.fraction-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
}
.f-bar {
  width: 100%;
  height: 6px;
  background: var(--text-main);
  margin: 4px 0;
}

/* 圓形與幾何 */
.circle-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  flex-wrap: wrap;
}
.circle-formula-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cf-math-rule {
  background: #dcfce7;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

/* 隨堂互動練習題 (Adaptive Practice) */
.practice-container {
  max-width: 860px;
  margin: 0 auto;
}
.question-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.question-text {
  font-family: var(--font-zihi);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.85;
  letter-spacing: 0.05em;
  margin-bottom: 24px;
}
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.option-btn {
  font-family: var(--font-zihi);
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: 20px;
  padding: 18px 24px;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 6px 0 #cbd5e1;
  position: relative;
}
.option-btn .option-label {
  font-family: var(--font-base);
  font-weight: 800;
  font-size: 1.15rem;
  padding: 6px 12px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.option-btn:nth-child(1) .option-label {
  background: #ffe4e6;
  color: #be123c;
}
.option-btn:nth-child(2) .option-label {
  background: #e0f2fe;
  color: #0369a1;
}
.option-btn:nth-child(3) .option-label {
  background: #dcfce7;
  color: #15803d;
}
.option-btn:nth-child(4) .option-label {
  background: #f3e8ff;
  color: #7e22ce;
}
.option-btn .option-text {
  font-family: var(--font-zihi);
  letter-spacing: 0.04em;
  color: #1e293b;
  flex: 1;
}
.option-btn:hover:not(:disabled) {
  border-color: #6366f1;
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #c7d2fe;
  background: #faf5ff;
}
.option-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #c7d2fe;
}
.option-btn.selected-correct {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0) !important;
  border-color: #10b981 !important;
  box-shadow: 0 6px 0 #059669 !important;
  color: #065f46 !important;
  transform: scale(1.02);
  animation: correctBounce 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.option-btn.selected-wrong {
  background: #fff7ed !important;
  border-color: #fb923c !important;
  box-shadow: 0 5px 0 #ea580c !important;
  color: #9a3412 !important;
  animation: gentleShake 0.4s ease-in-out;
}

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

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

/* 提示回饋盒 */
.feedback-box {
  font-family: var(--font-zihi);
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  font-size: 1.25rem;
  line-height: 1.75;
  letter-spacing: 0.04em;
  display: none;
}
.feedback-box.show {
  display: block;
}
.feedback-box.success {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #065f46;
  border: 3px solid #10b981;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.15);
}
.feedback-box.hint {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  color: #92400e;
  border: 3px solid #f59e0b;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.15);
}
.feedback-box.encouragement-card {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  color: #854d0e;
  border: 3px solid #fb923c;
  box-shadow: 0 8px 20px rgba(251, 146, 60, 0.18);
  border-radius: 20px;
}
  background: var(--accent-light);
  color: #92400e;
  border: 2px solid var(--accent);
}

/* IEP 隨堂評量產生器 */
.iep-tracker-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .iep-tracker-layout {
    grid-template-columns: 1fr;
  }
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.report-output-box {
  background: #ffffff;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 250px;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.7;
}

/* 頁尾 Footer */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ========================================================
   字嗨注音標楷專用類別 (給特教孩童閱讀之題目與指引)
   ======================================================== */
.zihi-font,
.child-math-question,
.child-question-text {
  font-family: var(--font-zihi) !important;
  letter-spacing: 0.04em !important;
}

/* ========================================================
   童趣化主題、伴讀吉祥物與聲光慶祝特效系統
   ======================================================== */

/* 伴讀吉祥物互動卡片 (Mascot Companion Card) */
.mascot-companion-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 20px;
  border: 3px solid #f59e0b;
  margin-bottom: 20px;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.12);
  transition: all 0.3s ease;
}
.mascot-avatar-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 3px solid #ffffff;
}
.mascot-avatar-circle:hover {
  transform: scale(1.1) rotate(5deg);
}
.mascot-avatar-circle:active {
  transform: scale(0.95);
}
.mascot-emoji-big {
  font-size: 2.5rem;
  user-select: none;
}
.mascot-info-area {
  flex: 1;
}
.mascot-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.mascot-name-row strong {
  font-size: 1.25rem;
  color: #1e1b4b;
}
.mascot-role-pill {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
}
.mascot-switcher-mini {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.mascot-switch-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.mascot-switch-btn:hover {
  transform: scale(1.15);
  border-color: #f59e0b;
}
.mascot-switch-btn.active {
  border-color: #f59e0b;
  background: #fef3c7;
  transform: scale(1.1);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}
.mascot-speech-bubble {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 1.05rem;
  color: #334155;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.mascot-speech-bubble strong {
  color: #d97706;
}

/* 慶祝聲光彈出視窗 (Celebration Modal) */
.kid-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.25s ease-out;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.kid-modal-card {
  background: #ffffff;
  border-radius: 28px;
  max-width: 540px;
  width: 100%;
  padding: 32px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  animation: cardPopIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes cardPopIn {
  from { transform: scale(0.7) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.celebration-card {
  border: 4px solid #facc15;
}
.celebration-sunburst {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.25) 0%, rgba(250, 204, 21, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: sunburstSpin 20s linear infinite;
}
@keyframes sunburstSpin {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

.celebration-mascot-jump {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
  animation: mascotHop 0.8s ease-in-out infinite alternate;
}
@keyframes mascotHop {
  from { transform: translateY(0); }
  to { transform: translateY(-16px); }
}
.celebration-badge {
  font-size: 4rem;
  display: block;
}
.celebration-crown {
  position: absolute;
  top: -14px;
  right: -8px;
  font-size: 2rem;
  animation: crownWiggle 1s ease-in-out infinite alternate;
}
@keyframes crownWiggle {
  from { transform: rotate(-10deg); }
  to { transform: rotate(15deg); }
}

.celebration-title {
  font-size: 2rem;
  color: #1e1b4b;
  font-weight: 900;
  margin-bottom: 10px;
}
.celebration-reward-pill {
  display: inline-block;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 8px 20px;
  border-radius: 999px;
  border: 2px solid #f59e0b;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}
.celebration-speech-box {
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 24px;
  border: 2px dashed #cbd5e1;
}
.celebration-cheer {
  font-size: 1.2rem;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: 4px;
}
.celebration-hint-note {
  font-size: 1rem;
  color: #475569;
}
.celebration-action-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 童趣專用大按鈕 */
.kid-btn {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kid-btn-primary {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  box-shadow: 0 5px 0 #312e81;
}
.kid-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #312e81;
}
.kid-btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #312e81;
}
.kid-btn-solution {
  background: #eff6ff;
  color: #1d4ed8;
  border: 2px solid #bfdbfe;
  box-shadow: 0 5px 0 #93c5fd;
}
.kid-btn-solution:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #93c5fd;
}
.kid-btn-secondary {
  background: #ffffff;
  color: #475569;
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 0 #94a3b8;
}

/* 代幣計數器跳動特效 */
.pulse-celebrate {
  animation: counterPulse 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) !important;
}
@keyframes counterPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.35) rotate(-5deg); color: #f59e0b; }
  100% { transform: scale(1); }
}

/* ========================================================
   雙人即時計算搶答擂台專用樣式 (Math Battle Arena)
   ======================================================== */
.battle-stage-card {
  background: #ffffff;
  border: 3px solid #6366f1;
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.12);
  margin-bottom: 30px;
}
.battle-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 2px dashed #e2e8f0;
  margin-bottom: 20px;
}
.battle-unit-picker-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.battle-meta-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.battle-round-badge {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 999px;
  border: 2px solid #f59e0b;
  font-size: 1rem;
}

/* 雙人計分板 */
.battle-scoreboard-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}
@media (max-width: 768px) {
  .battle-scoreboard-grid {
    grid-template-columns: 1fr;
  }
}
.battle-player-card {
  border-radius: 22px;
  padding: 18px 20px;
  border: 3px solid transparent;
  transition: all 0.2s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}
.battle-player-card.player-blue {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: #3b82f6;
}
.battle-player-card.player-red {
  background: linear-gradient(135deg, #fff1f2, #ffe4e6);
  border-color: #f43f5e;
}

.battle-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.battle-player-badge {
  font-weight: 800;
  font-size: 1.05rem;
}
.battle-player-select {
  padding: 4px 8px;
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  font-weight: 700;
  background: #ffffff;
}

.battle-player-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.battle-avatar {
  font-size: 3.2rem;
  width: 76px;
  height: 76px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.battle-score-box {
  text-align: right;
}
.battle-score-num {
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
}
.player-blue .battle-score-num { color: #1d4ed8; }
.player-red .battle-score-num { color: #be123c; }
.battle-score-unit {
  font-size: 0.95rem;
  font-weight: 700;
  color: #64748b;
  margin-top: 4px;
}
.battle-status-msg {
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

/* VS 徽章 */
.battle-vs-badge-box {
  text-align: center;
  padding: 0 10px;
}
.battle-vs-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
  box-shadow: 0 6px 14px rgba(217, 119, 6, 0.3);
  border: 3px solid #ffffff;
}
.battle-vs-sub {
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748b;
}

/* 題目展示區 */
.battle-question-display {
  background: #ffffff;
  border: 3px solid #e0e7ff;
  border-radius: 22px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
}
.battle-question-tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.battle-question-sub-title {
  background: #e0e7ff;
  color: #3730a3;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
}
.battle-question-text {
  font-family: var(--font-zihi);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.8;
  color: #0f172a;
}

/* 雙人作答站台 (Stations Grid) */
.battle-stations-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .battle-stations-grid {
    grid-template-columns: 1fr;
  }
}
.battle-station {
  background: #f8fafc;
  border-radius: 22px;
  padding: 18px;
  border: 3px solid #cbd5e1;
}
.station-blue {
  border-color: #93c5fd;
  background: #f0f7ff;
}
.station-red {
  border-color: #fecdd3;
  background: #fff5f5;
}
.station-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  margin-bottom: 14px;
  font-size: 1.05rem;
}
.station-label .key-hint {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: normal;
}

.station-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.battle-opt-btn {
  font-family: var(--font-zihi);
  padding: 14px 18px;
  font-size: 1.3rem;
  font-weight: 600;
  border-radius: 16px;
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.12s;
  min-height: 58px;
}
.battle-opt-btn .key-badge {
  font-family: var(--font-base);
  font-size: 0.85rem;
  font-weight: 900;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px 8px;
  box-shadow: 0 2px 0 #94a3b8;
}
.battle-opt-btn .opt-label {
  font-family: var(--font-base);
  font-weight: 800;
  font-size: 1.1rem;
}
.battle-opt-btn .opt-content {
  flex: 1;
}

.btn-blue {
  background: #ffffff;
  border-color: #93c5fd;
  color: #1e3a8a;
  box-shadow: 0 4px 0 #bfdbfe;
}
.btn-blue:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #93c5fd;
  border-color: #3b82f6;
}
.btn-blue:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #93c5fd;
}

.btn-red {
  background: #ffffff;
  border-color: #fecdd3;
  color: #881337;
  box-shadow: 0 4px 0 #fecdd3;
}
.btn-red:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #fda4af;
  border-color: #f43f5e;
}
.btn-red:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #fda4af;
}

.btn-correct-burst {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 6px 0 #047857 !important;
  animation: correctBounce 0.4s ease-out;
}
.btn-wrong-shake {
  background: #fed7aa !important;
  color: #9a3412 !important;
  border-color: #f97316 !important;
  animation: gentleShake 0.4s ease-out;
  opacity: 0.7;
}

/* 頒獎典禮卡片 (Ceremony Card) */
.ceremony-card {
  border: 4px solid #f59e0b;
}
.ceremony-rewards-box {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: #fffbeb;
  border: 2px dashed #f59e0b;
  border-radius: 18px;
  padding: 18px;
  margin: 16px 0;
}
.ceremony-reward-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.badge-star {
  background: #f59e0b;
  color: #ffffff;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* ========================================================
   🎪 互動遊戲冒險館專用樣式 (Interactive Math Arcade)
   ======================================================== */
.arcade-container {
  max-width: 1200px;
  margin: 0 auto;
}

.arcade-hero-card {
  background: linear-gradient(135deg, #eef2ff, #faf5ff);
  border: 3px solid #818cf8;
  border-radius: 24px;
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.1);
}
.arcade-hero-content {
  display: flex;
  align-items: center;
  gap: 16px;
}
.arcade-hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.arcade-tag {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  color: #475569;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* 遊戲展示卡片網格 */
.arcade-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}
.arcade-card {
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}
.arcade-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.12);
  border-color: #818cf8;
}
.arcade-card-banner {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid transparent;
}
.arcade-card-icon {
  font-size: 2.8rem;
  line-height: 1;
}
.arcade-card-badge {
  background: #ffffff;
  color: #1e1b4b;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.arcade-card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.arcade-card-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 10px;
  line-height: 1.4;
}
.arcade-card-desc {
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 16px;
  flex: 1;
}
.arcade-card-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.arcade-card-skills span {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
}
.arcade-card-actions {
  display: flex;
  gap: 10px;
}

/* 遊戲內嵌播放器視窗 */
.arcade-player-card {
  background: #ffffff;
  border: 4px solid #4f46e5;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(79, 70, 229, 0.2);
}
.arcade-player-header {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* =========================================================================
   特教競賽評審專區與輔具樣式 (Contest & Assistive Technology Styles)
   ========================================================================= */

/* 1. 🕹️ 單鍵微動開關掃描輔具 (Switch Access) */
.switch-scan-highlight {
  outline: 4px solid #f59e0b !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.75) !important;
  animation: switchPulse 0.9s infinite alternate !important;
  transform: scale(1.04) !important;
  transition: all 0.2s ease !important;
}
@keyframes switchPulse {
  from { outline-color: #f59e0b; box-shadow: 0 0 15px rgba(245, 158, 11, 0.5); }
  to { outline-color: #ef4444; box-shadow: 0 0 30px rgba(239, 68, 68, 0.85); }
}
.switch-scan-active {
  background: #f59e0b !important;
  color: #ffffff !important;
  transform: scale(0.96) !important;
}
.switch-widget-floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border: 3px solid #f59e0b;
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
  animation: widgetSlideUp 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes widgetSlideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.switch-widget-badge {
  font-weight: 900;
  color: #b45309;
  font-size: 1rem;
}
.switch-widget-instruction {
  font-size: 0.85rem;
  color: #1e293b;
  font-weight: 700;
}
.switch-widget-controls {
  display: flex;
  align-items: center;
  margin-top: 4px;
  font-size: 0.85rem;
}
.switch-speed-selector {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85rem;
}

/* 3. 🏆 評審專屬評閱專區 (Judges' Showcase Dossier) */
.judges-dossier-card {
  border: 4px solid #facc15 !important;
  background: linear-gradient(180deg, #ffffff, #fffdf5) !important;
}
.judges-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.judges-metric-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
}
.judges-metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1e1b4b;
  font-size: 1rem;
  margin-bottom: 6px;
}
.judges-metric-card p {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}
.j-icon {
  font-size: 1.4rem;
}

/* 4. 🧠 認知錯誤型態雷達圖與 C-R-A 成長歷程 */
.clinic-dashboard-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 16px;
}
@media (max-width: 768px) {
  .clinic-dashboard-container {
    grid-template-columns: 1fr;
  }
}
.radar-display-box {
  background: #ffffff;
  border: 2px solid #c7d2fe;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.growth-chart-box {
  background: #ffffff;
  border: 2px solid #bbf7d0;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.08);
}


