/* ========== Design Tokens ========== */
:root {
  --bg: #0f1221;
  --bg-soft: #161a30;
  --card: #1e2340;
  --line: #2a3158;
  --text: #e7eaf6;
  --muted: #9aa3c7;
  --primary: #6c8cff;
  --primary-2: #8a5cff;
  --accent: #25d4a8;
  --danger: #ff6b81;
  --warn: #ffb84d;
  --code-bg: #0b0e1f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --max-width: 1100px;
}

[data-theme='light'] {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --line: #e5e8f3;
  --text: #1a1f3a;
  --muted: #5a6485;
  --primary: #4f6cff;
  --primary-2: #7a3cff;
  --accent: #14a37f;
  --danger: #e74c66;
  --warn: #d98a1c;
  --code-bg: #f1f3fb;
  --shadow: 0 6px 18px rgba(40, 50, 110, 0.08);
}

/* ========== Reset ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei',
    'Helvetica Neue', Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}
a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
}
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ========== Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
}
.logo:hover {
  text-decoration: none;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 14px;
  display: grid;
  place-items: center;
  letter-spacing: 0.5px;
}
.main-nav {
  display: flex;
  gap: 22px;
}
.main-nav a {
  color: var(--muted);
  font-size: 14px;
  position: relative;
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  text-decoration: none;
}
.main-nav a.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 2px;
}
.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}
.theme-toggle:hover {
  border-color: var(--primary);
}

/* ========== Hero ========== */
.hero {
  padding: 90px 0 70px;
  text-align: center;
  background: radial-gradient(
      1200px 400px at 50% -50%,
      color-mix(in srgb, var(--primary) 25%, transparent),
      transparent
    ),
    radial-gradient(
      900px 300px at 80% 0%,
      color-mix(in srgb, var(--primary-2) 22%, transparent),
      transparent
    );
}
.hero-title {
  font-size: clamp(34px, 6vw, 60px);
  margin: 0 0 14px;
  letter-spacing: 0.5px;
  font-weight: 800;
}
.grad {
  background: linear-gradient(90deg, var(--primary), var(--primary-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-subtitle {
  color: var(--muted);
  font-size: 17px;
  max-width: 640px;
  margin: 0 auto 28px;
}
.hero-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 40px;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 60px;
  flex-wrap: wrap;
}
.hero-stats > div {
  display: flex;
  flex-direction: column;
}
.hero-stats b {
  font-size: 28px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-stats span {
  color: var(--muted);
  font-size: 13px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  user-select: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(108, 140, 255, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 10px 24px rgba(108, 140, 255, 0.5);
  text-decoration: none;
}
.btn-ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
}
.btn-ghost:hover {
  border-color: var(--primary);
  text-decoration: none;
}

/* ========== Topic & Card ========== */
.main-content {
  padding: 40px 20px 80px;
}
.topic {
  padding: 50px 0;
  border-bottom: 1px dashed var(--line);
}
.topic:last-child {
  border-bottom: none;
}
.topic-title {
  font-size: 28px;
  margin: 0 0 8px;
  font-weight: 800;
}
.topic-desc {
  color: var(--muted);
  margin-bottom: 24px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.card h4 {
  margin: 8px 0 6px;
  font-size: 15px;
  color: var(--primary);
}
.card.demo {
  border-left: 4px solid var(--accent);
}
.step-list {
  margin: 0;
  padding-left: 22px;
}
.step-list li {
  margin: 6px 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.grid-2 > * {
  min-width: 0;
}

code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
  font-size: 13.5px;
}
pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid var(--line);
  max-width: 100%;
  box-sizing: border-box;
}
pre code {
  background: transparent;
  padding: 0;
}

/* ========== HTML demo: form ========== */
.demo-form {
  display: grid;
  gap: 12px;
  max-width: 420px;
}
.demo-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}
.demo-form input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.demo-form input:focus {
  border-color: var(--primary);
}
.demo-output {
  margin: 6px 0 0;
  font-family: Menlo, Consolas, monospace;
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ========== Box Model ========== */
.box-demo {
  display: inline-block;
  margin: 10px 0;
}
.bm-margin {
  background: rgba(255, 184, 77, 0.18);
  padding: 18px;
  border: 1px dashed var(--warn);
  color: var(--warn);
  font-size: 12px;
  border-radius: 8px;
}
.bm-border {
  background: rgba(108, 140, 255, 0.15);
  padding: 14px;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-size: 12px;
  margin-top: 4px;
}
.bm-padding {
  background: rgba(37, 212, 168, 0.18);
  padding: 14px;
  color: var(--accent);
  font-size: 12px;
  margin-top: 4px;
}
.bm-content {
  background: var(--bg-soft);
  padding: 18px 36px;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 4px;
}

/* ========== Flex Demo ========== */
.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.ctrl-row select {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  margin-left: 6px;
}
.flex-stage {
  display: flex;
  height: 140px;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  transition: all 0.3s;
}
.flex-stage > div {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  width: 60px;
  min-height: 50px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 600;
}

/* ========== Grid Demo ========== */
.grid-stage {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 60px 120px 50px;
  grid-template-areas:
    'a a'
    'b c'
    'd d';
  gap: 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
}
.grid-stage > div {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
}

/* ========== Animation Demo ========== */
.anim-stage {
  height: 80px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}
.anim-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  position: absolute;
  top: 15px;
  left: 15px;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.anim-ball.run {
  transform: translateX(calc(100% + 600px)) rotate(720deg);
}

/* ========== JS Demos ========== */
.badge {
  display: inline-block;
  padding: 6px 12px;
  margin-left: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--accent);
}
.dt-stage {
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  height: 100px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: crosshair;
  user-select: none;
  margin-bottom: 10px;
}
.dt-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
.dt-meta b {
  color: var(--accent);
}

/* reactive */
#reactiveInput {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  width: 100%;
  max-width: 400px;
  outline: none;
}
#reactiveInput:focus {
  border-color: var(--primary);
}

