/* 伽利略星球首頁。色票與首頁 index.html 的 :root 一致；不使用純黑 #000。 */
:root {
  --bg-base: #16241f;
  --bg-panel: #1e2f27;
  --bg-panel-hover: #24382f;
  --chalk-white: #f6f3ea;
  --chalk-muted: #9fb0a8;
  --chalk-yellow: #f2d675;
  --chalk-teal: #7fc8c4;
  --chalk-coral: #f0955c;
  --chalk-blue: #6fa8f2;
  --chalk-green: #a8e6cf;
  --rule: rgba(246, 243, 234, 0.14);
  --ink: #0b1a15;
  --hall-color: var(--chalk-yellow);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-base);
  color: var(--chalk-white);
  font-family: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; }

#app {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(55% 42% at 16% 20%, rgba(56, 189, 248, 0.11), rgba(56, 189, 248, 0) 70%),
    radial-gradient(50% 38% at 86% 80%, rgba(244, 114, 182, 0.08), rgba(244, 114, 182, 0) 70%),
    radial-gradient(38% 28% at 80% 16%, rgba(253, 224, 71, 0.06), rgba(253, 224, 71, 0) 70%),
    radial-gradient(120% 90% at 50% 40%, #274a40 0%, #182f28 50%, #0b1a15 100%);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
body.no-3d #scene { display: none; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ===== 頂端列 ===== */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar .spacer { flex: 1; pointer-events: none; }
#topbar [hidden] { display: none !important; }

.fab {
  min-width: 44px;
  height: 44px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 22px;
  border: 2px solid #ffe066;
  background: rgba(17, 38, 31, 0.92);
  color: var(--chalk-white);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(11, 26, 21, 0.6), 0 0 14px rgba(255, 224, 102, 0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.fab svg { width: 22px; height: 22px; flex: none; }
.fab:hover, .fab:focus-visible { background: #ffe066; color: var(--bg-base); transform: translateY(-2px); }
.fab:active { transform: translateY(0); }
.classic-text { font-size: 18px; font-weight: 700; white-space: nowrap; }

.lang {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  height: 52px;
  border-radius: 26px;
  border: 2px solid var(--chalk-teal);
  background: rgba(17, 38, 31, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.lang button {
  min-width: 48px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--chalk-white);
  font-size: 18px;
  font-weight: 700;
}
.lang button.active { background: var(--chalk-teal); color: var(--ink); }

/* ===== 星球層標題與提示 ===== */
#intro {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 0; right: 0;
  z-index: 10;
  text-align: center;
  pointer-events: none;
}
#intro h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  color: var(--chalk-yellow);
  text-shadow: 0 2px 0 var(--ink), 0 6px 20px rgba(11, 26, 21, 0.7);
}
#intro p {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--chalk-muted);
}
#hint {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 10;
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-size: 20px;
  color: var(--chalk-white);
  text-shadow: 0 2px 8px var(--ink);
  pointer-events: none;
  transition: opacity 0.3s ease;
}
body.at-hall #intro, body.at-hall #hint, body.booting #hint { opacity: 0; visibility: hidden; }

/* ===== 館名牌（以 3D 位置投影；沒有 3D 時變成 2×2 格） ===== */
#plates { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.plate {
  position: absolute;
  left: 0; top: 0;
  min-height: 44px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 999px;
  border: 2px solid var(--hall-color);
  background: rgba(17, 38, 31, 0.9);
  color: var(--chalk-white);
  box-shadow: 0 6px 18px rgba(11, 26, 21, 0.6), 0 0 16px color-mix(in srgb, var(--hall-color) 35%, transparent);
  pointer-events: auto;
  will-change: transform;
  transition: opacity 0.2s ease;
}
.plate .plate-name { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--hall-color); }
.plate .plate-sub { font-size: 18px; line-height: 1.2; color: var(--chalk-white); opacity: 0.88; white-space: nowrap; }
.plate.is-hidden { opacity: 0; pointer-events: none; }
.plate:hover, .plate:focus-visible { background: color-mix(in srgb, var(--hall-color) 22%, var(--bg-base)); }
body.at-hall #plates { display: none; }

