/* Tetris-specific styles */
.game--tetris { max-width: 760px; }

.t-layout {
  display: grid;
  grid-template-columns: 130px auto 130px;
  gap: 14px;
  align-items: start;
  justify-content: center;
}
.t-side { display: flex; flex-direction: column; gap: 12px; }
.t-side--right { justify-self: start; }

.t-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  text-align: center;
}
.t-box__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.t-preview {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  display: block;
}

.t-hud { flex-direction: column; }
.t-hud .stat { min-width: 0; }

.t-stage { display: flex; justify-content: center; }
#board {
  display: block;
  width: min(46vw, 300px);
  height: auto;
  aspect-ratio: 1 / 2;
  background: #fbfcff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.t-mobile-controls { display: none; }
.t-mobile-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

.keyhelp {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 12px;
}

/* ---- Compact mobile layout: fit everything in the viewport ---- */
@media (max-width: 640px) {
  .game--tetris {
    min-height: calc(100dvh - 56px);
    display: flex;
    flex-direction: column;
    padding-top: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  /* Top row: hold | board | next side by side, board dominates */
  .t-layout {
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
  }
  .t-side { gap: 8px; }
  .t-side--left { order: 1; }
  .t-stage { order: 2; }
  .t-side--right { order: 3; justify-self: end; }
  .t-box { padding: 6px; }
  .t-box__label { font-size: 0.6rem; margin-bottom: 3px; }

  /* board sized to fit height first (it's tall), then width */
  #board { width: min(42vw, 38vh, 250px); }

  .t-preview { width: 58px; }

  /* HUD: compact horizontal strip under the play area */
  .t-hud {
    flex-direction: row;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
  }
  .t-hud .stat { padding: 6px 10px; min-width: 0; }
  .t-hud .stat__value { font-size: 1rem; }

  /* touch controls pinned toward the bottom */
  .t-mobile-controls { display: block; margin-top: 10px; }
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 5px; }

  .keyhelp { display: none; }
}

@media (max-width: 640px) and (min-height: 760px) {
  #board { width: min(44vw, 44vh, 290px); }
  .dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
}
