.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.boardCard,
.trayCard {
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.boardCard {
  position: relative;
  overflow: visible;
  --boardSize: min(92vmin, 520px);
}

.boardHeader {
  padding: 12px 14px 0 14px;
}

.boardHint {
  font-size: 13px;
  color: var(--muted);
}

.noSpaceBtn {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 150px;
  z-index: 80;

  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;

  padding:
    50px
    14px;

  border-radius: 0;
  border: 0;
  background:#00000094;
  box-shadow: 0 -16px 32px rgba(0, 0, 0, 0.32);
  color: rgba(255, 255, 255, 0.98);
  font-size: 35px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.6px;
  cursor: pointer;
  text-align: center;
  transition: transform 120ms ease, filter 120ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.noSpaceBtn:active {
  transform: scale(0.98);
}

.noSpaceBtn:focus {
  outline: none;
  filter: brightness(1.12);
}

.noSpaceBtn.hidden {
  display: none;
}

#boardHint {
  display: none;
}

.board {
  width: var(--boardSize);
  height: var(--boardSize);
  padding: 5px;
  display: grid;
  position: relative;
  direction: ltr;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  touch-action: none;
  border-radius: 12px;
  background: #1f2549;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.15),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25),
    0 10px 18px rgba(0, 0, 0, 0.25);
  border: 4px solid #141830;
}

.cell {
  --bevel: 6px;
  --bevelLineHalf: 1px;
  --bevelShade: rgba(88, 44, 10, 0.34);
  --bevelShade2: rgba(70, 34, 8, 0.52);

  background: var(--cell);

  position: relative;
  overflow: hidden;
  z-index: 2;
}

.cell.filled {
  border-color: var(--cellFilledStroke);
  background: var(--fill, rgba(255, 255, 255, 0.2));
  border-style: solid;
  border-width: var(--bevel);
  border-top-color: var(--fillTop, rgba(255, 255, 255, 0.22));
  border-right-color: var(--fillRight, rgba(0, 0, 0, 0.18));
  border-bottom-color: var(--fillBottom, rgba(0, 0, 0, 0.22));
  border-left-color: var(--fillLeft, rgba(255, 255, 255, 0.16));
  box-shadow: none;
}

.cell.filled.hint-glow {
  box-shadow: 0 0 8px 3px rgba(107, 191, 89, 0.6);
}

.cell.filled::before {
  content: none;
}

.cell.filled::after {
  content: none;
}

.cell.hint-glow {
  box-shadow: 0 0 8px 3px rgba(107, 191, 89, 0.6), inset 0 0 6px rgba(107, 191, 89, 0.2);
  z-index: 3;
}

.cell.cell-selectable {
  cursor: crosshair;
}

.cell.cell-select-hammer {
  animation: cellPulse 1s ease-in-out infinite;
}

.cell.cell-select-bomb {
  animation: cellPulseBomb 1s ease-in-out infinite;
}

.cell.cell-selectable:hover {
  box-shadow: 0 0 12px 4px rgba(255, 215, 0, 0.5), inset 0 0 8px rgba(255, 215, 0, 0.15);
  z-index: 5;
}

@keyframes cellPulse {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(107, 191, 89, 0.4); }
  50% { box-shadow: 0 0 14px 5px rgba(107, 191, 89, 0.8); }
}

@keyframes cellPulseBomb {
  0%, 100% { box-shadow: 0 0 4px 1px rgba(255, 80, 80, 0.4); }
  50% { box-shadow: 0 0 14px 5px rgba(255, 80, 80, 0.8); }
}

.cell.linePreview {
  outline-offset: 0px;
  box-shadow:
    0 0 0 2px var(--linePreviewRing, rgba(255, 255, 255, 0.18)),
    0 0 10px 3px var(--linePreviewGlow, rgba(255, 255, 255, 0.18));
  z-index: 3;
}

.cell.ghostPiece {
  border-color: var(--cellFilledStroke);
  background: var(--ghostFill, rgba(255, 255, 255, 0.2));
  border-style: solid;
  border-width: var(--bevel);
  border-top-color: var(--ghostFillTop, rgba(255, 255, 255, 0.22));
  border-right-color: var(--ghostFillRight, rgba(0, 0, 0, 0.18));
  border-bottom-color: var(--ghostFillBottom, rgba(0, 0, 0, 0.22));
  border-left-color: var(--ghostFillLeft, rgba(255, 255, 255, 0.16));
  box-shadow: none;
  opacity: 0.55;
  filter: saturate(1.05) brightness(1.06);
}

.cell.ghostPiece::before {
  content: none;
}

.cell.ghostPiece::after {
  content: none;
}

.cell.ghostPieceBad {
  border-color: var(--cellFilledStroke);
  background: var(--ghostFill, rgba(255, 255, 255, 0.2));
  border-style: solid;
  border-width: var(--bevel);
  border-top-color: var(--ghostFillTop, rgba(255, 255, 255, 0.22));
  border-right-color: var(--ghostFillRight, rgba(0, 0, 0, 0.18));
  border-bottom-color: var(--ghostFillBottom, rgba(0, 0, 0, 0.22));
  border-left-color: var(--ghostFillLeft, rgba(255, 255, 255, 0.16));
  box-shadow: none;
  opacity: 0.32;
  filter: saturate(0.85) brightness(0.95);
}

