/**
 * ArenaLayout v1.2 — viewport float layer; free 2D drag.
 * Immersion v1 no longer transforms panels; keep transform kill as safety.
 */

#arena-float-layer.arena-float-layer {
  position: fixed !important;
  inset: 0 !important;
  z-index: 35;
  pointer-events: none; /* panels re-enable */
  overflow: visible !important;
  transform: none !important;
  filter: none !important;
  perspective: none !important;
  contain: none !important;
  will-change: auto !important;
}

/* When float is active, clear the old flex reservation so nothing stretches */
body.chess-page.arena-float-active .chess-main-row {
  position: relative !important;
  display: block !important;
  min-height: 40vh !important;
  overflow: visible !important;
  contain: none !important;
}

body.chess-page.arena-float-active .chess-hero-portrait {
  position: relative;
  z-index: 2;
}

/* Kill immersion float animations that fight drag (transform keyframes) */
body.chess-page.arena-float-active .flight-deck,
body.chess-page.arena-float-active aside.chess-match-rail,
body.chess-page.arena-float-active .chess-match-rail.tactical-sidebar,
body.chess-page.arena-float-active .arena-float-panel,
body.chess-page.arena-is-dragging .flight-deck,
body.chess-page.arena-is-dragging aside.chess-match-rail {
  animation: none !important;
  transform: none !important;
  will-change: auto !important;
}

/* Panels live on the float layer as absolute (layer is fixed viewport) */
#arena-float-layer .arena-float-panel.arena-float-enabled,
body.chess-page.arena-float-active .arena-float-panel.arena-float-enabled {
  position: absolute !important;
  z-index: 40;
  pointer-events: auto !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  max-width: none !important;
  flex: none !important;
  min-width: 0 !important;
  transform: none !important;
  animation: none !important;
  contain: none !important;
  will-change: auto !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
  left: 0;
  top: 0;
}

.arena-float-panel.arena-float-enabled.is-dragging,
.arena-float-panel.arena-float-enabled.is-resizing {
  z-index: 70;
  opacity: 0.97;
  user-select: none !important;
  touch-action: none !important;
}

body.arena-is-dragging {
  user-select: none !important;
  cursor: grabbing !important;
}

/* ── Chrome (compact handgrab / pin / lock — leave room for board) ── */
.arena-float-bar,
.arena-float-panel .side-panel-header.arena-float-drag {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  padding: 0.12rem 0.28rem !important;
  min-height: 1.15rem !important;
  height: 1.25rem !important;
  max-height: 1.35rem !important;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background: linear-gradient(
    180deg,
    rgba(0, 48, 28, 0.98),
    rgba(0, 18, 12, 0.95)
  ) !important;
  border-bottom: 1px solid rgba(0, 255, 136, 0.22) !important;
  color: #9fdfb0;
  font-family: "Courier New", monospace;
  font-size: 0.58rem !important;
  letter-spacing: 0.08em;
  font-weight: 700;
  flex: 0 0 auto !important;
  box-sizing: border-box !important;
}

.arena-float-panel.is-dragging .arena-float-bar,
.arena-float-panel.is-dragging .side-panel-header.arena-float-drag {
  cursor: grabbing;
}

.arena-float-panel.is-pinned .arena-float-bar,
.arena-float-panel.is-pinned .side-panel-header.arena-float-drag {
  cursor: default;
  opacity: 0.92;
}

.arena-float-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-float-tools {
  display: flex;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.arena-float-btn {
  appearance: none;
  border: 1px solid rgba(0, 255, 136, 0.35);
  background: rgba(0, 0, 0, 0.4);
  color: #b8f0c8;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 3px;
  font-size: 0.65rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.arena-float-btn:hover {
  background: rgba(0, 255, 136, 0.18);
  color: #fff;
}

.arena-float-btn.is-on {
  border-color: rgba(255, 200, 80, 0.7);
  color: #ffd86a;
  background: rgba(70, 45, 0, 0.5);
}

/* Board panel */
body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='board'].arena-float-enabled,
#arena-float-layer
  .arena-float-panel[data-float-id='board'].arena-float-enabled {
  display: flex !important;
  flex-direction: column !important;
  width: var(--arena-board-panel-w, var(--board-size, 440px)) !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  background: var(--forge-panel, rgba(0, 14, 8, 0.96));
  border: 1px solid var(--forge-line, rgba(0, 255, 136, 0.25));
  border-radius: 10px;
  padding: 0 0 2px !important;
  flex: none !important;
  contain: none !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='board'].flight-deck {
  width: var(--arena-board-panel-w, var(--board-size, 440px)) !important;
  max-width: none !important;
  flex: none !important;
  contain: none !important;
  animation: none !important;
  transform: none !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='board']
  #board-wrapper,
body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='board']
  #main-grid {
  width: var(--arena-board-size, var(--board-size, 440px)) !important;
  height: var(--arena-board-size, var(--board-size, 440px)) !important;
  max-width: none !important;
  max-height: none !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='board']
  .user-meta-zone {
  width: var(--arena-board-size, var(--board-size, 440px)) !important;
  max-width: none !important;
}

/* Moves panel — free height (kill min-height: board-size from playable) */
body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='moves'].arena-float-enabled,
body.chess-page.arena-float-active
  aside.chess-match-rail.arena-float-enabled,
body.chess-page.arena-float-active
  .chess-match-rail.tactical-sidebar.arena-float-enabled,
#arena-float-layer
  .arena-float-panel[data-float-id='moves'].arena-float-enabled {
  display: flex !important;
  flex-direction: column !important;
  width: var(--arena-moves-w, 280px) !important;
  min-width: 200px !important;
  max-width: min(480px, 95vw) !important;
  height: var(--arena-moves-h, 420px) !important;
  min-height: 200px !important;
  max-height: none !important;
  flex: none !important;
  align-self: auto !important;
  overflow: hidden !important;
  background: var(--forge-panel, rgba(0, 14, 8, 0.96)) !important;
  border: 1px solid var(--forge-line, rgba(0, 255, 136, 0.22)) !important;
  border-radius: 10px !important;
  animation: none !important;
  transform: none !important;
  contain: none !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='moves']
  .rail-shape,
body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='moves']
  .rail-fill {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='moves']
  .match-rail-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.chess-page.arena-float-active
  .arena-float-panel[data-float-id='moves']
  #move-history-list {
  flex: 1 1 auto !important;
  min-height: 6rem !important;
  max-height: none !important;
  overflow-y: auto !important;
}

/* Resize handle */
.arena-float-resize {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 8;
  touch-action: none;
  background: linear-gradient(
      135deg,
      transparent 45%,
      rgba(0, 255, 136, 0.35) 46%,
      rgba(0, 255, 136, 0.35) 54%,
      transparent 55%
    ),
    linear-gradient(
      135deg,
      transparent 68%,
      rgba(0, 255, 136, 0.7) 69%,
      rgba(0, 255, 136, 0.7) 78%,
      transparent 79%
    );
  border-radius: 0 0 8px 0;
}

.arena-float-panel.is-pinned .arena-float-resize {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  body.chess-page.arena-float-active .chess-hero-portrait {
    display: none;
  }
}