/* ========== Footer ========== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
.site-footer .muted {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 4px;
}

/* ========== Back to top ========== */
.to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  font-size: 20px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.to-top:hover {
  text-decoration: none;
}
.to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========== Responsive ========== */
/* 旧 hero/导航响应式已移到文件末尾的统一移动端模块 */

/* =====================================================
 * 进阶模块（WebSocket / Worker / Canvas / 文件 等）
 * ===================================================== */

/* WebSocket 演示 */
.ws-stage {
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
}
.ws-log {
  height: 180px;
  overflow-y: auto;
  font-family: Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 8px 10px;
  background: var(--code-bg);
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  scroll-behavior: smooth;
}
.ws-log .row {
  margin: 3px 0;
  word-break: break-all;
}
.ws-log .row.send {
  color: var(--primary);
}
.ws-log .row.recv {
  color: var(--accent);
}
.ws-log .row.sys {
  color: var(--muted);
  font-style: italic;
}
.ws-log .row.err {
  color: var(--danger);
}
.ws-input {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ws-input input {
  flex: 1;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  outline: none;
}
.ws-input input:focus {
  border-color: var(--primary);
}

/* 加载小球（用于 Worker 演示主线程是否阻塞） */
.ws-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  vertical-align: middle;
  margin-left: 6px;
  animation: spin-bounce 1s infinite ease-in-out;
}
@keyframes spin-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-8px) scale(1.15);
  }
}

/* Canvas */
#particleCanvas {
  width: 100%;
  height: 220px;
  display: block;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* 对比表格 */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 10px 0;
}
.cmp-table th,
.cmp-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.cmp-table thead th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
}
.cmp-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* localStorage 演示 */
#noteArea {
  width: 100%;
  min-height: 100px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
}
#noteArea:focus {
  border-color: var(--primary);
}

/* Drag & Drop */
.drop-zone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--primary);
}
.preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* fancy-btn（Web Component 默认外观兜底，组件内 ShadowDOM 已控样） */
fancy-btn {
  display: inline-block;
  margin-top: 8px;
}

/* =====================================================
 * 视频通话 RTC 演示
 * ===================================================== */
.rtc-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
  width: 100%;
}
@media (max-width: 720px) {
  .rtc-stage {
    grid-template-columns: 1fr;
  }
}
.rtc-box {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0; /* 防止 grid 子项超出 */
}
.rtc-label {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.rtc-box video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 280px;
  background: #000;
  object-fit: cover;
  display: block;
}
.rtc-meta {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  background: var(--card);
  border-top: 1px solid var(--line);
  font-family: Menlo, Consolas, monospace;
}
.rtc-meta.live {
  color: var(--accent);
}
.rtc-meta.live::before {
  content: '● ';
  color: var(--danger);
  animation: blink 1.4s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}
.rtc-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.rtc-controls .btn {
  padding: 8px 14px;
  font-size: 13px;
}
.rtc-controls .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.rtc-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.rtc-shots img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s;
}
.rtc-shots img:hover {
  transform: scale(1.05);
}

/* =====================================================
 * SFU 多人会议演示
 * ===================================================== */
.sfu-panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 14px 0;
}
.sfu-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.sfu-controls .btn {
  padding: 8px 14px;
  font-size: 13px;
}
.sfu-controls .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sfu-stat {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  font-family: Menlo, Consolas, monospace;
}

