/* face — Retro-Futurism / Cyberpunk
   设计语言:深空黑底、霓虹青为主 + 品红锐利点缀;
   签名细节:CRT 扫描线、透视网格地平线、glitch 故障字、HUD 角标视频窗格、辉光脉冲。 */

@font-face {
  font-family: 'Orbitron';
  src: url('/vendor/fonts/orbitron/files/orbitron-latin-wght-normal.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('/vendor/fonts/space-grotesk/files/space-grotesk-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --void: #04030a;
  --panel: #0b0a16;
  --panel-2: #110f20;
  --cyan: #00f0ff;
  --cyan-dim: rgba(0, 240, 255, 0.35);
  --magenta: #ff2bd6;
  --magenta-dim: rgba(255, 43, 214, 0.35);
  --amber: #ffb800;
  --text: #d8f4ff;
  --text-dim: #7a8a9e;
  --line: rgba(0, 240, 255, 0.18);
  --cut: 12px; /* 切角尺寸 */
  --display: 'Orbitron', 'PingFang SC', sans-serif;
  --body: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  font-family: var(--body);
  background: var(--void);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* ---------- 签名细节 1:CRT 扫描线(全局覆盖) ---------- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

/* ---------- 签名细节 2:透视网格地平线 ---------- */
.grid-floor {
  position: fixed;
  left: -20vw;
  right: -20vw;
  bottom: -6vh;
  height: 42vh;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(transparent, rgba(255, 43, 214, 0.06)),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 44px);
  transform: perspective(420px) rotateX(62deg);
  transform-origin: bottom;
  mask-image: linear-gradient(transparent, #000 35%);
  -webkit-mask-image: linear-gradient(transparent, #000 35%);
}

.glow-orb {
  position: fixed;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.14;
  pointer-events: none;
  z-index: 0;
}
.glow-orb.cyan { background: var(--cyan); top: -16vw; right: -12vw; }
.glow-orb.magenta { background: var(--magenta); bottom: -14vw; left: -10vw; opacity: 0.1; }

/* ---------- 头部:glitch 故障字 ---------- */
header {
  text-align: center;
  padding: 36px 0 8px;
  position: relative;
  z-index: 2;
  width: 100%;
}

.wordmark {
  font-family: var(--display);
  font-size: clamp(30px, 5.6vw, 50px);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text);
  display: inline-block;
  position: relative;
  text-shadow:
    0 0 8px var(--cyan-dim),
    0 0 32px rgba(0, 240, 255, 0.25);
}
.wordmark .tld {
  font-weight: 500;
  font-size: 0.4em;
  color: var(--magenta);
  letter-spacing: 0.2em;
  text-shadow: 0 0 10px var(--magenta-dim);
  vertical-align: super;
}

/* 双层色差 glitch:青/品红错位,间歇触发 */
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  opacity: 0.8;
  pointer-events: none;
}
.glitch::before {
  color: var(--cyan);
  animation: glitch-a 3.7s infinite steps(1);
  clip-path: inset(0 0 60% 0);
}
.glitch::after {
  color: var(--magenta);
  animation: glitch-b 4.3s infinite steps(1);
  clip-path: inset(55% 0 0 0);
}
@keyframes glitch-a {
  0%, 92%, 100% { transform: none; opacity: 0; }
  93% { transform: translate(-3px, -2px); opacity: 0.8; }
  95% { transform: translate(2px, 1px); opacity: 0.6; }
  97% { transform: none; opacity: 0; }
}
@keyframes glitch-b {
  0%, 88%, 100% { transform: none; opacity: 0; }
  89% { transform: translate(3px, 2px); opacity: 0.8; }
  91% { transform: translate(-2px, -1px); opacity: 0.5; }
  94% { transform: none; opacity: 0; }
}

.slogan {
  color: var(--text-dim);
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 0.28em;
}

.lang-btn {
  position: absolute;
  top: 26px;
  right: 5vw;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.15em;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: all 0.25s ease;
}
.lang-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px var(--cyan-dim); }

main {
  width: 100%;
  max-width: 1100px;
  padding: 12px 16px 48px;
  position: relative;
  z-index: 2;
}

/* ---------- 按钮:切角 + 霓虹描边 ---------- */
button {
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 13px 22px;
  cursor: pointer;
  color: var(--text);
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid var(--line);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: all 0.22s ease;
}
button:hover:not(:disabled) {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 16px var(--cyan-dim), inset 0 0 14px rgba(0, 240, 255, 0.07);
  text-shadow: 0 0 8px var(--cyan-dim);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

button.primary {
  background: linear-gradient(135deg, rgba(255, 43, 214, 0.22), rgba(255, 43, 214, 0.08));
  border-color: var(--magenta);
  color: #ffd9f6;
  animation: pulse-magenta 2.6s ease-in-out infinite;
}
button.primary:hover:not(:disabled) {
  border-color: var(--magenta);
  color: #fff;
  box-shadow: 0 0 24px var(--magenta-dim), inset 0 0 16px rgba(255, 43, 214, 0.12);
  text-shadow: 0 0 10px var(--magenta-dim);
}
@keyframes pulse-magenta {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 43, 214, 0.25); }
  50% { box-shadow: 0 0 22px rgba(255, 43, 214, 0.5); }
}

