/* ============================================================
   PlayPulse - Per-game styles
   ============================================================ */

/* Shared: game box keeps overlays aligned to the playfield */
.game-box {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.touch-hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ============================================================
   2048
   ============================================================ */
.g2048 {
  position: relative;
  width: min(92vw, 460px);
  aspect-ratio: 1;
  background: #1c2230;
  border-radius: var(--radius-sm);
  padding: 10px;
  touch-action: none;
  user-select: none;
}
.g2048 .grid-bg {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}
.g2048 .cell { background: rgba(255, 255, 255, .045); border-radius: 6px; }
.g2048 .tiles { position: absolute; inset: 10px; }

.g2048 .tile {
  position: absolute;
  width: calc((100% - 30px) / 4);
  height: calc((100% - 30px) / 4);
  border-radius: 6px;
  font-weight: 800;
  font-size: clamp(18px, 5.2vw, 30px);
  background: #eee4da;
  color: #776e65;
  transform: translate(
    calc(var(--c, 0) * (100% + 10px)),
    calc(var(--r, 0) * (100% + 10px))
  );
  transition: transform .11s ease-in-out;
  will-change: transform;
}
/* inner span carries the pop/merge animation so it never fights the
   positioning transform above */
.g2048 .tile-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.g2048 .tile.new   .tile-inner { animation: pp-pop .19s ease; }
.g2048 .tile.merge .tile-inner { animation: pp-merge .19s ease; }

@keyframes pp-pop   { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes pp-merge { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* tile palette (classic 2048 colours) */
.g2048 .v2    { background: #eee4da; }
.g2048 .v4    { background: #ede0c8; }
.g2048 .v8    { background: #f2b179; color: #f9f6f2; }
.g2048 .v16   { background: #f59563; color: #f9f6f2; }
.g2048 .v32   { background: #f67c5f; color: #f9f6f2; }
.g2048 .v64   { background: #f65e3b; color: #f9f6f2; }
.g2048 .v128  { background: #edcf72; color: #f9f6f2; font-size: clamp(15px, 4.2vw, 24px); }
.g2048 .v256  { background: #edcc61; color: #f9f6f2; font-size: clamp(15px, 4.2vw, 24px); }
.g2048 .v512  { background: #edc850; color: #f9f6f2; font-size: clamp(15px, 4.2vw, 24px); }
.g2048 .v1024 { background: #edc53f; color: #f9f6f2; font-size: clamp(12px, 3.4vw, 20px); }
.g2048 .v2048 { background: #edc22e; color: #f9f6f2; font-size: clamp(12px, 3.4vw, 20px); box-shadow: 0 0 22px rgba(243, 215, 116, .6); }
.g2048 .vbig  { background: #3c3a32; color: #f9f6f2; font-size: clamp(12px, 3.4vw, 20px); }

/* ============================================================
   Snake
   ============================================================ */
.gsnake-wrap { touch-action: none; }
.gsnake { border: 1px solid var(--border); }

/* ============================================================
   Tetris
   ============================================================ */
.tetris-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}
.tetris-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 108px;
}
.tetris-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  text-align: center;
}
.tetris-box .label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.tetris-box .value { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tetris-canvas { border: 1px solid var(--border); }

/* ============================================================
   Minesweeper
   ============================================================ */
.mine-toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.mine-select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 7px 11px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.mine-board {
  display: grid;
  gap: 3px;
  background: var(--bg-elev-2);
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  touch-action: manipulation;
  user-select: none;
}
.mine-cell {
  width: clamp(24px, 7.4vw, 32px);
  height: clamp(24px, 7.4vw, 32px);
  display: grid;
  place-items: center;
  background: #2b3446;
  border-radius: 4px;
  font-weight: 800;
  font-size: clamp(12px, 3.2vw, 15px);
  cursor: pointer;
  transition: background .1s;
  line-height: 1;
}
.mine-cell:hover { background: #35405a; }
.mine-cell.open { background: #1a2030; cursor: default; }
.mine-cell.open:hover { background: #1a2030; }
.mine-cell.flag { background: #3d2f2a; }
.mine-cell.mine { background: var(--danger); color: #fff; }
.mine-cell.wrong { background: #7f1d1d; }
.mine-cell.exploded { background: var(--danger); animation: pp-shake .3s; }

@keyframes pp-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* classic number colours */
.n1 { color: #6aa9ff; } .n2 { color: #3fb950; } .n3 { color: #f85149; }
.n4 { color: #a78bfa; } .n5 { color: #d29922; } .n6 { color: #22d3ee; }
.n7 { color: #e6edf3; } .n8 { color: #8b97a8; }

.mine-status {
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-muted);
  min-height: 22px;
}

/* ============================================================
   Memory Match
   ============================================================ */
.memory-board {
  display: grid;
  gap: 10px;
  touch-action: manipulation;
  user-select: none;
  perspective: 800px;
}
.memory-card {
  position: relative;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.memory-card.flipped, .memory-card.matched { transform: rotateY(180deg); }
.memory-card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  font-size: clamp(22px, 6vw, 34px);
}
.memory-card .back {
  background: linear-gradient(145deg, #2a3448, #1e2636);
  border: 1px solid var(--border-light);
  color: var(--accent);
  font-size: 20px;
}
.memory-card .front {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-light);
  transform: rotateY(180deg);
}
.memory-card.matched .front {
  background: rgba(63, 185, 80, .18);
  border-color: var(--success);
  animation: pp-pop .25s;
}
.memory-card.matched { cursor: default; }

/* ============================================================
   Breakout
   ============================================================ */
.breakout-wrap { touch-action: none; }
.breakout-canvas { border: 1px solid var(--border); }

/* ============================================================
   On-screen touch d-pad (used by Snake / Tetris / Breakout)
   ============================================================ */
.touch-pad {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 46px);
  gap: 6px;
  justify-content: center;
  margin: 14px auto 0;
  width: max-content;
}
.touch-pad button {
  border: 1px solid var(--border-light);
  background: var(--bg-elev-2);
  color: var(--text);
  border-radius: 9px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.touch-pad button:active { background: var(--accent); color: #fff; }
.touch-pad .up    { grid-column: 2; grid-row: 1; }
.touch-pad .left  { grid-column: 1; grid-row: 2; }
.touch-pad .down  { grid-column: 2; grid-row: 2; }
.touch-pad .right { grid-column: 3; grid-row: 2; }

@media (hover: none) and (pointer: coarse) {
  .touch-pad { display: grid; }
}

/* ---------- Sudoku ---------- */
.sudoku {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background: #161b22;
  border: 2px solid #8b949e;
  border-radius: 10px;
  overflow: hidden;
  touch-action: manipulation;
}
.su-cell {
  display: grid;
  place-items: center;
  border-right: 1px solid #30363d;
  border-bottom: 1px solid #30363d;
  font-size: clamp(16px, 4.4vw, 26px);
  font-weight: 600;
  color: #7dd3fc;
  cursor: pointer;
  user-select: none;
  transition: background .08s ease;
}
.su-cell.given { color: #e6edf3; font-weight: 800; }
.su-cell.sel  { background: rgba(88,166,255,.28); }
.su-cell.same { background: rgba(88,166,255,.13); }
.su-cell.bad  { color: #ff6b6b; }
.su-cell.bb   { border-bottom: 2px solid #8b949e; }
.su-cell.rb   { border-right: 2px solid #8b949e; }
.su-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 440px;
  margin: 14px auto 0;
}
.su-key {
  padding: 11px 0;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #21262d;
  color: #e6edf3;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.su-key:hover   { background: #30363d; }
.su-key.erase   { grid-column: span 1; font-size: 13px; }
@media (max-width: 520px) {
  .su-pad { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- Connect Four ---------- */
.c4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 10px;
  background: #1f6feb;
  border-radius: 12px;
  touch-action: manipulation;
}
.c4-col { display: flex; flex-direction: column; gap: 5px; cursor: pointer; }
.c4-col:hover .c4-cell { background: #1c2128; }
.c4-cell {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #0d1117;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  transition: background .18s ease;
}
.c4-cell.p1 { background: #ff5a5a; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.c4-cell.p2 { background: #ffd23f; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
