/* ── CELL SIZE TOKEN ─────────────────────────────────────────── */
:root { --nm-cell: 42px; }

@media (max-width: 580px) { :root { --nm-cell: 36px; } }

/* ── GRID WRAPPER ────────────────────────────────────────────── */
.nm-scroll {
  overflow-x: auto;
  overflow-y: visible;
  margin: 0 -4px;
  padding: 0 4px 6px;
}

/* ── GRID ────────────────────────────────────────────────────── */
#nmGrid {
  display: grid;
  grid-template-columns: repeat(9, var(--nm-cell));
  gap: 3px;
  background: var(--border-light);
  border: 2px solid var(--btn-border);
  border-radius: 12px;
  padding: 6px;
  width: fit-content;
  margin: 0 auto;
  transition: filter .25s;
}

#nmGrid.blurred {
  filter: blur(8px);
  pointer-events: none;
}

/* ── CELL ────────────────────────────────────────────────────── */
.nm-cell {
  width: var(--nm-cell);
  height: var(--nm-cell);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform .1s, box-shadow .1s;
}

.nm-cell.nm-empty {
  background: transparent;
  cursor: default;
  border: 1px dashed rgba(100,120,160,.18);
}

[data-theme="dark"] .nm-cell.nm-empty {
  border-color: rgba(150,170,220,.13);
}

.nm-cell:not(.nm-empty):hover { transform: scale(1.1); }

.nm-cell.nm-selected {
  box-shadow: 0 0 0 3px var(--primary), 0 0 14px rgba(42,111,189,.28);
  transform: scale(1.12);
  z-index: 1;
}

/* ── NUMBER COLORS (light) ───────────────────────────────────── */
.nm-v1 { background: #dbeafe; color: #1e40af; }
.nm-v2 { background: #dcfce7; color: #166534; }
.nm-v3 { background: #fee2e2; color: #991b1b; }
.nm-v4 { background: #fef9c3; color: #854d0e; }
.nm-v5 { background: #ccfbf1; color: #115e59; }
.nm-v6 { background: #ede9fe; color: #5b21b6; }
.nm-v7 { background: #e0f2fe; color: #075985; }
.nm-v8 { background: #fce7f3; color: #9d174d; }
.nm-v9 { background: #ffedd5; color: #9a3412; }

/* ── NUMBER COLORS (dark) ────────────────────────────────────── */
[data-theme="dark"] .nm-v1 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .nm-v2 { background: #14532d; color: #86efac; }
[data-theme="dark"] .nm-v3 { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .nm-v4 { background: #422006; color: #fde047; }
[data-theme="dark"] .nm-v5 { background: #042f2e; color: #5eead4; }
[data-theme="dark"] .nm-v6 { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .nm-v7 { background: #082f49; color: #7dd3fc; }
[data-theme="dark"] .nm-v8 { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .nm-v9 { background: #431407; color: #fdba74; }

/* ── BEST TIME INLINE ────────────────────────────────────────── */
.best-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.best-info b {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

/* ── SCORE ROW ───────────────────────────────────────────────── */
.nm-score {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.nm-score b {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

/* ── ACTION BUTTONS (centered below grid) ────────────────────── */
.nm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ── DISABLED BUTTON STATE ───────────────────────────────────── */
.act-btn.nm-btn-off {
  opacity: .45;
  cursor: not-allowed;
}
.act-btn.nm-btn-off:hover { transform: none; box-shadow: none; }

/* ── NO MOVES / SHUFFLE MESSAGES ────────────────────────────── */
#noMovesMsg {
  display: none;
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-top: 10px;
}
[data-theme="dark"] #noMovesMsg {
  background: #422006;
  color:      #fde047;
  border-color: #854d0e;
}

/* ── SHUFFLE MESSAGE ─────────────────────────────────────────── */
#shuffleMsg {
  display: none;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-top: 10px;
}
[data-theme="dark"] #shuffleMsg {
  background: #082f49;
  color:      #7dd3fc;
  border-color: #075985;
}

/* ── HINT CELL HIGHLIGHT ─────────────────────────────────────── */
@keyframes nm-hint-pulse {
  0%, 100% { box-shadow: 0 0 0 3px #f59e0b, 0 0 8px rgba(245,158,11,.35); transform: scale(1); }
  50%       { box-shadow: 0 0 0 3px #f59e0b, 0 0 22px rgba(245,158,11,.7); transform: scale(1.14); }
}

.nm-cell.nm-hint {
  z-index: 2;
  animation: nm-hint-pulse 0.55s ease-in-out 3;
}

/* ── HINT AD MODAL ───────────────────────────────────────────── */
#hintModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,15,45,.72);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#hintModal.show { display: flex; }

.hint-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 72px rgba(0,0,40,.32);
  animation: pop .38s cubic-bezier(.34,1.56,.64,1);
  width: 360px;
  max-width: 90vw;
  position: relative;
}

#hintPhase1, #hintPhase2, #hintPhase3 { display: none; }
#hintPhase1.active, #hintPhase2.active, #hintPhase3.active { display: block; }

.hint-icon  { font-size: 50px; line-height: 1.15; }
.hint-title { font-size: 1.25em; font-weight: 800; color: var(--primary); margin: 10px 0 6px; }
.hint-sub   { font-size: 14px; color: var(--muted); line-height: 1.55; }

.hint-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

.hint-btn-primary {
  padding: 11px 24px; border: none; border-radius: 26px;
  background: var(--primary); color: white;
  font-size: 14px; font-weight: 700; cursor: pointer; transition: .16s;
}
.hint-btn-primary:hover { background: var(--primary-dk); transform: translateY(-1px); }

.hint-btn-ghost {
  padding: 9px 24px; border: 2px solid var(--btn-border); border-radius: 26px;
  background: transparent; color: var(--btn-text);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: .16s;
}
.hint-btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

#hintPhase2 { position: relative; }
.hint-close-btn {
  position: absolute; top: -8px; right: -8px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--btn-border); background: var(--card-bg);
  cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: .14s;
}
.hint-close-btn:hover { border-color: var(--err-color); color: var(--err-color); }

#hintAdSlot { margin: 0 auto; }

.hint-progress-label { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.hint-progress-wrap  { height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden; }
.hint-progress-bar   { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; transition: width 1s linear; }

/* ── SIDE PANEL ADS (hidden by default) ─────────────────────── */
.side-panel-ad     { display: none; }
.side-panel-mid-ad { display: none; }
.game-mid-ad       { display: none; margin: 0 auto 14px; }

@media (max-width: 775px) {
  .hdr-nav .ad-leaderboard { display: none; }
  .game-mid-ad { display: flex; }
}
@media (max-width: 1100px) {
  .content-row { grid-template-columns: 1fr; }
}
@media (min-width: 775px) and (max-width: 1100px) {
  .right-sidebar { display: none; }
  .side-panel-ad { display: flex; }
}
@media (max-width: 650px) {
  .side-panel-mid-ad { display: flex; margin: 0 auto; }
}
