/* Grid game styles - Sudoku, Minesweeper, 2048. Shared layout, per-game palettes. */

.grid-board-wrap {
  display: flex; justify-content: center;
  padding: calc(var(--space) * 1.2);
  border-radius: 18px;
  background: radial-gradient(120% 90% at 50% 28%, #2e4d78 0%, #1d2f4a 55%, #152238 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 0 60px rgba(0,0,0,0.35);
}
.grid-board {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 9), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 9), 1fr);
  gap: 2px;
  width: min(100%, 560px);
  max-width: min(100%, calc(100vh - 260px));
  aspect-ratio: 1 / 1;
  background: #0d1724;
  padding: 4px;
  border-radius: 10px;
}

/* ---- Sudoku ---- */
.grid-board--sudoku { gap: 1px; }
.sudoku-cell {
  display: flex; align-items: center; justify-content: center;
  background: #1c2a3f;
  font-weight: 600;
  font-size: clamp(14px, 2.8vh, 26px);
  color: #dde6f2;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  position: relative;
}
.sudoku-cell--given { color: #e8edf4; background: #24354d; font-weight: 800; }
.sudoku-cell--placed { color: #8ecbf5; }
.sudoku-cell--wrong { color: #ff7a7a; background: #3a1a25; }
.sudoku-cell--empty { color: #4a5c76; }
.sudoku-cell.is-shaded { background: #263a52; }
.sudoku-cell.is-same { background: #2f4967; color: #f5c542; }
.sudoku-cell.is-selected {
  background: #3b5c8a;
  box-shadow: inset 0 0 0 2px var(--focus);
  z-index: 2;
}
.sudoku-cell.is-cursor::after {
  content: "";
  position: absolute; inset: -2px;
  border: 2px dashed rgba(245,197,66,0.6);
  border-radius: 5px;
  pointer-events: none;
}
/* 3x3 box edges */
.sudoku-cell:nth-child(3n):not(:nth-last-child(-n+9)) { border-right: 2px solid #091019; }
.sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-cell:nth-child(n+46):nth-child(-n+54),
.sudoku-cell:nth-child(n+73):nth-child(-n+81) { border-bottom: 2px solid #091019; }
.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  width: min(100%, 560px);
  margin: 12px auto 0;
}
.sudoku-pad__key {
  aspect-ratio: 1 / 1;
  min-height: 44px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  font-size: clamp(14px, 2.4vh, 20px);
  font-weight: 700;
  color: var(--fg);
}
.sudoku-pad__key--clear { grid-column: span 1; background: rgba(255,255,255,0.16); font-size: 0.8em; }
.sudoku-pad__key.is-focused, .sudoku-pad__key:focus { outline: none; }
.sudoku-pad__key:hover { background: rgba(255,255,255,0.16); }

/* ---- Minesweeper ---- */
.grid-board--minesweeper { gap: 1px; background: #0e1a26; }
.ms-cell {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #3a5375 0%, #2a4058 100%);
  border-radius: 3px;
  font-weight: 800;
  font-size: clamp(10px, 2.4vh, 22px);
  color: #dde6f2;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), inset 0 -1px 0 rgba(0,0,0,0.35);
}
.ms-cell--covered { }
.ms-cell--open { background: #16202d; box-shadow: inset 0 1px 2px rgba(0,0,0,0.35); }
.ms-cell--flag { color: #f5c542; }
.ms-cell--flag::before { content: "\2691"; font-size: 1em; }
.ms-cell--mine { background: #3a1a1a; color: #ff8080; }
.ms-cell--mine::before {
  content: "";
  display: inline-block;
  width: 50%; height: 50%;
  border-radius: 50%;
  background: #ff5050;
  box-shadow: inset 0 0 6px #000;
}
.ms-cell--exploded { background: #ff3b3b; }
.ms-cell--exploded::before { background: #fff; }
.ms-cell--n1 { color: #4a90e2; }
.ms-cell--n2 { color: #43a047; }
.ms-cell--n3 { color: #e05a5a; }
.ms-cell--n4 { color: #1a2a4a; }
.ms-cell--n5 { color: #a02730; }
.ms-cell--n6 { color: #35c4c8; }
.ms-cell--n7 { color: #000; background: #cfd6e2; }
.ms-cell--n8 { color: #888; }
.ms-cell.is-cursor::after {
  content: "";
  position: absolute; inset: -1px;
  border: 2px dashed rgba(245,197,66,0.6);
  border-radius: 4px;
  pointer-events: none;
}

/* ---- 2048 ---- */
.grid-board--g2048 {
  gap: 8px;
  background: #1e2b3f;
  padding: 10px;
  touch-action: none; /* swipe must not scroll the page */
}
.t2048-cell {
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  font-weight: 800;
  font-size: clamp(16px, 3.6vh, 40px);
  color: #fff;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s ease, transform 0.12s ease;
}
.t2048-label { display: block; }
/* Warm gradient palette per tier. */
.t2048-cell--v2 { background: #cdd6e4; color: #1a2332; }
.t2048-cell--v4 { background: #c2c9d5; color: #1a2332; }
.t2048-cell--v8 { background: #f2b179; color: #fff; }
.t2048-cell--v16 { background: #f59563; color: #fff; }
.t2048-cell--v32 { background: #f67c5f; color: #fff; }
.t2048-cell--v64 { background: #f65e3b; color: #fff; }
.t2048-cell--v128 { background: #edcf72; color: #fff; }
.t2048-cell--v256 { background: #edcc61; color: #fff; }
.t2048-cell--v512 { background: #edc850; color: #fff; }
.t2048-cell--v1024 { background: #edc53f; color: #fff; }
.t2048-cell--v2048 { background: #edc22e; color: #fff; box-shadow: 0 0 20px rgba(237,194,46,0.6); }
.t2048-cell--vSuper { background: #3c3a32; color: #fff; }

/* ---- Tier row ---- */
.tier-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space);
  margin: var(--space) 0;
}
.tier-btn {
  min-height: 84px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-2);
  font-weight: 700;
  font-size: 1.1em;
  color: var(--fg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.tier-btn:hover { background: #2e466a; }

@media (max-width: 700px) {
  .grid-board-wrap { padding: 6px; margin: 0 -6px; }
  .sudoku-pad { grid-template-columns: repeat(5, 1fr); }
  .t2048-cell { font-size: clamp(14px, 3vh, 32px); }
}

@media (max-height: 500px) {
  .grid-board { max-width: min(100%, calc(100vh - 140px)); }
}
