/* match3.css — Gem Match. Immersive: site chrome hidden; only the HUD, the
   level-goal bar, the board and the overlay show. */

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

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

/* ── HUD ── */
.wg-m3-hud { width: 100%; max-width: 480px; display: flex; align-items: center; gap: 10px; color: #eaf0f5; }
.wg-m3-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-m3-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wg-m3-score { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.wg-m3-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em; }
.wg-m3-mini { font-size: 0.7rem; color: #8a99a8; font-weight: 600; }
.wg-m3-hud-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.wg-m3-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-m3-hbtn:hover { background: rgba(255,255,255,0.16); }
.wg-m3-hbtn:disabled { opacity: 0.4; cursor: default; }

/* ── Level goal ── */
.wg-m3-goal { width: 100%; max-width: 480px; display: flex; align-items: center; gap: 10px; }
.wg-m3-bar { flex: 1 1 auto; height: 8px; background: rgba(255,255,255,0.10); border-radius: 999px; overflow: hidden; }
.wg-m3-bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #17c257, #ffd54a); transition: width 0.25s ease; }
.wg-m3-goal-txt { flex: 0 0 auto; font-size: 0.7rem; font-weight: 700; color: #8a99a8; }

/* ── Board ── */
.wg-m3-boardwrap { position: relative; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; }
.wg-m3-board {
  position: relative; overflow: hidden;
  width: min(94vw, calc(100vh - 210px), 460px);
  width: min(94vw, calc(100dvh - 210px), 460px);
  aspect-ratio: 1 / 1;
  background: #0f1720; border: 1px solid rgba(255,255,255,0.10); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* Firework layer sits above the gems and never eats taps. */
.wg-m3-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* Each gem is exactly one cell, so translate(col*100%,row*100%) lands on grid. */
.wg-m3-gem {
  position: absolute; top: 0; left: 0;
  width: calc(100% / var(--n, 8)); height: calc(100% / var(--n, 8));
  box-sizing: border-box; border: 3px solid transparent; background-clip: padding-box;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.24s cubic-bezier(.22,.61,.36,1), opacity 0.18s ease;
  will-change: transform;
}
.wg-m3-gem.is-sel { outline: 3px solid #fff; outline-offset: -6px; border-radius: 12px; }
.wg-m3-gem.is-pop { opacity: 0; transform-origin: center; }
@media (prefers-reduced-motion: reduce) { .wg-m3-gem { transition: none; } }

/* Gem types — distinct hue AND shape, so they're separable without colour. */
.wg-m3-gem.t0 { background: #f6524f; }
.wg-m3-gem.t1 { background: #4a7bf7; border-radius: 12px; }
.wg-m3-gem.t2 { background: #3ecf6a; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.wg-m3-gem.t3 { background: #f5c518; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); border-radius: 0; }
.wg-m3-gem.t4 { background: #b46ef0; clip-path: polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%); border-radius: 0; }
.wg-m3-gem.t5 { background: #24c8d8; clip-path: polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%); border-radius: 0; }

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

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