/* Shared stage. Scoreboard on the left, tree on the right, both at the
   same height so the full artwork stays in frame. Practice uses this now.
   Live head-to-head and tournament screens can add .ptl-stage around their
   existing tree and board without a rewrite. Artwork is not cropped:
   height drives the size, width follows the file aspect ratio. */

.ptl-stage {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  background: transparent;
}

html.arena-mode .ptl-stage > .solo-board,
html.arena-mode .ptl-stage > .ptl-stage__board,
.ptl-stage > .solo-board,
.ptl-stage > .ptl-stage__board {
  order: 1 !important;
  flex: 0 0 auto;
  height: var(--ptl-stage-h, 520px);
  width: auto;
  margin: 0;
}

html.arena-mode .ptl-stage > .tree-v2,
html.arena-mode .ptl-stage > .ptl-stage__tree,
.ptl-stage > .tree-v2,
.ptl-stage > .ptl-stage__tree {
  order: 2 !important;
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

.ptl-stage > .solo-board img,
.ptl-stage > .ptl-stage__board img,
.ptl-stage .ptl-tree-art {
  height: var(--ptl-stage-h, 520px);
  width: auto;
  max-width: none;
  object-fit: contain;
}

/* Desktop practice. Width, not pointer type, so a laptop trackpad and a
   mouse get the same stage. 230px is the chrome under and over the
   equipment: tabs, delay row, Hold to stage, mode line, tools. */
html.arena-mode,
html.arena-mode body {
  overflow: hidden !important;
  background: #000 !important;
}
@media (min-width: 1024px) {
  html.arena-mode,
  html.arena-mode body {
    background: #000 !important;
  }
  html.arena-mode main {
    position: fixed !important;
    top: var(--psh-top, 94px) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: var(--psh-bot, 0px) !important;
    height: auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 clamp(16px, 2.5vw, 40px) 6px !important;
    margin: 0 !important;
    background: #000 !important;
  }
  html.arena-mode {
    /* Header is outside this number. 172px reserves the control bar, the
       hold row, and a 36px toolbar with the gaps between them. The stem is
       inside the button, so it is not part of this reserve. A 1440x900 tree
       stays near 670px and a 1366x768 tree near 540px, both at least +50%
       on the previous baselines. */
    --ptl-stage-h: clamp(520px, calc(100svh - var(--psh-top, 64px) - var(--psh-bot, 0px) - 172px), 840px);
  }
  html.arena-mode .arena {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    justify-content: flex-start !important;
    gap: 4px !important;
  }
  html.arena-mode .stage-pair,
  html.arena-mode .ptl-stage {
    flex: 0 0 auto !important;
    /* The base .ptl-stage rule sets min-height: 0, which let the grid crush
       the row and paint the hold button over the tree base. The art is the
       row's minimum. */
    height: var(--ptl-stage-h) !important;
    min-height: var(--ptl-stage-h) !important;
    max-height: none !important;
    overflow: visible !important;
  }
  html.arena-mode .tb-row {
    flex: 0 0 auto !important;
    margin-top: 2px !important;
  }
  html.arena-mode .tb-row .transbrake-zone,
  html.arena-mode .tb-row .bump-zone {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  html.arena-mode .tb-row .transbrake-label,
  html.arena-mode .tb-row .transbrake-hint,
  html.arena-mode .tb-row .bump-hint { display: none !important; }
  html.arena-mode .tb-row .transbrake-hint { margin: 2px 0 0 !important; }
  html.arena-mode .stage-pair,
  html.arena-mode .ptl-stage {
    --stage-h: var(--ptl-stage-h);
    align-items: flex-end !important;
    justify-content: center !important;
    gap: 12px !important;
    width: 100%;
    max-width: none;
    margin: 0 auto !important;
  }
  html.arena-mode .stage-pair .tree-v2 .ptl-tree-art,
  html.ptl-tree-result.arena-mode .stage-pair .tree-v2 .ptl-tree-art,
  html.arena-mode .ptl-stage .ptl-tree-art {
    height: var(--ptl-stage-h) !important;
    width: auto !important;
    max-height: none !important;
    object-fit: contain !important;
  }
  html.arena-mode .stage-pair .solo-board,
  html.ptl-tree-result.arena-mode .stage-pair .solo-board,
  html.arena-mode .ptl-stage > .solo-board {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    opacity: 1 !important;
    height: var(--ptl-stage-h) !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    align-self: flex-end !important;
  }
  html.arena-mode .stage-pair .solo-board img,
  html.arena-mode .ptl-stage > .solo-board img {
    height: 100% !important;
    width: auto !important;
    max-width: none !important;
    object-fit: contain !important;
  }
  html.arena-mode .tb-row .transbrake-btn,
  html.ptl-tree-result.arena-mode .tb-row .transbrake-btn {
    min-height: 68px !important;
    font-size: 14px !important;
    letter-spacing: 0.14em !important;
    padding: 8px 18px 8px 92px !important;
  }
  html.arena-mode .tb-row .transbrake-btn::before {
    width: 58px !important;
    height: 58px !important;
  }
  /* The grip is painted from the button's vertical center with no upward
     shift, so a 66px stem hangs through the toolbar. Keep it inside the
     button, under the dome. */
  html.arena-mode .tb-row .transbrake-btn::after {
    top: auto !important;
    bottom: 4px !important;
    height: 22px !important;
    width: 22px !important;
    left: 30px !important;
    right: auto !important;
    transform: none !important;
  }
}
