:root {
  --bg: #080d17; --bg2: #0d1422; --panel: #111a2b; --panel2: #172236; --glass: rgba(10, 16, 28, .62);
  --line: rgba(255, 255, 255, .08); --line2: rgba(255, 255, 255, .14);
  --text: #e9eef7; --muted: #8592a8; --dim: #5d6a80;
  --blue: #4f9dff; --red: #ff5a5f; --lock: #ffd23f; --ok: #3ddc97; --gold: #f5c451; --silver: #c3cbd8; --bronze: #d49163;
  --accent: #4fd1ff; --r: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- header */
header.top { display: flex; align-items: center; gap: 22px; padding: 0 20px; height: 54px; flex: none;
  background: rgba(8, 13, 23, .92); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; letter-spacing: .5px; }
.brand svg { color: var(--accent); width: 22px; height: 22px; }
nav { display: flex; gap: 2px; }
nav a { display: flex; align-items: center; gap: 7px; color: var(--muted); padding: 7px 13px; border-radius: 10px; transition: .15s; }
nav a:hover { color: var(--text); background: var(--panel); }
nav a.active { color: #fff; background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line2); }
.spacer { flex: 1; }
.toast { font-size: 13px; padding: 6px 12px; border-radius: 10px; background: rgba(61, 220, 151, .12); color: var(--ok); opacity: 0; transform: translateY(-4px); transition: .25s; pointer-events: none; max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: none; } .toast.err { background: rgba(255, 90, 95, .14); color: var(--red); }

/* ---------------------------------------------------------------- 控制元件 */
button, select, input { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--panel2); cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.primary { background: linear-gradient(180deg, #2aa8ff, #1478e0); border-color: transparent; font-weight: 600; box-shadow: 0 6px 18px rgba(20, 120, 224, .35); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: linear-gradient(180deg, #ff5a5f, #d63a40); border-color: transparent; font-weight: 600; }
.btn.ghost { background: none; } .btn.big { padding: 12px; font-size: 15px; width: 100%; }
.danger-t { color: var(--red); }
.ibtn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text); flex: none; }
.ibtn:hover { background: rgba(255, 255, 255, .08); }
.chip { border: 1px solid var(--line2); background: rgba(255, 255, 255, .05); border-radius: 99px; padding: 4px 10px; cursor: pointer; font-family: var(--mono); font-size: 12px; min-width: 46px; }
select, input:not([type]), input[type=number], input[type=text] { background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; outline: none; min-width: 0; }
select:focus, input:focus { border-color: var(--accent); }
.seg { display: inline-flex; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 5px 10px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel2); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 2px 8px rgba(0, 0, 0, .3); }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }
.seg svg.i { width: 16px; height: 16px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.a { background: var(--blue); box-shadow: 0 0 8px var(--blue); } .dot.b { background: var(--red); box-shadow: 0 0 8px var(--red); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch > i { width: 34px; height: 20px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line2); position: relative; transition: .2s; flex: none; }
.switch > i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + i { background: #1478e0; border-color: transparent; } .switch input:checked + i::after { left: 16px; background: #fff; }
.switch.small { font-size: 13px; color: var(--muted); }
.status { font-size: 12px; color: var(--muted); min-height: 18px; }
.row { display: flex; gap: 8px; align-items: center; }
kbd { font-family: var(--mono); }

/* ---------------------------------------------------------------- 一般頁面 */
.page { flex: 1; overflow-y: auto; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 24px 60px; }
.wrap.narrow { max-width: 680px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: .5px; flex: 1; }
.actions { display: flex; gap: 8px; align-items: center; }
h2 { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .5px; margin: 0 0 10px; display: flex; align-items: center; gap: 7px; }
h2 small { font-weight: 400; color: var(--dim); }
h2 svg.i { width: 15px; height: 15px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumb a { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; border-radius: 8px; }
.crumb a:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.crumb .sep { opacity: .4; }
.crumb svg.i { width: 16px; height: 16px; }
.prog { position: relative; height: 30px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; margin-bottom: 14px; display: flex; align-items: center; padding: 0 12px; font-size: 12px; color: var(--muted); }
.prog i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(42, 168, 255, .25), rgba(42, 168, 255, .45)); width: 0; transition: width .4s; }
.prog span { position: relative; }

/* 排行榜 */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; align-items: end; }
.pod { position: relative; background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: 18px; padding: 18px; cursor: pointer; transition: .2s; overflow: hidden; }
.pod:hover { transform: translateY(-3px); border-color: var(--line2); }
.pod::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.pod .rk { position: absolute; right: 14px; top: 10px; font: 700 44px/1 var(--mono); color: var(--c); opacity: .2; }
.pod .medal { color: var(--c); } .pod .medal svg.i { width: 26px; height: 26px; }
.pod .nm { font-size: 18px; font-weight: 700; margin: 8px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .elo { font: 700 30px/1.1 var(--mono); }
.pod .elo small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.pod.r1 { --c: var(--gold); padding: 24px 18px; } .pod.r2 { --c: var(--silver); } .pod.r3 { --c: var(--bronze); }
.wdl { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, .06); margin-top: 10px; }
.wdl i { display: block; height: 100%; } .wdl .w { background: var(--ok); } .wdl .d { background: #7a879c; } .wdl .l { background: var(--red); }
.wdl-n { display: flex; gap: 10px; font: 12px var(--mono); color: var(--muted); margin-top: 6px; }
.wdl-n b { font-weight: 600; } .wdl-n .w { color: var(--ok); } .wdl-n .l { color: var(--red); }
.board { display: flex; flex-direction: column; gap: 6px; }
.brow { display: grid; grid-template-columns: 40px minmax(120px, 1.4fr) 90px minmax(120px, 1.6fr) 70px 22px; gap: 14px; align-items: center;
  padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: .15s; }
.brow:hover { border-color: var(--line2); background: var(--panel2); }
.brow .rk { font: 700 16px var(--mono); color: var(--dim); text-align: center; }
.brow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brow .elo { font: 700 18px var(--mono); }
.brow .wr { font: 600 15px var(--mono); text-align: right; }
.brow .go { color: var(--dim); }
.brow .wdl { margin: 0; }
.board-h { display: grid; grid-template-columns: 40px minmax(120px, 1.4fr) 90px minmax(120px, 1.6fr) 70px 22px; gap: 14px; padding: 0 16px 4px; font-size: 11px; color: var(--dim); letter-spacing: .5px; }
.board-h span:nth-child(5) { text-align: right; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, .06); color: var(--muted); font-weight: 400; }
.elo-note { margin: 12px 4px 0; }
.queue { margin-top: 14px; }
.queue h2 small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.qlist li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 13px; background: rgba(255, 255, 255, .02); min-width: 0; flex-wrap: wrap; }
.qlist li .vs { color: var(--dim); font-size: 11px; }
.qlist li.run { background: rgba(42, 168, 255, .1); border: 1px solid rgba(42, 168, 255, .25); }
.qlist li.fail { background: rgba(255, 90, 95, .08); }
.empty-msg { text-align: center; color: var(--muted); padding: 50px 0; }
.empty-msg svg.i { width: 40px; height: 40px; color: var(--dim); display: block; margin: 0 auto 10px; }

