:root {
  --green: #1f9d55;
  --green-dark: #16793f;
  --bg: #f4f9f6;
  --card-bg: #ffffff;
  --text: #1b2b22;
  --muted: #566b5e;
  --primary: var(--green);
  --danger: #d9534f;
  --warn: #e8a33d;
  --warn-bg: #fdf3e3;
  --border: #dcecE2;

  /* 四科主題色 */
  --sci-nature: #527e0e;
  --sci-biology: #0d9488;
  --sci-chemphys: #e8590c;
  --sci-earth: #4263eb;
}

* { box-sizing: border-box; }

:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 2px; border-radius: 4px; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.site-header {
  background: var(--green-dark);
  color: #fff;
  padding: 16px 20px;
  text-align: center;
}

header.site-header h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 900; letter-spacing: 0.02em; }
header.site-header p { margin: 0; font-size: 0.82rem; font-weight: 500; opacity: 0.85; }

.hero-tagline { margin-top: 4px !important; font-size: 0.74rem !important; opacity: 0.75 !important; }

.hero-stats { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 10px; }

.hero-stat {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  padding: 4px 9px;
  border-radius: 999px;
  opacity: 0.82;
}

.hero-stat strong { font-size: 0.78rem; }

.hero-stat--primary {
  font-size: 0.9rem;
  font-weight: 800;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.32);
  padding: 6px 14px;
  opacity: 1;
}

.hero-stat--primary strong { font-size: 1.15rem; }

.site-header.is-new-player .hero-stat { display: none; }
.site-header.is-new-player .hero-mission,
.site-header.is-new-player .rank-next-goal { display: none; }
.site-header.is-new-player .hero-stats::after {
  content: "開始練習，累積你的第一個戰功";
  display: block;
  color: #d8f5e2;
  font-size: .86rem;
  font-weight: 800;
}
.site-header.is-new-player .new-player-guide { width: min(100%, 760px); color: var(--text); text-align: left; }

