/* =========================================================================
   VideoDuel — 蓝色 HUD 主题（纯 CSS 计算生成，无图片素材）
   ========================================================================= */
:root {
  --bg: #040a16;
  --bg-2: #071226;
  --panel: rgba(9, 22, 46, .88);
  --panel-2: rgba(14, 34, 68, .9);
  --line: rgba(84, 178, 255, .18);
  --line-strong: rgba(96, 196, 255, .42);
  --text: #dcebff;
  --muted: #7f9dc7;
  --dim: #4f6b92;
  --accent: #3fd8ff;
  --accent-2: #0a6cff;
  --accent-ink: #021019;
  --coral: #ff7a5c;
  --gold: #ffd166;
  --danger: #ff5f7a;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --shadow: 0 20px 60px rgba(0, 6, 20, .7);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dock-h: 78px;
  --glow: 0 0 18px rgba(63, 216, 255, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 背景：网格 + 光晕 ---------- */
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 45% at 18% 0%, rgba(24, 108, 255, .28), transparent 70%),
    radial-gradient(50% 40% at 88% 8%, rgba(63, 216, 255, .16), transparent 70%),
    radial-gradient(70% 60% at 50% 110%, rgba(10, 60, 160, .35), transparent 70%);
}
.bg-glow::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(70, 160, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 160, 255, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(75% 60% at 50% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(75% 60% at 50% 35%, #000 30%, transparent 100%);
}

#app { position: relative; height: 100dvh; z-index: 1; }

/* ---------- 屏幕切换动画 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  opacity: 0;
}
.screen.is-active { display: flex; opacity: 1; animation: screenIn .42s var(--ease) both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(22px) scale(.985); filter: blur(3px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tileIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================================
   HUD 通用件
   ========================================================================= */

/* 四角括号 */
.hud-corners::after,
.gate-wrap::after,
.tile::after,
.preview-stage::after {
  content: ""; position: absolute; inset: 8px; pointer-events: none; z-index: 2;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left top / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 1px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 12px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 1px 12px no-repeat;
  opacity: .55;
}

/* ---------- 按钮 ---------- */
.btn {
  position: relative;
  isolation: isolate;
  height: 46px; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; letter-spacing: .5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background:
    repeating-linear-gradient(0deg, rgba(120, 200, 255, .05) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, rgba(24, 60, 124, .85), rgba(6, 18, 40, .95));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(150, 220, 255, .12), 0 4px 18px rgba(0, 8, 24, .5);
  transition: border-color .18s, box-shadow .22s, transform .1s, background .22s;
  overflow: hidden;
}
.btn::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(63, 216, 255, .18), transparent 55%);
  opacity: 0; transition: opacity .2s;
}
.btn:hover { border-color: var(--accent); box-shadow: inset 0 1px 0 rgba(180, 235, 255, .25), 0 0 20px rgba(63, 216, 255, .35); }
.btn:hover::before { opacity: 1; }
.btn:active { transform: translateY(1px); box-shadow: inset 0 2px 10px rgba(0, 0, 0, .5), 0 0 12px rgba(63, 216, 255, .25); }
.btn[disabled] { opacity: .42; pointer-events: none; }

