:root {
  /* 柔光配色：暮色藍紫底、桃子、蜂蜜、薄荷。搶眼但不刺眼。 */
  --bg: #171b34;
  --panel: rgba(30, 35, 66, 0.84);
  --panel-solid: #232948;
  --panel-2: #2b3256;
  --line: #3f4774;
  --text: #f7f1e6;
  --muted: #bec1d8;
  --orange: #f2b38a;
  --gold: #efcf8e;
  --teal: #a6dccf;
  --dark-star: #7d80a8;
  --shadow: 0 8px 24px rgba(6, 8, 24, 0.35);
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6; overflow: hidden;
}
body.list { overflow: auto; }
a { color: var(--teal); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 探索畫面 ---------- */
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
body.list #world, body.list .hud-zoom { display: none; }

.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: flex-start; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(18, 20, 42, 0.75), rgba(18, 20, 42, 0));
}
.hud-top > * { pointer-events: auto; }
.brand img { display: block; width: 150px; height: auto; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5)); }
.scene { flex: 1; min-width: 0; }
.scene h1 { margin: 0; font-size: 24px; line-height: 1.2; color: var(--orange); text-shadow: 0 2px 8px rgba(6, 8, 24, 0.5); }
.scene p { margin: 2px 0 6px; color: var(--muted); font-size: 13px; }
.explore { width: min(220px, 100%); height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.explore span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width 0.6s; }
.hud-buttons { display: flex; gap: 8px; align-items: center; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); font-size: 18px; display: grid; place-items: center; backdrop-filter: blur(6px);
}
.round[aria-pressed="true"]#list-btn { border-color: var(--teal); color: var(--teal); }
.logbook {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--gold);
  background: var(--panel); color: var(--gold); font-weight: 700; white-space: nowrap; backdrop-filter: blur(6px);
}
.logbook span { display: inline-block; min-width: 1.6em; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--gold); color: var(--bg); text-align: center; }
.logbook.pop span { animation: pop 0.6s; }
@keyframes pop { 30% { transform: scale(1.6); } }

.hud-zoom { position: fixed; right: 16px; top: 45%; z-index: 5; display: grid; gap: 8px; }
.preview-note {
  position: fixed; left: 16px; top: calc(120px + env(safe-area-inset-top)); z-index: 4; margin: 0; max-width: 260px;
  padding: 6px 10px; border-radius: 10px; background: var(--panel); color: var(--muted); font-size: 12px;
}
body.list .preview-note { position: static; max-width: none; margin: 0 0 12px; }

.hud-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 10, 22, 0.92), rgba(5, 10, 22, 0));
}
body.has-player .hud-bottom { bottom: 104px; background: none; }
.extras { display: flex; gap: 8px; justify-content: center; padding: 8px 0; flex-wrap: wrap; }
.extra {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); backdrop-filter: blur(6px);
}
.extra[aria-selected="true"] { border-color: var(--teal); color: var(--teal); background: rgba(166, 220, 207, 0.12); }

/* 收音機調頻刻度 */
.tuner {
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 20px;
  border: 1px solid rgba(242, 179, 138, 0.35); background:
    repeating-linear-gradient(90deg, rgba(242, 179, 138, 0.25) 0 1px, transparent 1px 12px) bottom / 100% 10px no-repeat,
    linear-gradient(180deg, rgba(44, 40, 68, 0.92), rgba(26, 30, 56, 0.92));
  box-shadow: var(--shadow);
  max-width: 1100px; margin: 0 auto;
}
.dial-step {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--orange);
  background: radial-gradient(circle at 35% 30%, #4a4466, #2a2a48); color: var(--orange); font-size: 24px;
}
.dial-track { display: flex; gap: 6px; margin: 0; padding: 4px 2px 12px; list-style: none; overflow-x: auto; scroll-snap-type: x mandatory; flex: 1; scrollbar-width: none; }
.dial-track::-webkit-scrollbar { display: none; }
.knob {
  position: relative; scroll-snap-align: center; flex: none; min-width: 108px; min-height: 52px; padding: 6px 10px;
  border-radius: 12px; border: 1px solid transparent; background: transparent; text-align: center; color: var(--muted);
}
.knob b { display: block; font-size: 15px; white-space: nowrap; color: var(--text); }
.knob small { font-size: 11px; }
.knob .first { display: block; color: var(--teal); font-size: 10px; }
.knob[aria-current="true"] { color: var(--gold); background: rgba(242, 179, 138, 0.14); border-color: rgba(242, 179, 138, 0.5); }
.knob[aria-current="true"] b { color: var(--orange); }
.knob[aria-current="true"]::after {
  content: ""; position: absolute; left: 50%; bottom: -12px; width: 3px; height: 16px; margin-left: -1.5px;
  border-radius: 2px; background: #f29a8a;
}
.knob.locked { opacity: 0.4; cursor: not-allowed; }

