/* 啟思創客 程式體驗課:明亮兒童風、白底;程式碼區與終端機才用深色 */
:root {
  --forest: #16a34a;
  --forest-600: #15803d;
  --forest-100: #dcfce7;
  --forest-50: #f0fdf4;
  --sky: #4a97dd;
  --sky-600: #3579bd;
  --sky-100: #e3f0fa;
  --honey: #f7c948;
  --honey-500: #edb417;
  --honey-100: #fdf3d1;
  --berry: #f43f5e;
  --berry-100: #ffe4e6;
  --navy: #2d4a78;
  --ink: #2e4059;
  --muted: #6b7a90;
  --line: #e3e8ef;
  --bg: #ffffff;
  --bg-soft: #f7faf6;
  --code-bg: #212121;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(46, 64, 89, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
}
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.b { font-weight: 800; }
.big { font-size: 20px; font-weight: 900; margin: 0 0 4px; }
.center { text-align: center; }
.gap { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.berry { color: var(--berry); }
.eyebrow { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: 0.08em; color: var(--forest-600); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 10px 20px;
  font-weight: 900; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-lg { padding: 13px 28px; font-size: 19px; }
.btn-block { width: 100%; }
.btn-go { background: var(--forest); color: #fff; box-shadow: 0 4px 0 var(--forest-600); }
.btn-go:hover:not(:disabled) { background: var(--forest-600); }
.btn-stop, .btn-berry { background: var(--berry); color: #fff; }
.btn-sky { background: var(--sky); color: #fff; box-shadow: 0 4px 0 var(--sky-600); }
.btn-honey { background: var(--honey-500); color: #3b2f05; }
.btn-honey:hover { background: var(--honey); }
.btn-ghost { background: #fff; border: 2px solid var(--line); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { border-color: #c5ceda; }
.btn-dark { background: transparent; border: 2px solid #555; color: #ddd; }
.btn-dashed { background: #fff; border: 2px dashed #9fd9b3; color: var(--forest-600); }
.btn-outline-go { background: #fff; border: 2px solid #86d3a1; color: var(--forest-600); }
.btn-outline-berry { background: #fff; border: 2px solid #fecdd3; color: var(--berry); }
.icon-btn { border: 0; background: none; color: #9aa6b6; cursor: pointer; font-size: 16px; }
.icon-btn:hover { color: var(--berry); }

/* ---------- 開機 / 登入 ---------- */
.boot { min-height: 70vh; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); font-weight: 800; }
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 18%, var(--honey-100) 0 90px, transparent 91px),
    radial-gradient(circle at 88% 82%, var(--forest-100) 0 130px, transparent 131px),
    radial-gradient(circle at 90% 12%, var(--sky-100) 0 70px, transparent 71px),
    #fff;
}
.login-card {
  width: min(440px, 100%); background: #fff; border: 3px solid var(--forest-100);
  border-radius: 28px; padding: 28px 26px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.login-mascot { width: 130px; height: 130px; object-fit: contain; align-self: center; margin-top: -8px; }
.login-card h1 { margin: 0 0 4px; font-size: 32px; color: var(--navy); }
.login-card .lead { margin: 0 0 14px; color: var(--muted); font-weight: 700; }
.login-card label { font-weight: 900; margin-top: 10px; }
.login-card input { margin-top: 4px; }
.login-card .btn { margin-top: 14px; }
.hint { font-size: 14px; color: var(--muted); background: var(--sky-100); border-radius: 12px; padding: 8px 12px; margin: 12px 0 0; }
input, textarea {
  width: 100%; border: 2px solid #cfe3d4; border-radius: 14px; padding: 10px 14px; background: #fff; outline: none;
}
input:focus, textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-100); }
textarea { resize: vertical; }
/* 語音輸入按鈕(同正式站 MicButton:平常是麥克風,聽的時候變紅點並閃動) */
.mic-btn {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 2px solid var(--line); border-radius: 50%; background: #fff; font-size: 18px; line-height: 1; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
/* hover 只給有滑鼠的裝置:觸控螢幕點完,綠色會黏在按鈕上,看起來像還開著 */
@media (hover: hover) { .mic-btn:hover { border-color: var(--forest); background: var(--forest-50); } }
.mic-btn:focus-visible { outline: 3px solid var(--forest-600); outline-offset: 2px; }
.mic-btn.mic-sm { width: 36px; height: 36px; font-size: 16px; }
/* 觸控螢幕:按鈕放大到孩子的手指按得準(旁邊就是刪除卡片的鈕) */
@media (pointer: coarse) { .mic-btn, .mic-btn.mic-sm { width: 44px; height: 44px; font-size: 19px; } }
.mic-btn.listening { border-color: var(--berry); background: var(--berry-100); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .mic-btn.listening { animation: none; } }
/* 大輸入框:麥克風浮在右下角,文字留出位置不被蓋住(避開右下角拉大小的把手) */
.mic-wrap { position: relative; }
.mic-wrap textarea { display: block; }
.mic-wrap.has-mic textarea { padding-right: 62px; }
.mic-wrap .mic-btn { position: absolute; right: 16px; bottom: 16px; }
/* 麥克風打不開時的說明,浮在按鈕旁邊 */
.mic-tip {
  position: fixed; z-index: 3000; max-width: min(300px, calc(100vw - 16px)); padding: 8px 12px; border-radius: 12px;
  background: var(--honey-100); border: 2px solid var(--honey); color: #3b2f05; font-size: 14px; font-weight: 800; line-height: 1.5;
  box-shadow: 0 8px 20px rgba(60, 50, 10, .18);
  pointer-events: none; /* 只是說明,不擋住底下的輸入框和按鈕 */
}
.form-err { color: var(--berry); font-weight: 800; margin: 8px 0 0; min-height: 0; }
.form-err:empty { display: none; }

/* ---------- 頂部(同正式站:64px 高、底下 4px 淺藍線、字標 h-9) ---------- */
@font-face {
  /* 正式站的 logo 字型子集,經 Worker 代理 /fonts/ 取得 */
  font-family: "OpenHuninnLogo";
  src: url("/fonts/openhuninn-logo.woff2?v=3") format("woff2");
  font-display: swap;
}
:root { --chrome: 252px; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px 14px; min-height: 64px; padding: 6px 16px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(6px);
  border-bottom: 4px solid #bcd3ec;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex: none; transition: transform .15s; }
.brand:hover { transform: scale(1.04); }
.brand-mark, .wordmark { height: 36px; width: auto; display: block; }
.brand-sub { font-size: 14px; font-weight: 900; color: var(--navy); background: var(--honey-100); border: 2px solid #f5dc8c; border-radius: 999px; padding: 1px 10px; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { background: var(--forest-50); border: 2px solid var(--forest-100); border-radius: 999px; padding: 3px 12px; font-weight: 800; font-size: 14px; }
.chip-sky { background: var(--sky-100); border-color: #cfe4f6; color: var(--sky-600); }

/* ---------- 進度列(寬螢幕放在頁首中間;窄螢幕換到頁首第二行) ---------- */
.progress { order: 3; flex: 1 0 100%; }
.progress ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.step button {
  width: 100%; display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; text-align: left;
}
.step-dot { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--sky-100); font-size: 15px; }
.step-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.step-text b { font-size: 14px; white-space: nowrap; }
.step-text small { color: var(--muted); font-weight: 700; font-size: 12px; white-space: nowrap; }
.step.done .step-dot { background: var(--forest); color: #fff; font-weight: 900; }
.step.done button { border-color: #9fd9b3; }
.step.current button { border-color: var(--honey-500); background: var(--honey-100); box-shadow: 0 2px 0 var(--honey-500); }
.step.locked button { opacity: .5; cursor: not-allowed; background: #f6f7f9; }
.bar { height: 4px; border-radius: 999px; background: #eef2f6; margin-top: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--forest), #4ade80); border-radius: 999px; transition: width .5s; }
/* 六關排成一行需要比五關時期(1200px)更寬的螢幕;不夠寬就維持進度列在第二行 */
@media (min-width: 1400px) {
  :root { --chrome: 196px; }
  .topbar { flex-wrap: nowrap; }
  .who { flex-wrap: nowrap; flex: none; } /* 右邊的次數、暱稱、換人玩不可以被擠成兩行(頁首會變高,蓋到下面) */
  .progress { order: 0; flex: 1 1 auto; min-width: 0; max-width: 1000px; }
}
/* 1400–1699px:六關放得下,但要省一點(不顯示第二行小字) */
@media (min-width: 1400px) and (max-width: 1699px) {
  .step button { padding: 3px 6px; gap: 4px; }
  .step-text b { font-size: 13px; }
  .step-text small { display: none; }
}

/* ---------- 關卡(滿版寬;第 4、5 關內容置中) ---------- */
.stage { padding: 12px 16px 16px; }
.stage-4, .stage-5, .stage-6 { padding-bottom: 60px; }
.narrow { max-width: 1100px; margin: 0 auto; }
.card { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin: 14px 0; }
.intro {
  display: flex; align-items: center; gap: 12px; padding: 5px 14px 5px 6px; border-radius: 16px; margin-bottom: 10px; min-height: 52px;
  background: linear-gradient(100deg, var(--forest-50), var(--sky-100)); border: 2px solid var(--forest-100);
}
.intro h2 { margin: 0; font-size: 20px; color: var(--navy); white-space: nowrap; }
.intro h2 .eyebrow { display: inline; margin-right: 8px; font-size: 13px; }
.intro p { margin: 0; font-weight: 700; color: #4b5b73; font-size: 15px; line-height: 1.4; }
.intro-img { width: 58px; height: 40px; object-fit: cover; border-radius: 10px; flex: none; background: #fff; }

.tabs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 12px 12px 0 0; font-weight: 900; font-size: 15px; color: #8a96a8; cursor: pointer; border-bottom: 4px solid transparent; }
.tab.active { color: var(--navy); border-bottom-color: var(--forest); background: #fff; }
.tabs .btn { margin-left: auto; }

/* 學習 / 練習(同正式站 LessonTabs:圓角分頁 + 一整塊有框面板) */
.lesson-tabs { display: flex; gap: 6px; }
.lesson-tabs .tab {
  position: relative; z-index: 1; margin-bottom: -2px; padding: 9px 32px; font-size: 18px; border-radius: 16px 16px 0 0;
  background: #f4f4f5; color: #a1a1aa; border: 2px solid transparent; border-bottom: 0;
}
.lesson-tabs .tab.active { background: #fff; color: #2d4a78; border-color: #bcd3ec; }
.work-panel {
  display: flex; flex-direction: column; height: calc(100dvh - var(--chrome)); min-height: 500px;
  background: #fff; border: 2px solid #bcd3ec; border-radius: 0 24px 24px 24px; overflow: hidden;
}
.work-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lesson-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 24px 32px; }
.lesson-inner { max-width: 900px; margin: 0 auto; }
.pane-scroll { overflow-y: auto; }
.pane-scroll > * { flex-shrink: 0; }

/* 課文 */
.lesson summary { cursor: pointer; font-weight: 900; color: var(--navy); }
.lesson-title { margin-top: 0; color: var(--navy); font-size: 24px; }
.md { max-width: 820px; }
.md h3 { color: var(--navy); font-size: 22px; margin: 26px 0 8px; }
.md h4 { font-size: 19px; margin: 18px 0 6px; }
.md p, .md li { font-size: 17px; }
.md strong { color: var(--forest-600); }
.md code { background: var(--honey-100); border-radius: 6px; padding: 1px 6px; font-family: Consolas, "Cascadia Mono", monospace; font-size: .92em; color: #7a4d00; }
.md-code { background: var(--code-bg); color: #c3e88d; border-radius: 14px; padding: 12px 16px; overflow-x: auto; font-size: 15px; }
.md-code code { background: none; color: inherit; padding: 0; }
.comic, .md-figure { margin: 10px 0 18px; }
.comic img { width: 100%; border-radius: 16px; border: 3px solid var(--honey-100); }
.md-figure img { max-height: 420px; border-radius: 14px; border: 2px solid var(--line); }

/* 挑戰橫幅 */
.challenge {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between;
  background: var(--honey-100); border: 2px solid #f5dc8c; border-radius: 14px; padding: 10px 16px; font-weight: 900; margin: 12px 0;
}
.challenge.ok { background: var(--forest-50); border-color: #9fd9b3; color: var(--forest-600); }

/* 工作區(同正式站 GameRunner:上方挑戰任務列,下面左右分割、中間細分隔線) */
.ide { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ide > .challenge { margin: 0; border: 0; border-radius: 0; border-bottom: 2px solid rgba(247, 201, 72, 0.4); padding: 7px 16px; font-size: 15px; }
.ide > .challenge.ok { border-bottom-color: #9fd9b3; }
.ide > .challenge .btn { padding: 5px 16px; font-size: 14px; }
.ide-fixed { flex: none; height: 400px; border: 2px solid #bcd3ec; border-radius: 18px; overflow: hidden; }
.split { flex: 1; min-height: 0; display: flex; }
.split-left { flex: 0 0 var(--split, 50%); min-width: 0; display: flex; flex-direction: column; }
.split-right { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.split-left > .tab-pane, .split-right > .tab-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.split-handle { flex: none; width: 10px; display: flex; align-items: center; justify-content: center; background: #f4f4f5; cursor: col-resize; transition: background .15s; }
.split-handle:hover { background: #bcd3ec; }
.split-handle span { width: 4px; height: 40px; border-radius: 999px; background: #d4d4d8; }
.pane-bar { margin: 0; padding: 5px 10px 0; flex: none; }
.pane-bar-code { background: #f2f6fb; border-bottom: 2px solid #dde9f6; }
.pane-bar-code .tab.active { box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.06); border-bottom-color: transparent; }
.pane-bar-code .btn { margin: 0 0 5px auto; }
.pane-bar-view { background: #f4f4f5; border-bottom: 2px solid #e4e4e7; }
.pane-bar-view .tab { font-size: 16px; padding: 8px 20px; }
.pane-bar-view .tab.active { border-bottom-color: #3a5d94; }
.editor { position: relative; flex: 1; min-height: 0; background: #212121; }
.editor .CodeMirror { position: absolute; top: 0; left: 0; right: 0; bottom: 0; height: 100%; font-size: 17px; line-height: 1.65; font-family: Consolas, "Cascadia Mono", monospace; }
.code-fallback { position: absolute; inset: 0; height: 100%; font-family: Consolas, monospace; background: var(--code-bg); color: #eee; border-radius: 0; border: 0; }
.runbar { flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px 10px; background: #27272a; }
/* 這一列的按鈕是一組(執行、停止、靜音):同樣的高度、字級和底下那道厚度。
   原本只有「執行」有厚度,看起來比旁邊的「停止」高一截;行高也收掉(內文的 1.7 會把按鈕撐得太高) */
.runbar .btn { padding: 8px 18px; font-size: 16px; line-height: 1.25; }
.runbar .btn-go { box-shadow: 0 3px 0 var(--forest-600); }
.runbar .btn-stop { box-shadow: 0 3px 0 #be123c; }
.runbar .btn-ghost { padding: 6px 16px; background: transparent; border-color: #52525b; color: #d4d4d8; }
.run-status { color: #d4d4d8; font-size: 13px; font-weight: 700; }
/* 靜音鈕:按下去(靜音中)要一眼看得出來 */
.btn-mute[aria-pressed="true"] { background: var(--honey-100); border-color: var(--honey-500); color: #3b2f05; }
.btn-mute svg { flex: none; }
.runbar .btn-mute { padding: 8px 18px; border: 0; background: #52525b; color: #fff; box-shadow: 0 3px 0 #3f3f46; }
.runbar .btn-mute:hover { background: #5f5f68; }
.cert-todo { margin: 12px 0 0; }
.cert-peek { margin-top: 8px; }
.cert-preview { display: inline-block; margin: 0 0 14px; padding: 4px 16px; border: 2px dashed var(--honey-500); border-radius: 999px; background: var(--honey-100); color: #3b2f05; font-size: 15px; font-weight: 900; }
.runbar .btn-mute[aria-pressed="true"] { background: var(--honey); color: #3b2f05; box-shadow: 0 3px 0 #c9960c; }
.stage-box { position: relative; flex: 1; min-height: 0; background: #27272a; }
.stage-canvas { position: absolute; top: 8px; left: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; outline: none; }
.game-canvas { display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; border-radius: 12px; background: #e0f2fe; outline: none; }
.game-canvas:focus { box-shadow: 0 0 0 3px var(--honey); }
.console {
  background: #111827; color: #e5e7eb; font-family: Consolas, "Cascadia Mono", monospace; font-size: 15px; line-height: 1.6;
  padding: 10px 14px; min-height: 160px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.split-right .console { flex: 1; min-height: 0; max-height: none; background: #09090b; }
.console .err { color: #fda4af; font-weight: 700; }
.console .warn { color: #fcd34d; }
.console .ok { color: #86efac; font-weight: 700; }
.console .muted { color: #6b7280; }
.assets { flex: 1; min-height: 0; padding: 10px 14px; overflow: auto; }
.assets ul { list-style: none; margin: 0; padding: 0; }
.assets li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f2f5; }
.assets img, .assets .sound { width: 46px; height: 46px; object-fit: contain; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--line); cursor: pointer; }
.assets code { flex: 1; font-weight: 800; }
.tag { border-radius: 999px; padding: 1px 10px; font-size: 13px; font-weight: 900; }
.tag-sky { background: var(--sky-100); color: var(--sky-600); }
.tag-green { background: var(--forest-100); color: var(--forest-600); }

/* 觸控方向鍵 */
.dpad { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 10px; background: var(--sky-100); user-select: none; -webkit-user-select: none; }
.dpad-row { display: flex; gap: 8px; }
.dpad-btn { width: 56px; height: 52px; border: 0; border-radius: 14px; background: var(--navy); color: #fff; font-size: 20px; font-weight: 900; touch-action: none; }
.dpad-btn.wide { width: auto; padding: 0 22px; font-size: 17px; }
.dpad-btn:active { background: var(--forest); }

/* 指揮官 */
.forge-left { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.mission { background: var(--honey-100); border-radius: 14px; padding: 10px 14px; font-weight: 800; }
.label { margin: 8px 0 0; font-weight: 900; color: #4b5b73; }
.cards { display: flex; flex-direction: column; gap: 6px; }
.card-row { display: flex; align-items: center; gap: 6px; }
.card-no { flex: none; font-size: 13px; font-weight: 900; color: var(--forest-600); background: var(--forest-50); border-radius: 8px; padding: 2px 8px; }
/* 迴聲雷達:奇奇動工前複述的三句話,每句都按「對」才動工 */
.echo { border: 2px solid var(--honey); background: #fffbeb; border-radius: 16px; padding: 12px 14px; }
.echo[hidden] { display: none; }
.echo > p { margin: 0; color: #4b5b73; }
.echo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.echo-say { flex: 1 1 220px; min-width: 0; margin: 0; padding: 9px 14px; border-radius: 12px; background: #fff; font-weight: 800; color: #4b5b73; line-height: 1.5; }
.echo-say.ok { color: var(--forest-600); }
.echo-row .btn { flex: none; }
/* 手機:一句話佔一整行,「對」「不對」並排在它下面(不然「不對」會自己掉到下一行) */
@media (max-width: 520px) { .echo-say { flex-basis: 100%; } }
.forge-right { padding: 14px 16px; background: #fafafa; }
.ai-panel { background: #1f2937; border-radius: var(--radius); overflow: hidden; border: 2px solid #374151; }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; color: #e5e7eb; font-weight: 900; font-size: 14px; }
.ai-actions { display: flex; gap: 8px; }
.ai-badge { margin-left: 8px; background: #374151; border-radius: 999px; padding: 1px 9px; font-size: 13px; color: #fde68a; }
.ai-badge.demo { color: #fda4af; }
.ai-code { margin: 0; padding: 10px 16px 14px; color: #86efac; font-family: Consolas, "Cascadia Mono", monospace; font-size: 15px; line-height: 1.6; max-height: 26rem; overflow: auto; white-space: pre; border-bottom: 1px solid #374151; }
.small-code { max-height: 16rem; background: var(--code-bg); border-radius: 12px; }
.forge-right .console { border-radius: 0; min-height: 140px; }
.station { margin-top: 12px; }
.station.stamped { background: var(--forest-50); border-color: #9fd9b3; }
.station-title { font-weight: 900; color: #4b5b73; margin: 4px 0; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-weight: 800; flex-wrap: wrap; }
.version-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--sky-100); color: var(--sky-600); border-radius: 12px; padding: 6px 12px; font-size: 14px; font-weight: 800; }
.pill { background: #fff; border-radius: 999px; padding: 1px 10px; font-weight: 900; }
.pill-dark { background: #374151; color: var(--honey); font-size: 13px; }
.revise { border: 2px dashed var(--honey); background: #fffbeb; border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.revise p { margin: 0 0 4px; }
/* 右半欄可能很窄(平板直向、分隔線被拖過去):輸入框不到 200px 寬時,按鈕自己換到下一行 */
.revise-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.revise-row textarea { flex: 1 1 200px; width: auto; min-width: 0; }
.revise-actions { flex: none; display: flex; gap: 8px; align-items: center; margin-left: auto; }
.stamp-done { text-align: center; }
.stamp-img { width: 150px; height: 150px; object-fit: contain; animation: stamp .5s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes stamp { from { transform: scale(2.2) rotate(-18deg); opacity: 0; } to { transform: scale(1) rotate(-6deg); opacity: 1; } }

/* 偵探 */
.detective { padding: 16px 20px 28px; }
.step-card { margin-bottom: 22px; }
.step-card h3 { margin: 0 0 10px; color: var(--navy); }
.suspect-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--code-bg); }
.suspect-wrap .suspect { border-radius: 0; min-height: 100%; }
.fix-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.fix-grid .console { border-radius: 14px; max-height: none; }
.fix-ed { border-radius: 14px; overflow: hidden; border: 2px solid var(--line); }
.suspect { margin: 0; background: var(--code-bg); color: #c3e88d; border-radius: 14px; padding: 10px 12px; font-family: Consolas, monospace; font-size: 15px; overflow-x: auto; }
.ln { display: inline-block; width: 1.8em; text-align: right; margin-right: 12px; color: #6b7280; user-select: none; }
.locked-note { background: #f6f7f9; border: 2px dashed var(--line); border-radius: 14px; padding: 14px; color: var(--muted); font-weight: 800; margin: 0; }
.hunt { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; }
.scene { background: #1f2937; border: 3px solid #374151; border-radius: 22px; padding: 14px; color: #e5e7eb; }
.scene-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 900; color: #9ca3af; margin-bottom: 6px; }
.code-line { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: #86efac; font-family: Consolas, monospace; font-size: 15px; padding: 5px 10px; border-radius: 10px; cursor: pointer; white-space: pre; overflow-x: auto; }
.code-line:hover { background: #374151; }
.code-line.caught { background: var(--forest); color: #fff; }
.code-line.miss { background: var(--berry); color: #fff; }
.miss-note { color: #fecdd3; font-weight: 900; font-size: 14px; }
.why { background: rgba(22, 163, 74, 0.2); border-radius: 14px; padding: 10px 12px; margin-top: 8px; }
.why p { margin: 4px 0 0; font-size: 15px; color: #e5e7eb; }
.why b { color: #bbf7d0; }
.still { background: #111827; color: var(--honey); border-radius: 10px; padding: 6px 10px; font-weight: 900; font-size: 14px; }
.witness { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.witness p { margin: 0; }
.tip { background: var(--honey-100); border-radius: 12px; padding: 6px 10px; font-size: 14px; font-weight: 800; }
.ask { width: 100%; text-align: left; border: 2px solid #86d3a1; background: #fff; color: var(--forest-600); border-radius: 12px; padding: 7px 12px; font-weight: 800; font-size: 15px; cursor: pointer; }
.ask:hover:not(:disabled) { background: var(--forest-50); }
.ask.asked { border-color: var(--line); color: var(--muted); background: var(--bg-soft); cursor: default; }
.answer { margin: 4px 0 0 12px !important; background: #f1f5f9; border-radius: 10px; padding: 6px 10px; font-weight: 900; font-size: 15px; }
.success { display: flex; gap: 14px; align-items: center; background: var(--forest-50); border: 2px solid #9fd9b3; border-radius: 16px; padding: 12px 16px; margin-top: 12px; }
.success p { margin: 0 0 6px; }

/* 作品分享 */
.share { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--forest-50); border-color: #9fd9b3; }
.share-text { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.share-text p { margin: 0; }
.url-row { display: flex; gap: 8px; width: 100%; }
.url { font-family: Consolas, monospace; font-size: 15px; }
.qr { background: #fff; padding: 12px; border-radius: 16px; border: 2px solid var(--line); }
.qr img, .qr canvas { display: block; }
/* 第 5 關:貼上第 4 關的程式 + 放執行畫面 */
.maker .card h3 { margin: 0 0 6px; }
.paste-card input, .paste-card textarea { margin-top: 10px; }
.paste-code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 15px; line-height: 1.6; white-space: pre; overflow: auto; }
.paste-hint { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--sky-100); color: #1d4f7a; font-weight: 800; line-height: 1.6; }
.paste-hint[hidden] { display: none; }
.paste-hint.warn { background: var(--honey-100); color: #6b4e00; }
.paste-card .center { margin-top: 12px; }
.maker-next { margin: 6px 0 14px; }
/* 存檔後捲到結果、貼圖後捲到預覽:上面有黏住的頁首(窄一點的視窗會變兩行),留出它的高度 */
.paste-out, .paste-out .shot-zone { scroll-margin-top: 130px; }
.paste-note { margin: 8px 0 0; font-weight: 800; color: var(--forest-600); text-align: center; }
.paste-note:empty { display: none; }
.web-foot { margin: 0 0 14px; padding: 10px 4px 0; border-top: 0; }
.maker-next:empty { display: none; }
.shot-panel p { margin: 0 0 6px; line-height: 1.7; }
.shot-warn { color: #9a3412; font-weight: 800; }
.shot-zone { margin-top: 8px; border: 3px dashed #c5ceda; border-radius: 16px; background: #fafcff; min-height: 150px; display: grid; place-items: center; text-align: center; padding: 12px; color: var(--muted); cursor: pointer; }
.shot-zone:focus-visible, .shot-zone:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-100); }
.shot-zone.has { border-style: solid; border-color: #9fd9b3; background: #fff; cursor: default; }
.shot-zone img { display: block; max-width: 100%; max-height: 420px; border-radius: 10px; }
.shot-zone p { margin: 0; }
.shot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.shot-msg { margin: 8px 0 0; font-weight: 800; color: var(--forest-600); }
.shot-msg:empty { display: none; }
.shot-msg.err { color: var(--berry); }
.shot-foot { margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--line); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.shot-steps { margin: 0 0 6px; padding-left: 1.4em; line-height: 1.9; }
.shot-panel kbd { display: inline-block; padding: 0 7px; border: 2px solid var(--line); border-bottom-width: 3px; border-radius: 7px; background: #fff; font: 800 13px Consolas, monospace; color: var(--navy); }
.shot-zone.confirm { border-color: var(--honey); background: #fffbeb; cursor: default; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.shot-zone.confirm img { max-height: 320px; border: 2px solid #fff; box-shadow: 0 4px 14px rgba(60, 50, 10, .18); }
.shot-actions.center { justify-content: center; margin-top: 2px; }

/* 隱藏關卡 */
.mystery {
  margin: 30px auto; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 4px dashed var(--honey-500);
  background: var(--honey-100); border-radius: 28px; padding: 26px 40px; cursor: pointer; font-size: 20px;
}
.mystery .gift { font-size: 72px; animation: wiggle 1.4s ease-in-out infinite; }
.mystery small { color: var(--muted); font-weight: 800; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.bonus-title { font-size: 30px; color: var(--navy); margin: 0; }
.bonus-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bonus-top .eyebrow { margin: 0; }
.home { display: flex; gap: 16px; align-items: center; background: var(--sky-100); border-radius: 16px; padding: 12px 16px; margin: 10px 0; }
.home ol { margin: 4px 0 0; padding-left: 22px; }
.home-img { width: 170px; flex: none; border-radius: 12px; }
.prompt-box { border: 2px solid rgba(247, 201, 72, 0.6); border-radius: 18px; overflow: hidden; margin-top: 12px; }
.prompt-top { background: rgba(253, 243, 209, 0.6); padding: 12px 16px; }
.prompt-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.prompt-task { white-space: pre-wrap; font-size: 16px; line-height: 2.3; margin: 8px 0 0; }
.slot {
  display: inline-block; width: auto; margin: 0 2px; padding: 0 4px; border: 0; border-bottom: 2px dashed var(--honey-500);
  border-radius: 6px; background: rgba(247, 201, 72, 0.45); text-align: center; font-weight: 900; color: var(--navy); line-height: 1.6;
}
.slot:focus { background: #fff; box-shadow: 0 0 0 2px var(--honey); border-bottom-style: solid; }
.prompt-rules { background: #fafafa; border-top: 2px dashed rgba(247, 201, 72, 0.5); padding: 10px 16px; }
.prompt-rules p { margin: 2px 0; }
.rule { font-size: 14px; color: var(--muted); }
.copy-fail { background: var(--berry-100); border-radius: 10px; padding: 6px 10px; font-size: 14px; font-weight: 800; margin: 8px 0 0; }

/* 證書 */
.cert { max-width: 860px; margin: 16px auto; padding: 14px; border-radius: 28px; background: linear-gradient(135deg, var(--honey), var(--forest) 50%, var(--sky)); }
.cert-inner { background: #fffdf5; border-radius: 20px; padding: 28px 32px; text-align: center; }
.cert-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.cert-head h2 { margin: 0; font-size: 30px; color: var(--navy); }
.cert-to { margin: 18px 0 0; color: var(--muted); font-weight: 800; }
.cert-name { margin: 0; font-size: 44px; font-weight: 900; color: var(--forest-600); border-bottom: 3px dashed var(--honey-500); display: inline-block; padding: 0 24px; }
.cert-text { max-width: 620px; margin: 14px auto; font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 18px 0; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 2px solid var(--forest-100); border-radius: 18px; padding: 10px 4px; }
.badge-icon { font-size: 40px; line-height: 64px; height: 64px; width: 64px; border-radius: 50%; background: var(--honey-100); }
.badge img { width: 64px; height: 64px; object-fit: contain; }
.badge b { font-size: 15px; }
.badge small { color: var(--muted); font-size: 12px; }
.cert-foot { display: flex; justify-content: space-between; align-items: flex-end; font-weight: 800; color: var(--muted); }
.cert-mascot { width: 90px; }

/* ---------- 平板與手機 ---------- */
@media (max-width: 1000px) {
  .hunt { grid-template-columns: minmax(0, 1fr); }
  .step-text small { display: none; }
}
/* 手機:上下排(同正式站 GameRunner:程式區 64dvh、遊戲畫面 48dvh) */
@media (max-width: 767px) {
  body { font-size: 16px; }
  .work-panel { height: auto; min-height: 0; }
  .split { flex-direction: column; }
  .split-handle { display: none; }
  .split-left { flex: none; border-bottom: 2px solid #e4e4e7; }
  /* 直向排列時右欄也要用內容高度。少了這行,桌機的 flex: 1 1 0 會讓右欄塌成 0,
     指揮官關的程式碼、終端機、驗收站在手機上就整個看不到(.ide 版本另外指定高度,不受影響) */
  .split-right { flex: none; }
  .ide .split-left { height: 64dvh; }
  .ide .split-right { height: 48dvh; flex: none; }
  .ide-fixed { height: auto; }
  .ide-fixed .split-left { height: 300px; }
  .ide-fixed .split-right { height: 220px; }
  .brand-sub { display: none; }
  .brand-mark, .wordmark { height: 30px; }
  .lesson-tabs .tab { padding: 7px 18px; font-size: 16px; }
  .lesson-scroll { padding: 12px 14px 24px; }
}
@media (max-width: 760px) {
  .progress ol { gap: 4px; }
  .step button { flex-direction: column; padding: 4px 2px; text-align: center; gap: 2px; }
  .step-text b { font-size: 12px; }
  .step-dot { width: 26px; height: 26px; font-size: 14px; }
  .intro { flex-wrap: wrap; }
  .intro h2 { font-size: 18px; }
  .badges { grid-template-columns: repeat(3, 1fr); }
  .cert-inner { padding: 18px 12px; }
  .cert-name { font-size: 32px; }
  .home { flex-direction: column; }
  .revise-row, .url-row { flex-direction: column; align-items: stretch; }
  .revise-actions .btn { flex: 1; }
}

@media print {
  .topbar, .progress, .intro, .no-print, .stage > div > section, .stage .card:not(.cert) { display: none !important; }
  .cert { margin: 0 auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 指揮官的遊戲舞台(深色工地面板裡的分頁) */
.tabs-dark { margin: 0; padding: 6px 8px 0; background: #111827; border-top: 1px solid #374151; }
.tabs-dark .tab { color: #9ca3af; }
.tabs-dark .tab.active { color: #fff; background: #1f2937; border-bottom-color: var(--forest); }
.forge-stage { background: #27272a; padding: 8px; display: grid; place-items: center; }
.forge-stage .game-canvas { max-width: 560px; }
.forge-result .console { border-radius: 0; }

/* 第 5 關:前往 Gemini(另開視窗) */
.gemini-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
/* 第 4 關 Gemini 實戰:驗收清單(同正式站 Checklist —— 一項一項親手勾,全部勾完才能領徽章) */
.workshop .gemini-go { margin: 16px 0 6px; }
.checklist { margin: 12px 0; border: 2px solid var(--line); border-radius: 22px; background: #fff; padding: 16px 18px; transition: border-color .2s, background-color .2s; }
.checklist.all { border-color: #9fd9b3; background: var(--forest-50); }
.check-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.check-head p { margin: 0; color: #4b5b73; }
.check-count { margin-left: auto; background: #eef1f5; color: var(--muted); font-size: 13px; padding: 3px 12px; }
.checklist.all .check-count { background: var(--forest); color: #fff; }
.check-item { display: flex; align-items: flex-start; gap: 12px; padding: 8px 10px; border-radius: 14px; cursor: pointer; font-weight: 800; line-height: 1.6; }
@media (hover: hover) { .check-item:hover { background: #f6f8fa; } }
.check-item input { flex: none; width: 22px; height: 22px; margin: 3px 0 0; padding: 0; border-radius: 6px; accent-color: var(--forest); cursor: pointer; box-shadow: none; }
.check-item.ticked span { color: #9aa6b6; text-decoration: line-through; }
.check-status { margin: 10px 0 0; padding: 9px 14px; border-radius: 14px; background: #eef1f5; color: var(--muted); font-weight: 900; }
.checklist.all .check-status { background: var(--forest-100); color: var(--forest-600); }
.workshop-finish { margin: 18px 0; }
.btn-gemini { background: var(--navy); color: #fff; text-decoration: none; box-shadow: 0 4px 0 #1d3766; }
.btn-gemini:hover { background: #24406b; }
.gemini-hint { color: var(--muted); font-size: 15px; }

/* 第 5 關提示詞:我要自己寫 */
.prompt-free { width: 100%; margin-top: 10px; padding: 10px 12px; border: 2px solid var(--honey-500); border-radius: 12px; background: #fff; font: inherit; font-size: 16px; line-height: 1.9; color: var(--ink); resize: vertical; }
.prompt-free:focus { outline: none; box-shadow: 0 0 0 3px var(--honey-100); }
.prompt-tip { margin: 6px 0 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.btn-mode { border: 2px solid var(--sky); color: var(--sky-600); background: #fff; }
.btn-mode:hover { background: var(--sky-100); }

/* 關卡標題列右側:重玩這一關 */
.intro .replay { margin-left: auto; flex: none; white-space: nowrap; border: 2px solid var(--forest-100); background: #fff; color: var(--navy); }
.intro .replay:hover { background: var(--honey-100); border-color: var(--honey-500); }

/* 啟思探長助教:可拖動的放大鏡浮動鈕 + 對話面板(外觀同正式站 PickTutor) */
.tutor { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 56px; height: 56px; }
.tutor-fab {
  width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; cursor: grab;
  display: grid; place-items: center; position: relative;
  background: var(--forest); color: #fff; font-size: 27px; line-height: 1;
  box-shadow: 0 6px 18px rgba(30, 60, 40, .3);
  touch-action: none; /* 手機要能拖,不要被捲動搶走 */
  transition: transform .15s;
}
.tutor-fab:hover { transform: scale(1.08); }
.tutor-fab:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.tutor.dragging .tutor-fab { cursor: grabbing; transform: scale(1.06); transition: none; }
.tutor-icon { display: grid; place-items: center; pointer-events: none; }
.tutor-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; padding: 1px 5px;
  border-radius: 999px; border: 2px solid #fff; background: var(--honey-500); color: #3b2f0b;
  font-size: 12px; font-weight: 900; font-variant-numeric: tabular-nums;
}
/* 面板在按鈕旁邊展開。位置由 JS 算(positionPanel)並夾在視窗內:
   按鈕拖到下半部時若讓面板往下開,會有一半在螢幕外,而它是固定定位的,捲頁面也看不到 */
.tutor-panel {
  position: fixed; left: 0; top: 0;
  /* 寬度跟著視窗走:大螢幕寬一點(長的回答少折幾行),最窄 360;手機幾乎滿版。高度由 app.js 的 positionPanel 依按鈕上下的空間決定 */
  width: min(clamp(360px, 36vw, 540px), calc(100vw - 24px)); max-height: min(560px, 70vh);
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 18px; background: #fff; border: 2px solid var(--forest-100);
  box-shadow: 0 16px 40px rgba(30, 60, 40, .24);
  /* 保底:視窗矮到連最少的內容都放不下(例如手機橫放)時,整個面板可以捲,輸入列才碰得到 */
  overflow-y: auto; overscroll-behavior: contain;
}
.tutor-head { display: flex; align-items: center; gap: 8px; }
.tutor-head .grow { flex: 1; min-width: 0; }
.tutor-log { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; min-height: 120px; }
/* 對話泡泡不能被壓扁:面板不夠高時是整串對話捲動(直排的 flex 預設會把每一則往內擠) */
.tutor-log > * { flex: none; }
.tutor-head, .tutor-note, .tutor-quick, .tutor-row { flex: none; }
.tutor-msg { padding: 9px 12px; border-radius: 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.tutor-msg.me { align-self: flex-end; background: var(--sky-100); color: var(--navy); border-bottom-right-radius: 4px; }
.tutor-msg.pick { align-self: flex-start; background: var(--forest-50); color: var(--ink); border-bottom-left-radius: 4px; }
.tutor-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.tutor-tip { cursor: pointer; border: 0; font-size: 13px; }
.tutor-row { display: flex; gap: 6px; align-items: center; }
.tutor-input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 2px solid var(--line); font: inherit; font-size: 15px; }
.tutor-input:focus { outline: none; border-color: var(--forest); }
@media (max-width: 640px) { .tutor { right: 10px; bottom: 10px; } }
/* 探長按鈕預設浮在右下角,頁尾先留出它的高度;拖走之後也不會有壞處 */
@media (max-width: 767px) { .stage { padding-bottom: 82px; } }
/* 探長回覆裡的行內程式碼 */
.tutor-code { padding: 1px 5px; border-radius: 6px; background: #eef2f6; color: var(--forest); font-family: Consolas, "Cascadia Mono", monospace; font-size: .92em; word-break: break-all; }
/* 合規:AI 揭露,不可移除 */
.tutor-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); font-weight: 700; }
