/* 國小三年級數學互動語音教學平台 — 共用樣式 */
:root {
  --bg: #FFFBF2;
  --card: #FFFFFF;
  --ink: #0F172A;
  --muted: #64748B;
  --orange: #EA580C;
  --orange-bg: #FFEDD5;
  --teal: #0D9488;
  --teal-bg: #CCFBF1;
  --blue: #2563EB;
  --blue-bg: #DBEAFE;
  --purple: #7C3AED;
  --purple-bg: #EDE9FE;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --yellow: #FEF08A;
  --border: #E2E8F0;
  --radius: 22px;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background:
    radial-gradient(circle at 8% 12%, #FEF3C7 0%, transparent 32%),
    radial-gradient(circle at 92% 8%, #DBEAFE 0%, transparent 30%),
    radial-gradient(circle at 88% 88%, #FCE7F3 0%, transparent 28%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

body.theme-teal {
  background:
    radial-gradient(circle at 10% 10%, #CCFBF1 0%, transparent 32%),
    radial-gradient(circle at 90% 12%, #EDE9FE 0%, transparent 32%),
    radial-gradient(circle at 85% 90%, #FEF3C7 0%, transparent 28%),
    #F8FAFC;
}

/* Top Navigation Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 251, 242, 0.93);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid #FDE68A;
  padding: 12px 20px;
}
body.theme-teal .topbar {
  background: rgba(248, 250, 252, 0.94);
  border-bottom-color: #99F6E4;
}

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

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

.home-link {
  text-decoration: none;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  color: #334155;
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.home-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: #EFF6FF;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #F97316, #FACC15);
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.28);
}
body.theme-teal .brand-icon {
  background: linear-gradient(135deg, #0D9488, #2563EB);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.28);
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  color: #1E3A5F;
}
body.theme-teal .brand h1 { color: #134E4A; }
.brand p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: #FEF3C7;
  padding: 5px;
  border-radius: 999px;
}
body.theme-teal .nav-tabs { background: #CCFBF1; }
.nav-tab {
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  color: #92400E;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
body.theme-teal .nav-tab { color: #115E59; }
.nav-tab.active {
  background: #FFFFFF;
  color: var(--orange);
  box-shadow: 0 3px 10px rgba(146, 64, 14, 0.14);
}
body.theme-teal .nav-tab.active { color: var(--teal); }

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.star-pill {
  background: #FEF9C3;
  border: 2px solid #FACC15;
  color: #854D0E;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.speaking-pill {
  display: none;
  align-items: center;
  gap: 8px;
  background: #1E3A5F;
  color: #FFFFFF;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  animation: pulse 1.3s infinite;
}
.speaking-pill.show { display: inline-flex; }
.speaking-pill button {
  border: none;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Layout & Cards */
.container {
  max-width: 1100px;
  margin: 22px auto 60px;
  padding: 0 18px;
}
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { transform: scale(0.86); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 2px solid #E2E8F0;
  margin-bottom: 22px;
}
.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title {
  margin: 0;
  font-size: 21px;
  color: #1E3A5F;
  display: flex;
  align-items: center;
  gap: 8px;
}
body.theme-teal .card-title { color: #134E4A; }

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s, filter 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.96); }
.btn:hover { filter: brightness(1.04); }
.btn-primary { background: linear-gradient(135deg, #2563EB, #3B82F6); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24); }
.btn-teal { background: linear-gradient(135deg, #0D9488, #14B8A6); color: #fff; box-shadow: 0 4px 12px rgba(13, 148, 136, 0.24); }
.btn-orange { background: linear-gradient(135deg, #EA580C, #F97316); color: #fff; box-shadow: 0 4px 12px rgba(234, 88, 12, 0.24); }
.btn-green { background: linear-gradient(135deg, #16A34A, #22C55E); color: #fff; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.24); }
.btn-soft { background: #F1F5F9; color: #334155; }
.btn-yellow { background: #FEF3C7; color: #92400E; border: 2px solid #FCD34D; }
.btn-purple { background: #EDE9FE; color: #5B21B6; border: 2px solid #C4B5FD; }
.btn-teacher { background: #FFE4E6; color: #BE123C; border: 2px solid #FDA4AF; }

/* Shared Badges & Highlighting */
.badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  display: inline-block;
}
.num-o { color: var(--orange); background: var(--orange-bg); padding: 2px 10px; border-radius: 10px; }
.num-b { color: var(--blue); background: var(--blue-bg); padding: 2px 10px; border-radius: 10px; }
.num-p { color: var(--purple); background: var(--purple-bg); padding: 2px 10px; border-radius: 10px; }
.kw-mark { background: var(--yellow); padding: 2px 6px; border-radius: 8px; box-shadow: inset 0 -3px 0 #FACC15; }

/* Shared Quiz Navigation & Feedback */
.zone-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.zone-btn {
  border: 2px solid #E2E8F0;
  background: #fff;
  border-radius: 14px;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  color: #334155;
}
.zone-btn.active { border-color: var(--orange); background: #FFF7ED; color: var(--orange); }
body.theme-teal .zone-btn.active { border-color: var(--teal); background: #F0FDFA; color: #0F766E; }

.dot-nav { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.q-dot {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 2px solid #CBD5E1;
  background: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  color: #475569;
  position: relative;
}
.q-dot.current { border-color: var(--blue); background: var(--blue); color: #fff; transform: scale(1.06); }
.q-dot.solved { border-color: var(--green); background: var(--green-bg); color: #15803D; }
.q-dot.solved.current { background: var(--green); color: #fff; }
.q-dot.wrong { border-color: var(--red); background: var(--red-bg); color: #B91C1C; }

.prob-text {
  font-size: 22px;
  font-weight: 800;
  color: #0F172A;
  background: #FFFDF7;
  border: 2px solid #FDE68A;
  border-radius: 18px;
  padding: 18px 20px;
  margin: 14px 0 16px;
  line-height: 1.7;
}

.hint-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.hint-panel, .teacher-panel {
  display: none;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
  animation: fadeIn 0.25s ease;
}
.hint-panel.show, .teacher-panel.show { display: block; }
.hint-panel { background: #F8FAFC; border: 2px solid #CBD5E1; }
.teacher-panel { background: linear-gradient(135deg, #FFF1F2, #FFFBEB); border: 2px solid #FDA4AF; }
.teacher-step-list { margin: 10px 0; padding-left: 22px; font-size: 17px; font-weight: 700; color: #1E293B; }
.teacher-step-list li { margin-bottom: 6px; }
.teacher-ans-pill {
  display: inline-block;
  background: #16A34A;
  color: #fff;
  padding: 8px 18px;
  border-radius: 14px;
  font-size: 19px;
  font-weight: 900;
}

.feedback-banner {
  display: none;
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 800;
}
.feedback-banner.show { display: block; animation: popIn 0.22s ease; }
.feedback-banner.ok { background: var(--green-bg); border: 2px solid #4ADE80; color: #14532D; }
.feedback-banner.err { background: var(--red-bg); border: 2px solid #F87171; color: #7F1D1D; }
.feedback-banner.warn, .feedback-banner.tip { background: #FEF9C3; border: 2px solid #F59E0B; color: #713F12; }

.prob-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }

.victory-box {
  display: none;
  text-align: center;
  background: linear-gradient(135deg, #FEF9C3, #FFEDD5);
  border: 3px solid #F59E0B;
  border-radius: 22px;
  padding: 24px;
  margin-bottom: 20px;
}
body.theme-teal .victory-box {
  background: linear-gradient(135deg, #FEF9C3, #CCFBF1);
  border-color: #0D9488;
}
.victory-box.show { display: block; animation: popIn 0.3s ease; }

.num-input {
  width: 96px;
  height: 46px;
  border: 3px solid #93C5FD;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  color: #0F172A;
  background: #fff;
  font-family: inherit;
}
.num-input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.14);
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}