body.no-3d #plates {
  position: absolute;
  inset: calc(150px + var(--safe-top)) 16px calc(80px + var(--safe-bottom)) 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: center;
  max-width: 720px;
  margin: 0 auto;
}
body.no-3d.at-hall #plates { display: none; }
body.no-3d .plate .plate-sub { white-space: normal; text-align: center; }
body.no-3d .plate {
  min-width: 0;
  position: static;
  transform: none !important;
  border-radius: 20px;
  min-height: 132px;
  justify-content: center;
}
body.no-3d .plate.is-hidden { opacity: 1; pointer-events: auto; }
body.no-3d .plate .plate-name { font-size: 28px; }

#focusLabel {
  position: absolute;
  left: 0; top: 0;
  z-index: 18;
  max-width: min(70vw, 360px);
  padding: 6px 14px;
  border-radius: 14px;
  border: 2px solid var(--hall-color);
  background: rgba(17, 38, 31, 0.92);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
  will-change: transform;
}

/* ===== 館內底部卡片 ===== */
#sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  padding-bottom: var(--safe-bottom);
  border-top: 2px solid var(--hall-color);
  border-radius: 22px 22px 0 0;
  background: linear-gradient(to top, rgba(22, 36, 31, 0.98), rgba(22, 36, 31, 0.93));
  box-shadow: 0 -10px 30px rgba(11, 26, 21, 0.55);
  transition: transform 0.35s ease;
  will-change: transform;
}
#sheet[hidden] { display: none; }
#sheet.collapsed { transform: translateY(calc(100% - 56px - var(--safe-bottom))); }

.sheet-handle {
  position: relative;
  width: 100%;
  min-height: 56px;
  padding: 14px 56px 6px 20px;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  text-align: left;
}
.sheet-handle .grip {
  position: absolute;
  top: 8px; left: 50%;
  width: 44px; height: 5px;
  margin-left: -22px;
  border-radius: 3px;
  background: var(--rule);
}
.sheet-title { font-size: 22px; font-weight: 700; color: var(--hall-color); }
.sheet-title small { margin-left: 10px; font-size: 18px; font-weight: 400; color: var(--chalk-muted); }
.sheet-handle .chev {
  position: absolute;
  right: 14px; top: 50%;
  width: 28px; height: 28px;
  margin-top: -12px;
  transition: transform 0.3s ease;
}
#sheet.collapsed .chev { transform: rotate(180deg); }

.chips {
  display: flex;
  gap: 8px;
  padding: 2px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 22px;
  border: 2px dashed var(--rule);
  background: rgba(255, 255, 255, 0.05);
  color: var(--chalk-muted);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}
.chip:hover { color: var(--chalk-white); border-color: var(--chalk-white); }
.chip.active {
  border: 2px solid var(--hall-color);
  background: var(--hall-color);
  color: var(--ink);
  box-shadow: 0 0 16px color-mix(in srgb, var(--hall-color) 45%, transparent);
}