.hero-rank { background: rgba(255, 212, 59, 0.25); color: #ffd43b; }
.rank-next-goal { margin: 7px 0 0; color: #d8f5e2; font-size: .76rem; font-weight: 700; }
.sound-toggle { margin-top: 7px; border: 1px solid #ffffff66; border-radius: 999px; background: #ffffff18; color: #fff; padding: 5px 10px; cursor: pointer; }
.bat-companion-plus { filter: drop-shadow(0 0 7px #ffd43b); }

.daily-goal { max-width: 340px; margin: 12px auto 0; }

.daily-goal-label {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.9;
  margin-bottom: 4px;
}

.daily-goal-bar {
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.daily-goal-bar > div {
  height: 100%;
  background: #ffd43b;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.daily-goal.done .daily-goal-bar > div { background: #69db7c; }
.daily-goal.done .daily-goal-label { color: #d3f9d8; }

.trust-line {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 8px 0 0;
  padding: 0 16px;
}

.primary-tools { display: flex; justify-content: center; margin: 14px auto 0; }
.io-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0 4px; }

.io-btn {
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.io-btn:hover { border-color: var(--green); color: var(--green-dark); }

/* 介面圖示：專案美術風格真圖，缺圖 onerror 換回 emoji（.io-ico-emoji 維持原字級） */
.io-ico { width: 1.9em; height: 1.9em; object-fit: contain; vertical-align: middle; margin-right: 0.15em; }
.io-ico-emoji { vertical-align: middle; }
header.site-header h1 .brand-ico { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: -0.3em; margin-right: 0.1em; }

.io-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 4px 0 0;
  padding: 0 16px;
}

.site-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 20px 16px 28px;
}

.site-footer a { color: var(--green-dark); }
.visitor-badge { max-width: 180px; height: auto; }
.text-link-btn { border: 0; padding: 0; color: var(--green-dark); background: transparent; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

.sh-overlay, .info-overlay, .base-overlay, .fusion-overlay, .mkt-overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(15, 29, 23, .78); }
.sh-overlay[hidden], .info-overlay[hidden], .base-overlay[hidden], .fusion-overlay[hidden], .mkt-overlay[hidden] { display: none; }
.sh-panel, .info-panel, .base-panel, .fusion-panel, .mkt-panel { max-height: 90vh; overflow: auto; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.sh-head, .info-head, .base-topbar, .fusion-head, .mkt-head { display: flex; align-items: center; gap: 12px; }

/* 班級協力學習榜 */
.classboard-panel { position: relative; width: min(92vw, 640px); padding: 26px 24px 28px; background: #f5faf1; color: #21331f; }
.classboard-close { position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border: none; border-radius: 50%; background: rgba(82,126,14,.12); color: var(--sci-nature, #527e0e); font-size: 22px; line-height: 1; cursor: pointer; }
.classboard-close:hover { background: rgba(82,126,14,.22); }
.classboard-header h2 { margin: 4px 0 6px; font-size: 1.5rem; }
.classboard-header p { margin: 0; color: var(--muted, #566b5e); font-size: .92rem; line-height: 1.6; }
.classboard-eyebrow { margin: 0; font-size: .82rem; font-weight: 700; letter-spacing: .04em; color: var(--sci-nature, #527e0e); }
.classboard-total-card { margin: 18px 0; padding: 18px; text-align: center; border-radius: 16px; background: linear-gradient(135deg, #eaf4dc, #dcedca); border: 1px solid rgba(82,126,14,.2); }
.classboard-total-card span { display: block; font-size: .9rem; color: var(--muted, #566b5e); }
.classboard-total-card strong { display: block; font-size: clamp(2.6rem, 11vw, 4rem); font-weight: 800; line-height: 1.05; color: var(--sci-nature, #527e0e); }
.classboard-total-card small { color: var(--muted, #566b5e); }
.classboard-milestone { margin-top: 14px; }
.classboard-milestone-bar { height: 10px; overflow: hidden; border-radius: 999px; background: #fff; }
.classboard-milestone-bar span { display: block; height: 100%; border-radius: inherit; background: var(--sci-nature, #527e0e); transition: width .35s ease; }
.classboard-milestone p { margin: 7px 0 0; color: #3a4a34; font-size: .84rem; font-weight: 700; }
.classboard-form { display: grid; gap: 12px; }
.classboard-form label { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; color: #3a4a34; }
.classboard-nick-field { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; color: #3a4a34; }
.classboard-nick-picker { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgba(82,126,14,.32); border-radius: 10px; background: #fff; }
.classboard-nick-picker strong { flex: 1; color: #21331f; }
.classboard-nick-picker button { min-height: 36px; border: 1px solid var(--sci-nature, #527e0e); border-radius: 8px; background: #fff; color: var(--sci-nature, #527e0e); font-weight: 700; cursor: pointer; }
.classboard-form input { padding: 10px 12px; border: 1px solid rgba(82,126,14,.32); border-radius: 10px; font-size: 1rem; background: #fff; color: #21331f; }
.classboard-form input:focus { outline: 2px solid var(--sci-nature, #527e0e); outline-offset: 1px; }
.classboard-privacy-note { margin: 2px 0 0; font-size: .78rem; color: var(--muted, #566b5e); line-height: 1.5; }
.classboard-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.classboard-actions button { flex: 1 1 160px; padding: 11px 14px; border-radius: 10px; font-size: .95rem; font-weight: 700; cursor: pointer; border: 1px solid var(--sci-nature, #527e0e); }
.classboard-refresh { background: #fff; color: var(--sci-nature, #527e0e); }
.classboard-refresh:hover { background: rgba(82,126,14,.08); }
.classboard-submit { background: var(--sci-nature, #527e0e); color: #fff; }
.classboard-submit:hover { filter: brightness(1.06); }
.classboard-status { min-height: 1.2em; margin: 12px 0 0; font-size: .86rem; color: var(--muted, #566b5e); }
.classboard-members-section { margin-top: 18px; }
.classboard-members-section h3 { margin: 0 0 8px; font-size: 1rem; color: #3a4a34; }
.classboard-members { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.classboard-member { display: flex; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid rgba(82,126,14,.14); font-size: .95rem; }
.classboard-member span:last-child { font-weight: 700; color: var(--sci-nature, #527e0e); }
.classboard-empty { padding: 12px 4px; color: var(--muted, #566b5e); font-size: .88rem; line-height: 1.6; list-style: none; }
.info-overlay { z-index: 1300; }
.info-panel { width: min(680px, 96vw); background: #fff; padding: 20px; text-align: left; }
.info-head { align-items: flex-start; }
.info-head h2 { flex: 1; margin: 0 0 12px; font-size: 1.25rem; }
.info-head button, .fusion-head button, .mkt-head button { min-width: 44px; min-height: 44px; display: grid; place-items: center; border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; }
.info-head button { color: var(--muted); }
.family-summary-text { width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #f8fbf9; color: var(--text); font: .9rem/1.6 ui-monospace, "SFMono-Regular", Menlo, monospace; }
.family-summary-btn { display: block; width: 100%; margin: 0 0 14px; }
.copy-status { min-height: 1.5em; margin: 8px 0 0; color: var(--green-dark); font-weight: 700; text-align: center; }
.parent-guide { line-height: 1.75; }
.parent-guide h3 { margin: 18px 0 6px; color: var(--green-dark); }
.parent-guide li + li { margin-top: 8px; }

.quiz-next-btn { width: 100%; margin-top: 10px; }

nav.tabs {
  display: flex;
  overflow-x: auto;
  background: #fff;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

nav.tabs button {
  flex: 1 0 auto;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.2s ease;
}

nav.tabs button.active {
  color: var(--green-dark);
  border-bottom-color: var(--green);
  font-weight: 700;
}

nav.tabs button[data-key="nature"].active   { color: var(--sci-nature);   border-bottom-color: var(--sci-nature); }
nav.tabs button[data-key="biology"].active  { color: var(--sci-biology);  border-bottom-color: var(--sci-biology); }
nav.tabs button[data-key="chemphys"].active { color: var(--sci-chemphys); border-bottom-color: var(--sci-chemphys); }
nav.tabs button[data-key="earth"].active    { color: var(--sci-earth);    border-bottom-color: var(--sci-earth); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.panel { display: none; }
.panel.active { display: block; animation: panelIn 0.22s ease-out; }

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

.panel[data-key="nature"]   .btn-primary, .panel[data-key="nature"]   .mode-switch button.active { background: var(--sci-nature); border-color: var(--sci-nature); }
.panel[data-key="biology"]  .btn-primary, .panel[data-key="biology"]  .mode-switch button.active { background: var(--sci-biology); border-color: var(--sci-biology); }
.panel[data-key="chemphys"] .btn-primary, .panel[data-key="chemphys"] .mode-switch button.active { background: var(--sci-chemphys); border-color: var(--sci-chemphys); }
.panel[data-key="earth"]    .btn-primary, .panel[data-key="earth"]    .mode-switch button.active { background: var(--sci-earth); border-color: var(--sci-earth); }

.panel[data-key="nature"]   .card { border-left-color: var(--sci-nature); }
.panel[data-key="biology"]  .card { border-left-color: var(--sci-biology); }
.panel[data-key="chemphys"] .card { border-left-color: var(--sci-chemphys); }
.panel[data-key="earth"]    .card { border-left-color: var(--sci-earth); }

.panel[data-key="nature"]   .progress-bar > div { background: var(--sci-nature); }
.panel[data-key="biology"]  .progress-bar > div { background: var(--sci-biology); }
.panel[data-key="chemphys"] .progress-bar > div { background: var(--sci-chemphys); }
.panel[data-key="earth"]    .progress-bar > div { background: var(--sci-earth); }

.placeholder-card {
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-switch button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.mode-switch button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.card {
  background: var(--card-bg);
  border: 1px solid rgba(0,0,0,0.04);
  border-left: 4px solid var(--green);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  margin-bottom: 14px;
}

.card.celebrate-in { animation: celebrateIn 0.35s ease-out; }
.first-success.celebrate-in { animation: firstSuccessIn 0.35s ease-out; }
.science-surprise.celebrate-in { animation: celebrateIn 0.35s ease-out; }

@keyframes celebrateIn {
  0% { transform: scale(0.97); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes firstSuccessIn {
  0% { transform: translate(-50%, var(--stack-offset, 0px)) scale(0.97); opacity: 0; }
  100% { transform: translate(-50%, var(--stack-offset, 0px)) scale(1); opacity: 1; }
}

.flash-term {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  margin: 10px 0;
}

.flash-meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
  opacity: 0.75;
}

.flash-def {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.7;
  min-height: 3.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: opacity 0.2s ease;
}

.flash-def.hidden { color: var(--muted); }

.flash-example {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
  padding: 8px 10px;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
}

.grade-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 4px 0 10px;
}

.grade-chip {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border, #ddd);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.grade-chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-row { display: flex; gap: 10px; margin-top: 18px; }

.btn {
  flex: 1;
  padding: 13px 12px;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.08); }
.btn:hover { filter: brightness(1.05); }

.btn-primary { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--green-dark); transform: translateY(2px); }
.btn-secondary { background: #eef4f0; color: var(--text); box-shadow: none; }
.btn-danger { background: #fdeceb; color: var(--danger); box-shadow: none; }
.btn-ok { background: #e7f6ec; color: var(--green-dark); box-shadow: none; }

.quiz-prompt {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.6;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

/* 克漏字回想題 */
.quiz-cloze-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-dark, #174d2d);
  background: #e7f6ec;
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 12px;
}
.quiz-cloze-prompt { font-size: 1.1rem; }
.quiz-cloze-prompt strong,
.quiz-cloze-prompt { letter-spacing: 0.02em; }
.quiz-cloze-hint {
  font-size: 0.92rem;
  color: var(--muted, #566b5e);
  margin: 4px 0 16px;
  line-height: 1.6;
}
.quiz-cloze-answer { margin-top: 6px; }
.quiz-cloze-term { font-size: 1.05rem; margin-bottom: 6px; }
.quiz-cloze-ask {
  font-size: 0.9rem;
  color: var(--muted, #566b5e);
  margin-bottom: 10px;
}

.quiz-option {
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.quiz-option:hover:not(:disabled) { border-color: var(--green); transform: translateX(2px); }
.quiz-option:active:not(:disabled) { transform: scale(.98); border-color: var(--green); background: #f3fbf5; }
.quiz-option:disabled { cursor: default; }

.quiz-option.correct {
  border-width: 2px;
  border-color: var(--green);
  background: #e7f6ec;
  font-weight: 700;
  animation: correctPop 0.25s ease;
  box-shadow: 0 0 0 3px rgba(31,157,85,0.12);
}

.quiz-option.wrong {
  border-width: 2px;
  border-color: var(--warn);
  background: var(--warn-bg);
  font-weight: 700;
  animation: wrongShake 0.3s ease;
  box-shadow: 0 0 0 3px rgba(232,163,61,0.15);
}

.quiz-result-banner {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 10px;
  margin-bottom: 14px;
  animation: bannerPop 0.3s ease;
}

.quiz-result-banner.is-correct { background: #e7f6ec; color: var(--green-dark); }
.quiz-result-banner.is-wrong { background: var(--warn-bg); color: #b5690a; }

@keyframes bannerPop {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

.card.flash-correct { animation: cardFlashGreen 0.5s ease; }
.card.flash-wrong { animation: cardFlashRed 0.5s ease; }
.card.correct {
  background: #e7f6ec;
  border-color: var(--green);
  animation: cardFlashGreen 0.5s ease;
}
.card.wrong {
  background: var(--warn-bg);
  border-color: var(--warn);
  animation: cardFlashRed 0.5s ease;
}

@keyframes cardFlashGreen {
  0% { background: #e7f6ec; }
  100% { background: var(--card-bg); }
}

@keyframes cardFlashRed {
  0% { background: var(--warn-bg); }
  100% { background: var(--card-bg); }
}

@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

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

.quiz-feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}

.quiz-feedback-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--warn);
  margin-bottom: 4px;
}

.quiz-feedback-compare {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border);
  opacity: 0.85;
}

.weak-intro {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin: 4px 0 10px;
}

.unit-map {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-bottom: 4px;
}

.unit-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  width: 64px;
}

.unit-chip-ring {
  --ring-color: var(--green);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--ring-color) calc(var(--progress) * 3.6deg), var(--border) 0);
  transition: background 0.3s ease;
}

.unit-chip-ring::before {
  content: '';
  position: absolute;
}

.unit-chip-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.unit-chip-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
  max-width: 64px;
}

.unit-chip.active .unit-chip-label { color: var(--green-dark); font-weight: 800; }
.unit-chip.active .unit-chip-icon { box-shadow: 0 0 0 2px var(--green); }

.unit-chip[data-status="untouched"] .unit-chip-ring { opacity: 0.55; }
.unit-chip[data-status="weak"] .unit-chip-ring { --ring-color: var(--warn); }
.unit-chip[data-status="mastered"] .unit-chip-ring { --ring-color: var(--green); }

.unit-chip-ring { position: relative; }

.unit-chip-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #fff;
}

.panel[data-key="nature"]   .unit-chip-ring { --ring-color: var(--sci-nature); }
.panel[data-key="biology"]  .unit-chip-ring { --ring-color: var(--sci-biology); }
.panel[data-key="chemphys"] .unit-chip-ring { --ring-color: var(--sci-chemphys); }
.panel[data-key="earth"]    .unit-chip-ring { --ring-color: var(--sci-earth); }

.milestone-card { text-align: center; position: relative; overflow: hidden; }
.milestone-icon { font-size: 2.6rem; margin-bottom: 6px; animation: milestoneIconPop 0.5s ease; }
.milestone-card h3 { margin: 4px 0 8px; }
.milestone-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.milestone-stat { font-size: 0.85rem; }
.milestone-stat strong { color: var(--green-dark); font-size: 1rem; }

@keyframes milestoneIconPop {
  0% { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.confetti-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.confetti-bit {
  position: absolute;
  top: 30%;
  left: 50%;
  width: 6px;
  height: 10px;
  background: hsl(calc(var(--i) * 35deg), 80%, 55%);
  animation: confettiFly 0.9s ease-out forwards;
  animation-delay: calc(var(--i) * 0.02s);
  transform-origin: center;
}

@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% {
    transform:
      translate(calc((cos(calc(var(--i) * 30deg))) * 90px), calc((sin(calc(var(--i) * 30deg))) * 90px - 20px))
      rotate(360deg);
    opacity: 0;
  }
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar > div {
  height: 100%;
  background: var(--green);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.weak-list { list-style: none; margin: 0; padding: 0; }

.weak-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.weak-list li:has(.weak-term-def) { flex-direction: column; align-items: stretch; }

.weak-term-row { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; }

.weak-term-def {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

.weak-list li:last-child { border-bottom: none; }

.weak-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.weak-score {
  color: var(--danger);
  font-weight: 700;
}

.btn-weak-practice {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: #fff;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-weak-practice:hover { background: var(--green); color: #fff; }

@media (max-width: 420px) {
  header.site-header h1 { font-size: 1.2rem; }
  .flash-term { font-size: 1.35rem; }
}

/* ================= 答題對戰 ================= */
.bat-hint { font-size: 0.82rem; color: var(--muted); margin: 0 0 10px; }

.bat-oppgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.bat-oppcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  text-align: center;
}

.bat-oppcard.locked { opacity: 0.55; cursor: not-allowed; }
.bat-oppcard:not(.locked):hover { border-color: var(--green); transform: translateY(-1px); }

.bat-face { font-size: 2rem; line-height: 1; }
.bat-face.big { font-size: 3rem; }

.bat-name { font-size: 0.85rem; font-weight: 700; }
.bat-tier { font-size: 0.72rem; color: var(--muted); }
.bat-locknote { font-size: 0.72rem; color: var(--muted); }

.bat-trophy { text-align: center; font-size: 0.8rem; color: var(--muted); }

.bat-arena {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
}

.bat-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bat-side.foe { align-items: center; }

.bat-hp {
  width: 100%;
  max-width: 260px;
  height: 16px;
  background: #eef4f0;
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.bat-hp-fill {
  transition: width .3s;
  height: 100%;
  background: var(--green);
  transition: width 0.4s ease;
}

.bat-side { position: relative; }
.bat-damage-pop {
  position: absolute;
  top: 0;
  color: var(--danger);
  font-weight: 900;
  pointer-events: none;
  animation: bat-damage-pop .5s ease-out forwards;
}
@keyframes bat-damage-pop {
  from { opacity: 1; transform: translateY(0) scale(.85); }
  to { opacity: 0; transform: translateY(-28px) scale(1.15); }
}
@keyframes rt-hit-flash { 50% { filter: brightness(1.6); transform: translateX(-3px); } }
.rt-hit-flash { animation: rt-hit-flash .3s ease-out; }

.bat-hp.foe .bat-hp-fill { background: var(--danger); }
.bat-hp.low .bat-hp-fill { background: var(--warn); }

.bat-hp span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.bat-log {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text);
  min-height: 1.3em;
}

.bat-result-emoji { font-size: 3rem; text-align: center; }
.bat-quote { text-align: center; font-size: 0.85rem; color: var(--muted); font-style: italic; margin: 6px 0 14px; }

.panel[data-key="nature"]   .bat-hp:not(.foe) .bat-hp-fill { background: var(--sci-nature); }
.panel[data-key="biology"]  .bat-hp:not(.foe) .bat-hp-fill { background: var(--sci-biology); }
.panel[data-key="chemphys"] .bat-hp:not(.foe) .bat-hp-fill { background: var(--sci-chemphys); }
.panel[data-key="earth"]    .bat-hp:not(.foe) .bat-hp-fill { background: var(--sci-earth); }

/* ── 段位條 ── */
.bat-rank {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.bat-rank-ico { font-size: 1.6rem; display: inline-flex; align-items: center; }
.bat-rank-img { width: 44px; height: 44px; object-fit: contain; }
.bat-rank-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.bat-rank-name { font-size: 0.85rem; font-weight: 700; }

.bat-rank-bar {
  display: block;
  height: 6px;
  background: #eef4f0;
  border-radius: 999px;
  overflow: hidden;
}

.bat-rank-bar > span { display: block; height: 100%; background: var(--warn); }
.bat-rank-next { font-size: 0.72rem; color: var(--muted); }

.bat-rankdelta { text-align: center; font-size: 0.82rem; font-weight: 700; margin: 6px 0 14px; }
.bat-rankdelta.up { color: var(--green-dark); }
.bat-rankdelta.down { color: var(--danger); }

/* ── 科學夥伴卡 ── */
.bat-companion {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.bat-companion-face { width: 48px; height: 48px; object-fit: contain; font-size: 2rem; flex: 0 0 auto; }
.bat-assist-img { width: 24px; height: 24px; object-fit: contain; vertical-align: middle; }
.bat-companion-body { display: flex; flex-direction: column; gap: 2px; }
.bat-companion-name { font-size: 0.85rem; font-weight: 700; }
.bat-companion-desc, .bat-companion-next { font-size: 0.72rem; color: var(--muted); }

.bat-assist { text-align: center; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.bat-pvp-btn { width: 100%; margin-bottom: 14px; }

.bat-turn { text-align: center; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

.bat-hp.active .bat-hp-fill { filter: brightness(1.15); }

/* ───────── 科學基地 ───────── */
body.base-open { overflow: hidden; }
.base-overlay { z-index: 900; padding: 12px; }
.base-panel { background: #f4faf5; width: min(96vw, 760px); max-height: 94vh; padding: 12px; }
.base-topbar { gap: 8px; flex-wrap: wrap; }
.base-topbar h2 { margin: 0 auto 0 0; color: var(--green-dark); }
.base-tool-btn { min-height: 44px; border: 1px solid var(--green); border-radius: 999px; background: #fff; color: var(--green-dark); padding: 10px 14px; cursor: pointer; }
.base-scene { position: relative; width: 100%; aspect-ratio: 4 / 3; margin-top: 10px; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #dff3ff, #eafbf0 55%, #d9eede); }
.sb-bg, .sb-bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sb-main, .sb-pav { position: absolute; aspect-ratio: 1 / 1; border: 0; padding: 0; background: none; cursor: pointer; }
.sb-main { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 26%; z-index: 3; }
.sb-main[data-stage="5"] img,
.sb-main[data-stage="6"] img { filter: drop-shadow(0 0 5px rgba(255, 212, 59, .55)); }
.sb-main[data-stage="7"] img,
.sb-main[data-stage="8"] img { filter: drop-shadow(0 0 8px rgba(255, 212, 59, .68)) drop-shadow(0 0 14px rgba(255, 146, 43, .25)); }
.sb-main[data-stage="9"] img,
.sb-main[data-stage="10"] img { filter: drop-shadow(0 0 11px rgba(255, 212, 59, .8)) drop-shadow(0 0 19px rgba(255, 146, 43, .38)); }
.sb-main[data-stage="11"] img,
.sb-main[data-stage="12"] img { filter: drop-shadow(0 0 14px rgba(255, 230, 92, .92)) drop-shadow(0 0 24px rgba(255, 146, 43, .5)); }
.sb-main[data-stage="12"]::before {
  content: "👑 典藏之冠";
  position: absolute;
  left: 50%;
  top: -16%;
  transform: translateX(-50%);
  z-index: 4;
  white-space: nowrap;
  color: #7a4b00;
  background: linear-gradient(135deg, #fff4b8, #ffd43b);
  border: 1px solid #d99a00;
  border-radius: 999px;
  padding: .18em .55em;
  font-size: clamp(.68rem, 1.6vw, .82rem);
  font-weight: 900;
  box-shadow: 0 0 18px rgba(255, 212, 59, .75);
}
.sb-pav { width: 20%; z-index: 2; }
.sb-pav--nature { left: 6%; top: 10%; }  .sb-pav--biology { right: 6%; top: 10%; }
.sb-pav--chemphys { left: 6%; bottom: 6%; }  .sb-pav--earth { right: 6%; bottom: 6%; }
.sb-main img, .sb-pav img, .sb-decor img { width: 100%; height: 100%; object-fit: contain; }
.sb-emoji { display: grid; place-items: center; width: 100%; height: 100%; font-size: clamp(1.5rem, 6vw, 3.6rem); }
.sb-balance { position: absolute; z-index: 6; top: 2%; right: 2%; border-radius: 999px; background: rgba(255,255,255,.92); padding: .3em .65em; font-weight: 700; }
.sb-motto { position: absolute; z-index: 5; top: 2%; left: 50%; transform: translateX(-50%); max-width: 58%; background: rgba(255,255,255,.86); border-radius: 999px; padding: .25em .65em; font-size: .72rem; text-align: center; }
.sb-plaque, .sb-main-rank, .sb-pav-meta { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; border-radius: 5px; background: rgba(255,255,255,.9); color: var(--green-dark); font-size: clamp(.72rem, 1.7vw, .78rem); padding: .12em .35em; }
.sb-plaque { bottom: 18%; font-weight: 700; }
.sb-main-rank, .sb-pav-meta { bottom: 4%; }
.sb-plaque--small { bottom: 18%; }
.sb-decor { position: absolute; width: 8%; aspect-ratio: 1 / 1; transform: translate(-50%, -50%); cursor: grab; z-index: 4; touch-action: none; border-radius: 50%; }
.sb-decor img { pointer-events: none; }
.sb-decor.grade-gold { box-shadow: 0 0 0 2px #e0b64e, 0 0 8px rgba(224,182,78,.7); }
.sb-decor.grade-silver { box-shadow: 0 0 0 2px #b8c0c8; }
.sb-decor.grade-bronze { box-shadow: 0 0 0 2px #b07a4e; }
.sb-decor.is-dragging { cursor: grabbing; z-index: 9; filter: drop-shadow(0 4px 8px rgba(0,0,0,.35)); }
.base-hint { margin: .65em 0 0; color: #456653; font-size: .75rem; text-align: center; }
.sb-sub { color: var(--green-dark); text-align: center; }
.sb-wall-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65em; padding: 8%; }
.sb-wall-item { display: flex; flex-direction: column; align-items: center; gap: .35em; border: 1px solid #b8dcc5; border-radius: 12px; background: rgba(255,255,255,.94); padding: 1em .5em; text-align: center; }
.sb-wall-icon { font-size: 2rem; }

@media (max-width: 520px) {
  .base-panel { width: 96vw; padding: 8px; }
  .base-topbar h2 { width: 100%; }
  .sb-wall-grid { grid-template-columns: 1fr; overflow-y: auto; height: 100%; }
}

/* ── 連線對戰 ── */
.rt-code { font-size: clamp(1.8rem, 10vw, 3rem); letter-spacing: .2em; word-break: break-all; text-align: center; font-weight: 700; margin: .5em 0; }
.rt-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .7em; margin-bottom: .6em; }
.rt-wait { text-align: center; }
.rt-adventure { border: 2px solid #e0b64e; background: #fff9df; text-align: center; }
.rt-result-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7em; }
.rt-input-label { display: flex; justify-content: center; align-items: center; gap: .5em; margin: .8em 0; }
.rt-input-label input { width: 7em; padding: .55em; font-size: 1.2rem; letter-spacing: .2em; text-align: center; }
.bat-hp > div { height: 8px; border-radius: 999px; background: #e8ece9; overflow: hidden; }
.bat-hp i { display: block; height: 100%; background: var(--green); transition: width .2s ease; }

.sb-panel { position: absolute; inset: 8%; z-index: 8; background: rgba(255, 255, 255, .96); border: 1px solid var(--green); border-radius: 12px; padding: .8em; overflow-y: auto; }
.sb-style-balance { margin-bottom: .6em; color: var(--green-dark); font-weight: 700; text-align: center; }
.sb-style-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55em; }
.sb-style-opt { display: flex; flex-direction: column; align-items: center; gap: .3em; border: 1px solid #b8dcc5; border-radius: 10px; background: #fff; padding: .5em; color: var(--green-dark); cursor: pointer; }
.sb-style-opt.is-active { border: 2px solid var(--green); box-shadow: 0 0 0 2px rgba(46,158,91,.16); }
.sb-style-opt img, .sb-style-opt .sb-emoji { width: 72px; height: 72px; object-fit: contain; }
.sb-word-bank { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35em; margin: .5em 0; }
.sb-word, .sb-motto-opt { border: 1px solid #b8dcc5; border-radius: 8px; background: #f4faf5; color: var(--green-dark); padding: .45em; cursor: pointer; }
.sb-preview { display: flex; align-items: center; justify-content: center; gap: .5em; flex-wrap: wrap; color: var(--green-dark); }
.sb-motto-list { display: grid; gap: .35em; }
.sb-panel-actions { display: flex; justify-content: center; gap: .5em; margin-top: .7em; }
.sb-epic { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(10, 18, 14, .6); animation: sbFade .3s ease; }
.sb-epic-card { background: #f4faf5; border: 2px solid var(--green); border-radius: 14px; padding: 1.4em 1.8em; text-align: center; max-width: 22em; animation: sbPop .45s cubic-bezier(.2, 1.4, .4, 1); }
.sb-epic-icon { font-size: 3rem; animation: sbGlow 1.6s ease infinite alternate; }
@keyframes sbFade { from { opacity: 0; } }
@keyframes sbPop { from { transform: scale(.6); opacity: 0; } }
@keyframes sbGlow { from { filter: drop-shadow(0 0 2px #7fd8a4); } to { filter: drop-shadow(0 0 14px #7fd8a4); } }

@media (max-width: 520px) {
  .sb-panel { inset: 4%; }
  .sb-style-list { grid-template-columns: 1fr; }
  .sb-word-bank { grid-template-columns: repeat(3, 1fr); }
}

/* ── 精靈融合坊 ── */
.fusion-overlay {
  z-index: 1100;
  padding: 18px;
}
.fusion-panel {
  width: min(980px, 96vw);
  max-height: 92vh;
  border: 2px solid var(--green);
  background: #f5fbf7;
}
.fusion-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 16px;
  color: #fff;
  background: var(--green-dark);
}
.fusion-head h2 { flex: 1; margin: 0; font-size: 1.25rem; }
.fusion-head button { color: #fff; }
.fusion-crystals { border-radius: 999px; background: rgba(255,255,255,.16); padding: .35em .7em; }
#fusion-body { padding: 16px; }
.fusion-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 14px; color: #31513c; }
.fusion-spirit-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fusion-spirit { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid #c9e4d2; border-radius: 12px; background: #fff; padding: 12px 8px; text-align: center; }
.fusion-spirit > span { font-size: 2rem; }
.fusion-spirit small { color: var(--muted); line-height: 1.45; }
.fusion-pair-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fusion-pair-card { display: flex; min-height: 220px; flex-direction: column; align-items: center; gap: 8px; border: 1px solid #c9e4d2; border-radius: 14px; background: #fff; padding: 14px; text-align: center; }
.fusion-pair-card.is-owned { border-color: #e0b64e; background: #fffbed; }
.fusion-pair-card.is-known { border-color: var(--green); }
.fusion-pair-card small { color: var(--muted); }
.fusion-pair-card p { margin: 0; color: #456653; font-size: .82rem; line-height: 1.5; }
.fusion-cub-face, .fusion-result-emoji { font-size: 3.2rem; }
.is-silhouette { filter: grayscale(1) brightness(.4) opacity(.6); }
.fusion-owned-tag { margin-top: auto; border-radius: 999px; background: #e9f7ee; color: var(--green-dark); padding: .25em .65em; font-size: .78rem; font-weight: 700; }
.fusion-reasons { width: 100%; margin: 0; padding-left: 1.2em; color: #a04c28; text-align: left; font-size: .75rem; }
.fusion-notice { margin-bottom: 14px; border: 1px solid #b8dcc5; border-radius: 12px; background: #fff; padding: 12px; text-align: center; }
.fusion-notice.celebrate-in { animation: celebrateIn 0.35s ease-out; }
.fusion-notice.is-success { border-color: #e0b64e; background: #fffbed; }
.fusion-notice.is-gentle { border-color: #8ab7d8; background: #f0f8ff; }
.fusion-notice.is-grand { border-color: #7b5cd6; background: linear-gradient(160deg, #f3efff, #eaf4ff); }

/* ── 終局融合：元靈聖獸 ── */
.fusion-grand { margin-top: 20px; padding: 18px; border-radius: 16px; display: flex; gap: 16px; align-items: center;
  background: linear-gradient(150deg, #1f2450, #3a2c66); color: #f4f1ff; border: 1px solid #6a53c0; }
.fusion-grand.is-locked { background: linear-gradient(150deg, #eef2f5, #e4ecf2); color: #33414d; border-color: #cdd8e0; }
.fusion-grand-face { flex: 0 0 108px; width: 108px; text-align: center; }
.fusion-grand-face .fusion-cub-img.grand, .fusion-grand-face .fusion-cub-emoji.grand { width: 108px; height: 108px; font-size: 76px; }
.fusion-grand-face.is-silhouette { font-size: 64px; filter: grayscale(1); opacity: .5; }
.fusion-grand-face.is-dormant .fusion-cub-img.grand { filter: brightness(.72) saturate(.7); }
.fusion-grand-body { flex: 1 1 auto; }
.fusion-grand-body h3 { margin: 4px 0 6px; }
.fusion-grand-body p { margin: 0 0 10px; font-size: .9rem; line-height: 1.6; opacity: .95; }
.fusion-grand-kicker { font-size: .78rem; font-weight: 700; letter-spacing: .05em; opacity: .85; }
.fusion-grand-hint { color: #ffd9a6; }
.fusion-grand.is-locked .fusion-grand-hint { color: #b8632a; }

/* ── 科學守護者巡禮 ── */
.prestige-scroll { text-align: center; background: linear-gradient(180deg, #f7f4ff, #eef4ff); border: 1px solid #d6cef0; }
.prestige-crown { margin: 0 auto 6px; }
.prestige-crown .fusion-cub-img.grand, .prestige-crown .fusion-cub-emoji.grand { width: 150px; height: 150px; font-size: 96px; }
.prestige-kicker { color: #6a53c0; font-weight: 800; letter-spacing: .06em; margin: 0; }
.prestige-scroll h2 { margin: 2px 0 8px; }
.prestige-lead { max-width: 40em; margin: 0 auto 16px; color: #3a4653; line-height: 1.7; }
.prestige-stats { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin: 12px 0 18px; }
.prestige-stats > div { min-width: 90px; }
.prestige-stats b { display: block; font-size: 1.7rem; color: #6a53c0; line-height: 1.1; }
.prestige-stats small { color: var(--muted); }
.prestige-scroll h3 { margin: 18px 0 10px; }
.prestige-spirit-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.prestige-spirit { background: #fff; border: 1px solid #e0dcf2; border-radius: 12px; padding: 10px 6px; }
.prestige-spirit span { font-size: 30px; }
.prestige-spirit b { display: block; font-size: .82rem; margin: 4px 0 2px; }
.prestige-spirit small { color: var(--muted); font-size: .72rem; }
.prestige-cub-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.prestige-cub { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid #e4e0f2; }
.prestige-cub-face .fusion-cub-img.small, .prestige-cub-face .fusion-cub-emoji.small { width: 46px; height: 46px; font-size: 34px; }
.prestige-cub-text b { display: block; }
.prestige-cub-text em { color: var(--muted); font-style: normal; font-size: .85rem; line-height: 1.5; }
.prestige-foot { max-width: 40em; margin: 18px auto 0; color: var(--muted); font-size: .86rem; line-height: 1.6; }
.fusion-collection { margin-top: 18px; }
.fusion-collection-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid #d9e9de; padding: 10px 0; }
.fusion-collection-name { min-width: 8em; }
.fusion-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.fusion-actions .btn, .fusion-pair-card .btn { padding: .55em .75em; font-size: .78rem; }
.fusion-empty { color: var(--muted); }
.fusion-back { margin-bottom: 10px; border: 0; background: transparent; color: var(--green-dark); cursor: pointer; font-weight: 700; }
.fusion-kicker { color: var(--green-dark); font-weight: 700; text-align: center; }
.fusion-quiz-feedback { text-align: center; }
.fusion-nickname { text-align: center; }
.fusion-nick-selects { display: flex; justify-content: center; gap: 8px; }
.fusion-nick-selects select { min-width: 90px; border: 1px solid #b8dcc5; border-radius: 8px; background: #fff; padding: .6em; font-size: 1rem; }

@media (max-width: 700px) {
  .fusion-spirit-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fusion-pair-grid { grid-template-columns: 1fr; }
  .fusion-collection-row { align-items: flex-start; flex-direction: column; }
  .fusion-grand { flex-direction: column; text-align: center; }
  .prestige-spirit-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prestige-stats { gap: 14px; }
}

/* ── 科學市集 ── */
.mkt-overlay { z-index: 1200; }
.mkt-panel { width: min(720px, 96vw); border: 2px solid #dfb84f; background: #fffdf5; }
.mkt-head { position: sticky; top: 0; z-index: 2; justify-content: space-between; padding: 12px 16px; color: #fff; background: #5a4320; }
.mkt-head h2 { margin: 0; font-size: 1.25rem; }
.mkt-head button { color: #fff; }
.mkt-panel > section, .mkt-panel > details, .mkt-pane, .mkt-topbar, .mkt-tabs, .mkt-status { margin: 14px; }
.mkt-topbar { display: flex; flex-wrap: wrap; gap: 8px; }
.mkt-topbar span { border-radius: 999px; background: #f4ead0; padding: .4em .75em; }
.mkt-open { color: #9b3f1d; font-weight: 800; }
.mkt-closed { color: #5b685f; }
.mkt-rules { border: 1px solid #e1ce98; border-radius: 12px; background: #fff; padding: 10px 12px; }
.mkt-rules summary { cursor: pointer; font-weight: 800; }
.mkt-rules table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.mkt-rules th, .mkt-rules td { border-bottom: 1px solid #eee2bf; padding: 6px; text-align: left; }
.mkt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mkt-card { display: flex; min-width: 0; flex-direction: column; gap: 6px; border: 2px solid #b98d57; border-radius: 12px; background: #fff; padding: 12px; }
.mkt-card small { color: var(--muted); line-height: 1.4; }
.mkt-card button { margin-top: auto; border: 0; border-radius: 8px; background: var(--green-dark); color: #fff; padding: .55em; cursor: pointer; }
.mkt-card button:disabled { opacity: .55; cursor: default; }
.mkt-silver { border-color: #8d9da6; }
.mkt-gold { border-color: #d4a928; background: #fffbed; }
.mkt-item-face { font-size: 2rem; }
.mkt-pending, .mkt-empty { color: var(--muted); font-size: .82rem; }
.mkt-tabs { display: flex; gap: 8px; }
.mkt-tabs button { border: 1px solid #b99b62; border-radius: 999px; background: #fff; padding: .55em .9em; cursor: pointer; }
.mkt-status { min-height: 1.5em; color: var(--green-dark); font-weight: 700; }
.mkt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid #eadcb7; padding-top: 12px; }
.mkt-tools h3 { width: 100%; margin: 0 0 4px; }
.mkt-tools select, .mkt-tools button { border: 1px solid #b99b62; border-radius: 8px; background: #fff; padding: .55em; }
.mkt-tools button { background: var(--green-dark); color: #fff; cursor: pointer; }
.mkt-claim { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 6px 0; }
.mkt-claim span { flex: 1 1 180px; }
.bat-carry { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 10px 0; border: 1px solid #c9e4d2; border-radius: 12px; background: #fff; padding: 10px; }
.bat-carry strong { width: 100%; }
.bat-carry button { border: 1px solid #9ec7aa; border-radius: 999px; background: #f5fbf7; padding: .45em .7em; cursor: pointer; }
.bat-carry button.active { background: var(--green-dark); color: #fff; }
@media (max-width: 560px) { .mkt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mkt-rules { overflow-x: auto; } }
.new-player-guide, .more-tools { max-width: 760px; margin: 16px auto; }
.new-player-guide { padding: 16px; border: 2px solid var(--primary); border-radius: 16px; background: #fff; }
.new-player-guide h2 { margin-top: 0; }
.new-player-guide ol { display: grid; gap: 8px; }
.new-player-guide li label { display: flex; align-items: center; gap: 8px; }
.new-player-guide input { width: 20px; height: 20px; accent-color: var(--primary); }
.new-player-guide button { width: 100%; padding: 10px; text-align: left; }
.more-tools > summary { cursor: pointer; font-weight: 700; text-align: center; }
.sb-rank-wall { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.sb-rank-badge { opacity: .38; display: grid; gap: 4px; place-items: center; padding: 10px; border-radius: 12px; }
.sb-rank-badge.is-lit { opacity: 1; border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent); }
.sb-rank-badge span { font-size: 2rem; }
.sb-rank-img { width: 48px; height: 48px; object-fit: contain; }
.bat-foe-img, .fusion-cub-img { width: 64px; height: 64px; object-fit: contain; }
.bat-foe-img.big, .fusion-result-emoji .fusion-cub-img { width: 96px; height: 96px; }
.fusion-cub-img.small, .bat-cub-chase { width: 32px; height: 32px; vertical-align: middle; }
.hero-mission { margin: 6px 0; color: #d8f5e2; font-weight: 700; }
.return-review-hint, .long-tail-guide { max-width: 760px; margin: 12px auto; border: 1px solid #b8dcc5; border-radius: 14px; background: #f3fbf5; padding: 12px 16px; color: #294b34; }
.focus-unit-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; margin-bottom: 10px; border: 1px dashed #9ec7aa; border-radius: 12px; padding: 9px 11px; }
.focus-unit-picker select { border: 1px solid #9ec7aa; border-radius: 8px; background: #fff; padding: 6px; }
.focus-unit-picker small { color: var(--muted); }
.bat-mission { border-left: 4px solid #d9bd69; background: #fffbea; padding: 9px 12px; font-weight: 700; }
.energy-gain-pop { position: fixed; left: 50%; top: 36%; z-index: 2600; transform: translate(-50%, var(--stack-offset, 0px)); border-radius: 999px; background: #173c2b; color: #fff6c2; padding: 10px 18px; font-size: 1.25rem; font-weight: 900; pointer-events: none; animation: energy-float 1.35s ease-out forwards; }
@keyframes energy-float { 0% { opacity: 0; transform: translate(-50%, calc(18px + var(--stack-offset, 0px))) scale(.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, calc(-55px + var(--stack-offset, 0px))) scale(1.08); } }
.first-success { position: fixed; left: 50%; top: 18%; z-index: 2500; transform: translate(-50%, var(--stack-offset, 0px)); display: grid; gap: 4px; max-width: min(420px, calc(100vw - 32px)); border: 2px solid #d9bd69; border-radius: 16px; background: #fffbea; padding: 16px 20px; box-shadow: 0 10px 30px #0003; text-align: center; }
.first-success.endless-milestone-toast.celebrate-in { animation: endlessMilestoneIn .5s cubic-bezier(.2, .9, .3, 1.25); }
.endless-milestone-toast { overflow: visible; }
.endless-milestone-toast::after {
  content: "✦ ✧ ✦ ✧ ✦";
  position: absolute;
  left: 50%;
  top: -1.2rem;
  transform: translateX(-50%);
  color: #f6b800;
  letter-spacing: .55rem;
  text-shadow: 0 8px 0 #69db7c, 12px 5px 0 #74c0fc, -12px 5px 0 #ff8787;
  pointer-events: none;
}
@keyframes endlessMilestoneIn {
  0% { transform: translate(-50%, var(--stack-offset, 0px)) scale(.72); opacity: 0; }
  65% { transform: translate(-50%, var(--stack-offset, 0px)) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, var(--stack-offset, 0px)) scale(1); opacity: 1; }
}
/* 非阻擋式吐司：容器 pointer-events:none 讓點擊穿透到底下控制項（不打斷正在進行的操作），只有關閉鈕可點。 */
.rest-reminder { position: fixed; right: 16px; bottom: 16px; z-index: 2400; display: flex; align-items: center; gap: 10px; max-width: min(430px, calc(100vw - 32px)); border: 1px solid #8bb9a0; border-radius: 14px; background: #f3fbf5; padding: 12px 14px; box-shadow: 0 8px 24px #0002; pointer-events: none; }
.rest-reminder button { flex: none; border: 1px solid #527e62; border-radius: 8px; background: #fff; padding: 6px 9px; cursor: pointer; pointer-events: auto; }
.fusion-notice.is-hatching { min-height: 150px; display: grid; place-items: center; gap: 5px; text-align: center; background: radial-gradient(circle, #fffbd6, #eefaf2); }
.fusion-egg { font-size: 5rem; filter: drop-shadow(0 0 8px #ffe46b); animation: fusion-hatch 1s ease-in-out both; }
.fusion-egg-img { width: 104px; height: 104px; object-fit: contain; display: block; }
@keyframes fusion-hatch { 0%, 100% { transform: rotate(0) scale(.95); filter: drop-shadow(0 0 2px #ffe46b); } 25% { transform: rotate(-7deg) scale(1); } 50% { transform: rotate(7deg) scale(1.04); filter: drop-shadow(0 0 18px #ffe46b); } 75% { transform: rotate(-4deg) scale(1.07); } }
.fusion-museum-grid, .journey-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fusion-museum-grid article, .journey-grid article { display: grid; gap: 6px; place-items: center; border: 1px solid #c9e4d2; border-radius: 14px; background: #fff; padding: 14px; text-align: center; }
.fusion-museum-grid p { margin: 0; color: var(--muted); font-size: .85rem; }
.fusion-museum-grand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.journey-panel { width: min(92vw, 760px); padding: 22px; }
.journey-intro { text-align: center; color: var(--muted); }
.journey-grid article > span { font-size: 2rem; }
.journey-rank-img { width: 44px; height: 44px; object-fit: contain; }
.journey-grid article strong { color: var(--green-dark); }
.journey-grid article small { color: var(--muted); }
.book-progress-list { display: grid; gap: 10px; margin: 12px 0; }
.book-progress-row { display: grid; gap: 4px; }
.book-progress-row small { color: var(--muted); }
.book-progress-bar { height: 9px; overflow: hidden; border-radius: 999px; background: #e0ebe4; }
.book-progress-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.sb-lore-card.is-locked { border-style: dashed; background: #f2f3f1; color: #6c736d; filter: grayscale(1); }
.milestone-lore { display: grid; gap: 5px; margin: 16px 0; border: 1px solid #d9bd69; border-radius: 14px; background: #fffbea; padding: 14px; text-align: left; }
.milestone-lore span { color: var(--muted); }
.milestone-lore p { margin: 0; }
.sb-lore-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; padding: 0 12px 18px; }
.sb-lore-card { border: 1px solid #d9bd69; border-radius: 14px; background: #fffbea; padding: 12px; }
.sb-lore-card > span { font-size: 2rem; }
.sb-lore-card h4, .sb-lore-card p { margin: 6px 0; }
.science-surprise { position: fixed; right: 16px; bottom: 16px; z-index: 2500; max-width: min(360px, calc(100vw - 32px)); border: 2px solid #d9bd69; border-radius: 14px; background: #fffbea; padding: 14px 16px; box-shadow: 0 8px 24px #0002; font-weight: 700; }
body:has(.rest-reminder) .science-surprise { bottom: 96px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