.btn-primary {
  color: #eaf9ff;
  border-color: transparent;
  /* 外层亮蓝 = 描边色；内层 ::before 盖住中间，斜边自然连上 */
  background: linear-gradient(180deg, #8df0ff, #2a8bff 45%, #1350c8);
  text-shadow: 0 0 10px rgba(140, 225, 255, .55);
  box-shadow: none;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  filter: drop-shadow(0 0 14px rgba(24, 120, 255, .55));
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 1.6px;
  z-index: -1;
  opacity: 1;
  background:
    repeating-linear-gradient(0deg, rgba(160, 230, 255, .07) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #1b6ce0, #0a2f78 70%, #061a44);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #c8f8ff, #57b6ff 45%, #1a63e0);
  filter: drop-shadow(0 0 22px rgba(63, 216, 255, .8));
}
.btn-primary:hover::before {
  background:
    repeating-linear-gradient(0deg, rgba(180, 240, 255, .1) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #2a8bf5, #0d3a92 70%, #072050);
}
.btn-primary:active { filter: drop-shadow(0 0 10px rgba(63, 216, 255, .5)); }

/* 悬停扫光 */
.btn::after {
  content: ""; position: absolute; top: -20%; left: -70%; width: 45%; height: 140%;
  background: linear-gradient(100deg, transparent, rgba(180, 235, 255, .22), transparent);
  transform: skewX(-18deg); opacity: 0; pointer-events: none;
}
.btn:hover::after { animation: btnSweep .75s ease forwards; }
@keyframes btnSweep {
  0% { left: -70%; opacity: 1; }
  100% { left: 130%; opacity: 0; }
}

.btn-ghost {
  background: linear-gradient(180deg, rgba(18, 42, 84, .55), rgba(6, 16, 36, .8));
  border-color: var(--line);
}

.btn-lg { height: 54px; font-size: 16px; border-radius: var(--r-md); }
.btn-mini {
  height: 28px; padding: 0 10px; font-size: 11px; border-radius: 6px;
  background: rgba(40, 100, 190, .18); border: 1px solid var(--line);
  color: #a9c8ee;
}
.btn-mini:hover { border-color: var(--accent); color: #eaf9ff; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center;
  color: #9fc0e8;
  background: rgba(20, 46, 92, .5);
  border: 1px solid var(--line);
  transition: color .18s, border-color .18s, box-shadow .2s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow); }
.icon-btn em {
  position: absolute; top: -5px; right: -5px; font-style: normal;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: linear-gradient(180deg, #57e2ff, #0a6cff); color: #02121f;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

/* 音效开关 */
.gate-wrap .sfx-toggle { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; z-index: 2; }
.sfx-toggle svg { width: 18px; height: 18px; }
.sfx-toggle.is-off { opacity: .45; }
.sfx-toggle.is-off::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 20px; height: 2px; border-radius: 2px;
  background: var(--danger); transform: translate(-50%, -50%) rotate(-45deg);
}

/* =========================================================================
   闸门
   ========================================================================= */
#screen-gate { align-items: center; justify-content: center; padding: 24px; }

/* 程序名下方的 logo（原图自带透明通道，直接叠在深色上） */
.logo-chip {
  display: block;
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  filter: drop-shadow(0 0 20px rgba(63, 216, 255, .4));
  user-select: none;
}
.gate-logo { width: min(228px, 60%); margin: 10px 0 2px; }
.brand-logo { width: 132px; margin-top: 6px; }
.brand-stack { display: flex; flex-direction: column; align-items: flex-start; }

/* 右下角声明 */
/* 右下角声明：进房前一直显示 */
.legal {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: right;
  font-size: 10px;
  line-height: 1.75;
  letter-spacing: .2px;
  color: rgba(127, 157, 199, .66);
  max-width: min(78vw, 420px);
  z-index: 3;
  pointer-events: none;
  animation: riseIn .65s .3s var(--ease) both;
}
body.in-room .legal { display: none; }

@media (max-height: 720px) {
  .gate-logo { width: min(170px, 48%); margin: 8px 0 0; }
  .brand-logo { width: 104px; }
  .legal { font-size: 9px; line-height: 1.6; }
}

.gate-wrap {
  position: relative;
  width: min(430px, calc(100vw - 44px));
  padding: 34px 28px 26px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(12, 32, 66, .94), rgba(4, 12, 28, .97));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(120, 200, 255, .16);
  max-height: 92dvh;
  overflow-y: auto;
}
.gate-wrap > * { animation: riseIn .55s var(--ease) both; }
.gate-wrap > :nth-child(1) { animation-delay: .04s; }
.gate-wrap > :nth-child(2) { animation-delay: .10s; }
.gate-wrap > :nth-child(3) { animation-delay: .16s; }
.gate-wrap > :nth-child(4) { animation-delay: .22s; }
.gate-wrap > :nth-child(5) { animation-delay: .28s; }
.gate-wrap > :nth-child(6) { animation-delay: .34s; }

/* 顶边高亮条 */
.gate-wrap::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .8;
  animation: topLine 3.2s ease-in-out infinite;
}
@keyframes topLine {
  0%, 100% { opacity: .25; transform: scaleX(.6); }
  50% { opacity: .9; transform: scaleX(1); }
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: 1px;
  color: #04121f;
  background: linear-gradient(160deg, #7ceaff, #1b7bff);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: 0 0 22px rgba(63, 216, 255, .55);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: 2px; }
.brand-text span { font-size: 10px; color: var(--accent); letter-spacing: 3px; text-transform: uppercase; opacity: .8; }
.brand.small .brand-mark { width: 32px; height: 32px; font-size: 11px; }
.brand.small .brand-text strong { font-size: 13px; letter-spacing: 1px; }

.gate-title { margin: 26px 0 6px; font-size: 24px; letter-spacing: 1px; }
.gate-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; letter-spacing: .3px; }

.gate-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; display: flex; justify-content: space-between; }
.field-label em { font-style: normal; color: var(--dim); }

.input {
  height: 48px; padding: 0 14px; width: 100%;
  background: rgba(8, 24, 52, .8);
  border: 1px solid var(--line);
  border-left: 2px solid rgba(63, 216, 255, .45);
  border-radius: 8px;
  outline: none; font-size: 16px;
  transition: border-color .18s, box-shadow .2s, background .2s;
}
.input::placeholder { color: var(--dim); }
.input:focus { border-color: var(--accent); background: rgba(12, 36, 74, .9); box-shadow: 0 0 16px rgba(63, 216, 255, .25); }

.hint { min-height: 18px; margin: 2px 0 0; font-size: 12px; color: var(--coral); }
.gate-foot { margin: 20px 0 0; text-align: center; font-size: 10px; color: var(--dim); letter-spacing: 2px; }

/* =========================================================================
   大厅
   ========================================================================= */
#screen-home { padding: 18px max(18px, env(safe-area-inset-left)); }
.topbar { display: flex; align-items: center; justify-content: space-between; }

.chip {
  height: 32px; padding: 0 12px; border-radius: 6px;
  background: rgba(20, 46, 92, .5); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); letter-spacing: .5px;
  display: inline-flex; align-items: center; gap: 6px;
}