.cards-wrap { position: relative; }
.cards {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 4px 16px 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.cards::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 min(88vw, 430px);
  height: 184px;
  scroll-snap-align: start;
  display: flex;
  overflow: hidden;
  border-radius: 16px;
  border: 2px solid var(--rule);
  background: var(--bg-panel);
  color: var(--chalk-white);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.card:hover { background: var(--bg-panel-hover); }
.card.active { border-color: var(--hall-color); }
.card-art {
  position: relative;
  flex: 0 0 38%;
  background: #0f1b17;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
}
.card-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-art .star {
  position: absolute;
  top: 8px; left: 8px;
  min-width: 28px; height: 28px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--chalk-yellow);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.card-body {
  flex: 1;
  min-width: 0;
  padding: 10px 12px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-unit { font-size: 16px; line-height: 1.3; color: var(--hall-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-blurb {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  color: #d9d6c9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-go { margin-top: auto; font-size: 18px; font-weight: 700; color: var(--hall-color); }

.arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px; height: 44px;
  margin-top: -32px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  border: 2px solid var(--hall-color);
  background: rgba(17, 38, 31, 0.92);
  color: var(--chalk-white);
}
.arrow svg { width: 22px; height: 22px; }
.arrow.prev { left: 6px; }
.arrow.next { right: 6px; }
.arrow:hover { background: var(--hall-color); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .arrow { display: inline-flex; } }

/* ===== 搜尋 ===== */
#searchPanel {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: 12px; right: 12px;
  z-index: 40;
  max-width: 520px;
  margin-left: auto;
  padding: 10px;
  border-radius: 18px;
  border: 2px solid var(--hall-color);
  background: rgba(17, 38, 31, 0.97);
  box-shadow: 0 12px 34px rgba(11, 26, 21, 0.65);
}
#searchPanel[hidden] { display: none; }
#searchInput {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--rule);
  background: var(--bg-base);
  color: var(--chalk-white);
  font: inherit;
  font-size: 20px;
}
#searchInput:focus { outline: none; border-color: var(--hall-color); }
#searchResults { list-style: none; margin: 8px 0 0; padding: 0; max-height: 46dvh; overflow-y: auto; }
#searchResults li button {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
}
#searchResults li button:hover, #searchResults li button:focus-visible { background: var(--bg-panel-hover); }
#searchResults .r-title { font-size: 20px; font-weight: 700; }
#searchResults .r-unit { font-size: 16px; color: var(--hall-color); }
#searchResults .none { padding: 12px 10px; font-size: 18px; color: var(--chalk-muted); }

/* ===== 提示與除錯 ===== */
#notice {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(64px + var(--safe-top));
  z-index: 45;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--chalk-coral);
  background: rgba(17, 38, 31, 0.97);
  font-size: 18px;
  line-height: 1.5;
}
#notice[hidden] { display: none; }
#notice a { color: var(--chalk-yellow); font-weight: 700; }
#debug {
  position: absolute;
  left: 8px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 60;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(11, 26, 21, 0.86);
  color: #b8f5c9;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}
#debug[hidden] { display: none; }

/* ===== 窄螢幕 ===== */
@media (max-width: 520px) {
  .classic-text { display: none; }
  .classic { padding: 0; width: 44px; }
  #intro h1 { font-size: 30px; }
  #intro { top: calc(62px + var(--safe-top)); }
  .plate { padding: 6px 12px; }
  .plate .plate-name { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* 第一次碰到星球後，標題淡出，避免和館名牌重疊 */
#intro { transition: opacity .4s ease; }
body.touched #intro { opacity: 0; pointer-events: none; }

/* ===== 寬螢幕（平板橫放、電腦）：卡片在左側直排 ===== */
body.layout-side #sheet {
  top: calc(76px + var(--safe-top, 0px));
  bottom: 0; left: 0; right: auto;
  width: min(430px, 40vw);
  display: flex; flex-direction: column;
  border-top: none;
  border-right: 2px solid var(--hall-color);
  border-radius: 0 22px 0 0;
  box-shadow: 10px 0 30px rgba(11, 26, 21, 0.55);
  background: linear-gradient(to right, rgba(22, 36, 31, 0.98), rgba(22, 36, 31, 0.93));
  padding-bottom: 0;
}
body.layout-side #sheet[hidden] { display: none; }
body.layout-side #sheet.collapsed { transform: translateX(calc(-100% + 56px)); }
body.layout-side #sheet.collapsed .chips,
body.layout-side #sheet.collapsed .cards-wrap { visibility: hidden; }
body.layout-side #sheet .chev { transform: rotate(90deg); }
body.layout-side #sheet.collapsed .chev { transform: rotate(-90deg); }
body.layout-side .sheet-handle { overflow: hidden; }
body.layout-side .chips { flex: none; flex-wrap: wrap; overflow: visible; padding-bottom: 10px; max-height: 148px; overflow-y: auto; }
body.layout-side .cards-wrap { flex: 1 1 auto; min-height: 0; display: flex; }
body.layout-side .cards {
  flex: 1 1 auto; flex-direction: column;
  overflow-x: hidden; overflow-y: auto;
  scroll-snap-type: y mandatory; scroll-padding-inline: 0; scroll-padding-block: 4px;
  padding: 4px 14px calc(18px + var(--safe-bottom, 0px));
}
body.layout-side .card { flex: 0 0 auto; width: 100%; }
body.layout-side .arrow { display: none !important; }
body.layout-side.at-hall #searchPanel { left: min(446px, calc(40vw + 16px)); }

/* ===== 科學家簡介卡 ===== */
#sciCard {
  position: absolute; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(11, 26, 21, 0.62);
}
#sciCard[hidden] { display: none; }
.sci-box {
  position: relative;
  width: min(560px, 100%);
  padding: 28px 28px 30px;
  border-radius: 22px;
  border: 3px solid var(--hall-color);
  background: var(--bg-panel);
  box-shadow: 0 18px 50px rgba(11, 26, 21, 0.7);
  color: var(--chalk-white);
}
.sci-close { position: absolute; top: 12px; right: 12px; }
.sci-kicker { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--hall-color); }
#sciName { margin: 0; font-size: 36px; line-height: 1.25; }
.sci-years { margin: 4px 0 0; font-size: 22px; color: var(--chalk-muted); }
.sci-role { margin: 2px 0 14px; font-size: 22px; color: var(--hall-color); }
.sci-text { margin: 0; font-size: 22px; line-height: 1.75; }