button.secondary {
  background: transparent;
  color: var(--text-dim);
}

/* ---------- 大厅 ---------- */
.lobby-card {
  margin: 26px auto;
  max-width: 470px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 30px 28px 28px;
  text-align: center;
  position: relative;
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}
/* HUD 顶部数据条 */
.lobby-card::before {
  content: 'SYS://MASK_ENGINE_READY';
  display: block;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--cyan-dim);
  text-align: left;
  margin-bottom: 16px;
}

.preview-wrap {
  display: inline-block;
  line-height: 0;
  position: relative;
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.12), inset 0 0 18px rgba(0, 240, 255, 0.05);
}

#previewCanvas {
  width: 320px;
  max-width: 100%;
  transform: scaleX(-1);
  background: var(--void);
}

.hint {
  color: var(--text-dim);
  font-size: 12px;
  margin: 16px 0 20px;
  line-height: 1.7;
  letter-spacing: 0.04em;
}

.lobby-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

#lobbyStatus,
#status {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 12.5px;
  min-height: 18px;
  text-align: center;
  line-height: 1.7;
}
#status::before { content: '> '; color: var(--cyan); }
#status:empty::before { content: ''; }

/* ---------- 舞台:HUD 角标视频窗格 ---------- */
.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.pane {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
}
/* HUD 四角准星 */
.pane::before,
.pane::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  z-index: 6;
  pointer-events: none;
}
.pane::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan));
}
.pane::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid var(--cyan);
  border-right: 2px solid var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan));
}
#paneLocal::before,
#paneLocal::after {
  border-color: var(--magenta);
  filter: drop-shadow(0 0 6px var(--magenta));
}

.pane canvas,
.pane video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#localCanvas { transform: scaleX(-1); }

.tag {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: rgba(4, 3, 10, 0.78);
  border: 1px solid var(--line);
  padding: 5px 12px;
  color: var(--cyan);
  z-index: 5;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
.tag.stage {
  left: auto;
  right: 12px;
  color: var(--magenta);
  border-color: var(--magenta-dim);
}

#remoteWaiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.12em;
  background:
    radial-gradient(60% 50% at 50% 45%, rgba(0, 240, 255, 0.06), transparent),
    var(--panel);
  z-index: 4;
}
#remoteWaiting[hidden] { display: none; }
/* 扫描搜索动画线 */
#remoteWaiting::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.5;
  animation: scan-line 2.4s ease-in-out infinite;
}
@keyframes scan-line {
  0%, 100% { top: 12%; }
  50% { top: 86%; }
}
.online-count {
  font-family: var(--display);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.2em;
}

/* ---------- 聊天:终端风 ---------- */
#chatLog {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 44px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  z-index: 5;
  pointer-events: none;
  max-height: 55%;
  overflow: hidden;
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 88%;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(4, 3, 10, 0.82);
  color: var(--text);
  border-left: 2px solid var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.12);
  animation: tele-in 0.25s ease-out;
  word-break: break-word;
}
.chat-bubble.mine {
  align-self: flex-end;
  border-left: none;
  border-right: 2px solid var(--magenta);
  box-shadow: 0 0 10px rgba(255, 43, 214, 0.12);
}
@keyframes tele-in {
  from { transform: translateX(-6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

#chatForm {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

#chatInput {
  flex: 1;
  font-family: var(--body);
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px 18px;
  outline: none;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: all 0.25s ease;
}
#chatInput:focus { border-color: var(--cyan); box-shadow: 0 0 14px var(--cyan-dim); }
#chatInput::placeholder { color: var(--text-dim); opacity: 0.6; }

#chatSend { color: var(--cyan); }

/* ---------- 控制条 ---------- */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------- 摘面具同意弹层 ---------- */
.consent-mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 10, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.consent-mask[hidden] { display: none; }

.consent-card {
  background: var(--panel-2);
  border: 1px solid var(--magenta);
  box-shadow: 0 0 36px var(--magenta-dim), inset 0 0 24px rgba(255, 43, 214, 0.05);
  padding: 38px 34px 30px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  animation: tele-in 0.3s ease-out;
}

.consent-emoji {
  font-size: 42px;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 14px var(--magenta-dim));
}

.consent-card h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 10px;
  text-shadow: 0 0 12px var(--magenta-dim);
}

.consent-card p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 24px;
}

.consent-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ---------- 手机竖屏:对方全屏 + 自己小窗 ---------- */
@media (max-width: 760px) {
  .panes {
    display: block;
    position: relative;
  }

  #paneRemote {
    aspect-ratio: 3 / 4;
    max-height: 58vh;
    width: 100%;
  }

  #paneLocal {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32%;
    aspect-ratio: 3 / 4;
    z-index: 7;
    border: 1px solid var(--magenta-dim);
    box-shadow: 0 0 18px rgba(255, 43, 214, 0.25), 0 6px 20px rgba(0, 0, 0, 0.6);
  }

  #paneLocal .tag.name { display: none; }

  #paneLocal .tag.stage {
    left: 6px;
    right: auto;
    bottom: 6px;
    font-size: 8px;
    padding: 2px 7px;
  }

  .controls button { padding: 13px 14px; font-size: 11px; }
  .lang-btn { top: 16px; right: 16px; }
  .grid-floor { height: 30vh; }
}

/* ---------- 可达性 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 2px;
}
