/* 手機要滿版且完全不能拉動：position:fixed 把頁面釘死在版面 viewport，
   加上 overscroll-behavior 擋掉 iOS 的橡皮筋、touch-action 擋掉捲動與雙指縮放 */
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden; background: #ffffff;
  position: fixed; inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; display: block; }
#loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .18em; text-transform: uppercase; color: #999; background: #fff;
  transition: opacity .6s ease; pointer-events: none;
}
#loading.hidden { opacity: 0; }
/* 讀取條在文字上方。寬度跟著視窗收，手機上不會頂到邊 */
#loading-bar {
  width: min(240px, 60vw); height: 2px; background: #eee; overflow: hidden;
}
#loading-bar > i {
  display: block; width: 0; height: 100%; background: #bbb;
  transform-origin: left center; transition: width .2s linear;
}
/* 伺服器沒回 Content-Length 就量不到進度（gzip 傳輸常見），改跑來回掃的動畫 */
#loading-bar.indeterminate > i { width: 40%; animation: loading-sweep 1.1s ease-in-out infinite; }
@keyframes loading-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
#loading-text.error { color: #d33; letter-spacing: .06em; text-transform: none; max-width: 80vw; text-align: center; }
#hint {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  font: 500 11px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .14em; text-transform: uppercase; color: #aaa;
  text-align: center; white-space: nowrap; user-select: none; pointer-events: none;
  transition: opacity .3s ease;
}
#crosshair {
  position: fixed; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px;
  border-radius: 50%; background: #bbb; opacity: 0; transition: opacity .3s ease;
  pointer-events: none;
}
#crosshair.visible { opacity: 1; }
/* 舉槍時張成圓環＋中心點：白色場景裡一顆灰點會被槍架吃掉，看不出瞄準點 */
#crosshair.armed {
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  background: transparent; border: 1.5px solid rgba(20, 20, 20, .65);
  transition: opacity .3s ease, width .15s ease, height .15s ease;
}
#crosshair.armed::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  border-radius: 50%; background: rgba(20, 20, 20, .8);
}
/* 模式選單靠左：畫面中央留給展示中的 bot，選單不要蓋在它臉上 */
#start {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center; gap: 10px;
  padding-left: clamp(24px, 8vw, 120px);
  opacity: 0; pointer-events: none; transition: opacity .5s ease;
}
#start.visible { opacity: 1; pointer-events: auto; }
/* 直式（手機）：標題釘在畫面上方、選單留在垂直中央，中間那段空白讓給 bot
   （bot 的取景往右偏，見 load.js 的 introBiasPortrait）。標題改用 absolute 是因為
   它與選單在同一個 flex 欄裡，不抽出來就沒辦法一個貼上、一個置中 */
@media (max-aspect-ratio: 1 / 1) {
  #start h1 {
    position: absolute; margin: 0;
    top: calc(env(safe-area-inset-top, 0px) + 8vh);
    left: clamp(24px, 8vw, 120px);
  }
}
/* 標題用 Futura。系統字型不做 webfont，Android 沒有就一路退到無襯線 */
#start h1 {
  margin: 0 0 22px;
  font: 500 42px/1.1 Futura, "Futura PT", "Trebuchet MS", -apple-system, sans-serif;
  letter-spacing: .04em; text-transform: uppercase; color: #111; user-select: none;
}
#start .mode {
  display: block; padding: 0; border: 0; background: none; cursor: pointer;
  text-align: left; color: #111; user-select: none;
}
#start .mode .name {
  display: block; position: relative;
  font: 600 26px/1.15 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .04em; text-transform: uppercase;
}
/* hover 的底線由左往右展開：scaleX 從 0 長到 1，原點釘在左邊 */
#start .mode .name::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: currentColor;
  transform: scaleX(0); transform-origin: left center;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
#start .mode:hover .name::after,
#start .mode:focus-visible .name::after { transform: scaleX(1); }
/* About：唯一一個彈出式視窗。Config 是「取代選單的另一頁」，About 只是一段說明，
   蓋在選單上面看完就關 —— 所以有半透明底與置中的卡片，跟其他面板長得不一樣。
   z-index 壓過 #back-button（7），不然左上角那顆會浮在遮罩上面 */