.sfu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  min-height: 140px;
  padding: 10px;
  background: var(--code-bg);
  border-radius: 10px;
  border: 1px dashed var(--line);
}
.sfu-grid:empty::before {
  content: '暂无成员，点击「我加入会议」开始';
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 0;
}
.sfu-tile {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}
.sfu-tile.me {
  border-color: var(--primary);
}
.sfu-tile.speaker {
  border-color: var(--accent);
  transform: scale(1.02);
}
.sfu-tile video,
.sfu-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sfu-name {
  position: absolute;
  left: 8px;
  bottom: 6px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 10px;
  font-size: 12px;
  backdrop-filter: blur(4px);
}
.sfu-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(255, 107, 129, 0.9);
  color: #fff;
  border-radius: 10px;
}
.sfu-badge.mic-off {
  background: rgba(100, 100, 100, 0.85);
}

.sfu-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .sfu-info {
    grid-template-columns: 1fr;
  }
}
.sfu-info b {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--primary);
}
.sfu-info pre {
  max-height: 160px;
  overflow-y: auto;
  margin: 0;
}
.sfu-band {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}
.sfu-band li {
  padding: 6px 10px;
  border-bottom: 1px dashed var(--line);
}
.sfu-band li:last-child {
  border-bottom: none;
}
.sfu-band b {
  display: inline;
  color: var(--accent);
  margin: 0;
}

/* =====================================================
 * 小程序模拟器
 * ===================================================== */
.mp-simulator {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: flex-start;
  margin: 14px 0;
}
@media (max-width: 780px) {
  .mp-simulator {
    grid-template-columns: 1fr;
  }
}

.mp-device {
  width: 360px;
  max-width: 100%;
  height: 640px;
  border-radius: 40px;
  background: #1a1a1a;
  padding: 14px 10px;
  box-shadow:
    0 0 0 2px #333,
    0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 auto;
  position: relative;
}
.mp-device::before {
  /* 顶部刘海 */
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 22px;
  background: #000;
  border-radius: 0 0 14px 14px;
  z-index: 2;
}
.mp-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  font-size: 12px;
  color: #fff;
  height: 22px;
}
.mp-navbar {
  background: linear-gradient(135deg, #6c8cff, #8a5cff);
  color: #fff;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
}
.mp-capsule {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  font-size: 14px;
  line-height: 1;
}
.mp-capsule .mp-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.4);
}

.mp-viewport {
  flex: 1;
  background: #f5f6fa;
  color: #1a1f3a;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.mp-refresh {
  height: 0;
  line-height: 40px;
  text-align: center;
  color: #999;
  font-size: 13px;
  transition: height 0.2s;
  overflow: hidden;
}
.mp-refresh.show {
  height: 40px;
}
.mp-pages {
  padding: 16px;
}
.mp-page {
  display: none;
}
.mp-page.active {
  display: block;
  animation: mp-fade 0.2s ease-out;
}
@keyframes mp-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 小程序页面内常用元素 */
.mp-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.mp-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #1a1f3a;
}
.mp-card p {
  margin: 4px 0;
  font-size: 13px;
  color: #666;
}
.mp-btn {
  display: inline-block;
  padding: 8px 18px;
  background: linear-gradient(135deg, #6c8cff, #8a5cff);
  color: #fff;
  border-radius: 20px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  margin-right: 8px;
  margin-top: 8px;
}
.mp-btn.ghost {
  background: #fff;
  color: #6c8cff;
  border: 1px solid #c4ccf5;
}
.mp-badge {
  display: inline-block;
  background: #6c8cff;
  color: #fff;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  margin-left: 6px;
}
.mp-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}
.mp-list-item .mp-price {
  color: #ff6b81;
  font-weight: 700;
}
.mp-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c8cff, #25d4a8);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 30px;
  margin: 10px auto;
}

.mp-tabbar {
  display: flex;
  background: #fff;
  border-top: 1px solid #eee;
  color: #999;
  font-size: 11px;
}
.mp-tab {
  flex: 1;
  text-align: center;
  padding: 8px 0 6px;
  cursor: pointer;
  transition: color 0.2s;
}
.mp-tab-icon {
  font-size: 20px;
  line-height: 1.1;
}
.mp-tab.active {
  color: #6c8cff;
}

/* 控制台 */
.mp-console {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
  height: 640px;
  display: flex;
  flex-direction: column;
}
.mp-console-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 8px;
}
.mp-console-clear {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.mp-console-clear:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.mp-console pre {
  flex: 1;
  background: var(--code-bg);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.7;
  margin: 0;
  color: var(--text);
  border: 1px solid var(--line);
}
.mp-console .mp-log-life { color: var(--warn); }
.mp-console .mp-log-data { color: var(--accent); }
.mp-console .mp-log-api  { color: var(--primary); }
.mp-console .mp-log-err  { color: var(--danger); }

/* Toast & Modal */
.mp-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 18px 24px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
  min-width: 120px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}
.mp-toast.show { opacity: 1; }
.mp-toast-icon { font-size: 34px; display: block; margin-bottom: 6px; }

