:root {
  --brand-blue: #015ADC;
  --court-blue: #005CE4;
  --navy: #06255C;
  --orange: #F94E00;
  --ball-yellow: #D2AE00;
  --grass: #98A557;
  --paper: #F2F1F6;
  --ice: #ECF2FF;
  --white: #FFFFFF;
  --pink: #f3a9c6;
  --gold: #f4d47c;
  --glass: rgba(7, 14, 38, 0.54);
  --line: rgba(255, 255, 255, 0.18);
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #02040e;
  color: var(--ice);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-root {
  position: fixed;
  inset: 0;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 18%, rgba(244, 212, 124, 0.22), transparent 32%),
    radial-gradient(circle at 16% 86%, rgba(1, 90, 220, 0.30), transparent 36%),
    linear-gradient(180deg, #050719 0%, #02040e 54%, #000 100%);
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 50% 42%, transparent 0 52%, rgba(2, 8, 40, 0.16) 78%, rgba(2, 8, 40, 0.40) 100%),
    linear-gradient(180deg, rgba(2, 8, 40, 0.10), transparent 22%, transparent 74%, rgba(2, 8, 40, 0.22));
  mix-blend-mode: multiply;
}

.primary-btn,
.ghost-btn,
.draw-btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  color: var(--navy);
  font-weight: 950;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.primary-btn,
.draw-btn {
  color: var(--white);
  background: linear-gradient(135deg, #2f8cff, #0b5cff 48%, #6fb4ff);
  box-shadow: 0 18px 46px rgba(1, 90, 220, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.22) inset;
}

.ghost-btn {
  color: var(--ice);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.primary-btn:hover,
.ghost-btn:hover,
.draw-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.08);
}

.draw-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55) brightness(0.72);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.hud {
  position: absolute;
  z-index: 10;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.top-hud {
  top: max(16px, env(safe-area-inset-top));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 4, 14, 0.46);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.brand span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.16em;
}

.brand strong {
  color: var(--white);
  font-size: 14px;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 4, 14, 0.46);
  backdrop-filter: blur(18px);
  font-weight: 900;
}

.hud-metrics span + span {
  color: var(--gold);
}

.gate-panel,
.search-panel,
.action-panel,
.result-panel {
  position: absolute;
  z-index: 12;
  border: 1px solid rgba(142, 203, 255, 0.30);
  background: linear-gradient(180deg, rgba(16, 52, 160, 0.74), rgba(5, 16, 66, 0.62));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.18);
}

.gate-panel {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 28%, rgba(244, 212, 124, 0.20), transparent 32%),
    radial-gradient(circle at 50% 82%, rgba(1, 90, 220, 0.30), transparent 38%),
    rgba(0, 0, 0, 0.34);
}

.gate-card {
  width: min(520px, 92vw);
  padding: clamp(26px, 5vw, 46px);
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.56);
  text-align: center;
}

.gate-card h1 {
  margin: 0 0 10px;
  color: var(--white);
  font-size: clamp(36px, 7vw, 68px);
  line-height: 0.98;
  letter-spacing: -0.06em;
  text-shadow: 0 0 30px rgba(244, 212, 124, 0.34), 0 0 80px rgba(1, 90, 220, 0.34);
}

.gate-card p {
  color: rgba(236, 242, 255, 0.82);
}

.gate-card input,
.search-panel input {
  width: 100%;
  margin: 12px 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  outline: none;
  color: var(--white);
  background: rgba(255, 255, 255, 0.10);
  font-weight: 850;
}

.gate-card input:focus,
.search-panel input:focus {
  border-color: rgba(244, 212, 124, 0.72);
  box-shadow: 0 0 0 4px rgba(244, 212, 124, 0.12);
}

.hint {
  margin-bottom: 0;
  color: rgba(236, 242, 255, 0.60);
  font-size: 13px;
  font-weight: 750;
}