/* ===== 開場：煙霧＋歡迎詞 ===== */
#launch {
  position: absolute; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
}
#launch[hidden] { display: none; }
#launch canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.launch-text {
  position: relative;
  text-align: center;
  padding: 0 24px;
  transition: transform 0.9s cubic-bezier(.5, 0, .75, 0), opacity 0.8s ease, filter 0.8s ease;
}
.launch-title { margin: 0; font-weight: 800; line-height: 1.3; }
.launch-title span {
  display: block;
  opacity: 0;
  transform: translateY(14px);
  filter: blur(8px);
  letter-spacing: 0.32em;
  color: var(--chalk-white);
  text-shadow: 0 2px 0 var(--ink), 0 0 26px rgba(11, 26, 21, 0.95), 0 0 8px rgba(11, 26, 21, 0.8);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.2, .8, .2, 1), filter 1.1s ease, letter-spacing 1.4s cubic-bezier(.2, .8, .2, 1);
}
.launch-title .l1 { font-size: clamp(28px, 4.2vw, 46px); }
.launch-title .l2 { margin-top: 10px; font-size: clamp(40px, 6.6vw, 72px); transition-delay: 0.45s; }
.launch-title .l2 b { white-space: nowrap; color: #fde047; text-shadow: 0 2px 0 var(--ink), 0 0 30px rgba(253, 224, 71, 0.4), 0 0 14px rgba(11, 26, 21, 0.95); }
#launch.show .launch-title span { opacity: 1; transform: none; filter: none; letter-spacing: 0.06em; }
.launch-status {
  margin: 28px 0 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.12em;
  color: #55e9ff;
  text-shadow: 0 0 14px rgba(11, 26, 21, 0.95);
  opacity: 0;
  transition: opacity 0.8s ease 1.3s, color 0.2s ease;
}
#launch.show .launch-status { opacity: 1; }
.launch-status .dots i { font-style: normal; animation: launchDot 1.2s infinite; opacity: 0.2; }
.launch-status .dots i:nth-child(2) { animation-delay: 0.2s; }
.launch-status .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes launchDot { 0%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
#launch.go .launch-status { color: #fde047; transition-delay: 0s; }
#launch.go .launch-status .dots { display: none; }
#launch.parting .launch-text { transform: scale(1.8); opacity: 0; filter: blur(6px); }
#launchSkip {
  position: absolute;
  right: calc(20px + var(--safe-right));
  bottom: calc(22px + var(--safe-bottom));
  min-height: 48px; min-width: 88px;
  padding: 0 22px;
  border-radius: 999px;
  border: 2px solid rgba(246, 243, 234, 0.35);
  background: rgba(17, 38, 31, 0.72);
  color: var(--chalk-white);
  font-size: 22px; font-weight: 700;
  transition: opacity 0.3s ease, background 0.15s ease;
}
#launchSkip:hover, #launchSkip:focus-visible { background: var(--chalk-yellow); color: var(--ink); }
#launch.parting #launchSkip { opacity: 0; pointer-events: none; }
#topbar, #plates, #hint { transition: opacity 0.8s ease; }
body.launching #topbar, body.launching #intro, body.launching #hint, body.launching #plates, body.launching #focusLabel {
  opacity: 0 !important; visibility: hidden; pointer-events: none;
}