.mp-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9;
}
.mp-modal.show { display: flex; }
.mp-modal-box {
  width: 80%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  color: #1a1f3a;
}
.mp-modal-body {
  padding: 22px 18px 18px;
  text-align: center;
}
.mp-modal-body h4 {
  margin: 0 0 10px;
  font-size: 16px;
}
.mp-modal-body p {
  margin: 0;
  font-size: 13px;
  color: #666;
}
.mp-modal-actions {
  display: flex;
  border-top: 1px solid #eee;
}
.mp-modal-actions button {
  flex: 1;
  padding: 12px 0;
  background: #fff;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: #1a1f3a;
}
.mp-modal-actions button + button {
  border-left: 1px solid #eee;
  color: #6c8cff;
}

/* =====================================================
 * WebRTC 深度 Demo：DataChannel / 质量监控 / 录制
 * ===================================================== */
.dc-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}
@media (max-width: 720px) {
  .dc-stage {
    grid-template-columns: 1fr;
  }
}
.dc-col {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dc-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.dc-log {
  height: 180px;
  overflow-y: auto;
  background: var(--code-bg);
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 13px;
  font-family: Menlo, Consolas, monospace;
  margin-bottom: 8px;
}
.dc-log .msg {
  margin: 3px 0;
  word-break: break-all;
}
.dc-log .me  { color: var(--primary); }
.dc-log .peer { color: var(--accent); }
.dc-log .sys { color: var(--muted); font-style: italic; }
.dc-log .file {
  color: var(--warn);
  text-decoration: underline;
  cursor: pointer;
}
.dc-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dc-row input {
  flex: 1;
  min-width: 120px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.dc-row input:focus {
  border-color: var(--primary);
}
.dc-row .btn {
  padding: 6px 12px;
  font-size: 13px;
}
.dc-progress {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: Menlo, Consolas, monospace;
  min-height: 18px;
}

/* Stats 监控 */
.stats-panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card b {
  font-size: 18px;
  color: var(--primary);
  font-family: Menlo, Consolas, monospace;
}
#statsChart {
  width: 100%;
  height: 140px;
  background: var(--code-bg);
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* =====================================================
 * 现代 Web API 卡片栅格
 * ===================================================== */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.api-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color 0.2s, transform 0.2s;
}
.api-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.api-card pre {
  font-size: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.api-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.api-icon {
  font-size: 22px;
  line-height: 1;
}
.api-head > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.api-head b {
  font-size: 15px;
  color: var(--text);
}
.api-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.api-support {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(154, 163, 199, 0.15);
  color: var(--muted);
  white-space: nowrap;
}
.api-support.api-ok {
  background: rgba(37, 212, 168, 0.18);
  color: var(--accent);
}
.api-support.api-no {
  background: rgba(255, 107, 129, 0.18);
  color: var(--danger);
}
.api-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}
.api-demo {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}
.api-demo .btn {
  padding: 6px 12px;
  font-size: 12px;
}
.api-out {
  font-size: 12px;
  color: var(--accent);
  font-family: Menlo, Consolas, monospace;
  word-break: break-all;
  align-self: center;
}
.api-out-big {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* =====================================================
 * 流程图编辑器
 * ===================================================== */
.flow-editor {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  margin: 14px 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  height: 460px;
}
@media (max-width: 720px) {
  .flow-editor {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.flow-palette {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.flow-pal-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.flow-pal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  cursor: grab;
  user-select: none;
  transition: border-color 0.2s, transform 0.15s;
}
.flow-pal-item:hover {
  border-color: var(--primary);
  transform: translateX(2px);
}
.flow-pal-item:active {
  cursor: grabbing;
}
.pal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pal-dot.start { background: #25d4a8; }
.pal-dot.task  { background: #6c8cff; }
.pal-dot.cond  { background: #ffb84d; }
.pal-dot.end   { background: #ff6b81; }

.flow-mini-btn {
  padding: 6px 8px;
  font-size: 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, color 0.2s;
}
.flow-mini-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.flow-stage {
  position: relative;
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  min-height: 420px;
}
.flow-stage svg {
  width: 100%;
  height: 100%;
  display: block;
}
.flow-tip {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(108, 140, 255, 0.12);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  transition: opacity 0.3s;
}
.flow-tip.hide {
  opacity: 0;
}

/* 节点样式（SVG foreignObject 内） */
.flow-node {
  cursor: move;
}
.flow-node .node-body {
  stroke: var(--line);
  stroke-width: 1.5;
  transition: stroke 0.2s, filter 0.2s;
}
.flow-node.selected .node-body {
  stroke: var(--primary);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(108, 140, 255, 0.6));
}
.flow-node text {
  fill: #fff;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}
.flow-anchor {
  fill: #fff;
  stroke: var(--primary);
  stroke-width: 2;
  cursor: crosshair;
  transition: r 0.15s;
}
.flow-anchor:hover {
  r: 6;
}

/* 连线 */
.flow-edge {
  fill: none;
  stroke: #6c8cff;
  stroke-width: 2;
  cursor: pointer;
  transition: stroke 0.2s, stroke-width 0.2s;
}
.flow-edge.selected {
  stroke: var(--accent);
  stroke-width: 3;
}
.flow-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 12;
  cursor: pointer;
}

.flow-json {
  width: 100%;
  min-height: 160px;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  margin-top: 8px;
  outline: none;
  resize: vertical;
}
.flow-json:focus {
  border-color: var(--primary);
}

/* =====================================================
 * 无限画布
 * ===================================================== */
.canvas-wrap {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin: 14px 0;
}
.canvas-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.canvas-info {
  font-size: 12px;
  color: var(--muted);
  font-family: Menlo, Consolas, monospace;
  margin-right: auto;
}
#infCanvas {
  width: 100%;
  height: 500px;
  display: block;
  background: var(--code-bg);
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}
#infCanvas:active {
  cursor: grabbing;
}

/* =====================================================
 * 游戏模块
 * ===================================================== */
.game-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin: 10px 0;
  aspect-ratio: 800 / 420;
}
.game-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #0a0d1f;
}
.game-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  font-family: Menlo, Consolas, monospace;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
}
.game-hud span {
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}
.game-hud b {
  color: var(--accent);
  margin-left: 2px;
}
.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  text-align: center;
  color: #fff;
  transition: opacity 0.3s;
}
.game-overlay.hide {
  opacity: 0;
  pointer-events: none;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}

/* Audio stage */
.audio-stage {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
#audioCanvas {
  width: 100%;
  max-height: 260px;
  display: block;
  background: var(--code-bg);
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}
#audioCanvas:active {
  cursor: grabbing;
}