.search-panel {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 36px));
  padding: 20px;
  border-radius: 30px;
}

.search-panel h2,
.action-panel h2 {
  margin: 0 0 8px;
  color: var(--white);
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  max-height: 34vh;
  overflow: auto;
  padding-right: 4px;
}

.candidate {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  color: var(--ice);
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.candidate strong {
  color: var(--white);
  font-size: 17px;
}

.candidate span {
  color: rgba(236, 242, 255, 0.62);
  font-size: 12px;
  font-weight: 800;
}

.candidate em {
  grid-row: span 2;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--white);
  background: var(--brand-blue);
  font-style: normal;
  font-weight: 1000;
}

.candidate.female em {
  background: var(--pink);
  color: #28101b;
}

.candidate:hover {
  border-color: rgba(244, 212, 124, 0.70);
  background: rgba(244, 212, 124, 0.12);
}

.action-panel {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(620px, calc(100vw - 36px));
  padding: 18px;
  border-radius: 28px;
  transform: translateX(-50%);
  text-align: center;
}

.host-line {
  min-height: 28px;
  margin: 0 0 12px;
  color: var(--white);
  font-size: clamp(16px, 2.6vw, 22px);
  font-weight: 950;
  text-shadow: 0 0 24px rgba(244, 212, 124, 0.32);
}

.selected-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  color: rgba(236, 242, 255, 0.86);
  font-weight: 900;
}

.result-panel {
  right: max(18px, env(safe-area-inset-right));
  top: 50%;
  width: min(320px, calc(100vw - 36px));
  padding: 22px;
  border-radius: 30px;
  transform: translateY(-50%);
  text-align: center;
}

.result-face {
  display: grid;
  place-items: center;
  width: 148px;
  height: 212px;
  margin: 12px auto;
  border-radius: 22px;
  color: #101319;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.86), transparent 26%),
    linear-gradient(145deg, #fff 0%, #f6fbff 54%, #dfeaff 100%);
  box-shadow: 0 26px 80px rgba(1, 90, 220, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.70) inset;
  font-size: 54px;
  font-weight: 1000;
}

.result-face.red {
  color: #d71938;
}

.result-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  margin-bottom: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  color: #1b1200;
  background: linear-gradient(135deg, #fff6c2, var(--gold));
  font-size: 22px;
  font-weight: 1000;
}

.result-meta {
  color: rgba(236, 242, 255, 0.76);
  font-weight: 800;
}

.board-hint {
  margin: 12px 0 0;
  color: rgba(244, 212, 124, 0.90);
  font-size: 13px;
  font-weight: 950;
}

.result-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 12px 0 16px;
}

.result-board span {
  display: grid;
  gap: 3px;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  color: rgba(236, 242, 255, 0.72);
  background: rgba(255, 255, 255, 0.075);
  font-size: 12px;
  font-weight: 900;
}

.result-board b {
  color: var(--white);
  font-size: 21px;
  line-height: 1;
}

.subtitle {
  position: absolute;
  z-index: 16;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 122px);
  width: min(780px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  color: var(--white);
  background: rgba(0, 0, 0, 0.46);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
  text-align: center;
  font-size: clamp(15px, 2.5vw, 20px);
  font-weight: 950;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.subtitle.is-live {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: max(20px, env(safe-area-inset-top));
  max-width: min(560px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: var(--white);
  background: rgba(6, 10, 28, 0.82);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  font-weight: 900;
}

.match-fx {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.34), transparent 18%),
    radial-gradient(circle at 50% 46%, rgba(244, 212, 124, 0.38), transparent 34%),
    radial-gradient(circle at 18% 78%, rgba(1, 90, 220, 0.38), transparent 32%),
    rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(4px) saturate(1.3);
}

#fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.match-copy {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: matchPop 0.72s cubic-bezier(.2,1.4,.3,1) both;
}