.home-body {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 26px;
  max-width: 460px; margin: 0 auto; width: 100%; padding-bottom: 8vh;
}
.home-state { text-align: center; animation: riseIn .5s var(--ease) both; }
.home-state h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: 1px; }
.home-state p { margin: 0; color: var(--muted); font-size: 13px; }
.home-state .big-code {
  display: inline-block; margin: 16px 0 6px; padding: 12px 22px;
  font: 700 30px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 8px; color: var(--accent);
  background: rgba(10, 40, 80, .7);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  text-shadow: 0 0 18px rgba(63, 216, 255, .7);
  box-shadow: inset 0 0 24px rgba(24, 108, 255, .25);
}

.home-actions { display: flex; flex-direction: column; gap: 14px; animation: riseIn .5s .08s var(--ease) both; }
#btnCreate { flex-direction: column; gap: 2px; height: 76px; }
.btn-k { font-size: 17px; letter-spacing: 2px; }
.btn-d { font-size: 11px; font-weight: 500; opacity: .6; letter-spacing: .5px; }

.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 11px; letter-spacing: 1px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }

.join-row { display: flex; gap: 10px; }
.code-input {
  flex: 1; letter-spacing: 6px; text-align: center; text-transform: uppercase;
  font: 600 17px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.home-tips { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; color: var(--dim); font-size: 11px; text-align: center; letter-spacing: .5px; }

/* =========================================================================
   房间
   ========================================================================= */
#screen-room { background: #03070f; }

.room-head {
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(5, 14, 30, .98), rgba(5, 14, 30, .55));
  border-bottom: 1px solid rgba(63, 216, 255, .12);
  z-index: 6;
}