/* Gamepad */
.gp-panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-height: 240px;
}
.gp-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 10px;
}
.gp-name {
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 10px;
  font-family: Menlo, Consolas, monospace;
  word-break: break-all;
}
.gp-sticks {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  justify-content: center;
}
.gp-stick {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.gp-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--code-bg);
  border: 2px solid var(--line);
  position: relative;
  margin: 0 auto 4px;
}
.gp-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -8px 0 0 -8px;
  transition: transform 0.05s linear;
  box-shadow: 0 0 8px rgba(108, 140, 255, 0.6);
}
.gp-buttons {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.gp-btn {
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: Menlo, Consolas, monospace;
  color: var(--muted);
  transition: all 0.05s;
}
.gp-btn.pressed {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(108, 140, 255, 0.6);
}

/* =====================================================
 * 9.10 探索类 3D 漫游
 * ===================================================== */
.explore-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0d1f;
  margin: 10px 0;
  aspect-ratio: 16 / 9;
  max-height: 560px;
  user-select: none;
}
.explore-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.explore-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 22px;
  font-weight: 300;
  pointer-events: none;
  mix-blend-mode: difference;
  font-family: Menlo, Consolas, monospace;
}
.explore-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  font-family: Menlo, Consolas, monospace;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.explore-hud span {
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}
.explore-hud b {
  color: var(--accent);
  margin-left: 4px;
}
.explore-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}
.explore-controls > div {
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
  text-align: right;
}
.explore-controls kbd {
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.explore-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  text-align: center;
  color: #fff;
  transition: opacity 0.3s;
}
.explore-overlay.hide {
  opacity: 0;
  pointer-events: none;
}
.explore-chat {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 280px;
  max-height: 140px;
  overflow-y: auto;
  font-size: 12px;
  font-family: Menlo, Consolas, monospace;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.85);
}
.explore-chat .chat-line {
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 3px;
  animation: chat-in 0.25s ease-out;
}
@keyframes chat-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.explore-chat .chat-join  { color: #25d4a8; }
.explore-chat .chat-leave { color: #ff6b81; }

/* =====================================================
 * FPS 射击游戏 UI
 * ===================================================== */
.fps-stage {
  cursor: crosshair;
}

/* 准星（动态散布） */
.fps-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: rgba(255, 255, 255, 0.9);
  transition: filter 0.1s;
}
.fps-crosshair .ch-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  background: #25d4a8;
  border-radius: 50%;
  box-shadow: 0 0 4px #25d4a8;
}
.fps-crosshair .ch-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  transition: transform 0.1s ease-out;
}
.fps-crosshair .ch-line.ch-top {
  left: 50%;
  top: 0;
  margin-left: -1px;
  width: 2px;
  height: 8px;
}
.fps-crosshair .ch-line.ch-bottom {
  left: 50%;
  bottom: 0;
  margin-left: -1px;
  width: 2px;
  height: 8px;
}
.fps-crosshair .ch-line.ch-left {
  left: 0;
  top: 50%;
  margin-top: -1px;
  width: 8px;
  height: 2px;
}
.fps-crosshair .ch-line.ch-right {
  right: 0;
  top: 50%;
  margin-top: -1px;
  width: 8px;
  height: 2px;
}
.fps-crosshair.spread .ch-top    { transform: translateY(-6px); }
.fps-crosshair.spread .ch-bottom { transform: translateY(6px); }
.fps-crosshair.spread .ch-left   { transform: translateX(-6px); }
.fps-crosshair.spread .ch-right  { transform: translateX(6px); }