.match-copy h2 {
  margin: 0;
  color: var(--white);
  font-size: clamp(52px, 12vw, 140px);
  line-height: 0.88;
  letter-spacing: -0.08em;
  text-shadow:
    0 0 18px rgba(255, 255, 255, 0.80),
    0 0 50px rgba(244, 212, 124, 0.82),
    0 0 120px rgba(1, 90, 220, 0.74);
}

.match-copy p:last-child {
  margin: 16px auto 0;
  color: var(--white);
  font-size: clamp(18px, 3vw, 30px);
  font-weight: 1000;
}

@keyframes matchPop {
  0% {
    opacity: 0;
    transform: scale(0.70) rotate(-4deg);
    filter: blur(12px);
  }
  58% {
    opacity: 1;
    transform: scale(1.08) rotate(2deg);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .brand strong {
    display: none;
  }

  .hud-metrics {
    font-size: 12px;
  }

  .search-panel,
  .action-panel {
    left: 12px;
    right: 12px;
    width: auto;
    transform: none;
  }

  .result-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    transform: none;
  }

  .subtitle {
    bottom: 178px;
  }
}

/* ============ 海报封面 · 拨动开关 · 固定大屏 · 主持控制台 ============ */

.gate-panel {
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(255, 255, 255, 0.30), transparent 60%),
    radial-gradient(700px 380px at 84% 110%, rgba(244, 212, 124, 0.32), transparent 62%),
    radial-gradient(760px 420px at 10% 98%, rgba(142, 203, 255, 0.30), transparent 60%),
    linear-gradient(180deg, #0c63f6 0%, #0a4fe0 52%, #0736bb 100%);
}

.poster {
  width: min(460px, calc(100vw - 40px));
  padding: 34px 30px 26px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.09));
  border: 1px solid rgba(255, 255, 255, 0.44);
  box-shadow: 0 30px 80px rgba(2, 10, 60, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.38);
  text-align: center;
  backdrop-filter: blur(10px);
}

.poster .eyebrow {
  margin: 0 0 10px;
  color: rgba(244, 212, 124, 0.92);
  font-weight: 900;
  letter-spacing: 0.18em;
  font-size: 12px;
}

.poster h1 {
  margin: 0;
  font-size: clamp(34px, 8vw, 46px);
  line-height: 1.16;
  font-weight: 1000;
  color: #f4d47c;
  text-shadow: 0 4px 26px rgba(244, 212, 124, 0.32);
}

.poster h1 span {
  display: block;
  color: #ecf2ff;
  font-size: 0.62em;
  letter-spacing: 0.32em;
  margin-top: 4px;
}

.poster .slogan {
  margin: 14px 0 0;
  font-size: 19px;
  font-weight: 900;
  color: #d9ebff;
  letter-spacing: 0.10em;
}

.poster .gate-desc {
  margin: 12px auto 20px;
  max-width: 340px;
  font-size: 13px;
  line-height: 1.75;
  color: rgba(236, 242, 255, 0.72);
}

.mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 0 16px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(4, 20, 70, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.32);
}

.mode-switch .mode-thumb {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc(50% - 5px);
  border-radius: 999px;
  background: linear-gradient(135deg, #015adc, #2f8cff);
  box-shadow: 0 6px 18px rgba(1, 90, 220, 0.45);
  transition: transform 0.26s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.mode-switch[data-active="host"] .mode-thumb {
  transform: translateX(100%);
  background: linear-gradient(135deg, #8a6a1c, #f4d47c);
  box-shadow: 0 6px 18px rgba(244, 212, 124, 0.38);
}

.mode-switch button {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: rgba(236, 242, 255, 0.66);
  font-weight: 900;
  font-size: 15px;
  padding: 11px 0;
  cursor: pointer;
  border-radius: 999px;
  letter-spacing: 0.12em;
  transition: color 0.2s;
}

.mode-switch button.active {
  color: #061022;
}

.poster input {
  width: 100%;
  margin: 0 0 10px;
}

#hostToken {
  border-color: rgba(244, 212, 124, 0.4);
}

/* 固定 2D 实时大屏：不随 3D 视角旋转 */
.live-board {
  position: fixed;
  top: 66px;
  right: 14px;
  width: min(430px, calc(100vw - 28px));
  border-radius: 16px;
  background: linear-gradient(170deg, rgba(6, 14, 38, 0.94), rgba(1, 4, 14, 0.92));
  border: 1px solid rgba(142, 203, 255, 0.24);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 30;
}

.board-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(142, 203, 255, 0.14);
}

.board-title {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: #f4d47c;
  flex: 1;
}

#boardClock {
  font-size: 12px;
  color: rgba(236, 242, 255, 0.72);
  font-weight: 800;
}