.code-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 6px;
  background: rgba(14, 40, 80, .7); border: 1px solid var(--line);
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 3px;
  color: #bfe2ff;
}
.code-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blink 1.8s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pill {
  height: 26px; padding: 0 10px; border-radius: 5px;
  font-size: 11px; letter-spacing: 1px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(20, 46, 92, .6); color: var(--muted);
  border: 1px solid var(--line);
}
.pill.live { color: #ffd0d8; background: rgba(255, 60, 90, .16); border-color: rgba(255, 95, 122, .5); box-shadow: 0 0 14px rgba(255, 60, 90, .3); }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }

.tabs { display: flex; gap: 6px; padding: 0 12px 8px; }
.tab {
  height: 30px; padding: 0 16px; border-radius: 5px; font-size: 12px; letter-spacing: 1px;
  color: var(--muted); background: rgba(16, 40, 78, .5);
  border: 1px solid transparent;
  transition: color .18s, border-color .18s, background .18s;
}
.tab.is-on {
  color: var(--accent); background: rgba(20, 70, 130, .55);
  border-color: var(--line-strong); box-shadow: inset 0 0 16px rgba(63, 216, 255, .15);
}

.room-body { flex: 1; position: relative; overflow: hidden; }

/* ---------- 舞台 ---------- */
.stage { position: absolute; inset: 0; display: flex; gap: 10px; padding: 8px; }
.stage.layout-stack { flex-direction: column; align-items: center; justify-content: center; }
.stage.layout-stack .tile {
  width: 100%; flex: 0 0 auto; aspect-ratio: 16 / 9;
  max-height: calc(50% - 14px); max-width: 1400px;
}
.stage.layout-side { flex-direction: row; align-items: center; justify-content: center; }
.stage.layout-side .tile { flex: 1 1 0; height: 100%; min-width: 0; aspect-ratio: auto; }
.stage.layout-single { align-items: center; justify-content: center; }
.stage.layout-single .tile { width: 100%; max-width: 1600px; aspect-ratio: 16 / 9; max-height: 100%; }
.stage .tile-zoom video { object-fit: contain; }

.tile {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg);
  background: radial-gradient(120% 120% at 30% 0%, #0a1c3a, #03070f 72%);
  border: 1px solid rgba(63, 216, 255, .22);
  box-shadow: inset 0 0 40px rgba(10, 60, 140, .35), 0 10px 30px rgba(0, 4, 14, .6);
  min-height: 0; isolation: isolate;
  touch-action: none;
  animation: tileIn .36s var(--ease) both;
}
.tile.is-empty { display: grid; place-items: center; }

.tile-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.tile-zoom video {
  width: 100%; height: 100%; object-fit: contain; display: block;
  background: #000; transition: filter .2s;
}
.tile.mirror video { transform: scaleX(-1); }

.tile-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 3; }
.name-tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 4px;
  background: rgba(3, 12, 26, .78); backdrop-filter: blur(8px);
  border: 1px solid rgba(63, 216, 255, .2);
  font-size: 11px; letter-spacing: .5px; max-width: 70%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mic-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--danger); }
.mic-dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.tile-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; z-index: 4; }

/* 左上角昵称条 */
.tile-name {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 62%;
  height: 28px; padding: 0 12px 0 10px;
  background: linear-gradient(180deg, rgba(8, 24, 48, .88), rgba(4, 12, 26, .92));
  border: 1px solid rgba(63, 216, 255, .35);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 14px rgba(63, 216, 255, .18);
  font-size: 12px; letter-spacing: .5px; color: #d6ecff;
  pointer-events: none;
}
.tile-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-name .role { font-style: normal; font-size: 10px; color: var(--gold); opacity: .9; }
.tile:hover .tile-tools, .tile.show-tools .tile-tools { opacity: 1; }
@media (pointer: coarse) { .tile-tools { opacity: 1; } }
.tool-btn {
  width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center;
  background: rgba(4, 14, 30, .72); border: 1px solid var(--line);
  backdrop-filter: blur(8px); color: #bfe2ff;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn svg { width: 15px; height: 15px; }

.empty-state { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--dim); gap: 4px; }
.empty-state p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.empty-state span { font-size: 11px; }

/* ---------- 规则 ---------- */
.rules-pane { position: absolute; inset: 0; display: flex; flex-direction: column; background: #03070f; }
.rules-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); letter-spacing: .5px; }
.rules-pane iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.rules-fail { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; color: var(--muted); background: #03070f; }

/* ---------- 底部工具栏 ---------- */
.dock {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(3, 9, 20, .99), rgba(3, 9, 20, .6));
  border-top: 1px solid rgba(63, 216, 255, .14);
  min-height: var(--dock-h); z-index: 6;
}
.dock-btn {
  flex: 1; max-width: 88px; height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 8px; color: var(--muted); font-size: 10px; letter-spacing: .5px;
  position: relative; border: 1px solid transparent;
  transition: color .18s, border-color .18s, background .18s, box-shadow .2s;
}
.dock-btn:hover { color: var(--accent); border-color: rgba(63, 216, 255, .35); background: rgba(20, 56, 110, .4); }
.dock-btn[aria-pressed="true"] { color: var(--accent); background: rgba(20, 70, 130, .5); border-color: var(--line-strong); box-shadow: inset 0 0 16px rgba(63, 216, 255, .18); }
.dock-btn.off { color: var(--danger); }
.dock-btn[hidden] { display: none; }
.dock-btn:active { transform: translateY(1px); }
.cooldown {
  position: absolute; inset: 0; border-radius: 8px;
  background: conic-gradient(rgba(0, 0, 0, .62) var(--p, 0%), transparent 0);
  pointer-events: none;
}
.dock-main { flex: 1.5; max-width: 168px; height: 46px; }

