/* V49: the merge grid is one physical tray resting on the worktop. */

.merge-panel .board-wrap {
  overflow: visible;
  filter: none;
  perspective: none;
}

.merge-panel .board-stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 430px;
  height: 322.5px;
  max-width: none;
  padding-bottom: 10px;
  box-sizing: border-box;
  transform: perspective(860px) rotateX(22deg);
  transform-origin: 50% 78%;
  transform-style: preserve-3d;
  isolation: isolate;
  filter: drop-shadow(0 18px 11px rgb(12 7 8 / 42%));
  pointer-events: none;
}

.merge-panel .board-tray-base {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  pointer-events: none;
  user-select: none;
}

.merge-panel .board-tray-base img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.merge-panel .board-stage .board {
  position: relative;
  z-index: 1;
  margin: 0;
  pointer-events: auto;
}

.merge-panel .board-stage .cell {
  filter: drop-shadow(0 2px 1px rgb(8 7 11 / 34%));
}

.merge-panel .board-stage .cell:is(.selected-cell, .merge-target) {
  filter: brightness(1.12) drop-shadow(0 0 7px rgb(255 225 139 / 88%));
}

@media (min-width: 721px) and (min-height: 500px) {
  .merge-panel .board-wrap {
    place-items: start center;
    padding-top: 0;
  }

  .merge-panel .board-stage .board {
    grid-template-columns: repeat(5, 56px);
    grid-template-rows: repeat(4, 56px);
    gap: 2px;
    width: auto;
    height: auto;
  }

  .merge-panel .board-stage .cell {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    padding: 7px;
  }

  .merge-panel .board-stage .cell img {
    width: 42px;
    height: 42px;
  }

  .merge-panel .board-stage {
    top: -78px;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .merge-panel .board-wrap {
    padding: 0;
    place-items: start center;
  }

  .merge-panel .board-stage {
    width: 380px;
    height: 380px;
    padding-bottom: 4px;
    transform: perspective(800px) rotateX(10deg);
    transform-origin: 50% 76%;
    filter: drop-shadow(0 14px 9px rgb(10 6 8 / 38%));
    top: -20px;
  }

  .merge-panel .board-stage .board {
    grid-template-columns: repeat(5, 49px);
    grid-template-rows: repeat(4, 49px);
    gap: 2px;
    width: auto;
    height: auto;
    max-height: none;
  }

  .merge-panel .board-stage .cell {
    width: 49px;
    height: 49px;
    min-width: 49px;
    min-height: 49px;
    padding: 6px;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .merge-panel .board-wrap {
    padding: 0;
    place-items: start center;
  }

  .merge-panel .board-stage {
    width: 300px;
    height: 225px;
    padding-bottom: 2px;
    transform: perspective(760px) rotateX(5deg);
    transform-origin: 50% 78%;
    filter: drop-shadow(0 12px 8px rgb(9 6 8 / 38%));
    top: -21px;
  }

  .merge-panel .board-stage .board {
    grid-template-columns: repeat(5, 46px);
    grid-template-rows: repeat(4, 46px);
    gap: 2px;
    width: auto;
    height: auto;
  }

  .merge-panel .board-stage .cell {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    padding: 5px;
  }
}