.board-toggle {
  border: 1px solid rgba(142, 203, 255, 0.34);
  background: rgba(1, 90, 220, 0.18);
  color: #8ecbff;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.board-body {
  padding: 8px;
}

.board-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.live-board.collapsed .board-body {
  display: none;
}

/* 主持控制台 */
.host-panel {
  position: fixed;
  top: 66px;
  right: 14px;
  bottom: 14px;
  width: min(470px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(7, 15, 40, 0.96), rgba(1, 4, 14, 0.95));
  border: 1px solid rgba(244, 212, 124, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  z-index: 40;
  overflow: hidden;
}

.host-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 10px;
}

.host-head .eyebrow {
  margin: 0 0 4px;
  color: rgba(244, 212, 124, 0.9);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.18em;
}

.host-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 1000;
  color: #ecf2ff;
}

.host-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 4px 16px 10px;
}

.host-stats .stat {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 8px 10px;
}

.host-stats .stat b {
  display: block;
  font-size: 20px;
  font-weight: 1000;
  color: #f4d47c;
}

.host-stats .stat span {
  font-size: 11px;
  color: rgba(236, 242, 255, 0.66);
  font-weight: 800;
}

.host-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 10px;
}

.danger-btn {
  border: 1px solid rgba(255, 120, 120, 0.5);
  background: rgba(160, 30, 30, 0.32);
  color: #ffb4b4;
  font-weight: 900;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.danger-btn.armed {
  background: rgba(200, 40, 40, 0.6);
  color: #fff;
}

.host-tip {
  font-size: 11px;
  color: rgba(236, 242, 255, 0.55);
}

.host-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  border-top: 1px solid rgba(142, 203, 255, 0.12);
}

.host-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.host-row strong {
  color: #ecf2ff;
  font-weight: 900;
}

.host-row span {
  color: rgba(236, 242, 255, 0.6);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-row em {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: #8ecbff;
}

.host-row em.ok {
  color: #f4d47c;
}

.host-row em.muted {
  color: rgba(236, 242, 255, 0.38);
}

.host-row button {
  border: 1px solid rgba(142, 203, 255, 0.36);
  background: rgba(1, 90, 220, 0.16);
  color: #8ecbff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
}

.host-row button:hover {
  background: rgba(1, 90, 220, 0.34);
}

.host-events {
  max-height: 118px;
  overflow-y: auto;
  padding: 8px 16px 12px;
  border-top: 1px solid rgba(142, 203, 255, 0.12);
  font-size: 11px;
  line-height: 1.7;
  color: rgba(236, 242, 255, 0.62);
}

.host-events b {
  color: rgba(244, 212, 124, 0.9);
}

@media (max-width: 760px) {
  .live-board {
    top: 56px;
    right: 8px;
    width: min(300px, calc(100vw - 16px));
  }

  .host-panel {
    top: 56px;
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .host-row {
    grid-template-columns: 58px 1fr auto auto;
  }
}

/* 主持模式下，大屏让位到左侧，避免与控制台重叠 */
body.host-mode .live-board {
  right: auto;
  left: 14px;
}

@media (max-width: 760px) {
  body.host-mode .live-board {
    left: 8px;
  }
}
