/* WebGL board stage — real Three.js meshes, not CSS pseudo-3D */
.chess-stage {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 4px 0 8px;
}

.chess-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1.05 / 1;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(90, 70, 180, 0.4) 0%, transparent 55%),
    linear-gradient(180deg, #1a1438 0%, #0a0818 55%, #06040e 100%);
  box-shadow:
    0 18px 40px rgba(8, 6, 24, 0.55),
    inset 0 1px 0 rgba(160, 180, 255, 0.16);
}

.chess-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* Turn + score sit in front of the waterfall (top of the 3D view) */
.chess-hud-overlay {
  position: absolute;
  top: 3.5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: min(92%, 360px);
  text-align: center;
}

.chess-hud-turn {
  font-size: clamp(14px, 2.6vw, 18px);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.2;
  padding: 6px 14px;
  border-radius: 999px;
  color: #0f1a14;
  background: rgba(236, 248, 242, 0.88);
  box-shadow: 0 4px 18px rgba(12, 28, 22, 0.35);
  backdrop-filter: blur(6px);
}

.chess-hud-turn[data-side="w"] {
  color: #1a2228;
  background: rgba(220, 228, 236, 0.92);
}

.chess-hud-turn[data-side="b"] {
  color: #2a1e08;
  background: rgba(232, 196, 88, 0.92);
}

.chess-hud-score {
  font-size: clamp(11px, 2vw, 13px);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(245, 252, 248, 0.95);
  text-shadow: 0 1px 4px rgba(8, 20, 16, 0.75);
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(18, 36, 28, 0.42);
}

@media (max-width: 1024px) {
  .chess-stage {
    width: min(90vw, 70vmin, 680px);
  }
}

@media (max-width: 640px) {
  .chess-stage {
    width: min(96vw, 58vh, 480px);
  }
  .chess-canvas-wrap {
    border-radius: 12px;
  }
}

/* In-room: board + chat share one viewport (page itself must not scroll) */
.chess-play-shell {
  height: 100dvh;
  max-height: 100svh;
  overflow: hidden;
}

.chess-play-shell .chess-stage {
  width: min(100%, 58dvh, 560px);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 2px;
}

.chess-play-shell .chess-canvas-wrap {
  height: 100%;
  max-height: min(62dvh, 720px);
  aspect-ratio: auto;
}

@media (min-width: 768px) {
  .chess-play-shell .chess-stage {
    width: min(100%, 68dvh, 680px);
  }
  .chess-play-shell .chess-canvas-wrap {
    max-height: min(70dvh, 760px);
  }
}

@media (min-width: 1024px) {
  .chess-play-shell .chess-stage {
    width: min(100%, 74dvh, 780px);
  }
  .chess-play-shell .chess-canvas-wrap {
    max-height: min(78dvh, 820px);
  }
}
