/* 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 {
    height: calc(100dvh - 56px);
    display: flex;
    flex-direction: column;
    padding-top: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    overflow: hidden;
  }

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

  /* board: much more height available now that controls are one row */
  #board { width: min(44vw, 46dvh, 290px); }

  .t-preview { width: 52px; }

  /* HUD */
  .t-hud {
    flex-direction: row;
    justify-content: center;
    gap: 5px;
    margin-top: 4px;
    flex-shrink: 0;
  }
  .t-hud .stat { padding: 5px 8px; min-width: 0; }
  .t-hud .stat__value { font-size: 0.95rem; }

  /* single-row controls */
  .t-mobile-controls { display: block; margin-top: 8px; flex-shrink: 0; padding: 0 4px; }

  .t-ctrl-row {
    display: flex;
    gap: 5px;
  }

  .t-ctrl-btn {
    flex: 1;
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    height: clamp(48px, 11dvh, 68px);
    font-size: clamp(1.1rem, 2.8dvh, 1.5rem);
    font-weight: 650;
    color: var(--text-soft);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: grid;
    place-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.08s ease, transform 0.06s ease;
  }
  .t-ctrl-btn:active { background: var(--accent-soft); color: var(--accent); transform: scale(0.93); }

  .t-ctrl-btn--hold { background: var(--accent-soft); color: var(--accent-press); font-size: clamp(0.75rem, 1.8dvh, 0.9rem); font-weight: 700; }
  .t-ctrl-btn--drop { background: var(--accent); color: #fff; font-size: clamp(0.72rem, 1.7dvh, 0.88rem); font-weight: 700; }
  .t-ctrl-btn--drop:active { background: var(--accent-press); color: #fff; }

  .keyhelp { display: none; }
}

@media (max-width: 640px) and (min-height: 760px) {
  #board { width: min(46vw, 50dvh, 320px); }
  .t-ctrl-btn { height: clamp(56px, 11dvh, 72px); }
}