/* 击中反馈 */
.fps-hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  color: #ff6b81;
  font-size: 18px;
  opacity: 0;
}
.fps-hitmarker.show {
  animation: hit-pulse 0.25s ease-out;
}
.fps-hitmarker.headshot {
  color: #ffb84d;
}
.fps-hitmarker::before,
.fps-hitmarker::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 0 4px currentColor;
}
.fps-hitmarker::before { transform: translate(-50%, -50%) rotate(45deg); }
.fps-hitmarker::after  { transform: translate(-50%, -50%) rotate(-45deg); }
@keyframes hit-pulse {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* 受伤血色边缘 */
.fps-damage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 80px 20px rgba(255, 0, 0, 0);
  transition: box-shadow 0.3s;
}
.fps-damage.hit {
  box-shadow: inset 0 0 80px 20px rgba(255, 0, 0, 0.7);
}

/* 血量 / 护甲 条 */
.fps-stats {
  position: absolute;
  left: 14px;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #fff;
  font-family: Menlo, Consolas, monospace;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  min-width: 200px;
}
.fps-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.fps-bar-label {
  min-width: 50px;
}
.fps-bar {
  flex: 1;
  height: 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.fps-bar-fill {
  height: 100%;
  transition: width 0.2s ease-out;
  background: linear-gradient(90deg, #25d4a8, #6c8cff);
}
.fps-bar-fill.hp {
  background: linear-gradient(90deg, #ff6b81, #ffb84d);
}
.fps-bar-fill.ar {
  background: linear-gradient(90deg, #6c8cff, #25d4a8);
}
.fps-bar-row b {
  min-width: 30px;
  text-align: right;
  font-size: 14px;
  color: #fff;
}

/* 武器区 */
.fps-weapon {
  position: absolute;
  right: 14px;
  bottom: 14px;
  color: #fff;
  font-family: Menlo, Consolas, monospace;
  text-align: right;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.fps-weapon-name {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2px;
}
.fps-ammo {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.fps-ammo b {
  font-size: 40px;
  color: #ffb84d;
}
.fps-ammo span {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.7);
}
.fps-ammo i {
  font-style: normal;
  color: rgba(255, 255, 255, 0.7);
}
.fps-score {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.fps-score b {
  color: #25d4a8;
  margin: 0 2px;
}

/* 假枪模型 */
.fps-gun {
  position: absolute;
  right: 18%;
  bottom: -40px;
  width: 150px;
  height: 120px;
  pointer-events: none;
  transform-origin: center bottom;
  transition: transform 0.08s;
}
.fps-gun.shooting {
  animation: gun-recoil 0.08s;
}
@keyframes gun-recoil {
  0%   { transform: translateY(0) rotate(0); }
  40%  { transform: translateY(-10px) rotate(-3deg); }
  100% { transform: translateY(0) rotate(0); }
}
.gun-body {
  position: absolute;
  right: 20px;
  bottom: 0;
  width: 120px;
  height: 40px;
  background: linear-gradient(180deg, #3a3a3a, #1a1a1a);
  border-radius: 4px;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.6);
}
.gun-body::before {
  content: '';
  position: absolute;
  left: 16px;
  top: -14px;
  width: 24px;
  height: 16px;
  background: #2a2a2a;
  border-radius: 2px;
}
.gun-barrel {
  position: absolute;
  right: 0;
  bottom: 14px;
  width: 70px;
  height: 10px;
  background: #0a0a0a;
  border-radius: 2px;
}
.gun-muzzle {
  position: absolute;
  right: -4px;
  bottom: 18px;
  width: 0;
  height: 0;
  opacity: 0;
  background: radial-gradient(circle, #ffd24d 0%, #ff6b1a 40%, transparent 70%);
  border-radius: 50%;
  filter: blur(2px);
}
.gun-muzzle.flash {
  width: 40px;
  height: 40px;
  right: -18px;
  bottom: 0;
  opacity: 1;
  transition: opacity 0.06s;
}

/* 击杀信息流 */
.fps-kill-feed {
  position: absolute;
  right: 14px;
  top: 44px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  font-family: Menlo, Consolas, monospace;
  font-size: 12px;
  max-width: 300px;
}
.fps-kill-feed > div {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  animation: kill-in 0.3s ease-out;
  border-left: 3px solid #ff6b81;
}
.fps-kill-feed > div.me      { border-left-color: #25d4a8; }
.fps-kill-feed > div.headshot { border-left-color: #ffb84d; }
@keyframes kill-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* 死亡/复活遮罩 */
.fps-respawn {
  position: absolute;
  inset: 0;
  background: rgba(30, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
  text-align: center;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s;
}
.fps-respawn.hide {
  opacity: 0;
}
.fps-respawn h3 {
  font-size: 32px;
  margin: 0 0 10px;
  color: #ff6b81;
  text-shadow: 0 0 20px rgba(255, 107, 129, 0.6);
}
.fps-respawn p {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

/* 手雷计数 */
.fps-grenade {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
}
.fps-grenade b {
  color: #25d4a8;
  font-size: 16px;
}

/* 武器栏 */
.fps-loadout {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  pointer-events: none;
  font-family: Menlo, Consolas, monospace;
}
.loadout-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  min-width: 56px;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
}
.loadout-slot.active {
  background: rgba(108, 140, 255, 0.35);
  border-color: #6c8cff;
  color: #fff;
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(108, 140, 255, 0.4);
}
.loadout-slot.empty {
  opacity: 0.35;
}
.slot-key {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
}
.loadout-slot.active .slot-key {
  background: #fff;
  color: #6c8cff;
}
.slot-icon {
  font-size: 18px;
  line-height: 1;
  margin: 2px 0;
}
.slot-name {
  font-size: 10px;
}

/* 爆炸光圈 */
.fps-explosion {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 200, 50, 0.9) 0%, rgba(255, 80, 30, 0.5) 50%, transparent 80%);
  animation: explode 0.6s ease-out forwards;
}
@keyframes explode {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* =====================================================
 * 9.12 三协议对比仿真
 * ===================================================== */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.sim-col {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.sim-col h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--primary);
}
.sim-track {
  height: 40px;
  background: var(--code-bg);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
}
.sim-dot {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #25d4a8;
  box-shadow: 0 0 6px rgba(37, 212, 168, 0.8);
}
.sim-dot.lost {
  background: #ff6b81;
  box-shadow: 0 0 6px rgba(255, 107, 129, 0.8);
  opacity: 0.5;
}
.sim-dot.blocked {
  background: #ffb84d;
  box-shadow: 0 0 6px rgba(255, 184, 77, 0.8);
}
.sim-stat {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  font-family: Menlo, Consolas, monospace;
}
.sim-stat b {
  color: var(--accent);
}

/* =====================================================
 * 汉堡菜单按钮 / 遮罩（默认在桌面隐藏）
 * ===================================================== */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.nav-toggle span {
  display: block;
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, top 0.25s ease, opacity 0.2s ease;
}
.nav-toggle span:nth-child(1) { top: 11px; }
.nav-toggle span:nth-child(2) { top: 17px; }
.nav-toggle span:nth-child(3) { top: 23px; }
.nav-toggle.open span:nth-child(1) { top: 17px; transform: rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { top: 17px; transform: rotate(-45deg); }

.nav-mask {
  display: none;
  position: fixed;
  inset: 64px 0 0 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.nav-mask.show {
  display: block;
  opacity: 1;
}

/* =====================================================
 * 移动端适配 (≤ 900px 平板及手机)
 * ===================================================== */
@media (max-width: 900px) {
  :root { --max-width: 100%; }
  .container { padding: 0 16px; }

  /* 顶部导航：折叠成抽屉 */
  .nav-bar { height: 56px; }
  .logo-text { font-size: 14px; }
  .logo-mark { width: 28px; height: 28px; font-size: 12px; }
  .nav-toggle { display: block; }
  .nav-mask { inset: 56px 0 0 0; }

  .main-nav {
    position: fixed;
    top: 56px;
    right: 0;
    width: 70%;
    max-width: 280px;
    height: calc(100vh - 56px);
    background: var(--bg-soft);
    border-left: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 50;
    overflow-y: auto;
  }
  .main-nav.open { transform: translateX(0); }
  .main-nav a {
    padding: 14px 22px;
    font-size: 15px;
    color: var(--text);
    border-bottom: 1px solid var(--line);
  }
  .main-nav a.active::after { display: none; }
  .main-nav a.active {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
  }

  /* Hero */
  .hero { padding: 50px 0 40px; }
  .hero-subtitle { font-size: 15px; padding: 0 4px; }
  .hero-actions { gap: 10px; flex-wrap: wrap; }
  .hero-stats { gap: 28px; }
  .hero-stats b { font-size: 22px; }

  /* 卡片 / 标题 */
  .topic-title { font-size: 22px; }
  .topic-desc { font-size: 14px; }
  .card { padding: 16px; }

  /* 各种 grid 全部坍塌成单列 */
  .grid-2,
  .flex-stage,
  .grid-stage,
  .dt-stage,
  .rtc-stage,
  .sfu-info,
  .dc-stage,
  .mp-simulator,
  .flow-editor {
    grid-template-columns: 1fr !important;
  }

  /* 流程图：高度自适应，禁止固定 460 */
  .flow-editor { height: auto; padding: 8px; }
  .flow-palette {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0 0 8px;
  }
  .flow-pal-title { width: 100%; }
  .flow-pal-item { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .flow-stage { min-height: 360px; }

  /* 小程序模拟器 */
  .mp-device { margin: 0 auto; }
  .mp-console { height: 360px; }

  /* 表单 / 按钮 */
  .demo-form { gap: 8px; }
  .ctrl-row { flex-wrap: wrap; }
  .btn { padding: 9px 16px; font-size: 14px; }

  /* WebRTC / SFU */
  .rtc-controls { flex-wrap: wrap; }
  .sfu-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  /* 现代 API 卡片：单列更友好 */
  .api-grid { grid-template-columns: 1fr; }

  /* 三协议对比 */
  .sim-grid { grid-template-columns: 1fr; }

  /* 比较表格水平滚动 */
  .cmp-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* 代码块 */
  pre, pre code { font-size: 12px; }
  pre { padding: 12px; }

  /* 游戏舞台：小屏改为 4:3 更易看 */
  .game-stage { aspect-ratio: 4 / 3; }
  .game-hud { font-size: 11px; gap: 6px; }
  .game-hud span { padding: 3px 8px; }

  /* 探索 / FPS */
  .explore-stage { aspect-ratio: 4 / 3; max-height: none; }
  .explore-controls { display: none; } /* 移动端无键盘，隐藏键位提示 */
  .explore-chat { width: 60%; max-height: 100px; }

  /* FPS HUD 等比缩小，避免遮挡画面 */
  .fps-stats { left: 8px; bottom: 90px; min-width: 140px; }
  .fps-bar-row { font-size: 11px; }
  .fps-bar-label { min-width: 36px; }
  .fps-weapon { right: 8px; bottom: 8px; }
  .fps-ammo { font-size: 24px; }
  .fps-ammo b { font-size: 30px; }
  .fps-ammo span { font-size: 16px; }
  .fps-loadout { gap: 4px; bottom: 8px; flex-wrap: wrap; max-width: 90%; justify-content: center; }
  .loadout-slot { padding: 4px 6px; min-width: 44px; font-size: 10px; }
  .slot-icon { font-size: 14px; }
  .fps-gun { width: 100px; height: 80px; right: 8%; bottom: -28px; }
  .fps-kill-feed { font-size: 11px; max-width: 60%; }

  /* 无限画布 */
  #infCanvas { height: 360px; }

  /* 表格、文本可换行 */
  table { font-size: 13px; }

  /* 工具栏在移动端紧凑 */
  .canvas-toolbar { gap: 6px; }
  .canvas-toolbar .btn { padding: 6px 10px; font-size: 12px; }

  /* footer */
  .site-footer { font-size: 12px; padding: 24px 0; }

  /* 回到顶部按钮 */
  .to-top { right: 14px; bottom: 14px; width: 40px; height: 40px; }

  /* hero 标题用 clamp 已经处理；额外：中文断词 */
  .hero-title { word-break: break-word; }
}

/* =====================================================
 * 小屏深度优化 (≤ 480px)
 * ===================================================== */
@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .hero { padding: 40px 0 30px; }
  .hero-title { font-size: 28px; }
  .hero-subtitle { font-size: 14px; }
  .hero-stats { gap: 18px; }
  .hero-stats b { font-size: 20px; }
  .hero-stats span { font-size: 12px; }

  .topic-title { font-size: 20px; }
  .card { padding: 14px; border-radius: 10px; }
  .card h3 { font-size: 16px; }

  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-primary, .btn-ghost { width: auto; }

  .gp-buttons { grid-template-columns: repeat(4, 1fr); }
  .gp-circle { width: 64px; height: 64px; }

  /* FPS：极小屏只保留最关键 HUD */
  .fps-stats { bottom: 80px; min-width: 120px; }
  .fps-kill-feed { display: none; }
  .fps-loadout .slot-name { display: none; }
  .loadout-slot { min-width: 36px; padding: 4px; }

  /* 代码字号再降一档 */
  pre, pre code { font-size: 11px; }
}

/* =====================================================
 * 横屏手机（避免 FPS 全屏 HUD 重叠）
 * ===================================================== */
@media (max-width: 900px) and (orientation: landscape) {
  .game-stage,
  .explore-stage { aspect-ratio: 16 / 9; max-height: 80vh; }
  .fps-stats { bottom: 60px; }
}

/* 触摸设备：去掉 hover 残留高亮 */
@media (hover: none) {
  .api-card:hover,
  .flow-pal-item:hover,
  .btn:hover,
  .main-nav a:hover {
    transform: none;
  }
}