#about {
  position: fixed; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(250, 250, 250, .82);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
#about.visible { opacity: 1; pointer-events: auto; }
#about .card {
  position: relative;   /* 關閉鈕釘在右上角 */
  max-width: 420px; background: #fff; border: 1px solid #e6e6e6; border-radius: 6px;
  padding: 28px 30px; box-shadow: 0 12px 40px rgba(0, 0, 0, .08);
  color: #111; user-select: none;
}
#about h2 {
  margin: 0 0 14px;
  font: 500 26px/1.15 Futura, "Futura PT", "Trebuchet MS", -apple-system, sans-serif;
  letter-spacing: .04em; text-transform: uppercase;
}
#about p {
  margin: 0 0 12px;
  font: 400 14px/1.7 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: #444;
}
#about .by {
  margin: 0; color: #888; letter-spacing: .08em; text-transform: uppercase;
  font-size: 12px;
}
#about .by a { color: #111; text-decoration: none; border-bottom: 1px solid #ccc; }
#about .by a:hover { border-bottom-color: #111; }
/* 贊助那一段：用一條分隔線跟正文斷開，樣式壓得比說明更低調（灰、小字），
   免得整張卡片看起來是在要錢。帳號與信箱要能長按複製，所以只有這一段解除
   卡片的 user-select: none */
#about .support {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid #eee;
  user-select: text; -webkit-user-select: text;
}
#about .support h3 {
  margin: 0 0 8px; color: #888;
  font: 500 11px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .16em; text-transform: uppercase;
}
#about .support p {
  margin: 0 0 4px; color: #444;
  font: 400 13px/1.6 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}
#about .support p:last-child { margin-bottom: 0; }
/* 關閉鈕：右上角一個 X。卡片本來就窄，一顆有邊框的按鈕壓在文末會比說明本身還搶眼 */
#about .close {
  position: absolute; right: 10px; top: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 4px;
  background: none; color: #999; cursor: pointer; transition: color .15s ease;
}
#about .close:hover { color: #111; }
/* 設定面板：跟模式選單同一個位置與排版，兩者互相取代（同時只會亮一個） */
#config {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center; gap: 10px;
  padding-left: clamp(24px, 8vw, 120px);
  opacity: 0; pointer-events: none; transition: opacity .5s ease;
}
/* 面板本身放行滑鼠：它是整片 inset:0，吃掉事件的話畫布收不到 pointerdown，
   prefs.js 那段「拖曳轉 bot」就永遠不會觸發。只有實際要點的那幾列收事件 */
#config.visible { opacity: 1; pointer-events: none; }
#config.visible .row { pointer-events: auto; }
#config h2 {
  margin: 0; color: #888;
  font: 500 11px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .16em; text-transform: uppercase; user-select: none;
}
#config .row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
#config .opt {
  padding: 6px 14px; border: 1px solid #ddd; border-radius: 4px;
  background: #fff; color: #111; cursor: pointer;
  font: 500 15px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}
#config .opt.on { border-color: #111; }
/* 色塊：選中的那顆用外圈標示，不用勾勾 —— 深色塊上的勾看不清楚 */
#config .swatch {
  width: 28px; height: 28px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid #ddd; box-shadow: 0 0 0 0 #111; transition: box-shadow .15s ease;
}
#config .swatch.on { box-shadow: 0 0 0 2px #111; }
/* 調色盤那一格：畫圖示而不是色票。真正的 <input type="color"> 疊在底下代按，
   系統的取色視窗才有東西可以定位 */
#config .picker-wrap { position: relative; display: inline-flex; }
#config .swatch.picker {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: #111;
}
#config .picker-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; pointer-events: none;
}
#hint.hidden { opacity: 0; }
#prompt {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, 26px);
  font: 500 11px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .16em; text-transform: uppercase; color: #888;
  white-space: nowrap; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .18s ease;
}
#prompt.visible { opacity: 1; }
#prompt b { color: #111; font-weight: 600; }
#fps {
  position: fixed; left: 14px; top: 12px;
  font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em; color: #bbb; user-select: none; pointer-events: none;
  display: none;  /* 隱藏 FPS */
}
/* z-index 要壓過 #config／#start 那兩層全螢幕面板（position:fixed inset:0，
   在 DOM 裡排在後面）—— 沒有這行，設定面板開著時這顆會被整片蓋住，
   點不到也不會 hover */