/* ===== 開場旁白：出發按鈕、倒數大字、字幕 ===== */
#launchGo {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 22px;
  min-height: 64px; min-width: 200px;
  padding: 0 34px;
  border: 3px solid #fde047;
  border-radius: 999px;
  background: #fde047;
  color: var(--ink);
  font-size: 30px; font-weight: 800;
  box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.55), 0 10px 30px rgba(11, 26, 21, 0.6);
  animation: launchPulse 1.6s ease-in-out infinite;
}
#launchGo[hidden] { display: none; }
#launchGo:focus-visible { outline: 3px solid #55e9ff; outline-offset: 4px; }
@keyframes launchPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(253, 224, 71, 0.55), 0 10px 30px rgba(11, 26, 21, 0.6); transform: scale(1); }
  50% { box-shadow: 0 0 0 16px rgba(253, 224, 71, 0), 0 10px 30px rgba(11, 26, 21, 0.6); transform: scale(1.04); }
}
#launch.ready .launch-status { color: #fde047; }
#launch.ready .launch-status .dots { display: none; }
#launch.counting .launch-status .dots { display: none; }
#launch.counting .launch-status .st {
  display: inline-block;
  font-size: 76px; line-height: 1.1;
  color: #fde047;
  text-shadow: 0 3px 0 var(--ink), 0 0 30px rgba(253, 224, 71, 0.45);
  animation: launchCount 0.5s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes launchCount { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* ===== 開場：穿越蟲洞（取代舊的 3-2-1 倒數） ===== */
#launch.warping .launch-text { opacity: 0; transform: scale(0.9); filter: blur(5px); pointer-events: none; }
.warp-ui {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: max(9vh, 60px) 24px 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease 0.5s, transform 0.9s cubic-bezier(.5, 0, .75, 0), filter 0.8s ease;
}
#launch.warping .warp-ui { opacity: 1; }
.warp-cap {
  margin: 0;
  font-size: clamp(26px, 4vw, 44px); font-weight: 800; line-height: 1.3;
  letter-spacing: 0.08em;
  color: var(--chalk-white);
  text-shadow: 0 2px 0 var(--ink), 0 0 22px rgba(85, 233, 255, 0.6), 0 0 10px rgba(11, 26, 21, 0.9);
  transition: color 0.2s ease;
}
.warp-cap .dots i { font-style: normal; animation: launchDot 1.2s infinite; opacity: 0.2; }
.warp-cap .dots i:nth-child(2) { animation-delay: 0.2s; }
.warp-cap .dots i:nth-child(3) { animation-delay: 0.4s; }
#launch.warp-go .warp-cap { color: #fde047; text-shadow: 0 3px 0 var(--ink), 0 0 30px rgba(253, 224, 71, 0.5); }
#launch.warp-go .warp-cap .dots { display: none; }
#launch.parting .warp-ui { transform: scale(1.5); opacity: 0; filter: blur(5px); transition-delay: 0s; }
#narration {
  position: absolute;
  left: 50%; bottom: calc(92px + var(--safe-bottom));
  z-index: 95;
  width: max-content; max-width: min(92vw, 900px);
  transform: translate(-50%, 8px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
#narration[hidden] { display: none; }
#narration.on { opacity: 1; transform: translate(-50%, 0); }
#narration p {
  margin: 0;
  padding: 10px 24px;
  border-radius: 16px;
  background: rgba(11, 26, 21, 0.78);
  border: 1px solid rgba(246, 243, 234, 0.18);
  color: var(--chalk-white);
  font-size: 26px; font-weight: 700; line-height: 1.5;
  text-align: center;
}

/* ===== 段考章節與上課進度總覽彈窗 ===== */
#scheduleModal {
  position: absolute;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--safe-top)) calc(14px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: rgba(11, 26, 21, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#scheduleModal[hidden] { display: none; }
.schedule-box {
  position: relative;
  width: min(820px, 100%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
  border-radius: 22px;
  border: 2.5px solid var(--chalk-yellow);
  background: var(--bg-panel);
  box-shadow: 0 20px 60px rgba(11, 26, 21, 0.75);
  color: var(--chalk-white);
}
.schedule-close {
  position: absolute;
  top: 12px;
  right: 12px;
}
.schedule-title {
  margin: 0 54px 4px 0;
  font-size: 22px;
  line-height: 1.25;
  color: var(--chalk-yellow);
}
.schedule-sub {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--chalk-muted);
}
.schedule-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  flex: none;
}
.sch-tab {
  min-height: 40px;
  padding: 4px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--rule);
  background: var(--bg-base);
  color: var(--chalk-muted);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.18s ease;
}
.sch-tab:hover { color: var(--chalk-white); border-color: rgba(246, 243, 234, 0.36); }
.sch-tab.active {
  background: var(--chalk-yellow);
  color: var(--ink);
  border-color: var(--chalk-yellow);
}
.schedule-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sch-grade {
  background: rgba(22, 36, 31, 0.78);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 12px 14px;
}
.sch-grade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--rule);
}
.sch-grade-head h3 {
  margin: 0;
  font-size: 18px;
  color: var(--chalk-white);
}
.sch-grade-meta {
  font-size: 13px;
  color: var(--chalk-teal);
  font-weight: 700;
}
.sch-sem-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.sch-sem-card {
  background: rgba(30, 47, 39, 0.72);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 10px 12px;
}
.sch-sem-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--chalk-teal);
}
.sch-sem-count {
  font-size: 12px;
  color: var(--chalk-muted);
  white-space: nowrap;
}
.sch-unit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sch-unit {
  border: 1px solid rgba(246, 243, 234, 0.14);
  border-radius: 10px;
  background: rgba(22, 36, 31, 0.86);
  overflow: hidden;
}
.sch-unit-btn {
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--chalk-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}
.sch-unit-btn:hover { background: rgba(255, 255, 255, 0.04); }
.sch-unit-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.sch-hall-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--hall-color);
  border: 1px solid color-mix(in srgb, var(--hall-color) 55%, transparent);
  background: color-mix(in srgb, var(--hall-color) 14%, transparent);
  white-space: nowrap;
}
.sch-unit-name {
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.sch-unit-note {
  font-size: 12px;
  color: var(--chalk-muted);
  font-weight: 500;
}
.sch-unit-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--chalk-muted);
  white-space: nowrap;
  flex: none;
}
.sch-caret { display: inline-block; transition: transform 0.2s ease; }
.sch-unit.open .sch-caret { transform: rotate(180deg); }
.sch-unit-detail {
  display: none;
  padding: 6px 10px 10px;
  border-top: 1px dashed var(--rule);
  background: rgba(11, 26, 21, 0.45);
}
.sch-unit.open .sch-unit-detail { display: block; }
.sch-lessons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.sch-lesson-link {
  min-height: 38px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--bg-panel);
  color: var(--chalk-white);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.3;
}
.sch-lesson-link:hover {
  background: var(--bg-panel-hover);
  border-color: var(--hall-color);
  color: var(--hall-color);
}
.sch-fly-btn {
  min-height: 38px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--hall-color) 60%, transparent);
  background: color-mix(in srgb, var(--hall-color) 15%, transparent);
  color: var(--hall-color);
  font-size: 13px;
  font-weight: 700;
}
.sch-fly-btn:hover {
  background: var(--hall-color);
  color: var(--ink);
}

@media (max-width: 720px) {
  .sch-sem-grid { grid-template-columns: 1fr; }
  .schedule-box { padding: 16px 14px 14px; }
  .schedule-title { font-size: 20px; }
}