/* ---------- 清單模式 ---------- */
main { padding: calc(150px + env(safe-area-inset-top)) 16px 260px; max-width: 1100px; margin: 0 auto; }
.level { padding: 16px; border-radius: var(--radius); background: var(--panel-solid); margin-bottom: 12px; }
.level h2 { margin: 0 0 4px; font-size: 24px; }
.level .meta { color: var(--muted); margin: 0 0 8px; }
.zones { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.zones button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); font-size: 14px; }
.zones button[aria-pressed="true"] { border-color: var(--orange); color: var(--orange); }
.search { display: block; margin: 0 0 12px; }
.search input { width: 100%; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--text); font-size: 16px; }
.stops { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.stop {
  width: 100%; height: 100%; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; text-align: left;
  padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-solid);
}
.stop .ch { grid-row: span 2; min-width: 52px; padding: 4px 6px; border-radius: 10px; background: var(--panel-2); text-align: center; font-weight: 700; font-size: 14px; }
.stop .ch small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.stop .t { font-weight: 700; }
.stop .tags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.badge { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); }
.badge.vip { border-color: var(--gold); color: var(--gold); }
.badge.soon { color: var(--dark-star); }
.badge.lab { border-color: var(--teal); color: var(--teal); }
.stop.vip { box-shadow: 0 0 0 2px var(--gold) inset; }
.stop.unreleased { opacity: 0.55; }
.stamps { color: var(--orange); letter-spacing: 2px; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 16px; }

/* ---------- 頻道卡、實驗、日誌 ---------- */
dialog { color: var(--text); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 0; }
dialog::backdrop { background: rgba(3, 8, 18, 0.55); backdrop-filter: blur(2px); }
.sheet { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 48px); box-shadow: 0 16px 40px rgba(6, 8, 24, 0.45); }
.sheet[open] { animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes rise { from { transform: translateY(30px) scale(0.96); opacity: 0; } }
.sheet .inner { padding: 20px; overflow-y: auto; }
.sheet .hero { font-size: 56px; line-height: 1; margin: 0 0 8px; filter: drop-shadow(0 4px 10px rgba(6, 8, 24, 0.4)); }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.sheet .close { float: right; min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--orange); color: var(--bg); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; }
.btn.alt { background: transparent; color: var(--teal); border: 1px solid var(--teal); }
.btn.gold { background: var(--gold); }
.hold { position: relative; overflow: hidden; }
.hold .fill { position: absolute; inset: 0; width: 0; background: rgba(255, 255, 255, 0.35); transition: width 2s linear; }
.hold.holding .fill { width: 100%; }
.hint { color: var(--muted); font-size: 13px; }
.card { margin: 12px 0; padding: 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid rgba(239, 207, 142, 0.5); }
.card h3 { margin: 0 0 6px; color: var(--gold); }
.takeaways { list-style: none; margin: 8px 0; padding: 0; }
.takeaways li { padding: 6px 8px; border-radius: 8px; transition: background 0.3s; }
.takeaways li.on { background: #2a2416; color: var(--orange); }
.question { margin-top: 12px; padding: 12px; border-left: 3px solid var(--teal); background: var(--panel-2); border-radius: 8px; }

.labsheet { width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; }
.labbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel-2); }
.labbar span { flex: 1; font-weight: 700; }
.labbar button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--orange); background: transparent; color: var(--orange); }
.labsheet iframe { width: 100%; height: calc(100% - 60px); border: 0; background: #fff; }

.toast {
  position: fixed; left: 50%; top: 40%; z-index: 20; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none;
  padding: 16px 24px; border-radius: 20px; background: rgba(44, 38, 52, 0.94); border: 2px solid var(--gold);
  color: var(--gold); font-size: 22px; font-weight: 700; text-align: center; box-shadow: var(--shadow);
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4), opacity 0.4s;
}
.toast.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }

[hidden] { display: none !important; }
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--panel-2); border-top: 1px solid var(--line); display: grid; gap: 6px; }
.player audio { width: 100%; }
.player .now { display: flex; flex-direction: column; font-size: 14px; }
.player #now-takeaway { color: var(--orange); }