/* 黑底白字、整塊貼著畫面左緣（左側不留邊也不留圓角），hover 時字往右滑。
   滑的是 padding 不是整塊（transform 會把黑底一起帶走，左邊露出一條白縫）——
   黑底維持貼邊，只有內容往右跑，那幾 px 是唯一的互動回饋（黑底上換底色看不出來）*/
#back-button {
  position: fixed; left: 0; top: 12px; z-index: 7;
  font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .14em; color: #fff; background: #111;
  padding: 8px 16px; border-radius: 0 4px 4px 0; cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, padding-left .25s cubic-bezier(.4, 0, .2, 1);
}
#back-button.visible { opacity: 1; pointer-events: auto; }
#back-button:hover { padding-left: 30px; }
/* 開打前的倒數：擺在畫面中央偏上，讓出中間給兩軍對峙的畫面 */
#countdown {
  position: fixed; left: 50%; top: 26%; transform: translate(-50%, -50%);
  font: 300 84px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .06em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
#countdown.visible { opacity: .85; }
/* Duel 開場的 VS：正中央壓在兩人中間，跑完才換成倒數（兩者不會同時出現） */
#vs {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 800 128px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .1em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
}
#vs.visible { opacity: .9; }
/* Play 的關卡公告：跟倒數同一個位置，兩者不會同時出現 */
#round {
  position: fixed; left: 50%; top: 26%; transform: translate(-50%, -50%);
  font: 700 48px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .12em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
#round.visible { opacity: .9; }
/* 全破的字改成畫面正中央、更大一號，跟一輪一輪的公告區分開 */
#round.end { top: 50%; font-size: 64px; letter-spacing: .16em; }
/* Duel 記分：畫面中央上方，左邊玩家分數，右邊機器人分數 */
#score {
  position: fixed; left: 50%; top: 20%; transform: translate(-50%, -50%);
  font: 600 24px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .08em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
#score.visible { opacity: 1; }
/* Factory 的產線儀表：右上角一疊數字。等寬字體，數字跳動時左右不會抖 */
#factory-hud {
  position: fixed; right: 14px; top: 12px; text-align: right;
  font: 500 11px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em; color: #999; white-space: pre;
  user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
#factory-hud.visible { opacity: 1; }
/* Play 的任務清單：右上角，掛在產線儀表（#factory-hud）下方。跟它同一套字體與濃度 ——
   兩塊都是「一直掛著的資訊」，長得不一樣只會讓畫面更吵。文字本身靠左讀（勾選方框在
   每行開頭，靠右對齊的話方框會飄在句尾，一眼看不出哪幾條打勾），只有區塊釘在右側。
   #factory-hud 最多 7 行（18.7px 行高）+ top:12px，170px 留了一截安全間距，
   不用逐幀量它的實際高度 */
#quests {
  position: fixed; right: 14px; top: 170px; text-align: left;
  font: 500 11px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em; color: #999;
  user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
#quests.visible { opacity: 1; }
#quests h2 { margin: 0 0 4px; font: inherit; color: #666; }
#quests ul { margin: 0; padding: 0; list-style: none; }
/* 前面那顆方框就是勾選狀態：完成的畫刪除線並壓淡，
   一眼看得出「剩下哪幾條」而不必逐行讀字 */
#quests li::before { content: '□ '; }
#quests li.done::before { content: '■ '; }
#quests li.done { text-decoration: line-through; color: #c4c4c4; }
body.night #quests { color: #8a8a8a; }
body.night #quests h2 { color: #6a6a6a; }
body.night #quests li.done { color: #5a5a5a; }
/* 入侵倒數：中央上方。壓在 #countdown（26%）之上，兩者不會同時出現
   —— Factory 沒有開打倒數 —— 但位置錯開比較好認，這是一直掛著的計時器不是開場數字。
   最後十秒轉紅：那時候該找地方站好了 */