/* Agent 頁 */
.ag-head { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; background: linear-gradient(135deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; margin-bottom: 20px; }
.ag-head .rk { font: 700 40px/1 var(--mono); color: var(--dim); }
.ag-head .nm { font-size: 24px; font-weight: 700; }
.ag-head .sub { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.ag-head .kpis { display: flex; gap: 24px; }
.kpi { text-align: right; } .kpi b { display: block; font: 700 24px/1.1 var(--mono); } .kpi span { font-size: 11px; color: var(--muted); }
.ag-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.mlist { display: flex; flex-direction: column; gap: 6px; }
.m { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: .15s; }
.m:hover { border-color: var(--line2); background: var(--panel2); }
.m .res { align-self: stretch; border-radius: 3px; }
.m.W .res { background: var(--ok); } .m.L .res { background: var(--red); } .m.D .res { background: #7a879c; }
.m .who { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.m .who span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m .meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font: 12px var(--mono); }
.m .meta .rs { display: inline-flex; align-items: center; gap: 4px; }
.m .meta svg.i { width: 15px; height: 15px; }
.m .score { font: 12px var(--mono); color: var(--dim); }
.m .wl { font: 700 12px var(--mono); width: 18px; text-align: center; }
.m.W .wl { color: var(--ok); } .m.L .wl { color: var(--red); } .m.D .wl { color: #9aa6b8; }
.m .play-i { color: var(--dim); } .m:hover .play-i { color: var(--accent); }
.rs.kill { color: var(--lock); } .rs.crash, .rs.collision { color: #ff8f5a; } .rs.timeout { color: var(--muted); }
.opps { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.opp { display: grid; grid-template-columns: 1fr 120px 44px; gap: 10px; align-items: center; font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
.opp:hover { border-color: var(--line2); }
.opp .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .wdl { margin: 0; }
.opp b { font: 600 13px var(--mono); text-align: right; }
.quick { display: flex; flex-direction: column; gap: 10px; }
.quick-row { display: flex; gap: 8px; align-items: center; }
.quick-row select { flex: 1; }
.quick-row b { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs { font: 700 11px var(--mono); color: var(--dim); padding: 0 4px; }

/* ---------------------------------------------------------------- 3D 劇場 */
.theater { flex: 1; min-height: 0; display: flex; }
.side { width: 300px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.side-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.side-title svg { color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.pick { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding-left: 12px; }
.pick select { border: 0; background: none; flex: 1; padding-left: 2px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); margin-top: 4px; }
.kgrp { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.kpad { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: 30px 30px; gap: 3px; }
.kpad > :nth-child(1) { grid-column: 2; } .kpad > :nth-child(2) { grid-column: 1; grid-row: 2; }
.kpad > :nth-child(3) { grid-column: 2; grid-row: 2; } .kpad > :nth-child(4) { grid-column: 3; grid-row: 2; }
.kpad.sm { grid-template-columns: repeat(3, 24px); grid-template-rows: 24px 24px; gap: 2px; }
.kpad.sm kbd { min-width: 24px; height: 24px; font-size: 11px; } .kpad.sm kbd small { display: none; }
.kgrp.span2 { grid-column: 1 / -1; }
.krow { display: flex; gap: 3px; height: 30px; align-items: center; }
.keys kbd, .keyhint kbd { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 7px; background: var(--panel2);
  border: 1px solid var(--line2); border-bottom-width: 3px; font-size: 12px; font-weight: 700; color: var(--text); line-height: 1; padding: 0 4px; }
.keys kbd small, .keyhint kbd small { font-size: 9px; color: var(--accent); font-weight: 400; margin-top: 1px; }
.rule { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); }
.rule svg { color: var(--lock); width: 16px; height: 16px; } .rule b { color: var(--text); font-family: var(--mono); font-weight: 600; } .rule i { opacity: .4; font-style: normal; }

.stage { position: relative; flex: 1; min-width: 0; min-height: 0; background: #000; overflow: hidden; }
#view { position: absolute; inset: 0; } #view canvas { display: block; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: rgba(255, 255, 255, .5); }
.empty svg.i { width: 64px; height: 64px; stroke-width: 1.2; }

/* 3D 覆蓋層 */
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.overlay.off > * { display: none !important; }
.ov-tag { position: absolute; left: 0; top: 0; margin-top: -24px; translate: -50% 0; display: flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 99px;
  background: rgba(8, 13, 23, .7); backdrop-filter: blur(6px); font-size: 12px; white-space: nowrap; border: 1px solid var(--line2); }
.ov-tag i { width: 8px; height: 8px; border-radius: 50%; }
.ov-tag[data-a="0"] i { background: var(--blue); box-shadow: 0 0 6px var(--blue); } .ov-tag[data-a="1"] i { background: var(--red); box-shadow: 0 0 6px var(--red); }
.ov-tag b { font-weight: 600; } .ov-tag span { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.ov-bore { position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 2px solid rgba(255, 255, 255, .8); border-radius: 50%;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .8)); }
.ov-bore i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fff; }
.ov-bore.lock { border-color: var(--lock); } .ov-bore.lock i { background: var(--lock); }
.ov-tgt { position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.ov-tgt svg { width: 100%; height: 100%; overflow: visible; fill: none; stroke: currentColor; filter: drop-shadow(0 0 3px rgba(0, 0, 0, .7)); }
.ov-tgt .br { stroke-width: 2.5; }
.ov-tgt .trk { stroke: rgba(255, 255, 255, .15); stroke-width: 3; }
.ov-tgt .prg { stroke: var(--lock); stroke-width: 3.5; stroke-dasharray: 100; stroke-dashoffset: 100; transform: rotate(-90deg); transform-origin: 32px 32px; transition: stroke-dashoffset .1s; }
.ov-tgt .d, .ov-edge .d { position: absolute; top: 100%; left: 50%; translate: -50% 4px; font: 600 12px var(--mono); white-space: nowrap; color: #fff; text-shadow: 0 1px 3px #000; }
.ov-tgt.lock .br { stroke: var(--lock); animation: pulse .5s infinite alternate; }
.ov-edge { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.ov-edge svg { width: 100%; height: 100%; fill: currentColor; filter: drop-shadow(0 0 6px currentColor) drop-shadow(0 1px 2px #000); }
.ov-warn { position: absolute; inset: 0; box-shadow: inset 0 0 0 0 rgba(255, 60, 60, 0); transition: box-shadow .2s; }
.ov-warn.on { box-shadow: inset 0 0 90px 10px rgba(255, 50, 50, .45); animation: warn .6s infinite alternate; }
@keyframes warn { to { box-shadow: inset 0 0 60px 4px rgba(255, 50, 50, .2); } }
@keyframes pulse { to { opacity: .45; } }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.crumb.floating { position: absolute; left: 14px; top: 14px; margin: 0; pointer-events: auto; background: var(--glass); backdrop-filter: blur(10px); padding: 4px 10px 4px 4px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); }
.board-top { position: absolute; top: 12px; left: 0; right: 0; margin: 0 auto; width: fit-content; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px;
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line2); border-radius: 18px; padding: 6px; min-width: 460px; max-width: calc(100% - 340px); }
.pc { pointer-events: auto; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 8px; border-radius: 12px; cursor: pointer; min-width: 0; transition: .2s; }
.pc.r { justify-content: flex-end; }
.pc:hover { background: rgba(255, 255, 255, .05); }
.pc.focus { background: rgba(255, 255, 255, .08); box-shadow: inset 0 -2px 0 var(--c); }
.pc[data-a="0"] { --c: var(--blue); } .pc[data-a="1"] { --c: var(--red); }
.pc .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pc .sc { font: 700 22px/1 var(--mono); color: var(--c); }
.pc .ring { width: 32px; height: 32px; flex: none; transform: rotate(-90deg); }
.pc .ring circle { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: 3; }
.pc .ring circle.p { stroke: var(--c); stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; transition: stroke-dashoffset .1s; }
.pc.att .ring circle.p { stroke: var(--lock); filter: drop-shadow(0 0 4px var(--lock)); }
.board-top .mid { text-align: center; padding: 0 12px; }
.clock { font: 700 18px var(--mono); letter-spacing: .5px; }
.live { display: inline-block; font: 700 10px var(--mono); color: #fff; background: #e5383b; padding: 1px 7px; border-radius: 99px; letter-spacing: 1px; animation: pulse .9s infinite alternate; }
.tug { grid-column: 1 / -1; display: flex; height: 3px; border-radius: 2px; overflow: hidden; margin: 2px 10px 0; background: rgba(255, 255, 255, .08); }
.tug i { display: block; height: 100%; transition: width .3s; } .tug .ta { background: var(--blue); width: 50%; } .tug .tb { background: var(--red); width: 50%; }
.tele { position: absolute; bottom: 74px; left: 14px; display: flex; gap: 4px; align-items: stretch; padding: 6px; border-radius: 14px; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); }
.tele.r { left: auto; right: 14px; flex-direction: row-reverse; }
.tele .g { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; padding: 2px 6px; }
.tele .g b { font: 700 17px/1.1 var(--mono); }
.tele .g span { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); }
.tele .g svg.i { width: 11px; height: 11px; }
.tele .g.hi b { color: var(--lock); } .tele .g.max b { color: var(--red); }
.tele .thr { width: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); position: relative; overflow: hidden; margin: 2px 4px; }
.tele .thr i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(0deg, #ff9a3c, #ffd23f); }
.tele::before { content: ""; width: 3px; border-radius: 2px; background: var(--c); }
.tele[data-a="0"] { --c: var(--blue); } .tele[data-a="1"] { --c: var(--red); }

.banner { position: absolute; left: 50%; top: 46%; translate: -50% -50%; pointer-events: auto; text-align: center; padding: 26px 40px 22px; border-radius: 22px;
  background: rgba(8, 13, 23, .78); backdrop-filter: blur(16px); border: 1px solid var(--line2); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); min-width: 300px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { scale: .85; opacity: 0; } }
.banner .tro { color: var(--c, var(--gold)); } .banner .tro svg.i { width: 40px; height: 40px; stroke-width: 1.6; filter: drop-shadow(0 0 12px currentColor); }
.banner .w { font-size: 26px; font-weight: 800; margin: 6px 0 2px; color: var(--c, #fff); }
.banner .why { display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted); font: 13px var(--mono); }
.banner .why span { display: inline-flex; align-items: center; gap: 5px; }
.banner .why svg.i { width: 15px; height: 15px; }
.banner .row { justify-content: center; margin-top: 16px; }
.keyhint { position: absolute; left: 50%; bottom: 150px; translate: -50% 0; display: flex; gap: 18px; align-items: center; padding: 10px 16px; border-radius: 16px;
  background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); font-size: 11px; color: var(--muted); transition: opacity .6s; }
.keyhint .kg { display: flex; align-items: center; gap: 4px; }
.keyhint.fade { opacity: 0; }

/* 下方控制列 */
.controls { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 8px;
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line2); border-radius: 16px; }
.controls svg.i { width: 18px; height: 18px; }
.ctime { font: 12px var(--mono); color: var(--muted); white-space: nowrap; min-width: 92px; text-align: center; }
.timeline { position: relative; flex: 1; height: 30px; cursor: pointer; touch-action: none; border-radius: 8px; background: rgba(255, 255, 255, .05); min-width: 60px; }
.timeline canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.timeline .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, .07); border-radius: 8px 0 0 8px; pointer-events: none; }
.timeline .head { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1.5px; background: #fff; border-radius: 2px; box-shadow: 0 0 8px rgba(255, 255, 255, .7); pointer-events: none; }
.timeline .tip { position: absolute; bottom: 100%; margin-bottom: 8px; translate: -50% 0; font: 11px var(--mono); background: #000c; padding: 2px 6px; border-radius: 6px; pointer-events: none; opacity: 0; transition: opacity .15s; white-space: nowrap; }
.timeline:hover .tip { opacity: 1; }
.cams { background: rgba(0, 0, 0, .2); }
.cams button { padding: 5px 8px; }
.live-mode .timeline, .live-mode #c-play, .live-mode #c-speed, .live-mode #c-acmi, .live-mode .ctime { visibility: hidden; }
.live-mode .timeline { flex: 1; }

/* ---------------------------------------------------------------- 分析頁 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cards .card { margin: 0; } .cards .v { font: 700 24px var(--mono); } .cards .k { font-size: 12px; color: var(--muted); }
.scroll { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.data td:first-child, table.data th:first-child { text-align: left; }
table.data tr:last-child td { border-bottom: 0; }
table.matrix td { text-align: center; min-width: 60px; border-radius: 6px; font-family: var(--mono); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.bars .bar-r { display: grid; grid-template-columns: 90px 1fr 40px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.bars .track { height: 10px; background: var(--panel2); border-radius: 5px; overflow: hidden; } .bars .fill { height: 100%; background: linear-gradient(90deg, #1478e0, #4fd1ff); border-radius: 5px; }
.bars span:last-child { font-family: var(--mono); text-align: right; }

/* 上傳頁 */
.drop { border: 2px dashed var(--line2); border-radius: var(--r); padding: 30px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); transition: .2s; }
.drop .big-i svg.i { width: 36px; height: 36px; color: var(--accent); stroke-width: 1.6; }
.drop.over { border-color: var(--accent); background: rgba(79, 209, 255, .06); }
.filelist { list-style: none; margin: 12px 0; padding: 0; font: 12px var(--mono); color: var(--muted); max-height: 160px; overflow: auto; }
.filelist:empty { display: none; }
.card .row + .status { margin-top: 10px; }
.spec summary { cursor: pointer; color: var(--muted); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12px; overflow-x: auto; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------------- 窄螢幕 */
@media (max-width: 900px) {
  header.top { gap: 10px; padding: 0 12px; }
  nav a span:last-child, .brand b { display: none; }
  .theater { flex-direction: column; }
  .side { width: auto; max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .keys, .rule { display: none; }
  .board-top { min-width: 0; max-width: calc(100% - 24px); top: 58px; grid-template-columns: auto auto auto; }
  .pc .nm { display: none; }
  .controls { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 4px; justify-content: space-between; }
  .cams button { padding: 5px 6px; }
  .timeline { order: -1; flex: 1 0 100%; }
  .live-mode .timeline { display: none; }
  .keyhint { display: none; }
  .tele { display: none; }
  .ctime { display: none; }
  .podium { grid-template-columns: 1fr; }
  .brow, .board-h { grid-template-columns: 30px 1fr 60px 56px 16px; }
  .brow .wdl, .board-h span:nth-child(4) { display: none; }
  .ag-grid { grid-template-columns: minmax(0, 1fr); }
  .ag-head { grid-template-columns: 1fr; }
  .ag-head .rk { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* 按住的按鍵亮起 */
.keys kbd.on, .keyhint kbd.on { background: var(--accent); color: #04121c; border-color: var(--accent); translate: 0 2px; border-bottom-width: 1px; box-shadow: 0 0 12px rgba(79, 209, 255, .6); }
.keys kbd.on small, .keyhint kbd.on small { color: #04121c; }

/* 對打中: 全螢幕沉浸 */
body.playing header.top, body.playing .side { display: none !important; }
.exit-btn { position: absolute; left: 14px; top: 14px; pointer-events: auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  color: var(--text); background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line2); }
.exit-btn:hover { color: var(--red); border-color: var(--red); }

/* 雙人房間 */
.duel-box { display: flex; flex-direction: column; gap: 12px; }
.duel-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); }
.or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.code-in { text-align: center; font: 700 22px var(--mono); letter-spacing: 8px; text-transform: uppercase; padding: 10px; }
.code-in::placeholder { font: 14px -apple-system, "PingFang TC", sans-serif; letter-spacing: 1px; color: var(--dim); }
.room-code { text-align: center; font: 800 44px/1.1 var(--mono); letter-spacing: 10px; padding: 18px 0 18px 10px; border-radius: var(--r);
  background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line2); color: var(--accent); text-shadow: 0 0 24px rgba(79, 209, 255, .4); }
.waiting { display: flex; justify-content: center; gap: 8px; padding: 6px 0; }
.waiting i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: bounce 1s infinite ease-in-out; }
.waiting i:nth-child(2) { animation-delay: .15s; } .waiting i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .25; scale: .7; } 40% { opacity: 1; scale: 1; } }
.keyhint .kpad { display: inline-grid; }

/* 對手統整與展開回放 */
.opp-group { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.opp-group summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 14px; cursor: pointer; }
.opp-group summary::before { content: '▸'; grid-column: 2; grid-row: 1; text-align: right; }
.opp-group[open] summary::before { content: '▾'; }
.opp-group .n { overflow-wrap: anywhere; font-weight: 600; }
.opp-record { font: 12px var(--mono); color: var(--muted); }
.opp-group summary b { text-align: right; grid-column: 2; grid-row: 2; }
.opp-group .wdl { grid-column: 1 / -1; margin: 0; }
.opp-matches { padding: 0 12px 12px; }
@media (max-width: 700px) {
  .opp-matches .m { grid-template-columns: 5px 1fr; }
  .opp-matches .m .meta { grid-column: 2; flex-wrap: wrap; gap: 8px; }
  .ag-grid .page-head { flex-wrap: wrap; gap: 8px; }
}

.ag-grid > div, .quick-row select { min-width: 0; }
#ag-scope { max-width: 100%; }
.opp-record { min-width: 0; overflow-wrap: anywhere; }
.ag-head .nm { overflow-wrap: anywhere; }