/* ---------- 抽屉 ---------- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 88vw);
  background: linear-gradient(180deg, rgba(7, 20, 42, .99), rgba(3, 10, 24, .99));
  border-left: 1px solid var(--line-strong);
  box-shadow: -24px 0 60px rgba(0, 0, 0, .6);
  z-index: 20; display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 14px 14px;
  transform: translateX(100%);
  animation: drawerIn .32s var(--ease) forwards;
}
@keyframes drawerIn { to { transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.people-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.person {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; background: rgba(14, 36, 72, .45);
  border: 1px solid transparent; border-left: 2px solid rgba(63, 216, 255, .25);
}
.person.me { background: rgba(20, 64, 120, .5); border-left-color: var(--accent); }
.avatar {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: linear-gradient(150deg, #1b4f9c, #0a2b60);
  border: 1px solid rgba(90, 190, 255, .3);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  font-size: 13px; font-weight: 700; color: #cfeaff;
}
.person-info { flex: 1; min-width: 0; }
.person-name { font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.person-name .badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: rgba(255, 209, 102, .14); color: var(--gold); letter-spacing: .5px; }
.person-sub { font-size: 10px; color: var(--dim); line-height: 1.5; }
.person-act { display: flex; gap: 4px; }

.voice-panel { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.voice-panel h4 { margin: 0; font-size: 10px; color: var(--dim); font-weight: 500; letter-spacing: 2px; text-transform: uppercase; }
.seg { display: flex; background: rgba(12, 32, 64, .7); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button { flex: 1; height: 30px; border-radius: 5px; font-size: 11px; color: var(--muted); transition: background .18s, color .18s; }
.seg button.on { background: linear-gradient(180deg, rgba(30, 90, 170, .8), rgba(12, 40, 90, .9)); color: var(--accent); box-shadow: inset 0 0 14px rgba(63, 216, 255, .2); }

/* ---------- 底部面板 ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 15;
  background: linear-gradient(180deg, rgba(9, 26, 54, .99), rgba(3, 10, 24, .99));
  border-top: 1px solid var(--line-strong);
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -24px 60px rgba(0, 0, 0, .6);
  animation: sheetIn .34s var(--ease) both;
}
@keyframes sheetIn { from { transform: translateY(102%); } to { transform: none; } }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.sheet-head strong { letter-spacing: 2px; font-size: 14px; }
.sheet-note { font-size: 10px; color: var(--dim); letter-spacing: .5px; }

.sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-height: 52vh; overflow-y: auto; padding-right: 2px; -webkit-overflow-scrolling: touch; }
@media (max-width: 520px) { .sticker-grid { grid-template-columns: repeat(5, 1fr); } }
.sticker-item {
  aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center;
  font-size: 24px; background: rgba(14, 36, 72, .55);
  border: 1px solid var(--line);
  transition: transform .12s var(--ease), border-color .18s, box-shadow .2s;
  animation: tileIn .28s var(--ease) both;
}
.sticker-item:hover { border-color: var(--accent); box-shadow: var(--glow); }
.sticker-item:active { transform: scale(.9); }
.sticker-item img { width: 70%; height: 70%; object-fit: contain; }
.sticker-item.pink { filter: hue-rotate(300deg) saturate(2.4) brightness(1.25); }

/* 语音模式列表 */
.mode-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.mode-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px; border-radius: 8px; text-align: left;
  background: rgba(14, 36, 72, .5);
  border: 1px solid var(--line);
  transition: background .15s, border-color .15s, box-shadow .2s;
  animation: riseIn .3s var(--ease) both;
}
.mode-item:hover { border-color: var(--accent); }
.mode-item.on { background: rgba(20, 70, 130, .55); border-color: var(--line-strong); box-shadow: inset 0 0 20px rgba(63, 216, 255, .15); }
.mode-item i { font-style: normal; width: 16px; color: var(--accent); font-weight: 700; flex: 0 0 16px; }
.mode-item strong { display: block; font-size: 14px; letter-spacing: .5px; }
.mode-item span { font-size: 10px; color: var(--muted); line-height: 1.45; }
.mode-extra { margin-top: 10px; display: flex; gap: 8px; }
.mode-extra button { flex: 1; height: 38px; border-radius: 8px; background: rgba(14, 36, 72, .6); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.mode-extra button:hover { border-color: var(--accent); color: var(--accent); }

.bgm-select {
  width: 100%; height: 48px; border-radius: 8px; padding: 0 12px;
  background: rgba(10, 28, 58, .9); border: 1px solid var(--line);
  color: var(--text); font-size: 15px; outline: none; appearance: none;
}
.bgm-select:focus { border-color: var(--accent); box-shadow: 0 0 16px rgba(63, 216, 255, .2); }

/* ---------- 特效层 ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.float-sticker {
  position: absolute; width: 96px; height: 96px;
  display: grid; place-items: center;
  will-change: transform, opacity; pointer-events: none;
  filter: drop-shadow(0 0 14px rgba(63, 216, 255, .35)) drop-shadow(0 10px 22px rgba(0, 0, 0, .5));
}
.float-sticker img { width: 100%; height: 100%; object-fit: contain; display: block; }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 14;
  font: 800 96px/1 -apple-system, "PingFang SC", sans-serif;
  color: var(--accent); text-shadow: 0 0 40px rgba(63, 216, 255, .8);
  background: rgba(2, 6, 14, .68); backdrop-filter: blur(4px);
}

/* 电子牌玩家：画面位置直接渲染牌桌 */
.tile-board { position: absolute; inset: 0; z-index: 2; overflow: hidden; }
.tile-board i {
  position: absolute; width: 34px; height: 48px; margin: -24px 0 0 -17px;
  border-radius: 4px; background: linear-gradient(160deg, #1b5fd0, #0a2050);
  border: 1px solid rgba(120, 200, 255, .5);
  font: 700 6px/1.1 ui-monospace, monospace; color: #cfe8ff;
  display: grid; place-items: center; font-style: normal;
  transform: translate(-50%, -50%);
}
.tb-meta {
  position: absolute; left: 8px; bottom: 8px;
  font: 600 10px/1 ui-monospace, monospace; color: #9fc0e8;
  background: rgba(3, 12, 26, .8); padding: 5px 8px; border-radius: 4px;
  border: 1px solid rgba(63, 216, 255, .2);
}

/* ---------- 电子牌桌 ---------- */
.board {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #04101f, #030811);
  padding: max(10px, env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
}
.board-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; }
.board-head strong { letter-spacing: 2px; font-size: 14px; }
.board-acts { display: flex; gap: 6px; }
.board-body { flex: 1; display: flex; gap: 8px; min-height: 0; }
.bd-side { width: 74px; display: flex; flex-direction: column; gap: 6px; }
.bd-zone {
  flex: 1; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(14, 36, 72, .55); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; letter-spacing: .5px;
}
.bd-zone em { font-style: normal; font-size: 16px; color: var(--accent); font-weight: 700; }
.bd-zone.hot { border-color: var(--accent); box-shadow: var(--glow); }
.bd-field {
  flex: 1; position: relative; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(70,160,255,.05) 1px, transparent 1px) 0 0 / 100% 40px,
    linear-gradient(90deg, rgba(70,160,255,.05) 1px, transparent 1px) 0 0 / 40px 100%,
    rgba(6, 18, 38, .6);
}
.bd-card {
  position: absolute; width: 58px; height: 81px; border-radius: 6px;
  background: linear-gradient(160deg, #1b5fd0, #0a2050);
  border: 1px solid rgba(120, 200, 255, .55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5);
  transform-origin: 50% 50%;
  display: grid; place-items: center;
  font: 700 9px/1.2 ui-monospace, monospace; color: #cfe8ff;
  text-align: center; padding: 2px; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  user-select: none; touch-action: none;
}
.bd-card.face-down {
  background: center/cover url(/img/cardback.jpg), repeating-linear-gradient(45deg, #0b2a5e 0 6px, #082046 6px 12px);
  color: transparent;
}
.bd-card.face-down::after {
  content: "DTCG"; font: 800 8px/1 ui-monospace, monospace; color: rgba(120, 200, 255, .5);
  position: absolute; bottom: 6px;
}
.bd-card.tapped { transform: rotate(90deg); }
.bd-card.sel { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(63, 216, 255, .6); }
.bd-handed { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(1.6); z-index: 5; pointer-events: none; }
.bd-hand {
  margin-top: 8px; height: 96px; flex: 0 0 auto;
  display: flex; gap: 6px; overflow-x: auto; padding: 6px;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(8, 22, 46, .7);
}
.bd-hand .bd-card { position: relative; flex: 0 0 auto; }
.deck-text {
  width: 100%; height: 160px; resize: vertical;
  background: rgba(8, 24, 52, .9); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 10px; font: 12px/1.5 ui-monospace, monospace; outline: none;
}
.rotate-hint {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(2, 6, 14, .96); text-align: center; padding: 24px;
}
.rotate-phone { font-size: 64px; animation: rotatePhone 2.4s ease-in-out infinite; }
@keyframes rotatePhone {
  0%, 25% { transform: rotate(0deg); }
  55%, 80% { transform: rotate(90deg); }
  100% { transform: rotate(0deg); }
}
.rotate-hint strong { font-size: 20px; letter-spacing: 2px; }
.rotate-hint span { color: var(--muted); font-size: 12px; }

/* ---------- 预览 ---------- */
.preview-layer {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(2, 6, 14, .97);
  backdrop-filter: blur(12px);
  animation: screenIn .35s var(--ease) both;
}
.preview-head { text-align: center; margin-bottom: 14px; }
.preview-head strong { display: block; font-size: 17px; letter-spacing: 2px; }
.preview-head span { font-size: 11px; color: var(--muted); }
.preview-stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  border-radius: var(--r-lg); background: #000;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 40px rgba(10, 60, 140, .3);
}
.preview-stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-stage video.mirror { transform: scaleX(-1); }
.preview-tip { text-align: center; color: var(--dim); font-size: 11px; margin: 12px 0 14px; letter-spacing: .5px; }
.preview-actions { display: flex; gap: 8px; }
.preview-actions .btn { flex: 1; }
.preview-actions #btnPrevOk { flex: 1.4; }

/* ---------- 小窗 ---------- */
.self-pip {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  width: min(32vw, 220px); aspect-ratio: 16 / 9;
  border-radius: 8px; overflow: hidden; background: #000;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 24px rgba(63, 216, 255, .25), 0 12px 30px rgba(0, 0, 0, .6);
  animation: tileIn .3s var(--ease) both;
}
.self-pip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.self-pip.mirror video { transform: scaleX(-1); }
.self-pip .pip-tag { position: absolute; left: 8px; bottom: 6px; display: inline-flex; align-items: center; font-size: 9px; color: #cfeaff; text-shadow: 0 1px 3px #000; letter-spacing: .5px; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, 92vw);
}
.toast {
  padding: 10px 16px; border-radius: 6px; font-size: 12px; letter-spacing: .5px;
  background: rgba(8, 24, 50, .97); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), inset 0 0 18px rgba(63, 216, 255, .08);
  max-width: 100%; text-align: center;
}
.toast.err { border-color: rgba(255, 95, 122, .55); color: #ffc2cc; }
.toast.ok { border-color: rgba(63, 216, 255, .55); color: #bff2ff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 房间内的错峰飞入 */
#screen-room.is-active .room-head { animation: riseIn .45s .04s var(--ease) both; }
#screen-room.is-active .tabs { animation: riseIn .45s .1s var(--ease) both; }
#screen-room.is-active .dock { animation: riseIn .5s .14s var(--ease) both; }
#screen-room.is-active .tile:nth-child(1) { animation-delay: .1s; }
#screen-room.is-active .tile:nth-child(2) { animation-delay: .18s; }
#screen-room.is-active .self-pip { animation-delay: .26s; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}


/* ---------- unified account / deck library ---------- */
.auth-tabs { display:flex; gap:6px; margin:0 0 14px; padding:4px; border:1px solid var(--line); border-radius:9px; background:rgba(4,12,28,.6); }
.auth-tab { flex:1; height:34px; border-radius:6px; color:var(--muted); font-size:13px; }
.auth-tab.is-on { color:var(--accent); background:rgba(20,70,150,.35); box-shadow:inset 0 0 0 1px var(--line-strong); }
.my-decks { display:flex; flex-direction:column; gap:8px; max-height:300px; overflow:auto; margin:6px 0 12px; }
.my-deck { display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:9px; background:rgba(8,22,46,.65); }
.my-deck.is-active { border-color:var(--accent); box-shadow:0 0 16px rgba(63,216,255,.18); }
.my-deck .md-name { flex:1; font-size:13px; }
.my-deck .md-meta { font-size:10px; color:var(--muted); }
.my-deck button { height:28px; padding:0 9px; font-size:11px; }
.deck-sheet-actions { display:flex; gap:8px; flex-wrap:wrap; }
.deck-sheet-actions .btn { flex:1; min-width:90px; }
#deckImportBox { margin-top:10px; }


/* ---------- 网络延迟三格小柱子 ---------- */
.ping {
  display: inline-flex; align-items: flex-end; gap: 2px;
  height: 11px; width: 13px; margin-left: 6px;
  vertical-align: middle; flex: 0 0 auto;
}
.ping i {
  display: block; width: 3px; border-radius: 1px;
  background: rgba(150, 175, 205, .35);
  transition: background .2s;
}
.ping i:nth-child(1) { height: 4px; }
.ping i:nth-child(2) { height: 7px; }
.ping i:nth-child(3) { height: 10px; }
.ping.good i { background: #3fe0a0; box-shadow: 0 0 5px rgba(63, 224, 160, .45); }
.ping.mid i { background: #ffd166; box-shadow: 0 0 5px rgba(255, 209, 102, .4); }
.ping.bad i { background: #ff5f7a; box-shadow: 0 0 5px rgba(255, 95, 122, .45); }
.ping.na i { background: rgba(150, 175, 205, .3); box-shadow: none; }
.tile-name .ping { margin-left: 2px; }


/* ---------- 手工横屏 ---------- */
#screen-room.force-landscape {
  position: fixed !important; inset: auto !important;
  left: 50% !important; top: 50% !important;
  width: 100vh; height: 100vw;
  width: 100dvh; height: 100dvw;
  max-width: none; max-height: none;
  transform: translate(-50%, -50%) rotate(90deg) !important;
  transform-origin: center center;
  animation: none !important; opacity: 1 !important; z-index: 8;
}
html.force-landscape, body.force-landscape { overflow: hidden; background: #000; }
#screen-room.force-landscape .rotate-hint { display: none !important; }
.rotate-sub { font-size: 10px; color: var(--dim); }

/* ---------- 观众只看某位对战者 ---------- */
.focus-backdrop { position: absolute; inset: 0; z-index: 58; background: rgba(2, 6, 14, .5); }
.focus-sheet {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 59;
  width: min(330px, 88vw); padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, rgba(7, 20, 42, .99), rgba(3, 10, 24, .99));
  border-left: 1px solid var(--line-strong);
  box-shadow: -20px 0 50px rgba(0, 0, 0, .55);
}
.focus-backdrop[hidden], .focus-sheet[hidden] { display: none; }
.focus-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.focus-head strong { font-size: 14px; letter-spacing: 1.5px; }
.focus-info { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.focus-info .avatar { width: 42px; height: 42px; font-size: 18px; }
.focus-name { font-size: 15px; font-weight: 700; }
.focus-role { font-size: 10px; color: var(--gold); margin-top: 3px; }
.focus-tip { font-size: 11px; line-height: 1.7; color: var(--muted); }
.focus-exit {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 60; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(3, 12, 26, .9);
  color: var(--accent); font-size: 12px; letter-spacing: .5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.focus-exit[hidden] { display: none; }
.force-exit {
  position: absolute; left: 10px; bottom: 12px; z-index: 60;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(3, 12, 26, .9);
  color: var(--muted); font-size: 11px;
}
.force-exit[hidden] { display: none; }
