/* 製作者：瓦特老師 | https://water64.tw/ | Logo：assets/water-logo.svg
 * 使用請保留原始創作者資訊。第三方程式庫與素材依各自授權。 */
/* 版面概念：整頁就是 3D 校園，介面像導航儀表一樣浮在四個角落；班牌（色塊＋固定編號）是貫穿全站的視覺單位 */
:root {
  color-scheme: dark;
  --ink: #101923;            /* 儀表底色（深藏青） */
  --ink-2: #1a2634;
  --panel: rgba(16, 25, 35, .88);
  --line: rgba(255, 255, 255, .13);
  --paper: #f6f2e8;          /* 主要文字（米白，取自校舍牆面） */
  --muted: #9db0c2;
  --brand: #d8433a;          /* 屋瓦紅 */
  --route: #ffd23f;          /* 導航黃 */
  --ok: #58c98b;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --num: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", var(--font);
  --r: 14px;
  --sb: calc(36px + env(safe-area-inset-bottom, 0px));   /* 底部來源列的高度＋手機安全區 */
}
html, body { height: 100%; }
body { margin: 0; background: #b9d6ea; color: var(--paper); font-family: var(--font); font-size: 14px; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { position: absolute; left: var(--view-left, 0px); top: var(--view-top, 0px); width: var(--view-width, 100%); height: var(--view-height, 100dvh); overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; }   /* 介面跟著實際可見範圍；保留瀏覽器放大能力 */
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(6, 12, 20, .35); }

/* ── 最底下：靈感來源 ── */
#credit { position: absolute; left: 0; right: 0; bottom: 0; min-height: 36px; box-sizing: border-box; padding: 5px 16px calc(5px + env(safe-area-inset-bottom, 0px)); background: rgba(16, 25, 35, .78); border-top: 1px solid var(--line); font-size: 11.5px; line-height: 26px; color: var(--muted); text-align: center; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: text; -webkit-user-select: text; }
#credit { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; column-gap:4px; white-space:normal; }
#credit .by, #credit a { white-space:nowrap; }
#credit .creator-note { flex-basis:100%; font-size:10px; line-height:16px; }
#credit a { color: var(--paper); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(246, 242, 232, .4); }
#credit a:hover { text-decoration-color: var(--route); color: var(--route); }
#credit a:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; border-radius: 3px; }
#credit i { font-style: normal; opacity: .5; margin: 0 6px; }
#credit .by { display: inline-flex; align-items: center; gap: 7px; vertical-align: top; color: var(--paper); }
#credit .by img { width: 24px; height: 24px; display: block; flex: none; }   /* 瓦特老師標誌：assets/water-logo.svg，由 build.js 內嵌 */
#credit .by b { font-weight: 700; letter-spacing: .08em; }

/* ── 上方列 ── */
#top { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 10px; align-items: flex-start; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 0; pointer-events: none; flex-wrap: wrap; z-index: 3; }
#top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 7px 14px 7px 8px; font: inherit; color: inherit; text-align: left; cursor: pointer; }   /* 整塊是按鈕：點了回首頁 */
.brand .bt { display: block; }
.brand:hover { filter: brightness(1.18); }
.brand:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
.seal { width: 38px; height: 38px; flex: none; display: block; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 2px 6px rgba(0, 0, 0, .35); user-select: none; }  /* 校徽：assets/logo.webp，由 build.js 內嵌 */
.brand b { display: block; font-size: 15px; font-weight: 900; letter-spacing: .04em; line-height: 1.15; }
.brand small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
#loc { padding: 6px 12px; font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; align-self: flex-start; white-space: nowrap; }
#loc i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 3px rgba(88, 201, 139, .25); }
.search { position: relative; flex: 1 1 220px; max-width: 400px; min-width: 0; margin-left: auto; }
.search input { width: 100%; box-sizing: border-box; height: 44px; padding: 0 14px 0 40px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); outline: none; font-size: 15px; backdrop-filter: blur(10px); user-select: text; -webkit-user-select: text; }
.search input::placeholder { color: var(--muted); }
.search input:focus-visible { border-color: var(--route); box-shadow: 0 0 0 3px rgba(255, 210, 63, .25); }
.search svg { position: absolute; left: 13px; top: 13px; opacity: .7; pointer-events: none; z-index: 1; }
#venues { margin-top: 7px; padding: 7px 8px 8px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--route); }
#venues > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.venue-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 5px; }
.venue-buttons button { min-width: 0; min-height: 36px; padding: 4px; border: 1px solid var(--line); border-radius: 2px; background: rgba(255, 255, 255, .06); font-size: 12px; font-weight: 700; white-space: nowrap; }
.venue-buttons button:hover { background: rgba(255, 210, 63, .15); border-color: var(--route); }
.venue-buttons button:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
#results { position: absolute; left: 0; right: 0; top: 50px; margin: 0; padding: 6px; list-style: none; max-height: min(calc(var(--view-height, 100dvh) - 88px), 420px); overflow: auto; z-index: 5; }
#results li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
#results li:hover, #results li.on { background: rgba(255, 255, 255, .09); }
#results .where { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
#results .none { color: var(--muted); cursor: default; }
.actions { display: flex; gap: 6px; }
.ibtn { height: 44px; min-width: 44px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; font-size: 13px; backdrop-filter: blur(10px); white-space: nowrap; }
.ibtn:hover { background: rgba(32, 46, 62, .95); }
.ibtn.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.ibtn:focus-visible, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
.ibtn kbd { font-family: var(--num); font-size: 12px; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; line-height: 15px; }

