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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #101216;
  color: #e6e8ec;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#glCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
}

#glCanvas.is-dragging {
  cursor: grabbing;
}

body[data-camera-mode="seated"] #glCanvas { cursor: default; }
body[data-camera-mode="seated"] #glCanvas.has-media-pointer { cursor: none; }
body[data-camera-mode="seated"] #glCanvas.is-dragging { cursor: grabbing; }
body[data-camera-mode="roaming"] #glCanvas { cursor: crosshair; }

@media (max-aspect-ratio: 16/9) {
  body[data-camera-mode="seated"] #glCanvas,
  body[data-camera-mode="rising"] #glCanvas,
  body[data-camera-mode="sitting"] #glCanvas,
  body[data-camera-mode="poolPlay"] #glCanvas,
  body[data-camera-mode="roaming"] #glCanvas {
    position: absolute;
    inset: 0;
    height: min(100%, 56.25vw);
    margin: auto;
  }
}
.roaming-reticle { display: none; }
body[data-camera-mode="roaming"][data-pointer-locked="true"] .roaming-reticle,
body[data-camera-mode="roaming"][data-interaction-target] .roaming-reticle {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 8;
  display: block;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #f3f6fa;
  box-shadow: 0 0 2px 1px #111b;
  pointer-events: none;
}

.interaction-hint {
  position: fixed;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border: 1px solid #ffffff25;
  border-radius: 9px;
  background: #10151ac7;
  color: #fffffff0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
}

.interaction-hint {
  top: calc(50% + 25px);
  left: 50%;
  transform: translateX(-50%);
}

.interaction-hint[data-active="true"] { opacity: 1; }
.interaction-hint kbd {
  display: grid;
  min-width: 22px;
  height: 22px;
  padding-inline: 4px;
  place-items: center;
  border: 1px solid #ffffff9c;
  border-radius: 4px;
  background: #10151a80;
  font: 600 11px/1 ui-monospace, Consolas, monospace;
}
.interaction-hint svg { width: 22px; height: 22px; }
.interaction-hint svg { display: none; }
.interaction-hint[data-icon="chair"] .interaction-chair,
.interaction-hint[data-icon="eightBall"] .interaction-eight-ball,
.interaction-hint[data-icon="light"] .interaction-light { display: block; }
body[data-camera-mode="poolPlay"] #glCanvas { cursor: crosshair; }
.pool-controls, .pool-notice, .pool-shooter-tag {
  position: fixed;
  z-index: 8;
  padding: 7px 11px;
  border: 1px solid #aecbb85c;
  border-radius: 7px;
  background: #101e1be8;
  color: #edf4e8;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}
.pool-controls, .pool-notice {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 24px);
  transform: translateX(-50%);
}
.pool-notice { bottom: max(68px, env(safe-area-inset-bottom)); }
.pool-shooter-tag { transform: translate(-50%, -100%); color: #fff3bc; padding: 4px 8px; }
.pool-power { margin-top: 7px; height: 4px; border-radius: 2px; background: #ffffff35; }
.pool-power span { display: block; width: 0; height: 100%; border-radius: inherit; background: #e7c86b; }
.pool-power[data-mode="pull"] span { background: #9eb9b6; }

body[data-camera-mode="poolPlay"] #glCanvas[data-calling] { cursor: none; }
.pool-call-marker {
  position: fixed;
  z-index: 13;
  display: grid;
  justify-items: center;
  gap: 1px;
  transform: translate(-50%, -100%);
  pointer-events: none;
}
.pool-call-marker[hidden] { display: none; }
.pool-call-label {
  padding: 3px 8px;
  border: 1px solid #f6efd980;
  border-radius: 5px;
  background: #172822ed;
  color: #f6efd9;
  white-space: nowrap;
  font: 650 14px/1.35 "Microsoft YaHei", system-ui, sans-serif;
}
.pool-call-ball {
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #f7ebd4;
  border-radius: 50%;
  background: var(--ball-color);
  box-shadow: inset 0 -4px 7px #1b171951, 0 2px 8px #0008;
}
.pool-call-marker[data-ball-id] .pool-call-label { display: none; }
.pool-call-marker[data-ball-id] .pool-call-ball { display: grid; }
.pool-call-marker[data-striped] .pool-call-ball {
  background: linear-gradient(#e9e2d0 23%, var(--ball-color) 23% 77%, #e9e2d0 77%);
}
.pool-call-ball > span {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  background: #f6efde;
  color: #1e261f;
  font: 750 12px/1 system-ui, sans-serif;
}
.pool-call-arrow { display: block; grid-column: 1; }

.roaming-controls { display: none; }
body[data-camera-mode="roaming"]:not([data-pointer-locked="true"]) .roaming-controls {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(54px, env(safe-area-inset-bottom));
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 12px;
  border-radius: 8px;
  border: 1px solid #586679;
  background: #121821e8;
  color: #e0e9f4;
  font-size: 13px;
}
.room-panel {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid #ffffff23;
  border-radius: 8px;
  background: #111a24d9;
  color: #e7edf4;
  font-size: 12px;
  line-height: 1.2;
}
.room-panel[hidden] { display: none; }
.room-panel button {
  padding: 4px 6px;
  border: 1px solid #a6b8ca42;
  border-radius: 4px;
  background: transparent;
  color: #d9e4ef;
  font: inherit;
  cursor: pointer;
}
.room-panel button:hover { background: #d9e4ef22; }
.room-dot { width: 6px; height: 6px; border-radius: 50%; background: #e1bd77; }
.room-panel[data-status="connected"] .room-dot { background: #76d5b6; }
.room-panel[data-status="full"] .room-dot { background: #f1977d; }

.loading-overlay {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  width: min(340px, calc(100vw - 32px));
  padding: 14px 16px;
  background: rgba(18, 20, 26, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-title {
  font-size: 12px;
  color: #e6e8ec;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.loading-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.loading-fill {
  width: 0%;
  height: 100%;
  background: #e69d53;
  transition: width 0.12s ease-out;
}

.error-banner {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: 720px;
  padding: 12px 16px;
  background: rgba(120, 26, 26, 0.92);
  border: 1px solid rgba(255, 130, 130, 0.6);
  border-radius: 6px;
  color: #ffecec;
  font-size: 13px;
  white-space: pre-wrap;
}
