/* tetris.css — immersive Tetris. The page hides all site chrome; only the game
   (board, minimal HUD, touch controls, and an overlay that carries the start /
   game-over state + leaderboard) is shown. */

.wg-main.wg-main-game { max-width: none; width: 100%; margin: 0; padding: 0; }

.wg-tetris {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  background: #0b1016;
}

/* ── HUD (single slim bar) ─────────────────────────────────────────────── */
.wg-tetris-hud {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #eaf0f5;
}
.wg-tetris-exit {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1;
  color: #cdd6de; text-decoration: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
}
.wg-tetris-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wg-tetris-hud-score { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.wg-tetris-hud-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em; }
.wg-tetris-hud-mini { font-size: 0.72rem; color: #8a99a8; font-weight: 600; }
.wg-tetris-hud-next { flex: 0 0 auto; width: 48px; height: 48px; }
.wg-tetris-hud-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.wg-tetris-hbtn {
  font: inherit; font-size: 0.82rem; font-weight: 700;
  padding: 8px 12px; min-width: 40px;
  color: #eaf0f5; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; cursor: pointer;
}
.wg-tetris-hbtn:hover { background: rgba(255,255,255,0.16); }
.wg-tetris-hbtn:disabled { opacity: 0.4; cursor: default; }

/* ── Board (big — sized to the viewport) ───────────────────────────────── */
.wg-tetris-boardwrap {
  position: relative;
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
}
.wg-tetris-board {
  display: block;
  width: auto;
  /* Fit BOTH width (188vw = 2 x 94vw, the 1:2 ratio) and height (viewport minus
     the HUD + touch controls). The smallest wins, so it never overflows. */
  height: min(188vw, calc(100vh - 176px), 720px);
  height: min(188vw, calc(100dvh - 176px), 720px);
  aspect-ratio: 1 / 2;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #0f1720;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  touch-action: none;   /* board gestures (move/rotate/drop) are handled in JS */
}

/* ── Overlay (start / paused / game-over + leaderboard) ────────────────── */
.wg-tetris-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(9, 14, 20, 0.9); border-radius: 12px; padding: 14px;
}
.wg-tetris-overlay[hidden] { display: none; }
.wg-tetris-overlay-card {
  color: #fff; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 320px;
  max-height: 100%; overflow: hidden;   /* card stays put; only the leaderboard list scrolls */
}
/* The leaderboard fills the remaining space; its list is the only scroll region. */
.wg-tetris-lb { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; }
.wg-tetris-overlay-card h2 { margin: 0; font-size: 1.5rem; }
.wg-tetris-overlay-card p { margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.wg-tetris-overlay-card .wg-btn { min-width: 160px; }
.wg-t-final { font-size: 1.25rem; font-weight: 800; }
.wg-t-best-tag { color: #ffd54a; font-weight: 700; }
.wg-t-hint { font-size: 0.82rem; opacity: 0.82; }
.wg-tetris-controls { flex: 0 0 auto; margin: 0; font-size: 0.72rem; line-height: 1.45; color: #9fb0be; max-width: 300px; }
.wg-tetris-overlay-exit { color: #9fb0be; font-size: 0.85rem; text-decoration: underline; }
.wg-tetris-overlay-exit:hover { color: #fff; }

/* ── Touch controls ────────────────────────────────────────────────────── */
.wg-tetris-touch {
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.wg-tetris-tbtn {
  font: inherit; font-size: 1.5rem; padding: 14px 0;
  color: #eaf0f5; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 12px;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.wg-tetris-tbtn:active { background: rgba(255,255,255,0.2); transform: scale(.95); }
/* Precise pointer (desktop mouse): keyboard plays, so hide the touch pad and
   give the board a little more height. */
@media (pointer: fine) {
  .wg-tetris-touch { display: none; }
  .wg-tetris-board { height: min(188vw, calc(100vh - 104px), 760px); height: min(188vw, calc(100dvh - 104px), 760px); }
}

/* ── Leaderboard (inside the overlay) ──────────────────────────────────── */
.wg-tetris-lb { width: 100%; margin-top: 6px; text-align: left; }
.wg-tetris-lb-head { display: flex; align-items: baseline; gap: 8px; justify-content: center; margin-bottom: 6px; }
.wg-tetris-lb-head h3 { margin: 0; font-size: 1rem; color: #eaf0f5; }
.wg-tetris-lb-total { font-size: 0.78rem; color: #8a99a8; }
.wg-tetris-lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.wg-t-lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; font-size: 0.88rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
}
.wg-t-lb-row.is-me { border-color: var(--wg-color); background: rgba(14,175,76,0.18); }
.wg-t-lb-rank { flex: 0 0 auto; width: 22px; font-weight: 800; color: #8a99a8; text-align: center; }
.wg-t-lb-row:nth-child(1) .wg-t-lb-rank { color: #f5b301; }
.wg-t-lb-row:nth-child(2) .wg-t-lb-rank { color: #c4ced6; }
.wg-t-lb-row:nth-child(3) .wg-t-lb-rank { color: #cd7f32; }
.wg-t-lb-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wg-t-lb-name em { color: #7ee0a2; font-style: normal; font-weight: 700; font-size: 0.85em; }
.wg-t-lb-score { flex: 0 0 auto; font-weight: 800; }
.wg-tetris-lb-empty { color: #8a99a8; font-size: 0.86rem; text-align: center; padding: 6px 2px; }
.wg-tetris-lb-me { margin: 6px 0 0; font-size: 0.84rem; color: #7ee0a2; font-weight: 600; text-align: center; }

@media (prefers-reduced-motion: reduce) { .wg-tetris-tbtn:active { transform: none; } }
