:root {
  color-scheme: dark;
  --bg: #07101e;
  --panel: #101c2d;
  --panel-2: #16263a;
  --line: #2a3f55;
  --text: #f1f5f4;
  --muted: #a9bacb;
  --cyan: #94dfe1;
  --gold: #f4c26f;
  --lava: #ff8a3d;
  --lava-deep: #e2542a;
  --pink: #ed9fba;
  --radius: 20px;
  font-family: system-ui, -apple-system, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 15% -10%, #1b3550 0, transparent 55%), radial-gradient(ellipse at 100% 0, #3a1f24 0, transparent 45%), var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 上方 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 62px; padding: 0 max(16px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line); background: #07101ee6;
}
.brand { display: flex; align-items: center; }
.brand img { width: 116px; height: 46px; object-fit: contain; display: block; }
.switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.switch button { min-width: 48px; min-height: 38px; border: 0; border-radius: 999px; background: transparent; font-size: 14px; }
.switch button[aria-pressed=true] { background: #294659; color: #d4fffa; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
.hero { padding: 14px 4px 8px; }
.eyebrow { margin: 0 0 2px; color: var(--gold); font-size: 14px; font-weight: 700; letter-spacing: .04em; }
.hero h1 { margin: 0; font-size: clamp(27px, 4.6vw, 42px); line-height: 1.2; letter-spacing: .01em; }
.hero h1 em { font-style: normal; color: var(--lava); }
.sub { margin: 6px 0 0; color: var(--muted); font-size: clamp(15px, 2vw, 18px); }

/* ---------- 兩個玩法 ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 12px; }
.tabs button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 8px 12px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--panel); font-weight: 700; font-size: 17px;
  transition: transform .15s, border-color .15s, background .15s;
}
.tabs button .n {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: #24384d; color: var(--muted); font-size: 15px; flex: none;
}
.tabs button small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); line-height: 1.2; }
.tabs button span.t { text-align: left; line-height: 1.25; }
.tabs button[aria-selected=true] { border-color: var(--lava); background: linear-gradient(180deg, #2b2330, #1c2233); }
.tabs button[aria-selected=true] .n { background: var(--lava); color: #2a1206; }
.tabs button:hover { transform: translateY(-1px); border-color: #56708a; }

/* ---------- 實驗台 ---------- */
.lab { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, 1fr); gap: 14px; align-items: start; }
.stage {
  position: sticky; top: 10px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #050b18; box-shadow: 0 18px 40px #0008;
}
#scene { display: block; width: 100%; height: clamp(400px, calc(100vh - 268px), 640px); touch-action: pan-y pinch-zoom; }
#lift-track { position: absolute; touch-action: none; cursor: grab; border-radius: 40px; }
#lift-track:active { cursor: grabbing; }
.stage-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid #ffffff2e;
  background: #0b1626cc; font-size: 19px; backdrop-filter: blur(4px);
}
.stage-note { position: absolute; left: 12px; bottom: 8px; margin: 0; font-size: 12px; color: #c6d3e0b3; pointer-events: none; }
#float { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#float span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-weight: 900; font-size: clamp(26px, 6vw, 46px); color: #fff3d6;
  text-shadow: 0 2px 0 #b2401c, 0 0 18px #ff8a3dcc; animation: floatup 1.5s ease-out forwards;
}
#banner {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 120px); padding: 5px 16px 5px 6px; border-radius: 999px; white-space: nowrap;
  background: #0b1626e6; border: 1.5px solid #ff8a3d; box-shadow: 0 6px 18px #0009; animation: bannerin .45s cubic-bezier(.2, 1.4, .4, 1);
}
#banner[hidden] { display: none; }
#banner svg { width: 38px; height: 38px; flex: none; }
#banner b { font-size: clamp(17px, 2.6vw, 22px); }
#banner i { font-style: normal; padding: 1px 8px; border-radius: 99px; background: var(--gold); color: #2a1a06; font-size: 12px; font-weight: 800; }
@keyframes bannerin { from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.8); } }
@keyframes floatup {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  18% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.panel {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
}
.talk { display: flex; gap: 10px; align-items: flex-start; }
.talk img { width: 54px; height: 54px; border-radius: 50%; flex: none; border: 2px solid #ffffff22; background: #20344a; }
.talk p {
  position: relative; margin: 0; padding: 10px 14px; border-radius: 6px 18px 18px 18px;
  background: #f6efe2; color: #1d2433; font-size: 16px; line-height: 1.55; min-height: 54px;
}
.talk p b { color: #c2410c; }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meter { padding: 10px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid #ffffff10; }
.meter span { display: block; font-size: 13px; color: var(--muted); }
.meter b { display: block; font-size: 22px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.meter b small { font-size: 13px; font-weight: 600; color: var(--muted); }
.meter.size { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(120deg, #3a2516, #1f2a3d); border-color: #ff8a3d55; }
.meter.size b { font-size: 40px; color: var(--gold); }
.meter .bar { display: block; height: 8px; margin-top: 6px; border-radius: 8px; background: #0b1626; overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .12s; }
.size-dots { display: flex; align-items: center; gap: 10px; flex: none; }
.size-dots i { display: block; border-radius: 50%; }
.size-dots .was { width: 8px; height: 8px; border: 1.5px dashed #ffffff99; }
.size-dots .now { background: radial-gradient(circle at 35% 30%, #fff, #ffe7b3 35%, #ffb45c88 75%); border: 1.5px solid #fff; transition: width .12s, height .12s; }

.slider label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 2px; }
.slider .ends { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: -4px; }
input[type=range] { width: 100%; min-height: 44px; accent-color: var(--lava); }

.missions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.missions li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px;
  background: #0d1828; border: 1px dashed #ffffff22; font-size: 15px; color: #d3dde8;
}
.missions li::before { content: '☆'; font-size: 20px; color: #6b7f94; line-height: 1; }
.missions li.done { border-style: solid; border-color: #f4c26f88; background: #2a2416; color: #fff3d6; }
.missions li.done::before { content: '★'; color: var(--gold); animation: starpop .5s ease-out; }
@keyframes starpop { 0% { transform: scale(.2) rotate(-40deg); } 60% { transform: scale(1.5) rotate(10deg); } 100% { transform: none; } }

.cta {
  min-height: 56px; padding: 10px 18px; border-radius: 16px; border: 0;
  background: linear-gradient(180deg, #ffa24f, #f0582a); color: #2a1206; font-size: 20px; font-weight: 800;
  box-shadow: 0 6px 0 #9a3415, 0 12px 22px #0007; transition: transform .08s, box-shadow .08s, filter .15s;
}
.cta:hover { filter: brightness(1.07); }
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 #9a3415, 0 6px 12px #0007; }
.cta:disabled { filter: grayscale(.5) brightness(.8); cursor: default; }
.cta.next { background: linear-gradient(180deg, #b6f0ee, #6fc9cf); color: #082a30; box-shadow: 0 6px 0 #2f7d86, 0 12px 22px #0007; font-size: 17px; }
.cta.next:active { box-shadow: 0 2px 0 #2f7d86; }
.ghost { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px; }
.ghost:hover { border-color: var(--cyan); color: var(--text); }

.pick { margin: 0; padding: 0; border: 0; min-width: 0; }
.pick legend { padding: 0; margin-bottom: 6px; font-weight: 700; font-size: 16px; }
.pick legend i { font-style: normal; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 50%; background: #24384d; font-size: 14px; }
.pick .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pick button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 74px; padding: 6px 4px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel-2);
  font-size: 14.5px; font-weight: 700; line-height: 1.25; transition: transform .12s, border-color .12s;
}
.pick button .ico { font-size: 24px; line-height: 1.1; letter-spacing: -3px; }
.pick button[aria-pressed=true] { border-color: var(--lava); background: linear-gradient(180deg, #3a2516, #2a2030); transform: translateY(-2px); box-shadow: 0 4px 0 #9a3415; }
.pick-note { margin: 6px 2px 0; font-size: 14px; color: var(--muted); min-height: 22px; }

.result { padding: 12px 14px; border-radius: 16px; border: 1px solid #ff8a3d66; background: linear-gradient(140deg, #3a2516, #1b2436); animation: slidein .35s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }
.result .head { display: flex; align-items: center; gap: 12px; }
.result .head svg { width: 58px; height: 58px; flex: none; }
.result h3 { margin: 0; font-size: 21px; line-height: 1.3; }
.result h3 small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.result .new { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: var(--gold); color: #2a1a06; font-size: 12px; font-weight: 800; vertical-align: middle; }
.result p { margin: 8px 0 0; font-size: 15px; }
.result .tall { color: var(--gold); font-weight: 700; }
.result .real { color: #c9d6e2; font-size: 14px; }

.dex h3 { margin: 0 0 6px; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; }
.dex h3 span { color: var(--gold); font-variant-numeric: tabular-nums; }
.dex .row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dex button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 76px;
  border-radius: 12px; border: 1px solid var(--line); background: #0d1828; font-size: 11.5px; line-height: 1.2; color: var(--muted);
}
.dex button svg { width: 40px; height: 40px; }
.dex button.locked svg { filter: grayscale(1) brightness(.45); }
.dex button.got { border-color: #f4c26f88; color: var(--text); background: #1d2436; }
.dex button.fresh { animation: starpop .6s ease-out; }
.dex-hint { margin: 6px 2px 0; font-size: 13.5px; color: var(--muted); min-height: 20px; }

/* ---------- 下面的說明 ---------- */
.why { margin-top: 26px; }
.why h2, .listen h2 { margin: 0 0 10px; font-size: 22px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; counter-reset: step; }
.steps article { position: relative; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.steps .ico { font-size: 34px; line-height: 1; }
.steps h3 { margin: 8px 0 4px; font-size: 18px; }
.steps p { margin: 0; color: #cfd9e3; font-size: 15px; }

.listen { display: flex; gap: 16px; align-items: center; margin-top: 16px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(120deg, #172a3f, #101c2d); }
.listen img { width: 132px; height: auto; flex: none; }
.listen h2 { font-size: 19px; margin-bottom: 4px; }
.listen p { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 16px; border-radius: 12px; background: var(--cyan); color: #082a30; font-weight: 700; text-decoration: none; }
.link-btn.alt { background: transparent; color: var(--text); border: 1px solid var(--line); }

.grown { margin-top: 16px; padding: 6px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.grown summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.grown p, .grown li { color: #cfd9e3; font-size: 14.5px; }
.grown pre { white-space: pre-wrap; font: inherit; font-size: 14px; color: #cfd9e3; background: #0b1626; padding: 12px; border-radius: 12px; }
.grown ul { padding-left: 20px; }
footer { margin-top: 26px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- 手機 ---------- */
@media (max-width: 860px) {
  .lab { grid-template-columns: 1fr; gap: 10px; }
  #scene { height: clamp(250px, 44vh, 430px); }
  .stage { top: 6px; z-index: 5; box-shadow: 0 10px 24px #000a; }
  .steps { grid-template-columns: 1fr; }
  .hero { padding: 12px 2px 8px; }
  .wrap { padding: 0 10px 32px; }
  .topbar { height: 56px; padding: 0 10px; }
  .brand img { width: 96px; height: 38px; }
  .tabs button { min-height: 52px; font-size: 16px; gap: 8px; padding: 6px 8px; }
  .tabs button small { display: none; }
  .panel { padding: 12px; }
  .listen { flex-direction: column; align-items: flex-start; }
  .listen img { width: 110px; }
}
@media (max-width: 380px) {
  .meter b { font-size: 19px; }
  .meter.size b { font-size: 34px; }
  .pick button { font-size: 13.5px; min-height: 70px; }
  .dex button { font-size: 10.5px; }
}
@media (max-height: 520px) and (min-width: 600px) {
  .hero .sub, .eyebrow { display: none; }
  .hero { padding: 6px 2px; }
  .hero h1 { font-size: 22px; }
  .lab { grid-template-columns: minmax(0, 1.2fr) minmax(300px, 1fr); }
  #scene { height: 78vh; min-height: 230px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01s !important; transition: none !important; }
}


/* ---------- 星光偵探多出來的部分 ---------- */
@media (min-width: 861px) { #scene { height: clamp(420px, calc(100vh - 300px), 660px); } }
.stage canvas { cursor: crosshair; }
.stage canvas:focus-visible { outline: 3px solid var(--cyan); outline-offset: -3px; }
/* 畫面下方的四副眼鏡 */
.lensbar { position: absolute; left: 8px; right: 8px; bottom: 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lensbar[hidden] { display: none; }
.lensbar button {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 4px 6px;
  border-radius: 14px; border: 2px solid #ffffff26; background: #0b1626d9; backdrop-filter: blur(4px);
  font-size: 15px; font-weight: 800; line-height: 1.15; transition: transform .12s, border-color .12s; touch-action: manipulation;
}
.lensbar button .ico { font-size: 22px; line-height: 1; }
.lensbar button[aria-pressed=true] { border-color: var(--c); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 45%, #0b1626), #0b1626e6); transform: translateY(-3px); box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 60%, #000), 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); }
.lensbar button i { position: absolute; top: 2px; right: 6px; font-style: normal; font-size: 11px; color: #8aa0b6; }
.lensbar button i.no { font-size: 12px; }
.lensbar button:disabled { opacity: .75; cursor: default; }
.lensbar .rel {
  grid-column: 1 / -1; min-height: 60px; font-size: 21px; border: 0; color: #06281a;
  background: linear-gradient(180deg, #9dffbf, #39d47a); box-shadow: 0 5px 0 #1d7a45, 0 0 24px #5be28a88;
}
.lensbar .rel:active { transform: translateY(3px); box-shadow: 0 2px 0 #1d7a45; }
.stage-note { left: auto; right: 12px; bottom: auto; top: 62px; text-align: right; }
.cta.grab { background: linear-gradient(180deg, #9dffbf, #39d47a); color: #06281a; box-shadow: 0 6px 0 #1d7a45, 0 12px 22px #0007; font-size: 21px; }
.cta.grab:active { box-shadow: 0 2px 0 #1d7a45; }
.cta.grab:disabled { opacity: .5; }
.keys { margin: -4px 2px 0; font-size: 12.5px; color: var(--muted); }
.meter b#m-hearts { font-size: 20px; letter-spacing: 2px; }
.cheat { padding: 10px 12px; border-radius: 14px; background: #10263c; border: 1px solid #7fd6e033; animation: slidein .3s ease-out; }
.cheat h3 { margin: 0 0 4px; font-size: 15px; }
.cheat ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.cheat li { font-size: 14px; line-height: 1.45; color: #cfe3f1; padding-left: 10px; border-left: 3px solid var(--c); }
.cheat li b { color: var(--c); }
.result h3 .stars { display: inline-block; margin-left: 8px; color: var(--gold); letter-spacing: 2px; font-size: 22px; }
.result .head .big { font-size: 42px; line-height: 1; flex: none; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.levels button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 70px; padding: 6px 2px;
  border-radius: 14px; border: 2px solid var(--line); background: #0d1828; color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.2;
}
.levels button .big { font-size: 22px; line-height: 1.1; }
.levels button i { font-style: normal; color: var(--gold); font-size: 11.5px; letter-spacing: 1px; min-height: 14px; }
.levels button[aria-pressed=true] { border-color: var(--lava); background: linear-gradient(180deg, #3a2516, #2a2030); }
.levels button:disabled { opacity: .55; cursor: default; }
.levels button[aria-pressed=true]:disabled { opacity: 1; }
.dex .row.recs { grid-template-columns: repeat(5, 1fr); }
.dex .recs button { font-size: 11px; min-height: 92px; line-height: 1.25; }
.dex .recs button b { font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; }
.dex .recs button .big { display: block; font-size: 24px; line-height: 1.15; }
.dex .recs button.locked .big { filter: grayscale(1) brightness(.75); }
.dex .recs button.locked b { color: var(--muted); }
.dex .recs button.on { border-color: var(--cyan); box-shadow: 0 0 0 3px #94dfe144; }
.fact { margin: 8px 0 0; padding: 10px 12px; border-radius: 14px; background: #10263c; border: 1px solid #7fd6e033; font-size: 14px; line-height: 1.55; color: #cfe3f1; animation: slidein .3s ease-out; }
.ghost.wide { min-height: 50px; font-size: 15.5px; font-weight: 700; color: var(--text); border-color: #7fd6e066; background: #14304a; }
.meter.ruler { display: flex; align-items: center; justify-content: space-between; }
.meter.ruler b { font-size: 26px; color: var(--gold); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result.capsule .tall { margin-top: 6px; font-size: 17px; }
.dex .row.six { grid-template-columns: repeat(3, 1fr); }
.dex .row > div .big, .dex button .big { font-size: 26px; line-height: 1.15; }
.dex button small { font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; }
.dex button.locked small { color: var(--muted); }
.dex button.fresh { animation: starpop .6s ease-out; }
.dex button:disabled { cursor: default; opacity: .6; }
.eps { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.eps a { color: var(--text); text-decoration: none; font-size: 14.5px; }
.eps a:hover { color: var(--cyan); }
.eps b { color: var(--gold); margin-right: 4px; }
@media (max-width: 860px) {
  #scene { height: clamp(300px, 52vh, 460px); }
  .lensbar { left: 6px; right: 6px; bottom: 6px; gap: 4px; }
  .lensbar button { flex-direction: column; gap: 0; min-height: 54px; font-size: 12px; padding: 3px 2px; }
  .lensbar button .ico { font-size: 19px; }
  .keys { display: none; }
  .stage-note { display: none; }
}
@media (max-width: 380px) {
  .lensbar button { font-size: 11px; }
  .dex .recs button { font-size: 10px; }
  .levels button { font-size: 12px; }
}

/* ---------- 「實驗遊戲」標籤（所有新版實驗共用） ---------- */
.topbar .gamepill { margin-right: auto; margin-left: 10px; padding: 4px 12px; border-radius: 999px; background: linear-gradient(90deg, #ff8a3d, #ffc46b); color: #2a1406; font-weight: 800; font-size: 14px; white-space: nowrap; box-shadow: 0 3px 10px #0006; }
@media (max-width: 860px) { .topbar .gamepill { font-size: 12.5px; padding: 3px 10px; margin-left: 6px; } }

/* iPhone SE（320 寬）：單欄不能被裡面的東西撐寬，不然整頁會被瀏覽器縮小 */
@media (max-width: 860px) { .lab { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .dex .row { grid-template-columns: repeat(5, minmax(0, 1fr)); } .dex .row.recs { grid-template-columns: repeat(4, minmax(0, 1fr)); } .dex .row > * { min-width: 0; overflow-wrap: anywhere; } }