#invade-timer {
  position: fixed; left: 50%; top: 10%; transform: translate(-50%, -50%);
  font: 500 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
#invade-timer.visible { opacity: .7; }
/* 最後十秒轉紅。opacity 一定要跟 .visible 綁在一起 —— 只寫 .soon 的話，
   收起來時移掉 .visible 也沒用，這條的 .9 照樣把數字留在畫面上 */
#invade-timer.visible.soon { color: #c33; opacity: .9; }
body.night #invade-timer { color: #eee; }
body.night #invade-timer.soon { color: #f66; }
body.touch #invade-timer { font-size: 18px; }
/* Duel 的鏡頭體感操作：左下角一塊偵測預覽。放左下是因為右下是手機的動作鈕，
   而準心與提示都在中央 —— 這塊只是回饋，不該擋到任何要看的東西 */
#camctl {
  position: fixed; left: 14px; bottom: 14px; z-index: 7;   /* 檢視畫面（#viewer）疊在上面時預覽仍要看得到 */
  display: none; pointer-events: none; user-select: none;
}
#camctl.visible { display: block; }
#cam-view {
  display: block; width: 168px; height: auto;
  border: 1px solid #ccc; border-radius: 4px; background: #111;
  image-rendering: pixelated;   /* 縮圖本來就是格狀的，插值糊掉反而看不出前景的形狀 */
  opacity: .85;
}
#cam-status {
  margin-top: 5px;
  font: 500 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em; color: #888;
}
#cam-view { pointer-events: auto; cursor: pointer; }   /* 點一下切「原始畫面／偵測結果」 */
body.night #cam-view { border-color: #555; }
body.night #cam-status { color: #7a7a7a; }
/* 檢視畫面開著的時候，場上那幾塊 HUD 整層收掉：那個畫面只該有那具模型。
   主迴圈在 viewer 那一段就 return，各塊 HUD 的每幀更新都不會跑，
   所以要靠這一條蓋掉而不是等它們自己收。
   #round（公告）不在名單裡 —— 打勾那一則就是在這個畫面裡跳出來的 */
body.inspect #quests,
body.inspect #factory-hud,
body.inspect #invade-timer,
body.inspect #ammo,
body.inspect #score,
body.inspect #crosshair,
body.inspect #prompt,
body.inspect #hint,
body.inspect #touch { display: none; }
/* 拆解台的檢視畫面（見 src/viewer.js）：模型畫在同一塊 canvas 上，
   這一層只是疊在上面的字，整片吃不到滑鼠事件（拖曳要傳到 canvas 去轉物件）。
   離開靠左上角的返回鈕（#back-button，z-index 比這層高，見 input.js） */
#viewer {
  position: fixed; inset: 0; z-index: 6;
  display: none; pointer-events: none; user-select: none;
  color: #e6e8eb;
  font: 400 13px/1.7 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}
#viewer.visible { display: block; }
#viewer-head {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); text-align: center;
}
#viewer-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .12em; }
#viewer-state {
  margin-top: 6px;
  font: 500 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em; color: #7dd3fc;
}
/* 說明擺右下：左下是鏡頭預覽（#camctl）的位置，兩個疊在一起會互相蓋掉 */
#viewer-hint {
  position: absolute; right: 22px; bottom: 20px; max-width: 300px; text-align: right;
  font-size: 12px; line-height: 1.9; color: #9aa3b2;
}
/* 手機版檢視畫面：沒有鏡頭體感這條路（見 src/viewer.js），偵測狀態
   （「把手舉到鏡頭前」那一行）用不到，收掉。標題桌機版現在也置中，不用另外覆寫 */
body.touch #viewer-head { top: 16px; }
body.touch #viewer-state { display: none; }
/* 桌機版 Duel 開場挑操作方式：兩張卡蓋在畫面中央，選完才進體感測試／VS */
#duelpick {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 24px 28px; text-align: center;
  background: rgba(255, 255, 255, .92); border: 1px solid #ddd; border-radius: 8px;
  font: 400 14px/1.7 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: #333; user-select: none;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
