/* 視訊對戰間：沿用 VG卡讀的米紙底、墨色字與桃紅主色；視訊區用深色底，讓卡面更清楚。 */
:root {
  --ink: #10111b;
  --ink-soft: #515367;
  --paper: #f5f1e8;
  --panel: #fffdf8;
  --line: #d8d2c5;
  --accent: #e33372;
  --accent-dark: #bd1954;
  --red: #d8344a;
  --blue: #3e5ff0;
  --stage: #12131c;
  --shadow: 0 18px 50px rgba(24, 20, 34, .09);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 82% 5%, rgba(227, 51, 114, .12), transparent 28rem), var(--paper);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
.bt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bt-red { color: var(--red); }
.bt-blue { color: var(--blue); }

/* 頁首 */
.bt-header { display: flex; align-items: center; gap: .8rem; padding: .6rem clamp(14px, 4vw, 40px); border-bottom: 1px solid rgba(16, 17, 27, .13); background: rgba(245, 241, 232, .9); }
.bt-logo { height: 32px; width: auto; display: block; }
.bt-title { font-weight: 900; font-size: 1rem; letter-spacing: .04em; white-space: nowrap; }
.bt-title small { margin-left: .35rem; padding: .05rem .4rem; border-radius: 99px; background: var(--ink); color: #fff; font-size: .62rem; vertical-align: middle; }
.bt-back { margin-left: auto; color: var(--ink-soft); font-size: .85rem; text-decoration: none; white-space: nowrap; }
.bt-back:hover { color: var(--accent-dark); }

/* 按鈕 */
.bt-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: 0 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font: 700 .95rem/1.2 inherit; font-family: inherit; cursor: pointer; }
.bt-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.bt-btn:disabled { opacity: .45; cursor: not-allowed; }
.bt-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.bt-btn--primary { border-color: var(--ink); background: var(--ink); color: #fff; }
.bt-btn--primary:hover:not(:disabled) { border-color: var(--accent); background: var(--accent); color: #fff; }
.bt-btn--ghost { background: transparent; }
.bt-btn--danger { border-color: var(--accent-dark); color: var(--accent-dark); }
.bt-btn--danger:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }
.bt-btn--small { min-height: 34px; padding: 0 .7rem; font-size: .8rem; }
.bt-wide { width: 100%; }

/* 大廳 */
.bt-lobby { width: min(100%, 820px); margin: 0 auto; padding: clamp(20px, 5vw, 48px) 16px 48px; }
.bt-lobby-intro { text-align: center; margin-bottom: 1.6rem; }
.bt-lobby-intro h1 { margin: 0; font-family: Georgia, "Noto Serif TC", serif; font-size: clamp(1.6rem, 6vw, 2.4rem); line-height: 1.3; }
.bt-lobby-intro p { margin: .7rem auto 0; max-width: 34rem; color: var(--ink-soft); font-size: .92rem; line-height: 1.75; }
.bt-lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.bt-panel { display: flex; flex-direction: column; gap: .9rem; min-width: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.bt-panel h2 { margin: 0; font-size: 1.15rem; }
.bt-panel .bt-btn { margin-top: auto; }
.bt-choice { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; border: 0; }
.bt-choice legend { margin-bottom: .45rem; color: var(--ink-soft); font-size: .82rem; font-weight: 700; }
.bt-choice label { flex: 1 1 5.5rem; }
.bt-choice input { position: absolute; opacity: 0; pointer-events: none; }
.bt-choice span { display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; font-size: .9rem; cursor: pointer; }
.bt-choice input:checked + span { border-color: var(--accent); background: rgba(227, 51, 114, .09); color: var(--accent-dark); }
.bt-choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.bt-field { display: flex; flex-direction: column; gap: .4rem; color: var(--ink-soft); font-size: .82rem; font-weight: 700; }
.bt-field input { width: 100%; min-height: 48px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: 800 1.35rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .25em; text-transform: uppercase; }
.bt-field input::placeholder { color: #b3ab9e; font-size: 1rem; font-weight: 600; letter-spacing: .08em; text-transform: none; }
.bt-field input:focus { outline: 3px solid rgba(227, 51, 114, .35); border-color: var(--accent); }
.bt-hint { margin: 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.6; }
.bt-message { min-height: 1.4em; margin: 1rem 0 0; text-align: center; color: var(--accent-dark); font-size: .9rem; font-weight: 700; }
.bt-note { margin: .4rem 0 0; text-align: center; color: var(--ink-soft); font-size: .78rem; line-height: 1.6; }

/* 對戰間：桌機左視訊右側欄，手機上下排列 */
.bt-room { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; width: 100%; padding: 14px clamp(10px, 2vw, 20px) 20px; }
.bt-stage { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bt-video { position: relative; overflow: hidden; border-radius: 16px; background: var(--stage); }
.bt-video video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--stage); }
/* 轉向：以中心點旋轉（寬高由 battle.js 依容器計算） */
.bt-video video[data-rotate="90"], .bt-video video[data-rotate="180"], .bt-video video[data-rotate="270"],
.bt-overlay[data-rotate="90"], .bt-overlay[data-rotate="180"], .bt-overlay[data-rotate="270"] { position: absolute; left: 50%; top: 50%; max-width: none; }
.bt-video video[data-rotate="180"], .bt-overlay[data-rotate="180"] { width: 100%; height: 100%; }
/* 卡片辨識：點對手畫面辨識，疊加畫布畫出偵測到的卡框 */
#remoteVideo { cursor: crosshair; }
.bt-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.bt-search-tip { margin: 0; color: var(--ink-soft); font-size: .72rem; }
.bt-candidates { display: flex; flex-direction: column; gap: .35rem; padding: .55rem; border-radius: 12px; background: var(--paper); cursor: default; }
.bt-candidates-title { margin: 0; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.bt-candidates-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; }
.bt-candidate { min-width: 0; padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.bt-candidate img { display: block; width: 100%; aspect-ratio: 160 / 233; object-fit: cover; border-radius: 4px; background: #ece6dc; }
.bt-candidate[aria-pressed="true"] { border-color: var(--accent); }
.bt-video--remote { aspect-ratio: 16 / 10; max-height: calc(100dvh - 160px); min-height: 220px; }
.bt-video--local { position: absolute; right: 12px; top: 12px; width: clamp(110px, 22%, 240px); aspect-ratio: 4 / 3; border: 2px solid rgba(255, 255, 255, .7); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.bt-tag { position: absolute; left: 10px; bottom: 10px; padding: .15rem .55rem; border-radius: 99px; background: rgba(16, 17, 27, .72); color: #fff; font-size: .75rem; font-weight: 800; }
.bt-tag[data-color="red"] { background: var(--red); }
.bt-tag[data-color="blue"] { background: var(--blue); }
.bt-video--local .bt-tag { left: 6px; bottom: 6px; font-size: .68rem; }
.bt-stage-notice { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1rem; text-align: center; color: #eceaf4; background: rgba(18, 19, 28, .78); }
.bt-stage-notice p { margin: 0; }
.bt-stage-notice #stageNoticeText { font-size: 1.05rem; font-weight: 700; }
.bt-stage-code { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; color: #b9b6c9; font-size: .85rem; }
.bt-stage-code b { color: #fff; font: 800 1.6rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .2em; }
.bt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.bt-media-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.bt-media-bar .bt-btn[aria-pressed="false"] { border-color: var(--accent); color: var(--accent-dark); }
.bt-camera-select { display: flex; align-items: center; gap: .4rem; flex: 1 1 12rem; min-width: 0; color: var(--ink-soft); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.bt-camera-select select { flex: 1; width: 100%; min-width: 0; min-height: 34px; padding: 0 .5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font: inherit; font-size: .8rem; }

/* 側邊欄 */
.bt-side { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.bt-side-status { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.bt-room-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; font-size: .82rem; color: var(--ink-soft); }
.bt-room-line b { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; }
.bt-conn { padding: .1rem .55rem; border-radius: 99px; background: #eee8dc; font-size: .72rem; font-weight: 800; }
.bt-conn[data-state="ok"] { background: #e2f5e7; color: #1e7a3c; }
.bt-conn[data-state="bad"] { background: #fbe4ea; color: var(--accent-dark); }
.bt-first { margin: 0; font-size: 1.05rem; font-weight: 900; text-align: center; }
.bt-turn { display: flex; align-items: baseline; justify-content: center; gap: .45rem; padding: .5rem; border-radius: 12px; background: var(--paper); }
.bt-turn-label { color: var(--ink-soft); font-size: .8rem; font-weight: 700; }
.bt-turn b { font: 900 2rem/1 Georgia, serif; }
.bt-turn-owner { font-size: .85rem; font-weight: 800; }
.bt-clocks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.bt-clock { display: flex; flex-direction: column; align-items: center; gap: .15rem; min-width: 0; padding: .5rem .2rem; border: 1px solid var(--line); border-radius: 10px; }
.bt-clock span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: .7rem; font-weight: 700; }
.bt-clock b { font: 800 clamp(.95rem, 3.6vw, 1.15rem)/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.bt-clock[data-color="red"] b, .bt-clock[data-color="red"] span { color: var(--red); }
.bt-clock[data-color="blue"] b, .bt-clock[data-color="blue"] span { color: var(--blue); }
.bt-clock[data-active="true"] { border-width: 2px; border-color: currentColor; background: rgba(227, 51, 114, .05); }
.bt-clock[data-color="red"][data-active="true"] { color: var(--red); }
.bt-clock[data-color="blue"][data-active="true"] { color: var(--blue); }
.bt-pause { margin: -.3rem 0 0; text-align: center; color: var(--accent-dark); font-size: .78rem; font-weight: 700; }
.bt-hand { display: flex; align-items: baseline; justify-content: center; gap: .35rem; color: var(--ink-soft); font-size: .85rem; font-weight: 700; }
.bt-hand b { color: var(--ink); font: 900 1.6rem/1 Georgia, serif; }

/* 卡名搜尋 */
.bt-search { display: flex; flex-direction: column; gap: .4rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.bt-search-label { font-size: .85rem; font-weight: 800; }
.bt-search input { width: 100%; min-height: 42px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.bt-search input:focus { outline: 3px solid rgba(227, 51, 114, .3); border-color: var(--accent); }
.bt-search-status { margin: 0; color: var(--ink-soft); font-size: .75rem; }
.bt-search-status:empty { display: none; }
.bt-results { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.bt-results li + li { border-top: 1px solid #efe9de; }
.bt-result { display: flex; align-items: center; gap: .6rem; width: 100%; min-width: 0; padding: .4rem .2rem; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bt-result:hover, .bt-result:focus-visible { background: var(--paper); outline: none; }
.bt-result img { width: 34px; height: 50px; flex: none; border-radius: 3px; object-fit: cover; background: #ece6dc; }
.bt-result-text { display: flex; flex-direction: column; min-width: 0; }
.bt-result-name { font-size: .86rem; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.bt-result-meta { color: var(--ink-soft); font: 600 .7rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }

/* 卡效預覽：蓋住側邊欄 */
.bt-preview { position: absolute; inset: 0; z-index: 5; overflow-y: auto; border-radius: 16px; background: var(--panel); cursor: pointer; }
.bt-preview-inner { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.bt-preview-image { display: block; width: min(100%, 300px); height: auto; aspect-ratio: 300 / 438; margin: 0 auto; border-radius: 12px; object-fit: cover; background: #ece6dc; box-shadow: 0 12px 30px rgba(0, 0, 0, .2); }
.bt-preview-head h2 { margin: 0; font-size: 1.1rem; line-height: 1.4; overflow-wrap: anywhere; }
.bt-preview-meta { margin: .2rem 0 0; color: var(--ink-soft); font-size: .75rem; overflow-wrap: anywhere; }
.bt-preview-effect { color: var(--ink); font-size: .9rem; line-height: 1.75; overflow-wrap: anywhere; }
.bt-preview-effect h3, .bt-preview-effect h4 { margin: 0 0 6px; font-size: .9rem; line-height: 1.55; }
.bt-preview-effect p { margin: 0 0 8px; }
.bt-preview-effect ul { margin: 6px 0 0; padding-left: 1.2rem; }
.bt-preview-close { margin: 0; text-align: center; color: var(--ink-soft); font-size: .72rem; }

/* 選手牌數 */
.bt-dialog { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(16, 17, 27, .55); }
.bt-dialog-box { display: flex; flex-direction: column; gap: .8rem; width: min(100%, 420px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 1.2rem; border-radius: 16px; background: var(--panel); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.bt-dialog-box h2 { margin: 0; font-size: 1.1rem; }
.bt-hand-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.bt-hand-grid button { min-height: 46px; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: 800 1.05rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; cursor: pointer; }
.bt-hand-grid button:hover, .bt-hand-grid button:focus-visible { border-color: var(--accent); background: var(--accent); color: #fff; outline: none; }

/* 帶牌組進場 */
.bt-deck-lobby { margin: 0 0 1rem; gap: .5rem; }
.bt-decks { display: flex; flex-direction: column; gap: .45rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.bt-deck-row { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; min-width: 0; font-size: .82rem; }
.bt-deck-label { flex: none; color: var(--ink-soft); font-weight: 700; }
.bt-deck-label small { font-weight: 400; }
.bt-deck-name { flex: 1 1 8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-deck-actions { display: flex; gap: .35rem; margin-left: auto; }
.bt-deck-sub { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.bt-deck-sub h3 { margin: 0; font-size: .9rem; }
.bt-deck-list { display: flex; flex-direction: column; gap: .35rem; max-height: 40dvh; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.bt-deck-list:empty { display: none; }
.bt-deck-item { width: 100%; min-height: 40px; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: .88rem; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.bt-deck-item:hover, .bt-deck-item:focus-visible { border-color: var(--accent); outline: none; }
.bt-deck-item[aria-current="true"] { border-color: var(--accent); background: #fff1f6; }
.bt-deck-code { display: flex; gap: .4rem; min-width: 0; }
.bt-deck-code input { flex: 1; min-width: 0; min-height: 34px; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 16px; }
.bt-deck-message:empty { display: none; }
.bt-deck-suggest { margin: 0; padding: .45rem .65rem; border-left: 3px solid var(--accent); border-radius: 8px; background: #fff1f6; color: var(--ink); font-size: .8rem; line-height: 1.6; }
.bt-deck-suggest[hidden] { display: none; }
.bt-recog { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink-soft); font-size: .8rem; line-height: 1.5; }
.bt-recog span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bt-recog button[hidden] { display: none; }
.bt-recog[data-state="ready"] { border-color: #9fd6b0; background: #f1fbf4; color: #1f6b3a; }
.bt-recog[data-state="failed"] { border-color: var(--accent); background: #fff1f6; color: var(--accent-dark); font-weight: 700; }
.bt-deck-message { color: var(--accent-dark); font-weight: 700; }

.bt-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; max-width: calc(100% - 32px); padding: .6rem 1rem; border-radius: 12px; background: var(--ink); color: #fff; font-size: .85rem; transform: translateX(-50%); box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .bt-room { grid-template-columns: minmax(0, 1fr); padding: 10px 16px 20px; }
  .bt-video--remote { aspect-ratio: 4 / 3; min-height: 0; max-height: none; }
  .bt-video--local { width: 32%; right: 8px; top: 8px; }
  /* 手機版卡效預覽改為底部彈出，不必捲到側邊欄 */
  .bt-preview { position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 82dvh; border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); box-shadow: 0 -18px 50px rgba(0, 0, 0, .25); }
  .bt-preview-image { width: min(62%, 240px); }
}
@media (max-width: 420px) {
  .bt-title small, .bt-back { display: none; }
  .bt-hand-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.bt-netstats { position: absolute; left: 8px; top: 40px; z-index: 3; margin: 0; padding: 4px 8px; max-width: calc(100% - 16px); border-radius: 8px; background: rgba(0, 0, 0, .55); color: #fff; font: 11px/1.45 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }
/* 指出模式與最近辨識 */
.bt-point-mode[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
body.bt-pointing #remoteVideo, body.bt-pointing #localVideo { cursor: pointer; }
.bt-not-these { align-self: stretch; }
.bt-recent { display: flex; flex-direction: column; gap: .35rem; }
.bt-recent-title { margin: 0; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.bt-recent-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }
.bt-recent-card { min-width: 0; padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; }
.bt-recent-card:hover, .bt-recent-card:focus-visible { border-color: var(--accent); }
.bt-recent-card img { display: block; width: 100%; aspect-ratio: 160 / 233; object-fit: cover; border-radius: 4px; background: #ece6dc; }
/* 牌組側欄：和對戰資訊切換顯示，右緣是快速導覽條（拖動時浮出縮圖，跳到該卡並展開效果） */
.bt-deck-toggle { position: absolute; right: 12px; bottom: 12px; z-index: 4; }
.bt-deck-toggle[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.bt-side[data-view="deck"] > .bt-side-status { display: none; }
.bt-dd { display: flex; flex-direction: column; gap: .5rem; padding: .8rem; height: min(calc(100dvh - 110px), 820px); }
.bt-dd-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.bt-dd-tabs { display: flex; gap: .35rem; min-width: 0; }
.bt-dd-tab { padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); color: var(--ink-soft); font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.bt-dd-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.bt-dd-title { margin: 0; color: var(--ink-soft); font-size: .78rem; overflow-wrap: anywhere; }
.bt-dd-body { position: relative; flex: 1; min-height: 0; }
.bt-dd-list { height: 100%; overflow-y: auto; padding-right: 22px; overscroll-behavior: contain; }
.bt-dd-group { margin: .6rem 0 .3rem; color: var(--ink-soft); font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.bt-dd-group:first-child { margin-top: 0; }
.bt-dd-card { margin-bottom: .35rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bt-dd-card.is-open { border-color: #a7783f; }
.bt-dd-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: .55rem; align-items: center; width: 100%; padding: .35rem .45rem; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bt-dd-row img { display: block; width: 34px; aspect-ratio: 160 / 233; object-fit: cover; border-radius: 3px; background: #ece6dc; }
.bt-dd-name { display: block; overflow: hidden; color: var(--ink); font-size: .8rem; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.bt-dd-meta { display: block; color: var(--ink-soft); font-size: .7rem; }
.bt-dd-count { color: var(--ink-soft); font-size: .78rem; font-weight: 800; }
.bt-dd-effect { padding: .1rem .7rem .7rem; font-size: .8rem; line-height: 1.65; overflow-wrap: anywhere; }
.bt-dd-effect img.bt-dd-big { float: left; width: 96px; margin: .2rem .6rem .3rem 0; border-radius: 5px; }
.bt-dd-effect::after { content: ""; display: block; clear: both; }
.bt-dd-empty { margin: .5rem 0; color: var(--ink-soft); font-size: .82rem; }
.bt-dd-nav { position: absolute; top: 0; right: 0; bottom: 0; width: 18px; }
.bt-dd-nav-track { position: absolute; inset: 4px 5px; border-radius: 99px; background: #e7dccb; cursor: pointer; touch-action: none; }
.bt-dd-nav-track:focus-visible { outline: 2px solid #a7783f; outline-offset: 2px; }
.bt-dd-nav-thumb { position: absolute; left: 50%; width: 16px; height: 16px; border-radius: 50%; background: #a7783f; transform: translate(-50%, -50%); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); pointer-events: none; }
.bt-dd-nav-preview { position: absolute; right: 24px; width: 84px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); text-align: center; opacity: 0; transform: translateY(-50%); transition: opacity .15s; pointer-events: none; }
.bt-dd-nav.is-active .bt-dd-nav-preview { opacity: 1; }
.bt-dd-nav-preview img { display: block; width: 100%; aspect-ratio: 160 / 233; object-fit: cover; border-radius: 5px; }
.bt-dd-nav-preview span { display: block; margin-top: 3px; color: var(--ink-soft); font-size: .66rem; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .bt-dd { position: fixed; inset: auto 0 0 0; z-index: 35; height: 82dvh; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; background: var(--panel); box-shadow: 0 -18px 50px rgba(0, 0, 0, .25); }
  .bt-side[data-view="deck"] > .bt-side-status { display: flex; }
}
@media (prefers-reduced-motion: reduce) { .bt-dd-nav-preview { transition: none; } }

/* 大廳「使用前須知」：四張附示意圖的提示卡，手機版單欄 */
.bt-tips { margin: 0 0 1rem; padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.bt-tips-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .8rem; font-size: 1.05rem; }
.bt-tips-title::after { content: "Beta"; padding: .1rem .5rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .04em; }
.bt-tips-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: .75rem; margin: 0; padding: 0; list-style: none; }
.bt-tip { display: flex; align-items: center; gap: .8rem; min-width: 0; padding: .6rem; border-radius: 12px; background: var(--paper); }
.bt-tip-art { flex: 0 0 auto; width: 104px; height: auto; }
.bt-tip b { display: block; font-size: .92rem; line-height: 1.4; }
.bt-tip p { margin: .2rem 0 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.6; }
@media (max-width: 420px) { .bt-tip-art { width: 84px; } }

/* 對手畫面可按住拖曳框選卡片：觸控時不讓頁面跟著捲動 */
#remoteVideo { touch-action: none; }

/* 大廳登入提示（視訊對戰限會員） */
.bt-login-gate { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem 1rem; margin: 0 0 1rem; border-color: var(--accent); background: #fff1f6; }
.bt-login-gate b { font-size: 1rem; }
.bt-login-gate .bt-hint { margin-top: .25rem; }
.bt-login-gate .bt-btn { margin-top: 0; flex: 0 0 auto; text-decoration: none; }
.bt-login-status { margin: 0 0 .8rem; text-align: right; color: var(--ink-soft); font-size: .8rem; }
.bt-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 網路狀況提示：對手畫面左下角（右下角是「牌組 ▸」），不擋點擊 */
.bt-net-hint { position: absolute; left: 8px; bottom: 8px; z-index: 3; display: flex; flex-direction: column; gap: .3rem; max-width: min(28rem, calc(100% - 7.5rem)); padding: .45rem .65rem; border-radius: 10px; background: rgba(0, 0, 0, .72); color: #fff; font-size: .78rem; line-height: 1.5; pointer-events: none; }
.bt-net-hint p { margin: 0; }
.bt-net-hint-mine { color: #ffd27a; font-weight: 700; }
@media (max-width: 520px) { .bt-net-hint { max-width: calc(100% - 6.5rem); font-size: .7rem; padding: .35rem .5rem; } }

/* 截圖模式：對手網路極差時，最新一張截圖疊在視訊位置（跟著轉向，不擋點擊辨識） */
.bt-still { object-fit: contain; background: var(--stage); }

/* 狀態燈（對手畫面左上角）：辨識元件、卡圖、網路；點一下看說明 */
.bt-lights { position: absolute; left: 8px; top: 8px; z-index: 4; display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 0; border-radius: 999px; background: rgba(0, 0, 0, .55); cursor: pointer; }
.bt-lights:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.bt-light { display: inline-block; flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: #4a4c5c; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); transition: background .3s, box-shadow .3s; }
.bt-light[data-state="on"] { background: #3ddc84; box-shadow: 0 0 8px rgba(61, 220, 132, .85); }
.bt-light[data-state="bad"] { background: #ff5a6e; box-shadow: 0 0 8px rgba(255, 90, 110, .85); }
.bt-lights-legend { display: flex; flex-direction: column; gap: .7rem; margin: 0; padding: 0; list-style: none; }
.bt-lights-legend li { display: flex; gap: .6rem; align-items: flex-start; }
.bt-lights-legend .bt-light { margin-top: .3rem; }
.bt-lights-legend b { font-size: .92rem; }
.bt-lights-legend p { margin: .15rem 0 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.6; }
.bt-lights-now-title { margin: .2rem 0 0; font-size: .9rem; }
.bt-lights-now { margin: 0; padding-left: 1.1rem; color: var(--ink); font-size: .8rem; line-height: 1.7; }

/* 牌組切換與卡片辨識狀態：視訊下方、媒體按鈕底下；桌機左右並排，窄畫面上下排 */
.bt-stage-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; align-items: start; }
@media (max-width: 700px) { .bt-stage-tools { grid-template-columns: minmax(0, 1fr); } }

/* 對手能量（和對手手牌同一列）與我的能量調整 */
.bt-hand-sep { width: 1px; height: 1.1rem; margin: 0 .35rem; align-self: center; background: var(--line); }
.bt-energy { display: flex; flex-direction: column; gap: .45rem; }
.bt-energy-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--ink-soft); font-size: .85rem; font-weight: 700; }
.bt-energy-head b { color: var(--ink); font: 900 1.25rem/1 Georgia, serif; }
.bt-energy-toggles { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: .25rem; }
.bt-energy-toggle { min-width: 0; min-height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink-soft); font: 800 .85rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.bt-energy-toggle[aria-pressed="true"] { border-color: #e0a400; background: #ffc928; color: #3a2a00; box-shadow: 0 0 8px rgba(255, 201, 40, .55); }
.bt-energy-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 420px) { .bt-energy-toggles { grid-template-columns: repeat(5, minmax(0, 1fr)); } .bt-energy-toggle { min-height: 40px; } }

/* 教學：要介紹的地方框起來、其餘變暗，旁邊顯示說明卡 */
.bt-tour { position: fixed; inset: 0; z-index: 80; }
.bt-tour-spot { position: fixed; border: 2px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(16, 17, 27, .66); pointer-events: none; transition: left .25s, top .25s, width .25s, height .25s; }
.bt-tour-spot[hidden] { display: block !important; left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; border: 0; }
.bt-tour-card { position: fixed; width: min(340px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: .45rem; padding: 1rem 1.05rem .9rem; border-radius: 14px; background: var(--panel); color: var(--ink); box-shadow: 0 18px 50px rgba(0, 0, 0, .35); transition: left .25s, top .25s; }
.bt-tour-step { margin: 0; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.bt-tour-title { margin: 0; font-size: 1.05rem; }
.bt-tour-text { margin: 0; color: var(--ink-soft); font-size: .86rem; line-height: 1.7; }
.bt-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .3rem; }
.bt-tour-nav { display: flex; gap: .4rem; }
@media (prefers-reduced-motion: reduce) { .bt-tour-spot, .bt-tour-card { transition: none; } }
/* 大廳攝影機測試 */
.bt-camtest { margin: 0 0 1rem; gap: .7rem; }
.bt-camtest-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.bt-camtest-head h2 { margin: 0 auto 0 0; font-size: 1rem; }
.bt-camtest-body { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.bt-camtest-view { aspect-ratio: 16 / 9; }
.bt-camtest-guide { position: absolute; inset: 7% 5%; display: flex; align-items: flex-end; justify-content: center; border: 2px dashed rgba(255, 255, 255, .7); border-radius: 10px; pointer-events: none; }
.bt-camtest-guide span { margin-bottom: 8px; padding: .15rem .6rem; border-radius: 99px; background: rgba(255, 255, 255, .88); color: var(--ink); font-size: .72rem; font-weight: 700; }
.bt-camtest-tag, .bt-camtest-info { position: absolute; padding: .12rem .55rem; border-radius: 99px; background: rgba(16, 17, 27, .72); color: #fff; font-size: .7rem; font-weight: 700; }
.bt-camtest-tag { left: 8px; top: 8px; }
.bt-camtest-info { right: 8px; bottom: 8px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.bt-camtest-info:empty { display: none; }
.bt-camtest-controls { display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.bt-camtest-field { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--ink-soft); font-weight: 700; }
.bt-camtest-field select { width: 100%; min-width: 0; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-weight: 400; }
.bt-camtest-buttons { display: flex; flex-wrap: wrap; gap: .4rem; }
#camTestGuideToggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-dark); }
.bt-camtest-meter { height: 8px; border-radius: 99px; background: #ece6dc; overflow: hidden; }
.bt-camtest-meter i { display: block; width: 0; height: 100%; background: #2a9d62; transition: width .08s linear; }
.bt-camtest-status { margin: 0; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.bt-camtest-status[data-state="ok"] { color: #2a9d62; }
.bt-camtest-status[data-state="warn"] { color: #b7791f; }
.bt-camtest-status[data-state="bad"] { color: var(--red); }
@media (max-width: 720px) { .bt-camtest-body { grid-template-columns: minmax(0, 1fr); } }
