/* game2048.css — immersive 2048. Shares the wg-main-game full-bleed shell with
   Tetris. Square 4x4 board, swipe/keys/d-pad, overlay-hosted leaderboard. */

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

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

/* HUD */
.wg-g2048-hud { width: 100%; max-width: 460px; display: flex; align-items: center; gap: 10px; color: #eaf0f5; }
.wg-g2048-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-g2048-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wg-g2048-score { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.wg-g2048-num { font-size: 1.7rem; font-weight: 800; }
.wg-g2048-mini { font-size: 0.72rem; color: #8a99a8; font-weight: 600; }
.wg-g2048-hbtn {
  flex: 0 0 auto; font: inherit; font-size: 0.82rem; font-weight: 700; padding: 8px 14px;
  color: #eaf0f5; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; cursor: pointer;
}
.wg-g2048-hbtn:hover { background: rgba(255,255,255,0.16); }

/* Board */
.wg-g2048-boardwrap { position: relative; flex: 0 0 auto; }
.wg-g2048-board {
  width: min(94vw, calc(100vh - 230px), 460px);
  width: min(94vw, calc(100dvh - 230px), 460px);
  aspect-ratio: 1 / 1;
  container-type: size;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr);
  gap: 2.4%; padding: 2.4%;
  background: #1b2530; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  touch-action: none;
}
.wg-g2-cell {
  border-radius: 8px; background: rgba(255,255,255,0.04);
  display: grid; place-items: center;
  font-weight: 800; color: #776e65;
  font-size: 1.7rem; font-size: 9cqw;
}
.wg-g2-cell.is-med { font-size: 1.35rem; font-size: 7cqw; }
.wg-g2-cell.is-big { font-size: 1.05rem; font-size: 5.4cqw; }
.wg-g2-cell.is-tile { box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.wg-g2-cell.is-pop { animation: wg-g2-pop 0.16s ease; }
@keyframes wg-g2-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }

@media (min-width: 480px) and (pointer: fine) {
  .wg-g2048-board { width: min(94vw, calc(100vh - 150px), 520px); width: min(94vw, calc(100dvh - 150px), 520px); }
}

/* Overlay (start / game over + leaderboard) */
.wg-g2048-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(9, 14, 20, 0.92); border-radius: 12px; padding: 14px;
}
.wg-g2048-overlay[hidden] { display: none; }
.wg-g2048-overlay-card {
  color: #fff; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 100%; max-width: 300px; max-height: 100%; overflow: hidden;
}
.wg-g2048-overlay-card h2 { margin: 0; font-size: 1.6rem; }
.wg-g2048-overlay-card p { margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.wg-g2048-overlay-card .wg-btn { min-width: 160px; }
.wg-g2-final { font-size: 1.25rem; font-weight: 800; }
.wg-g2-best-tag { color: #ffd54a; font-weight: 700; }
.wg-g2-hint { font-size: 0.82rem; opacity: 0.82; }
.wg-g2048-overlay-exit { color: #9fb0be; font-size: 0.85rem; text-decoration: underline; }
.wg-g2048-overlay-exit:hover { color: #fff; }

/* D-pad (plus layout) */
.wg-g2048-dpad {
  display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 44px);
  gap: 6px; margin-top: 4px;
}
.wg-g2048-dbtn {
  font: inherit; font-size: 1.4rem; color: #eaf0f5;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.wg-g2048-dbtn:active { background: rgba(255,255,255,0.2); transform: scale(.95); }
.wg-g2048-d-up { grid-column: 2; grid-row: 1; }
.wg-g2048-d-left { grid-column: 1; grid-row: 2; }
.wg-g2048-d-right { grid-column: 3; grid-row: 2; }
.wg-g2048-d-down { grid-column: 2; grid-row: 3; }
@media (pointer: fine) { .wg-g2048-dpad { display: none; } }

/* One-line "how to play", always visible at the bottom. */
.wg-g2048-help { margin: 6px 0 0; font-size: 0.78rem; color: #8a99a8; text-align: center; max-width: 460px; }

/* Leaderboard (inside the overlay) */
.wg-g2048-lb { width: 100%; margin-top: 6px; text-align: left; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wg-g2048-lb-head { display: flex; align-items: baseline; gap: 8px; justify-content: center; margin-bottom: 6px; }
.wg-g2048-lb-head h3 { margin: 0; font-size: 1rem; color: #eaf0f5; }
.wg-g2048-lb-total { font-size: 0.78rem; color: #8a99a8; }
.wg-g2048-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-g2-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-g2-lb-row.is-me { border-color: var(--wg-color); background: rgba(14,175,76,0.18); }
.wg-g2-lb-rank { flex: 0 0 auto; width: 22px; font-weight: 800; color: #8a99a8; text-align: center; }
.wg-g2-lb-row:nth-child(1) .wg-g2-lb-rank { color: #f5b301; }
.wg-g2-lb-row:nth-child(2) .wg-g2-lb-rank { color: #c4ced6; }
.wg-g2-lb-row:nth-child(3) .wg-g2-lb-rank { color: #cd7f32; }
.wg-g2-lb-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wg-g2-lb-name em { color: #7ee0a2; font-style: normal; font-weight: 700; font-size: 0.85em; }
.wg-g2-lb-score { flex: 0 0 auto; font-weight: 800; }
.wg-g2048-lb-empty { color: #8a99a8; font-size: 0.86rem; text-align: center; padding: 6px 2px; }
.wg-g2048-lb-me { margin: 6px 0 0; font-size: 0.84rem; color: #7ee0a2; font-weight: 600; text-align: center; }

@media (prefers-reduced-motion: reduce) { .wg-g2-cell.is-pop { animation: none; } .wg-g2048-dbtn:active { transform: none; } }