#duelpick.visible { opacity: 1; pointer-events: auto; }
#duelpick h2 {
  margin: 0 0 16px; font-size: 15px; font-weight: 600; letter-spacing: .1em; color: #111;
}
#duelpick .picks { display: flex; gap: 12px; }
#duelpick .pick {
  flex: 1; width: 190px; padding: 16px 14px; cursor: pointer; text-align: left;
  background: none; border: 1px solid #ccc; border-radius: 6px;
  font: inherit; color: #666; transition: border-color .2s ease, color .2s ease;
}
#duelpick .pick:hover { border-color: #111; color: #111; }
#duelpick .pick b { display: block; font-size: 14px; color: #111; }
#duelpick .pick span { display: block; margin-top: 4px; font-size: 12px; line-height: 1.5; }
body.night #duelpick { background: rgba(18, 20, 24, .92); border-color: #444; color: #ccc; }
body.night #duelpick h2 { color: #eee; }
body.night #duelpick .pick { border-color: #555; color: #999; }
body.night #duelpick .pick:hover { border-color: #eee; color: #eee; }
body.night #duelpick .pick b { color: #eee; }
/* Duel 開場的體感測試：三個動作的檢查表，蓋在畫面中央 */
#camtest {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  min-width: 260px; padding: 22px 28px; text-align: center;
  background: rgba(255, 255, 255, .92); border: 1px solid #ddd; border-radius: 8px;
  font: 400 14px/1.7 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: #333; user-select: none;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
#camtest.visible { opacity: 1; pointer-events: auto; }
#camtest h2 {
  margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: .1em; color: #111;
}
#camtest ol { margin: 0; padding: 0; list-style: none; }
#camtest .step {
  padding: 7px 0; color: #aaa; transition: color .2s ease;
}
/* 現在要做的那一關才是黑的，做完的打勾轉灰綠 —— 一眼看得出輪到哪一個 */
#camtest .step.now { color: #111; font-weight: 600; }
#camtest .step.done { color: #4a9; text-decoration: line-through; }
#camtest .step.done::after { content: " ✓"; text-decoration: none; }
#camtest-skip {
  margin-top: 16px; padding: 6px 16px; cursor: pointer;
  background: none; border: 1px solid #ccc; border-radius: 4px;
  font: inherit; font-size: 12px; color: #888;
}
#camtest-skip:hover { color: #111; border-color: #999; }
body.night #camtest { background: rgba(18, 20, 24, .92); border-color: #444; color: #ccc; }
body.night #camtest h2 { color: #eee; }
body.night #camtest .step.now { color: #fff; }
/* Arena 勝利顯示：畫面中央大字 */
#winner {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 700 48px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .12em; color: #111; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .3s ease;
}
#winner.visible { opacity: 1; }
/* Duel K.O. 顯示：畫面中央大字 */
#ko {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 700 64px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .16em; color: #ff0000; user-select: none; pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
#ko.visible { opacity: 1; }
/* Arena Again 按鈕：顯示在勝利訊息下方 */
#again-button {
  position: fixed; left: 50%; top: 60%; transform: translate(-50%, -50%);
  font: 600 20px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .1em; color: #111; background: #fff;
  padding: 10px 24px; border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
#again-button.visible { opacity: 1; pointer-events: auto; }
#again-button:hover { background: #f0f0f0; }
#bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bubble {
  position: absolute; transform: translate(-50%, -100%);
  transform-origin: 50% 100%;   /* 縮放時底邊釘在頭頂那個點 */
  color: #fff;
  font: 600 14px/1.3 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .01em; white-space: nowrap; user-select: none;
  /* 外框描邊：paint-order 讓黑邊畫在字的外側，字身不會被吃掉 */
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  /* 不支援 paint-order 的瀏覽器退回八方向陰影 */
  text-shadow:
    -1px -1px 0 #000, 0 -1px 0 #000, 1px -1px 0 #000,
    -1px  0   0 #000,               1px  0   0 #000,
    -1px  1px 0 #000, 0  1px 0 #000, 1px  1px 0 #000;
  opacity: 0; transition: opacity .22s ease;
}
.bubble.visible { opacity: 1; }

/* ── 手機觸控層 ────────────────────────────────────────────────────────────
   平常整層不存在（display:none），只有 touch.js 認定是觸控裝置、而且真的在玩
   （body.touch-play）時才長出來 —— 開場選單與 Arena 觀看要讓手勢落到
   OrbitControls 上，操作層蓋著就轉不動鏡頭了 */