@media (max-width: 640px) {
  .brand img { width: 96px; }
  .round { width: 40px; height: 40px; font-size: 16px; }
  .logbook { min-height: 40px; }
  .logbook .label { display: none; }
  .logbook::before { content: "📔"; }
  .preview-note { display: none; }
  .scene h1 { font-size: 19px; }
  .logbook { padding: 0 10px; font-size: 14px; }
  .hud-top { flex-wrap: wrap; }
  .scene { order: 3; flex-basis: 100%; }
  .preview-note { top: calc(150px + env(safe-area-inset-top)); max-width: 200px; }
  .hud-zoom { top: auto; bottom: 190px; }
  .knob { min-width: 92px; }
  .toast { width: min(86vw, 360px); font-size: 18px; }
  .extras { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .extra { min-height: 38px; padding: 0 12px; font-size: 14px; white-space: nowrap; flex: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* ---------- 科學隊長與好奇博士 ---------- */
.guide-btn { padding: 0; overflow: hidden; border-color: var(--orange); }
.guide-btn img { width: 100%; height: 100%; display: block; }
.mission { margin: 4px 0 0; font-size: 13px; color: var(--gold); }
.mission.done { color: var(--teal); }
.guide {
  position: fixed; left: 16px; bottom: 190px; z-index: 7; width: min(460px, calc(100vw - 32px));
  display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: start;
  padding: 12px 12px 22px; border-radius: 20px; cursor: pointer;
  background: rgba(30, 35, 66, 0.95); border: 2px solid var(--orange);
  box-shadow: var(--shadow);
}
.guide[data-who="curious"] { border-color: var(--teal); }
.guide.bounce { animation: guide-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes guide-in { from { transform: translateY(16px) scale(0.95); opacity: 0.4; } }
.guide-avatar { width: 72px; height: 72px; border-radius: 50%; border: 3px solid var(--orange); background: #142036; }
.guide[data-who="curious"] .guide-avatar { border-color: var(--teal); animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(-6deg); } }
.guide-name { margin: 0; font-weight: 700; color: var(--orange); font-size: 14px; }
.guide[data-who="curious"] .guide-name { color: var(--teal); }
.guide-text { margin: 2px 0 0; font-size: 17px; line-height: 1.55; min-height: 2.4em; }
.guide-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.guide-action { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--orange); color: var(--bg); font-weight: 700; }
.guide[data-who="curious"] .guide-action { background: var(--teal); }
.guide-tools { display: grid; gap: 6px; }
.guide-tools button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; }
.guide-tools .guide-voice[aria-pressed="true"] { border-color: var(--gold); }
.guide-next { position: absolute; right: 16px; bottom: 4px; font-size: 11px; color: var(--muted); opacity: 0; }
.guide.typed .guide-next { opacity: 1; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
body.has-player .guide { bottom: 294px; }

/* 頻道卡上的兩人對話 */
.duo { display: grid; gap: 8px; margin: 4px 0 12px; }
.say { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: start; }
.say img { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--teal); }
.say p { margin: 0; padding: 8px 12px; border-radius: 4px 16px 16px 16px; background: var(--panel-2); font-size: 15px; }
.say.captain img { border-color: var(--orange); }
.say.captain p { border: 1px solid rgba(242, 179, 138, 0.5); }

@media (max-width: 640px) {
  .guide { left: 8px; right: 8px; width: auto; bottom: 178px; grid-template-columns: 56px 1fr auto; }
  .guide-avatar { width: 56px; height: 56px; }
  .guide-text { font-size: 16px; }
}

/* 3D 版 */
.warp-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 3;
  background: radial-gradient(circle at 50% 50%, rgba(255,246,234,0.7), rgba(200,188,240,0.35) 40%, rgba(23,27,52,0) 72%); }
.tip3d { position: fixed; z-index: 6; transform: translate(-50%, -100%); pointer-events: none; max-width: 260px;
  padding: 6px 10px; border-radius: 10px; background: rgba(30,35,66,0.94); border: 1px solid rgba(166,220,207,0.45);
  color: var(--text); font-size: 14px; line-height: 1.35; box-shadow: var(--shadow); }
.tip3d[hidden] { display: none; }
.hint3d { position: fixed; left: 50%; top: 58%; z-index: 4; transform: translate(-50%, -50%); margin: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: rgba(30,35,66,0.9); border: 1px solid rgba(166,220,207,0.45);
  color: var(--text); font-size: 15px; white-space: pre; text-align: center; transition: opacity 0.5s; animation: hint-in 0.6s ease-out; }
.hint3d.bye { opacity: 0; }
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, -30%); } }
@media (max-width: 700px) { .hint3d { font-size: 14px; } }
/* 上方標題後面一層淡淡的暗帶，亮的星球在後面也讀得清楚 */
body.gl::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 170px; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom, rgba(18, 20, 42, 0.6), rgba(18, 20, 42, 0)); }
body.gl.list::before { display: none; }
