:root {
  --bg: #070c18;
  --bg-2: #0c1428;
  --card: rgba(18, 28, 50, 0.72);
  --line: rgba(140, 200, 255, 0.14);
  --text: #e8f1ff;
  --dim: #8fa4c4;
  --cyan: #6ee7ff;
  --pink: #ff8fc7;
  --mint: #8ff5c8;
  --danger: #ff6b81;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

.hidden { display: none !important; }

/* ---------------- 密码门 ---------------- */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.gate-bg {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(45% 45% at 20% 20%, rgba(110, 231, 255, 0.22), transparent 70%),
    radial-gradient(40% 40% at 80% 70%, rgba(255, 143, 199, 0.18), transparent 70%),
    radial-gradient(60% 60% at 50% 110%, rgba(143, 245, 200, 0.12), transparent 70%),
    linear-gradient(160deg, #060a14, #0b1224 60%, #0a0f1d);
  filter: blur(0px);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1.02); }
  to { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

.gate-card {
  position: relative;
  width: min(400px, 100%);
  padding: 34px 30px 26px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(22, 34, 60, 0.92), rgba(12, 20, 38, 0.94));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  backdrop-filter: blur(14px);
}

.cone {
  font-size: 42px;
  line-height: 1;
  filter: drop-shadow(0 8px 18px rgba(110, 231, 255, 0.35));
}

.gate-card h1 {
  margin: 14px 0 6px;
  font-size: 26px;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.gate-card h1 span { color: var(--cyan); }

.gate-card .sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--dim);
  letter-spacing: 0.4px;
}

#gateForm { display: grid; gap: 10px; }

input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(140, 200, 255, 0.22);
  background: rgba(6, 12, 24, 0.75);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input[type="password"]:focus {
  border-color: rgba(110, 231, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.14);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition: transform 0.12s, background 0.18s, opacity 0.18s;
}

button:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#gateBtn {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  box-shadow: 0 10px 30px rgba(110, 231, 255, 0.25);
}

#gateBtn:hover { background: linear-gradient(135deg, #8af0ff, #a5ffd8); }

.gate-msg {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.gate-tip {
  margin: 6px 0 0;
  font-size: 11px;
  color: rgba(143, 164, 196, 0.75);
  line-height: 1.6;
}

/* ---------------- 舞台 ---------------- */

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(70% 50% at 50% -10%, rgba(110, 231, 255, 0.10), transparent 70%),
    linear-gradient(180deg, #070c18, #05080f);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 14, 26, 0.7);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  font-size: 12px;
  color: var(--dim);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.pill.ok { color: var(--mint); border-color: rgba(143, 245, 200, 0.35); background: rgba(143, 245, 200, 0.08); }
.pill.warn { color: #ffd58a; border-color: rgba(255, 213, 138, 0.35); background: rgba(255, 213, 138, 0.08); }
.pill.bad { color: var(--danger); border-color: rgba(255, 107, 129, 0.35); background: rgba(255, 107, 129, 0.08); }
.pill.ghost { cursor: pointer; }
.pill.ghost:hover { color: var(--text); }

/* ---------------- 主机 ---------------- */

.host {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  padding: 14px 16px 16px;
  min-height: 0;
}

.game-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.game-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#game { position: absolute; inset: 0; }
#game ruffle-player { width: 100%; height: 100%; display: block; }

.splash {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 40%, rgba(16, 26, 46, 0.9), rgba(4, 8, 16, 0.98));
  font-size: 13px;
  color: var(--dim);
  z-index: 5;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(110, 231, 255, 0.2);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.game-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.tag {
  font-size: 11.5px;
  color: var(--dim);
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.tag.warn { color: #ffd58a; border-color: rgba(255, 213, 138, 0.3); }
.tag.ok { color: var(--mint); border-color: rgba(143, 245, 200, 0.3); }

/* 面板 */

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 2px;
}

.panel-block {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.panel-title {
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(143, 164, 196, 0.8);
  margin-bottom: 10px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  margin-bottom: 9px;
}

.seg button {
  padding: 8px 6px;
  font-size: 12.5px;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
}

.seg button.on {
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  font-weight: 600;
}

.panel-hint {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--dim);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--dim);
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.check input { accent-color: #6ee7ff; width: 15px; height: 15px; }

.btn-row { display: flex; gap: 8px; }
.btn-row button { flex: 1; }

button.primary {
  color: #041018;
  font-weight: 600;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
}
button.primary:hover { background: linear-gradient(135deg, #8af0ff, #a5ffd8); }

button.danger { color: #ffd7dd; background: rgba(255, 107, 129, 0.16); border: 1px solid rgba(255, 107, 129, 0.35); }
button.danger:hover { background: rgba(255, 107, 129, 0.26); }

.stats { margin: 0; display: grid; gap: 7px; }
.stats > div { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; }
.stats dt { color: var(--dim); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }

.steps { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.75; color: var(--dim); }
.steps b { color: var(--text); font-weight: 600; }

/* ---------------- 客机 ---------------- */

.guest { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; padding: 12px 14px 14px; gap: 10px; }

.video-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
  outline: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 45%, rgba(14, 24, 44, 0.86), rgba(4, 8, 16, 0.96));
  transition: opacity 0.35s;
}

.overlay.hidden { display: none !important; }

.overlay h2 { margin: 0; font-size: 17px; font-weight: 600; }
.overlay p { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.7; max-width: 340px; }

.guest-hud {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: rgba(232, 241, 255, 0.85);
  pointer-events: none;
}

.guest-hud span {
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-variant-numeric: tabular-nums;
}

.guest-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.keys { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 6px;
  font-size: 11px;
  font-family: inherit;
  text-align: center;
  color: var(--text);
  border-radius: 6px;
  border: 1px solid rgba(140, 200, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.keys .dim { color: rgba(143, 164, 196, 0.65); }

.bar-actions { display: flex; gap: 8px; }
.bar-actions button { padding: 8px 14px; font-size: 12.5px; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--text);
  background: rgba(16, 26, 46, 0.95);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 99;
  max-width: min(90vw, 460px);
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .host { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .panel { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .panel-block { min-width: 230px; }
  .topbar { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .host { padding: 8px; gap: 8px; }
  .guest { padding: 8px; }
  .brand em { display: none; }
  .game-foot { display: none; }
}
