:root {
  --green: #1f9d55;
  --green-dark: #16793f;
  --bg: #f4f9f6;
  --card-bg: #ffffff;
  --text: #1b2b22;
  --muted: #6b7d72;
  --danger: #d9534f;
  --warn: #e8a33d;
  --warn-bg: #fdf3e3;
  --border: #dcecE2;

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

* { box-sizing: border-box; }

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; gap: 10px; margin-top: 10px; }

.hero-stat {
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255,255,255,0.15);
  padding: 5px 12px;
  border-radius: 999px;
}

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

.hero-rank { background: rgba(255, 212, 59, 0.25); color: #ffd43b; }

.daily-goal { max-width: 320px; margin: 10px auto 0; }

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

.daily-goal-bar {
  height: 6px;
  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;
}

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

.io-btn {
  padding: 8px 14px;
  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); }

.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); }

.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; }

@keyframes celebrateIn {
  0% { transform: scale(0.97); opacity: 0; }
  100% { transform: 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: 6px;
  justify-content: center;
  margin: 4px 0 10px;
}

.grade-chip {
  padding: 5px 12px;
  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, #2e9e5b);
  border-color: var(--green, #2e9e5b);
  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-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: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; }

@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.66rem;
  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 {
  padding: 6px 12px;
  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.7rem; color: var(--muted); }
.bat-locknote { font-size: 0.65rem; 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 {
  height: 100%;
  background: var(--green);
  transition: width 0.4s ease;
}

.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.68rem;
  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; }
.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.68rem; 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 { font-size: 2rem; }
.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.7rem; 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 { position: fixed; inset: 0; z-index: 900; background: rgba(10,18,14,.72); display: flex; align-items: center; justify-content: center; padding: 12px; }
.base-overlay[hidden] { display: none; }
.base-panel { background: #f4faf5; border-radius: 14px; width: min(96vw, 760px); max-height: 94vh; overflow-y: auto; padding: 12px; }
.base-topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.base-topbar h2 { margin: 0 auto 0 0; color: #174d2d; }
.base-tool-btn { border: 1px solid #2e9e5b; border-radius: 999px; background: #fff; color: #176b39; padding: .45em .8em; 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-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: #174d2d; font-size: clamp(.48rem, 1.7vw, .72rem); 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: #174d2d; 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: 3rem; letter-spacing: .3em; 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: #2e9e5b; transition: width .2s ease; }

.sb-panel { position: absolute; inset: 8%; z-index: 8; background: rgba(255, 255, 255, .96); border: 1px solid #2e9e5b; border-radius: 12px; padding: .8em; overflow-y: auto; }
.sb-style-balance { margin-bottom: .6em; color: #174d2d; 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: #174d2d; cursor: pointer; }
.sb-style-opt.is-active { border: 2px solid #2e9e5b; 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: #174d2d; padding: .45em; cursor: pointer; }
.sb-preview { display: flex; align-items: center; justify-content: center; gap: .5em; flex-wrap: wrap; color: #174d2d; }
.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 #2e9e5b; 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 {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 28, 19, .72);
}
.fusion-overlay[hidden] { display: none; }
.fusion-panel {
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border: 2px solid var(--green);
  border-radius: 18px;
  background: #f5fbf7;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .32);
}
.fusion-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #fff;
  background: var(--green-dark);
}
.fusion-head h2 { flex: 1; margin: 0; font-size: 1.25rem; }
.fusion-head button { border: 0; background: transparent; color: #fff; font-size: 1.2rem; cursor: pointer; }
.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.is-success { border-color: #e0b64e; background: #fffbed; }
.fusion-notice.is-gentle { border-color: #8ab7d8; background: #f0f8ff; }
.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; }
}

/* ── 科學市集 ── */
.mkt-overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 16px; background: rgba(15, 29, 23, .78); }
.mkt-overlay[hidden] { display: none; }
.mkt-panel { width: min(720px, 96vw); max-height: 90vh; overflow: auto; border: 2px solid #dfb84f; border-radius: 18px; background: #fffdf5; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.mkt-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; color: #fff; background: #5a4320; }
.mkt-head h2 { margin: 0; font-size: 1.25rem; }
.mkt-head button { border: 0; color: #fff; background: transparent; font-size: 1.2rem; cursor: pointer; }
.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; } }