.cell.ghostPieceBad::before {
  content: none;
}

.cell.ghostPieceBad::after {
  content: none;
}

.cell.ghostGood {
  outline: 2px solid rgba(34, 197, 94, 0.8);
  outline-offset: -1px;
}

.cell.ghostBad {
  outline: 2px solid rgba(251, 113, 133, 0.85);
  outline-offset: -1px;
}

.cell.flash {
  animation: flash 260ms ease-in-out 1;
}

.cell.place-pop {
  animation: pop calc(120ms / var(--time-scale)) ease-out 1;
}

@keyframes pop {
  0% { transform: scale(0.9); box-shadow: none; }
  70% {
    transform: scale(1.08);
    box-shadow:
      0 0 0 2px color-mix(in srgb, var(--popShadowColor, rgba(255, 255, 255, 0.35)) 65%, transparent),
      0 0 14px 2px var(--popShadowColor, rgba(255, 255, 255, 0.35));
  }
  100% { transform: scale(1); box-shadow: none; }
}

.cell.clear-flash {
  animation: clearFlash 260ms ease 1;
}

.cell.line-clear {
  overflow: visible;
  animation: clearLine calc(260ms / var(--time-scale)) cubic-bezier(.2,.9,.3,1) 1 forwards;
  transform-origin: center;
  z-index: 10;
}

.cell.line-clear.row {
  overflow: visible;
  z-index: 10;
  animation:
    clearRow calc(260ms / var(--time-scale)) ease-out 1 forwards,
    blockFlash calc(200ms / var(--time-scale)) ease forwards;
}

.cell.line-clear.col {
  overflow: visible;
  z-index: 10;
  animation:
    clearCol calc(260ms / var(--time-scale)) ease-out 1 forwards,
    blockFlash calc(200ms / var(--time-scale)) ease forwards;
}

#column-clear-beam,
.column-clear-beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0px;
  background: linear-gradient(to bottom, transparent, #ff9f1a, #ffd36a, #ff9f1a, transparent);
  box-shadow: 0 0 25px rgba(255, 160, 40, .9);
  opacity: 0;
  pointer-events: none;
  transform: scaleY(0.1);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 20;
}

#row-clear-beam,
.row-clear-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 0px;
  background: linear-gradient(to right, transparent, #ff9f1a, #ffd36a, #ff9f1a, transparent);
  box-shadow: 0 0 25px rgba(255, 160, 40, .9);
  opacity: 0;
  pointer-events: none;
  transform: scaleX(0.1);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 20;
}

#fx {
  position: absolute;
  inset: -28px;
  pointer-events: none;
  z-index: 60;
  width: 100%;
  height: 100%;
}

#column-clear-beam.beamActive,
.column-clear-beam.beamActive {
  opacity: 1;
  transform: scaleY(1);
}

#row-clear-beam.beamActive,
.row-clear-beam.beamActive {
  opacity: 1;
  transform: scaleX(1);
}

@keyframes clearLine {
  0% { transform: scale(1); filter: brightness(1.08); opacity: 1; }
  40% { transform: scale(1.12); filter: brightness(1.35); }
  100% { transform: translate(var(--shatter-x, 0px), var(--shatter-y, 0px)) rotate(var(--shatter-r, 0deg)) scale(0.3); clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); opacity: 0; }
}

@keyframes clearRow {
  0% { transform: translate(0, 0) rotate(0deg); filter: brightness(1.25); opacity: 1; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { transform: translate(var(--shatter-x, 0px), var(--shatter-y, 0px)) rotate(var(--shatter-r, 0deg)); clip-path: polygon(calc(var(--shatter-clip, 4px)*1.5) 0, calc(100% - var(--shatter-clip, 4px)) 0, 100% 35%, calc(100% - var(--shatter-clip, 4px)*1.5) 100%, var(--shatter-clip, 4px) 100%, 0 65%); opacity: 0; }
}

@keyframes clearCol {
  0% { transform: translate(0, 0) rotate(0deg); filter: brightness(1.25); opacity: 1; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { transform: translate(var(--shatter-x, 0px), var(--shatter-y, 0px)) rotate(var(--shatter-r, 0deg)); clip-path: polygon(0 calc(var(--shatter-clip, 4px)*1.5), 35% 0, calc(100% - var(--shatter-clip, 4px)) 0, 100% var(--shatter-clip, 4px), 100% calc(100% - var(--shatter-clip, 4px)*1.5), 65% 100%, var(--shatter-clip, 4px) 100%, 0 calc(100% - var(--shatter-clip, 4px))); opacity: 0; }
}

@keyframes blockFlash {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
  100% { filter: brightness(1); opacity: 0; }
}

@keyframes clearFlash {
  0% { filter: brightness(1.8); }
  100% { filter: brightness(1); }
}

.shake {
  animation: shake 260ms 1;
}

@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

@keyframes flash {
  0% { transform: scale(1); }
  50% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