/* ── 班牌：色塊＋名稱＋固定編號 ── */
.plate { display: inline-flex; align-items: stretch; border-radius: 7px; overflow: hidden; font-weight: 900; line-height: 1; flex: none; box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.plate .nm { padding: 6px 9px; font-size: 14px; letter-spacing: .02em; min-width: 26px; text-align: center; background: var(--c, #8a8f98); color: var(--k, #fff); }
.plate .no { padding: 6px 7px 6px 6px; background: #0b1119; color: #cfd8e3; font-family: var(--num); font-weight: 600; font-size: 13px; letter-spacing: .04em; display: flex; align-items: center; }
.plate .no::before { content: "No."; font-size: 9px; opacity: .6; margin-right: 3px; letter-spacing: .06em; }
.plate.big .nm { font-size: 24px; padding: 10px 16px; }
.plate.big .no { font-size: 20px; padding: 10px 12px 10px 10px; }

/* ── 小地圖 ── */
#minimap { pointer-events: none; position: absolute; left: 16px; bottom: calc(16px + var(--sb)); width: 172px; height: 172px; border-radius: 22px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .8); box-shadow: 0 10px 30px rgba(6, 12, 20, .45); background: #2b3644; }
#minimap canvas { width: 100%; height: 100%; display: block; }
#minimap .fl { position: absolute; right: 8px; bottom: 8px; background: var(--ink); border-radius: 8px; padding: 2px 8px; font-family: var(--num); font-weight: 700; font-size: 16px; letter-spacing: .04em; }
#minimap .n { position: absolute; left: 0; top: 0; width: 20px; height: 20px; margin: -10px; border-radius: 50%; background: var(--brand); color: #fff; font: 700 12px/20px var(--num); text-align: center; }

/* ── 導航列 ── */
#navbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--sb)); display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 12px; max-width: calc(100% - 232px); box-sizing: border-box; }
#navbar .txt { min-width: 0; flex: 1 1 auto; }
#navbar .t1 { font-size: 12px; color: var(--muted); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#navbar .t2 { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#navbar .dist { font-family: var(--num); font-weight: 700; font-size: 30px; color: var(--route); line-height: 1; white-space: nowrap; }
#navbar .dist small { font-size: 13px; margin-left: 2px; font-family: var(--font); }
.btn { height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); font-weight: 700; font-size: 13px; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, .16); }
.btn.pri { background: var(--route); color: #1b1500; border-color: var(--route); }
.btn.pri:hover { background: #ffdd66; }
.btn.red { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }

/* ── 區域名稱（進入新區域時浮現） ── */
#toast { position: absolute; right: 22px; bottom: calc(26px + var(--sb)); text-align: right; pointer-events: none; opacity: 0; transition: opacity .5s; text-shadow: 0 2px 10px rgba(0, 0, 0, .55); }
#toast.show { opacity: 1; }
#toast b { display: block; font-size: clamp(26px, 5vw, 44px); font-weight: 900; letter-spacing: .08em; line-height: 1.1; }
#toast span { font-family: var(--num); font-size: clamp(18px, 3vw, 26px); font-weight: 600; letter-spacing: .14em; color: var(--route); }
#prompt { position: absolute; left: 50%; bottom: calc(148px + var(--sb)); transform: translateX(-50%); padding: 8px 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; white-space: nowrap; }
#cross { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255, 255, 255, .75); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35); pointer-events: none; }

/* ── 鳥瞰：樓層切換與標籤 ── */
#floorbar { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; padding: 5px; gap: 3px; }
#floorbar span { font-size: 10px; color: var(--muted); text-align: center; letter-spacing: .1em; padding: 3px 0 2px; }
.seg button { border: 0; background: transparent; height: 36px; min-width: 48px; border-radius: 9px; font-family: var(--num); font-weight: 700; font-size: 16px; letter-spacing: .04em; }
.seg button:hover { background: rgba(255, 255, 255, .1); }
.seg button.on { background: var(--paper); color: var(--ink); }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lab { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: auto; cursor: pointer; will-change: transform; }
.lab.bld { background: var(--ink); color: var(--paper); font-weight: 900; font-size: 13px; letter-spacing: .1em; padding: 5px 10px 8px; border-radius: 0; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.lab.bld::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c, var(--brand)); }
.lab.poi { color: #16202b; font-weight: 700; font-size: 12px; background: rgba(255, 255, 255, .82); padding: 2px 8px; border-radius: 20px; }
.lab.rm .plate .nm { font-size: 12px; padding: 4px 6px; }
.lab.rm .plate .no { font-size: 11px; padding: 4px 5px 4px 4px; }
.lab.rm .plate .no::before { display: none; }

/* ── 開始畫面 ── */
#start { position: absolute; left: 16px; top: 50%; transform: translateY(-46%); width: min(372px, calc(100% - 32px)); padding: 22px 22px 18px; box-sizing: border-box; }
#start h1 { margin: 0 0 4px; font-size: 30px; font-weight: 900; letter-spacing: .04em; line-height: 1.15; text-wrap: balance; }
#start .yr { font-family: var(--num); color: var(--route); font-weight: 700; font-size: 17px; letter-spacing: .12em; }
#start p { margin: 12px 0 16px; color: #d3dce6; line-height: 1.7; }
#start .row { display: flex; gap: 8px; flex-wrap: wrap; }
#start .btn { height: 46px; font-size: 15px; flex: 1 1 130px; }
.keys { margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12.5px; color: #c4d0dc; }
.keys kbd { font-family: var(--num); font-weight: 600; font-size: 13px; background: rgba(255, 255, 255, .1); border-radius: 5px; padding: 1px 7px; letter-spacing: .04em; white-space: nowrap; }

/* ── 空間資訊卡 ── */
#card { position: absolute; left: 50%; top: calc(var(--top-bottom, 138px) + 12px); transform: translateX(-50%); padding: 14px; width: min(340px, calc(100% - 32px)); box-sizing: border-box; z-index: 6; }
#card .hd { display: flex; align-items: flex-start; gap: 12px; }
#card .where { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 10px; }
#card .where b { color: var(--paper); font-size: 15px; margin-right: 8px; }
#card .row { display: flex; gap: 8px; margin-top: 12px; }
#card .row .btn { flex: 1; }
#card .x { margin-left: auto; align-self: flex-start; }
.xbtn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .08); font-size: 18px; line-height: 1; flex: none; }
.xbtn:hover { background: rgba(255, 255, 255, .18); }

/* ── 電梯 ── */
#elev { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 16px; text-align: center; z-index: 7; }
#elev h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: .1em; }
#elev .seg { display: flex; gap: 6px; }
#elev .seg button { width: 54px; height: 54px; font-size: 22px; background: rgba(255, 255, 255, .08); }
#fade { position: absolute; inset: 0; background: #0b1119; opacity: 0; pointer-events: none; transition: opacity .25s; }
#fade.on { opacity: 1; }

/* ── 觸控 ── */
#touch { position: absolute; inset: 0; pointer-events: none; }
#stick { position: absolute; width: 112px; height: 112px; margin: -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); background: rgba(16, 25, 35, .25); display: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(255, 255, 255, .85); }
#tbtns { position: absolute; right: 16px; bottom: calc(22px + var(--sb)); display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
#tbtns button { width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55); background: rgba(16, 25, 35, .5); font-weight: 900; font-size: 15px; }
#tbtns button.on { background: var(--route); color: #1b1500; border-color: var(--route); }

/* 操作入口靠左側，讓畫面中央的人物保持完整；展開才顯示設定。 */
#moveTools { position: absolute; left: 16px; top: calc(var(--top-bottom, 72px) + 8px); z-index: 5; }
.move-buttons { display: flex; flex-direction: column; gap: 8px; }
.move-buttons .ibtn { border-radius: 24px; }
#movePanel { position: absolute; left: 0; top: calc(100% + 8px); width: min(320px, calc(var(--view-width, 100vw) - 32px)); box-sizing: border-box; padding: 14px; max-height: calc(var(--view-height, 100dvh) - var(--top-bottom, 72px) - var(--sb) - 120px); overflow: auto; }
.move-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.move-head h3 { font-size: 15px; margin: 0; }
#movePanel label:not(.move-check) { display: block; font-size: 13px; }
#movePanel label b { float: right; color: var(--route); }
#movePanel input[type=range] { display: block; width: 100%; height: 36px; margin: 4px 0 0; accent-color: var(--route); cursor: pointer; }
.range-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
#movePanel p { font-size: 12px; line-height: 1.6; margin: 10px 0; color: #c4d0dc; }
#movePanel select { width: 100%; display: block; margin: 6px 0 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); color: var(--paper); font: inherit; }
.move-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 12px 0; }
.move-check input { width: 18px; height: 18px; accent-color: var(--route); }
#moveReset { margin-top: 10px; width: 100%; }

/* ── 教室配置編輯 ── */
#editor { position: absolute; right: 0; top: 0; bottom: 0; width: min(620px, 100%); border-radius: 0; border-width: 0 0 0 1px; display: flex; flex-direction: column; z-index: 8; background: rgba(13, 21, 30, .96); user-select: text; -webkit-user-select: text; }
#editor header { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; gap: 12px; align-items: flex-start; border-bottom: 1px solid var(--line); }
#editor h2 { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: .04em; }
#editor header p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; max-width: 46ch; }
#editor .yrin { width: 58px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); text-align: center; font-family: var(--num); font-weight: 700; font-size: 17px; }
/* 雲端版的帳號列：左邊一條筆直的色條表示狀態（黃＝要登入、綠＝可以編輯、紅＝沒有權限） */
#eauth { display: flex; gap: 10px; align-items: center; padding: 8px 16px 8px 12px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--route); font-size: 12.5px; line-height: 1.5; background: rgba(255, 255, 255, .04); flex: none; }
#eauth.ok { border-left-color: var(--ok); }
#eauth.no { border-left-color: var(--brand); }
#eauth span { flex: 1; min-width: 0; color: #c4d0dc; overflow-wrap: anywhere; }
#eauth b { color: var(--paper); font-weight: 700; }
#eauth .btn { height: 32px; flex: none; }
.cell input:disabled { -webkit-text-fill-color: currentColor; opacity: 1; cursor: default; }
.acl { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.acl li { display: flex; gap: 10px; align-items: center; min-height: 40px; padding: 4px 6px 4px 10px; background: rgba(255, 255, 255, .055); border-left: 4px solid var(--ok); }
.acl li.own { border-left-color: var(--route); }
.acl li.none { border-left-color: #56606c; color: var(--muted); font-size: 12.5px; }
.acl .em { font-weight: 700; font-size: 13.5px; overflow-wrap: anywhere; min-width: 0; }
.acl small { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; }
.acl .btn { height: 30px; padding: 0 10px; font-size: 12px; flex: none; }
.access .row input { flex: 1 1 180px; min-width: 0; height: 38px; box-sizing: border-box; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); padding: 0 10px; font-size: 13.5px; outline: none; }
.access .row input:focus-visible { border-color: var(--route); }
#etabs { display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: none; }
#etabs button { border: 0; background: transparent; padding: 7px 11px; border-radius: 9px; font-weight: 700; font-size: 13px; white-space: nowrap; color: var(--muted); }
#etabs button.on { background: var(--paper); color: var(--ink); }
#ebody { flex: 1; overflow: auto; padding: 14px 16px 20px; min-height: 0; }
.bld { margin-bottom: 22px; }
.bld h3 { margin: 0 0 8px; font-size: 14px; font-weight: 900; letter-spacing: .1em; display: flex; align-items: center; gap: 8px; }
.bld h3 i { width: 4px; height: 14px; border-radius: 0; background: var(--c); display: inline-block; }
.bld h3 small { color: var(--muted); font-weight: 500; letter-spacing: 0; font-size: 12px; }
.stack { overflow-x: auto; padding-bottom: 4px; }
.flr { display: flex; gap: 3px; margin-bottom: 3px; align-items: stretch; }
.flr > b { flex: none; width: 30px; display: grid; place-items: center; font-family: var(--num); font-size: 15px; color: var(--muted); }
.cell { position: relative; flex: 1 0 0; min-width: 0; min-height: 50px; border-radius: 0; background: rgba(255, 255, 255, .055); padding: 8px 4px 4px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: space-between; }
.cell::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--c, #56606c); }   /* 一條筆直的色條，不跟著圓角彎 */
.cell.sm { flex-grow: .5; }
.cell.void { background: rgba(255, 255, 255, .025); padding-top: 4px; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.cell .no { font-family: var(--num); font-size: 12px; font-weight: 600; color: #b9c6d4; letter-spacing: .04em; line-height: 1.1; }
.cell input { width: 100%; box-sizing: border-box; border: 0; background: transparent; font-weight: 900; font-size: 15px; padding: 2px 0; outline: none; border-radius: 4px; text-align: center; min-width: 0; }
.cell input:focus { background: rgba(255, 255, 255, .14); box-shadow: 0 0 0 2px var(--route); }
.cell.void::before { display: none; }
.cell.chg::after { content: ""; position: absolute; right: 4px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--route); }
.stack .flr { min-width: var(--minw, 0); }
.tools { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.tools h4 { margin: 0; font-size: 13px; letter-spacing: .08em; }
.tools p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.tools textarea { width: 100%; box-sizing: border-box; min-height: 92px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); padding: 9px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; resize: vertical; outline: none; }
.tools textarea:focus-visible { border-color: var(--route); }
.tools .row { display: flex; gap: 8px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: #c4d0dc; margin: 0 0 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
#editor footer { border-top: 1px solid var(--line); padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; align-items: center; }
#estatus { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
#estatus.ok { color: var(--ok); }
#estatus.warn { color: var(--route); }

#help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 32px)); padding: 18px 20px; box-sizing: border-box; z-index: 9; }
#help h3 { margin: 0 0 4px; font-size: 17px; }
#help .keys { border-top: 0; margin-top: 8px; padding-top: 0; }
#help .keys kbd { align-self: start; }
#help { max-height: calc(100% - 24px - var(--sb)); overflow: auto; }
/* 使用說明的分頁與步驟。data-m 標記「哪一種版本才顯示」：cloud＝接了 Firebase、artifact＝Claude 頁面、local＝單純靜態網頁 */
#htabs { display: flex; gap: 4px; margin: 8px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
#htabs button { border: 0; background: transparent; padding: 7px 11px; border-radius: 9px; font-weight: 700; font-size: 13px; white-space: nowrap; color: var(--muted); }
#htabs button.on { background: var(--paper); color: var(--ink); }
#help [data-m] { display: none; }
#help[data-mode="cloud"] [data-m~="cloud"], #help[data-mode="artifact"] [data-m~="artifact"], #help[data-mode="local"] [data-m~="local"] { display: revert; }
#help .lead { margin: 0 0 10px; padding: 7px 10px; border-left: 4px solid var(--route); background: rgba(255, 255, 255, .05); font-size: 12.5px; line-height: 1.6; color: #c4d0dc; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 9px; font-size: 13px; line-height: 1.65; color: #c4d0dc; }
.steps li { counter-increment: st; position: relative; padding-left: 30px; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; display: grid; place-items: center; font-family: var(--num); font-weight: 700; font-size: 13px; background: rgba(255, 255, 255, .12); color: var(--paper); }
.steps li > b { color: var(--paper); margin-right: 8px; }
.steps code, .steps kbd { font-family: var(--num); font-weight: 600; font-size: 13px; background: rgba(255, 255, 255, .1); border-radius: 4px; padding: 0 6px; }
.lookset { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; font-size: 13px; }
.lookset h4 { margin: 0; font-size: 14px; letter-spacing: .06em; }
.lookset .row { display: grid; grid-template-columns: auto 1fr 48px; align-items: center; gap: 12px; }
.lookset .row b { font-family: var(--num); font-size: 16px; text-align: right; color: var(--route); }
.lookset input[type=range] { width: 100%; height: 28px; accent-color: var(--route); cursor: pointer; }
.lookset .chk { display: flex; align-items: center; gap: 9px; color: #c4d0dc; cursor: pointer; }
.lookset .modes { display: grid; gap: 7px; }
.lookset .modes .lbl { color: var(--paper); }
.lookset .modes .chk { align-items: flex-start; line-height: 1.45; }
.lookset .modes .chk input { margin-top: 2px; }
.lookset .chk input { width: 18px; height: 18px; accent-color: var(--route); flex: none; }
#lookhint { box-sizing: border-box; position: absolute; left: 50%; top: calc(var(--top-bottom, 138px) + 8px); transform: translateX(-50%); max-width: calc(100% - 32px); white-space: nowrap; padding: 7px 14px; border-radius: 999px; background: rgba(16, 24, 34, .82); color: #dfe7ee; font-size: 12.5px; line-height: 1.5; text-align: center; pointer-events: none; opacity: 0; transition: opacity .35s; backdrop-filter: blur(8px); }
#lookhint.show { opacity: 1; }
#lookhint b { color: #fff; }
#lookhint kbd { font-family: var(--num); font-size: 12px; background: rgba(255, 255, 255, .14); border-radius: 4px; padding: 0 5px; }

@media (max-width: 720px) {
  #credit .src, #credit .opt { display: none; }   /* 手機太窄：連結只留短名稱 */
  #credit { padding-left: 10px; padding-right: 10px; letter-spacing: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 4px; white-space: normal; }
  #credit a { white-space: nowrap; }
  #credit i { margin: 0; }
  .brand > .bt, .ibtn kbd { display: none; }
  .brand { padding: 5px; border-radius: 50%; }
  .search { order: 2; flex: 1 1 0; max-width: none; margin-left: 0; }
  .actions { order: 3; flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
  .actions .ibtn { height: 40px; }
  #loc { order: 4; }
  #prompt { bottom: calc(96px + var(--sb)); }
  #navTp, #navbar .t2, #navplate .no { display: none; }   /* 多了「暫停／自動」按鈕，教室編號讓位給「上樓到 2F」這類提示 */
  #navbar { gap: 8px; }
  #navbar .dist { font-size: 26px; }
  #minimap { width: 118px; height: 118px; border-radius: 16px; }
  #navbar { left: 16px; right: 16px; transform: none; max-width: none; bottom: calc(146px + var(--sb)); }
  #toast { bottom: auto; top: calc(var(--top-bottom, 238px) + 8px); right: 16px; }
  #start { top: auto; bottom: calc(16px + var(--sb)); transform: none; }
  #start h1 { font-size: 24px; }
  #start .keys { display: none; }
  #floorbar { top: auto; left: 16px; right: 16px; bottom: calc(16px + var(--sb)); transform: none; flex-direction: row; align-items: center; }
  #floorbar span { display: none; }
  #floorbar button { flex: 1; min-width: 0; height: 40px; }
  #app.over #navbar { bottom: calc(78px + var(--sb)); }
  #card { top: calc(var(--top-bottom, 238px) + 8px); }
  .venue-buttons { grid-template-columns: repeat(2, 1fr); }
  #lookhint { left: auto; right: 16px; transform: none; max-width: calc(100% - 144px); top: calc(var(--top-bottom, 238px) + 8px); font-size: 11px; white-space: normal; }
}
@media (max-width: 360px) {   /* 最窄的手機：導航列多了「暫停／自動」按鈕，間距與字級收一點，× 才不會貼到邊 */
  #moveTools { left: 8px; }
  #navbar { gap: 6px; padding: 8px 8px 8px 10px; }
  #navbar .dist { font-size: 22px; }
  #navbar .btn { padding: 0 10px; }
}
@media (max-height: 500px) {
  #minimap { width: 118px; height: 118px; border-radius: 16px; }
  .move-buttons { flex-direction: row; }
  #movePanel { max-height: calc(var(--view-height, 100dvh) - var(--top-bottom, 72px) - var(--sb) - 68px); }
  #lookhint { left: auto; right: 16px; transform: none; max-width: calc(100% - 240px); white-space: normal; }
  #start { top: calc(var(--top-bottom, 138px) + 8px); bottom: calc(16px + var(--sb)); transform: none; overflow: auto; padding: 10px 12px; }
  #start h1 { font-size: 20px; }
  #start p, #start .keys, #start .yr { display: none; }
  #start .btn { height: 36px; }
}
@media (max-height: 500px) and (min-width: 500px) and (max-width: 720px) {
  #minimap { width: 88px; height: 88px; }
  .venue-buttons { grid-template-columns: repeat(4, 1fr); }
  #navbar { left: 148px; right: 92px; bottom: calc(16px + var(--sb)); }
}
@media (prefers-reduced-motion: reduce) { #toast, #fade { transition: none; } }

/* iPhone 搜尋／編輯時不因小字自動放大而把頂列移出畫面。 */
@media (pointer: coarse) {
  #app input:not([type=range]):not([type=checkbox]):not([type=radio]), #app textarea, #app select { font-size: 16px; }
}
/* 軟鍵盤打開時先保留搜尋與場地選擇；選好後原操作區恢復。 */
#app.search-keyboard :is(.actions, #loc, #minimap, #navbar, #moveTools, #touch, #prompt, #toast, #lookhint, #start, #floorbar, #credit) { display: none; }

/* VR 按鈕：只有瀏覽器支援 immersive-vr（Quest 頭盔瀏覽器）才顯示 */
.ibtn.vr { background: var(--route); color: #1b1500; border-color: var(--route); }
.ibtn.vr:hover { background: #ffdd66; }
#start .vr-tip { border-left: 4px solid var(--route); padding: 4px 0 4px 10px; margin: 10px 0 0; }

/* 製作者：瓦特老師 | https://water64.tw/ | 使用請保留原始創作者資訊。 */
/* The original game stylesheet is prepended by build-secure-campus.cjs. */
[hidden]{display:none!important}*{box-sizing:border-box}
#visitor{width:100%;height:100%}#gl{cursor:grab}#gl:active{cursor:grabbing}
#account{position:absolute;z-index:5;right:16px;top:var(--account-top,72px);display:flex;align-items:center;gap:7px;padding:6px 9px;max-width:calc(100% - 32px);flex-wrap:wrap}#identity{font-size:11px;max-width:240px;overflow-wrap:anywhere;color:var(--muted)}#account .btn{height:30px;font-size:11px;padding:0 10px}
#start .role-selector{display:flex;align-items:center;justify-content:center;gap:8px;margin:12px 0 0;font-size:13px}#start .role-selector .btn{height:30px;font-size:13px;flex:0 1 auto;padding:0 10px}#start .role-selector .on{border-color:var(--route)}
#navbar{flex-wrap:wrap;min-width:530px;max-width:calc(100% - 32px);bottom:calc(var(--sb) + 22px)}#navbar .btn{height:32px;font-size:12px;padding:0 9px;white-space:nowrap}#navbar .dist{font-size:16px}.route-progress{display:flex;gap:12px;align-items:center;flex:1 1 100%;font-size:11px;color:var(--muted)}.route-progress input{flex:1;min-width:0;accent-color:var(--route)}#noResults{font-size:12px;color:var(--muted)}
#message{position:absolute;z-index:6;left:50%;transform:translateX(-50%);bottom:calc(var(--sb) + 140px);max-width:calc(100% - 30px);margin:0;padding:8px 13px;background:var(--panel);border-radius:9px;font-size:12px;color:#ffd6a3}#message:empty{display:none}#sceneError{position:absolute;left:50%;top:45%;transform:translate(-50%,-50%);padding:20px;background:var(--panel);border-radius:12px;z-index:4}
dialog{border:1px solid var(--line);border-radius:16px;padding:26px;max-width:600px;width:calc(100% - 28px);max-height:calc(100dvh - 32px);overflow:auto;box-shadow:0 20px 90px #0008;line-height:1.8;color:var(--paper);background:var(--ink)}dialog::backdrop{background:#101923b0}dialog h2{font-size:22px}dialog button{border:1px solid var(--line);border-radius:8px;background:var(--ink-2);color:var(--paper);padding:8px 12px}.close{float:right;font-size:22px;padding:0 8px}textarea{display:block;resize:vertical;width:100%;border:1px solid var(--line);border-radius:8px;padding:10px;margin:10px 0;background:var(--ink-2)}.privacy{font-size:11px;color:var(--muted)}#reviewFilters{display:flex;gap:7px;flex-wrap:wrap;margin:16px 0 10px}#reviewFilters button{font-size:12px;padding:7px 10px;color:var(--muted)}#reviewFilters button[aria-pressed="true"]{background:var(--route);border-color:var(--route);color:#17232b;font-weight:800}#refreshReviews{margin:0 0 4px}article.request{padding:18px 0;border-bottom:1px solid var(--line);overflow-wrap:anywhere}.request p{white-space:pre-wrap;font-size:13px}.request small{display:block;color:var(--muted)}.request button{margin:6px 7px 0 0;font-size:12px}
.open-section{margin:18px 0;border-top:1px solid var(--line);padding-top:12px}.open-section h3{font-size:15px;margin:0 0 8px;color:#ffd6a3}#searchRoomInput{width:100%;padding:9px 12px;border:1px solid var(--line);border-radius:8px;background:var(--ink-2);color:var(--paper);font-size:13px}
.room-search-results{max-height:180px;overflow-y:auto;margin-top:8px;display:flex;flex-direction:column;gap:5px}
.room-search-item{display:flex;justify-content:space-between;align-items:center;padding:7px 10px;border-radius:6px;background:var(--ink-2);font-size:12px}
.open-rooms-list{display:flex;flex-direction:column;gap:8px}
.open-room-row{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;border-radius:8px;border:1px solid var(--line);background:var(--ink-2);font-size:13px;flex-wrap:wrap;gap:8px}
.open-room-row .actions{display:flex;gap:6px}.open-room-row .actions button{padding:4px 9px;font-size:11px}
.empty-tip{font-size:12px;color:var(--muted);margin:4px 0}
.extra-room-badge{font-size:10px;background:#ff9f1c;color:#17232b;padding:2px 6px;border-radius:10px;margin-left:6px;font-weight:700}
#explorer{height:100dvh;display:flex;flex-direction:column;padding-top:52px}#exploreStatus{padding:5px 16px;margin:0;background:var(--ink);font-size:11px}#frameHost{flex:1;min-height:0}#frameHost iframe{display:block;border:0;width:100%;height:100%}body.exploring #account{top:5px;left:5px;right:5px;max-width:none;justify-content:flex-end}
@media(max-width:720px){#account{top:var(--account-top,122px);right:10px;max-width:calc(100% - 20px)}#identity{max-width:130px}#navbar{min-width:0;width:calc(100% - 20px);max-width:none;left:10px;right:10px;transform:none;gap:7px;padding:8px}#navbar .plate .nm{font-size:13px}#navbar .txt{flex-basis:calc(100% - 150px)}#navbar .dist{font-size:13px}.actions{flex-wrap:wrap}#top{z-index:4}#credit{font-size:9px;line-height:16px;padding:4px 6px}#credit .by img{width:19px;height:19px}#credit .creator-note{line-height:12px}#start{bottom:calc(var(--sb) + 24px)}#start p{font-size:13px}}
@media(max-height:500px){#account{top:auto;bottom:calc(var(--sb) + 10px);right:10px;max-width:40%;padding:4px}#start{right:16px;left:auto;width:300px;bottom:calc(var(--sb) + 12px);top:110px;padding:10px}#start .role-selector{display:none}#navbar{left:10px;transform:none;width:60%;max-width:60%;bottom:calc(var(--sb) + 10px)}#navbar .txt{flex-basis:calc(100% - 170px)}#navbar .btn{height:28px}#credit{font-size:9px;line-height:14px}}