#touch { display: none; }
body.touch-play #touch {
  display: block; position: fixed; inset: 0; z-index: 5;
  touch-action: none;   /* 擋掉捲動與雙指縮放，不然拖一下整個頁面在跳 */
  -webkit-user-select: none; user-select: none;
}
#touch-move, #touch-look { position: absolute; top: 0; bottom: 0; touch-action: none; }
#touch-move { left: 0; width: 45%; }
#touch-look { right: 0; width: 55%; }
/* 搖桿是浮動的：圓心跟著手指落點跑（left／top 由 JS 寫），
   knob 再用 --dx／--dy 位移，兩層分開才不用每幀重算圓心 */
#touch-stick {
  position: absolute; width: 112px; height: 112px; margin: -56px 0 0 -56px;
  border: 1.5px solid rgba(17, 17, 17, .16); border-radius: 50%;
  opacity: 0; transition: opacity .16s ease; pointer-events: none;
}
#touch-stick.visible { opacity: 1; }
#touch-stick i {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(17, 17, 17, .3);
  transform: translate(var(--dx, 0px), var(--dy, 0px));
}
.touch-btn {
  position: absolute; display: flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; border-radius: 50%;
  background: rgba(255, 255, 255, .82); border: 1.5px solid rgba(17, 17, 17, .18);
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .08em; color: #111; touch-action: none;
}
.touch-btn.down { background: #111; color: #fff; border-color: #111; }
/* 格擋擺在拇指最順的右下角，攻擊往左平移一個身位，同高並排 */
#touch-guard { right: max(24px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); }
#touch-punch { right: calc(max(24px, env(safe-area-inset-right)) + 74px); bottom: max(28px, env(safe-area-inset-bottom)); }

/* 手機沒有 ESC 也沒有指標解鎖，返回主畫面只能常駐在上方 */
body.touch-ingame #back-button {
  opacity: 1; pointer-events: auto; z-index: 6;
  top: max(12px, env(safe-area-inset-top));
  /* 一樣貼左緣，只讓開瀏海／圓角那一塊 */
  left: env(safe-area-inset-left, 0px);
}
/* 底部說明整條收掉：手機螢幕就那麼點，那行字只會跟搖桿與按鈕搶位置 */
body.touch #hint { display: none; }
/* 關卡公告縮一號：48px 的「Boss Fight!!」在手機上會頂到左右兩邊。
   .end（Game Over／End Game）也要一起指定 —— body.touch #round 的
   權重比 #round.end 高，不寫的話那條 64px 會被上面這行蓋掉 */
body.touch #round { font-size: 30px; letter-spacing: .08em; }
body.touch #round.end { font-size: 40px; letter-spacing: .1em; }
/* VS 也縮一半：128px 壓在手機上會蓋掉左右兩個人，那兩秒只看得到一個字 */
body.touch #vs { font-size: 64px; }
/* 同理，48px 的「Red Team Won」在手機上一定換行，縮到 20px 才一行放得下 */
body.touch #winner { font-size: 20px; }
/* 手機螢幕窄，Game Over／勝利那行大字會換行，Again 往下讓開才不會疊到 */
body.touch #again-button { top: 70%; }
body.touch #start h1 { font-size: 28px; margin-bottom: 16px; }
body.touch #start .mode .name { font-size: 22px; }
/* About 卡片的標題也縮一號：42px 的標題在手機上會擠成兩行，跟內文黏在一起 */
body.touch #about h2 { font-size: 22px; }
body.touch #start .mode { padding: 6px 0; }
/* 選項之間收緊：手機直式畫面高度有限，五顆排下來要留得住標題的空間 */
body.touch #start { gap: 4px; }
/* 顏色一排 5 個：九格（八個預設色＋調色盤）排成一列，在手機寬度會被擠到畫面外 */
body.touch #config-colors {
  display: grid; grid-template-columns: repeat(5, auto);
  justify-content: start; gap: 12px;
}
/* 一排五個，色塊比桌機小一點才排得開 */
body.touch #config .swatch { width: 24px; height: 24px; }
/* 手機不放調色盤：<input type="color"> 在行動瀏覽器會蓋出一整片系統取色面板，
   跟「一排色票點一下就換」的節奏差太多，五格預設色夠用 */
body.touch #config .picker-wrap { display: none; }

/* 手上那把槍與剩餘彈藥。擺在畫面正下方、說明文字上面一點 —— 射擊時眼睛在準心上，
   這是餘光掃得到的位置 */
#ammo {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  font: 500 14px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  letter-spacing: .12em; color: #111; background: rgba(255,255,255,.72);
  padding: 6px 14px; border-radius: 4px;
  opacity: 0; transition: opacity .2s ease; pointer-events: none; user-select: none;
}
#ammo.visible { opacity: 1; }
#ammo b { font-weight: 700; }
body.touch #ammo { bottom: 96px; }

/* 指令台：按 ~ 從畫面上方滑下來的半透明黑底終端機（見 src/console.js）。
   高度只佔一半：下半截還看得到場上發生什麼事，改完參數不必關掉才知道有沒有效。
   收起來時用 transform 移出畫面而不是 display:none —— 滑下來那一下要看得到動作，
   而且輸入框留在 DOM 裡，focus 才不會每次開都重接 */
#console {
  position: fixed; left: 0; top: 0; width: 100%; height: 50vh;
  display: flex; flex-direction: column; box-sizing: border-box; padding: 14px 16px 0;
  background: rgba(8, 8, 10, .82); color: #e8e8e8;
  font: 400 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  transform: translateY(-100%); transition: transform .18s ease;
  z-index: 60;   /* 壓過 #back-button 那一層，開著的時候什麼都不該蓋住它 */
  pointer-events: none;
}
#console.open { transform: none; pointer-events: auto; }
#console-log {
  flex: 1; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  scrollbar-width: thin; scrollbar-color: #444 transparent;
}
#console-log .cmd { color: #7fd1ff; }      /* 自己敲的那一行 */
#console-log .err { color: #ff8f8f; }
#console-log .dim { color: #8a8a8a; }
#console-input {
  flex: none; width: 100%; box-sizing: border-box; padding: 10px 0 14px;
  border: 0; border-top: 1px solid rgba(255, 255, 255, .14); outline: none;
  background: none; color: #fff; font: inherit;
}
#fps.visible { display: block; }

/* 換場淡入（見 ui.js 的 fadeIn）：整片蓋住畫面再化開。
   底色用白的 —— 這個場景本來就是白地白牆，黑幕化開的那一下會像斷電再開機；
   夜晚模式下換成場景那個深藍黑（跟 scene.js 的 NIGHT.bg 同一個值）。
   z-index 壓在指令台（60）以下、其餘 HUD 以上：淡入那半秒連血條與提示也一起蓋掉 */
#fade {
  position: fixed; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 55;
}
#fade.hold { opacity: 1; transition: none; }        /* 蓋上：不做動畫，直接遮住 */
#fade.run { opacity: 0; transition: opacity .55s ease; }   /* 化開 */
body.night #fade { background: #0b0d12; }

/* 夜晚模式（指令台的 darkmode）：3D 場景換成深色底之後，HUD 那幾行深灰字
   會整片消失在背景裡。旗標掛在 <body> 上（console.js 切），CSS 只負責把
   文字與底色反過來 —— 顏色寫在樣式表這一邊，JS 不必知道每一則提示長什麼樣 */
body.night #hint { color: #8b8b8b; }
body.night #prompt { color: #9a9a9a; }
body.night #prompt b,
body.night #countdown,
body.night #vs,
body.night #round,
body.night #score,
body.night #winner { color: #f0f0f0; }
body.night #fps { color: #666; }
body.night #factory-hud { color: #7a7a7a; }
body.night #crosshair { background: #eee; }
body.night #ammo { color: #f0f0f0; background: rgba(20, 22, 26, .72); }
/* 對話泡泡不必改：本來就是白字黑描邊，兩種底色下都讀得到 */
body.night .touch-btn { color: #eee; border-color: #666; }
body.night .touch-btn.down { background: #eee; color: #111; border-color: #eee; }
